Class CollectionManager

java.lang.Object
com.couchbase.client.java.manager.collection.CollectionManager

@Volatile public class CollectionManager extends Object
The CollectionManager provides APIs to manage bucket collections and scopes.
  • Constructor Details

  • Method Details

    • createCollection

      @Deprecated public void createCollection(CollectionSpec collectionSpec)
      Deprecated.
      This method cannot be used to set the collection's "history" property. Please use createCollection(String, String, CreateCollectionSettings) instead.
      Creates a collection if it does not already exist.

      Note that a scope needs to be created first (via createScope(String)) if it doesn't exist already.

      Parameters:
      collectionSpec - the collection spec that contains the properties of the collection.
      Throws:
      com.couchbase.client.core.error.CollectionExistsException - if the collection already exists
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createCollection

      @Deprecated public void createCollection(CollectionSpec collectionSpec, CreateCollectionOptions options)
      Deprecated.
      This method cannot be used to set the collection's "history" property. Please use createCollection(String, String, CreateCollectionSettings, CreateCollectionOptions) instead.
      Creates a collection if it does not already exist with custom options.

      Note that a scope needs to be created first (via createScope(String)) if it doesn't exist already.

      Parameters:
      collectionSpec - the collection spec that contains the properties of the collection.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.CollectionExistsException - if the collection already exists
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createCollection

      @Volatile public void createCollection(String scopeName, String collectionName)
      Creates a collection if it does not already exist.

      Note that a scope needs to be created first (via createScope(String)) if it doesn't exist already.

      Parameters:
      scopeName - the scope name
      collectionName - the collection name
      Throws:
      com.couchbase.client.core.error.CollectionExistsException - if the collection already exists
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createCollection

      @Volatile public void createCollection(String scopeName, String collectionName, CreateCollectionSettings settings)
      Creates a collection if it does not already exist with custom options.

      Note that a scope needs to be created first (via createScope(String)) if it doesn't exist already.

      Parameters:
      scopeName - the scope name to create the collection in
      collectionName - the collection name
      settings - the collection settings
      Throws:
      com.couchbase.client.core.error.CollectionExistsException - if the collection already exists
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createCollection

      @Volatile public void createCollection(String scopeName, String collectionName, CreateCollectionSettings settings, CreateCollectionOptions options)
      Creates a collection if it does not already exist with custom options.

      Note that a scope needs to be created first (via createScope(String)) if it doesn't exist already.

      Parameters:
      scopeName - the scope name to create the collection in
      collectionName - the collection name
      settings - the collection settings
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.CollectionExistsException - if the collection already exists
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createScope

      public void createScope(String scopeName)
      Creates a scope if it does not already exist.
      Parameters:
      scopeName - the name of the scope to create.
      Throws:
      com.couchbase.client.core.error.ScopeExistsException - if the scope already exists.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • createScope

      public void createScope(String scopeName, CreateScopeOptions options)
      Creates a scope if it does not already exist with custom options.
      Parameters:
      scopeName - the name of the scope to create.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.ScopeExistsException - if the scope already exists.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • updateCollection

      @Volatile public void updateCollection(String scopeName, String collectionName, UpdateCollectionSettings settings)
      Updates a collection with custom options.
      Parameters:
      scopeName - name of scope to update collection in
      collectionName - name of collection to update
      settings - the collection settings
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - (async) if the collection does not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - (async) if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - (async) if any other generic unhandled/unexpected errors.
    • updateCollection

      @Volatile public void updateCollection(String scopeName, String collectionName, UpdateCollectionSettings settings, UpdateCollectionOptions options)
      Updates a collection with custom options.
      Parameters:
      scopeName - name of scope to update collection in
      collectionName - name of collection to update
      settings - the collection settings
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - (async) if the collection does not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - (async) if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - (async) if any other generic unhandled/unexpected errors.
    • dropCollection

      @Deprecated public void dropCollection(CollectionSpec collectionSpec)
      Deprecated.
      Please use dropCollection(String, String) instead.
      Drops a collection if it exists.
      Parameters:
      collectionSpec - the collection spec that contains the properties of the collection.
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - if the collection did not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropCollection

      @Deprecated public void dropCollection(CollectionSpec collectionSpec, DropCollectionOptions options)
      Drops a collection if it exists with custom options.
      Parameters:
      collectionSpec - the collection spec that contains the properties of the collection.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - if the collection did not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropCollection

      @Volatile public void dropCollection(String scopeName, String collectionName)
      Drops a collection if it exists.
      Parameters:
      scopeName - the scope name containing the collection to drop
      collectionName - the collection name
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - if the collection did not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropCollection

      @Volatile public void dropCollection(String scopeName, String collectionName, DropCollectionOptions options)
      Drops a collection if it exists with custom options.
      Parameters:
      scopeName - the scope name containing the collection to drop
      collectionName - the collection name
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.CollectionNotFoundException - if the collection did not exist.
      com.couchbase.client.core.error.ScopeNotFoundException - if the specified scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropScope

      public void dropScope(String scopeName)
      Drops a scope if it exists.
      Parameters:
      scopeName - the name of the scope to drop.
      Throws:
      com.couchbase.client.core.error.ScopeNotFoundException - if the scope did not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropScope

      public void dropScope(String scopeName, DropScopeOptions options)
      Drops a scope if it exists with custom options.
      Parameters:
      scopeName - the name of the scope to drop.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.ScopeNotFoundException - if the scope did not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getScope

      @Deprecated public ScopeSpec getScope(String scopeName)
      Deprecated.
      use getAllScopes() instead.
      Returns the scope if it exists.
      Parameters:
      scopeName - the name of the scope.
      Returns:
      containing information about the scope.
      Throws:
      com.couchbase.client.core.error.ScopeNotFoundException - if scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getScope

      @Deprecated public ScopeSpec getScope(String scopeName, GetScopeOptions options)
      Deprecated.
      Returns the scope if it exists with custom options.
      Parameters:
      scopeName - the name of the scope.
      options - the custom options to apply.
      Returns:
      containing information about the scope.
      Throws:
      com.couchbase.client.core.error.ScopeNotFoundException - if scope does not exist.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getAllScopes

      public List<ScopeSpec> getAllScopes()
      Returns all scopes in this bucket.
      Returns:
      a (potentially empty) list of scopes in the bucket.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getAllScopes

      public List<ScopeSpec> getAllScopes(GetAllScopesOptions options)
      Returns all scopes in this bucket with custom options.
      Parameters:
      options - the custom options to apply.
      Returns:
      a (potentially empty) list of scopes in the bucket.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.