Class CollectionManager
- java.lang.Object
-
- com.couchbase.client.java.manager.collection.CollectionManager
-
@Volatile public class CollectionManager extends Object
TheCollectionManagerprovides APIs to manage bucket collections and scopes.
-
-
Constructor Summary
Constructors Constructor Description CollectionManager(AsyncCollectionManager async)Creates a newCollectionManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcreateCollection(CollectionSpec collectionSpec)Creates a collection if it does not already exist.voidcreateCollection(CollectionSpec collectionSpec, CreateCollectionOptions options)Creates a collection if it does not already exist with custom options.voidcreateScope(String scopeName)Creates a scope if it does not already exist.voidcreateScope(String scopeName, CreateScopeOptions options)Creates a scope if it does not already exist with custom options.voiddropCollection(CollectionSpec collectionSpec)Drops a collection if it exists.voiddropCollection(CollectionSpec collectionSpec, DropCollectionOptions options)Drops a collection if it exists with custom options.voiddropScope(String scopeName)Drops a scope if it exists.voiddropScope(String scopeName, DropScopeOptions options)Drops a scope if it exists with custom options.List<ScopeSpec>getAllScopes()Returns all scopes in this bucket.List<ScopeSpec>getAllScopes(GetAllScopesOptions options)Returns all scopes in this bucket with custom options.ScopeSpecgetScope(String scopeName)Deprecated.usegetAllScopes()instead.ScopeSpecgetScope(String scopeName, GetScopeOptions options)Deprecated.usegetAllScopes(GetAllScopesOptions)instead.
-
-
-
Constructor Detail
-
CollectionManager
@Internal public CollectionManager(AsyncCollectionManager async)
Creates a newCollectionManager.This API is not intended to be called by the user directly, use
Bucket.collections()instead.- Parameters:
async- the underlying async collection manager.
-
-
Method Detail
-
createCollection
public void createCollection(CollectionSpec collectionSpec)
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:
CollectionExistsException- if the collection already existsScopeNotFoundException- if the specified scope does not exist.CouchbaseException- if any other generic unhandled/unexpected errors.
-
createCollection
public void createCollection(CollectionSpec collectionSpec, 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:
collectionSpec- the collection spec that contains the properties of the collection.options- the custom options to apply.- Throws:
CollectionExistsException- if the collection already existsScopeNotFoundException- if the specified scope does not exist.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:
ScopeExistsException- if the scope already exists.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:
ScopeExistsException- if the scope already exists.CouchbaseException- if any other generic unhandled/unexpected errors.
-
dropCollection
public void dropCollection(CollectionSpec collectionSpec)
Drops a collection if it exists.- Parameters:
collectionSpec- the collection spec that contains the properties of the collection.- Throws:
CollectionNotFoundException- if the collection did not exist.ScopeNotFoundException- if the specified scope does not exist.CouchbaseException- if any other generic unhandled/unexpected errors.
-
dropCollection
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:
CollectionNotFoundException- if the collection did not exist.ScopeNotFoundException- if the specified scope does not exist.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:
ScopeNotFoundException- if the scope did not exist.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:
ScopeNotFoundException- if the scope did not exist.CouchbaseException- if any other generic unhandled/unexpected errors.
-
getScope
@Deprecated public ScopeSpec getScope(String scopeName)
Deprecated.usegetAllScopes()instead.Returns the scope if it exists.- Parameters:
scopeName- the name of the scope.- Returns:
- containing information about the scope.
- Throws:
ScopeNotFoundException- if scope does not exist.CouchbaseException- if any other generic unhandled/unexpected errors.
-
getScope
@Deprecated public ScopeSpec getScope(String scopeName, GetScopeOptions options)
Deprecated.usegetAllScopes(GetAllScopesOptions)instead.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:
ScopeNotFoundException- if scope does not exist.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:
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:
CouchbaseException- if any other generic unhandled/unexpected errors.
-
-