Package org.forgerock.openam.cts
Class CTSPersistentStoreImpl
- java.lang.Object
-
- org.forgerock.openam.cts.CTSPersistentStoreImpl
-
- All Implemented Interfaces:
CTSPersistentStore
@Singleton public class CTSPersistentStoreImpl extends Object implements CTSPersistentStore
Implementation of the CTS (Core Token Store) persistence layer. This implementation offers synchronous and asynchronous approaches to decouple callers from the processing of token related tasks. This is detailed in theCoreTokenAdapterin more detail.- See Also:
Token,CoreTokenAdapter
-
-
Constructor Summary
Constructors Constructor Description CTSPersistentStoreImpl(CoreTokenAdapter adapter, Debug debug)Creates a default implementation of the CTSPersistentStoreImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContinuousQueryListener(ContinuousQueryListener listener, TokenFilter tokenFilter)Performs a continuous query against the persistent store using the provided TokenFilter.Collection<PartialToken>attributeQuery(TokenFilter tokenFilter)Performs a partial Token query against the store synchronously.voidcreate(Token token)This implementation blocks until we get the results, and ignores non-exception results.voidcreate(Token token, org.forgerock.util.Options options)This implementation blocks until we get the results, and ignores non-exception results.voidcreateAsync(Token token)Creates a Token in the persistent store asynchronously.voidcreateAsync(Token token, org.forgerock.util.Options options)Creates a Token in the persistent store asynchronously.voiddelete(String tokenId)Delete the Token from the store synchronously based on its id.voiddelete(String tokenId, org.forgerock.util.Options options)Delete the Token from the store synchronously based on its id.intdelete(Map<CoreTokenField,Object> query)Delete a collection of Tokens from the Token Store asynchronously using a filter to narrow down the Tokens to be deleted.voiddelete(Token token)Delete the Token from the store synchronously.voiddeleteAsync(String tokenId)Delete the Token from the store asynchronously based on its id.voiddeleteAsync(String tokenId, org.forgerock.util.Options options)Delete the Token from the store asynchronously based on its id.voiddeleteAsync(Token token)Deletes the Token from the store asynchronously.voiddeleteOnQueryAsync(TokenFilter tokenFilter)Performs an asynchronous query against the persistent store using the provided TokenFilter and then deletes the matching tokens from the store.Collection<Token>query(TokenFilter tokenFilter)Performs a synchronous query against the persistent store using the provided TokenFilter.Tokenread(String tokenId)Read a Token from the persistent store synchronously.Tokenread(String tokenId, org.forgerock.util.Options options)Read a Token from the persistent store synchronously.voidremoveContinuousQueryListener(ContinuousQueryListener listener, TokenFilter tokenFilter)Removes aContinuousQueryListenerfrom a specifiedTokenFilter.voidstopContinuousQuery(TokenFilter tokenFilter)Removes allContinuousQueryListeners and stops aContinuousQuerygenerated for a specifiedTokenFilter.voidupdate(Token token)Updates an existing Token in the store synchronously.voidupdate(Token token, org.forgerock.util.Options options)Updates an existing Token in the store synchronously.voidupdateAsync(Token token)Updates an existing Token in the store asynchronously.voidupdateAsync(Token token, org.forgerock.util.Options options)Updates an existing Token in the store asynchronously.
-
-
-
Constructor Detail
-
CTSPersistentStoreImpl
@Inject public CTSPersistentStoreImpl(CoreTokenAdapter adapter, Debug debug)
Creates a default implementation of the CTSPersistentStoreImpl.- Parameters:
adapter- Required for CTS operations.debug- Required for debugging.
-
-
Method Detail
-
create
public void create(Token token) throws CoreTokenException
This implementation blocks until we get the results, and ignores non-exception results.- Specified by:
createin interfaceCTSPersistentStore- Parameters:
token- Non null Token to create.- Throws:
CoreTokenException- In the case of issues with
-
create
public void create(Token token, org.forgerock.util.Options options) throws CoreTokenException
This implementation blocks until we get the results, and ignores non-exception results.- Specified by:
createin interfaceCTSPersistentStore- Parameters:
token- Non null Token to create.options- Non null Options for the operation.- Throws:
CoreTokenException- In the case of issues with
-
createAsync
public void createAsync(Token token) throws CoreTokenException
Description copied from interface:CTSPersistentStoreCreates a Token in the persistent store asynchronously. The result of the operation (success/failure) is ignored.- Specified by:
createAsyncin interfaceCTSPersistentStore- Parameters:
token- Non null Token to create.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token.
-
createAsync
public void createAsync(Token token, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreCreates a Token in the persistent store asynchronously. The result of the operation (success/failure) is ignored.- Specified by:
createAsyncin interfaceCTSPersistentStore- Parameters:
token- Non null Token to create.options- Non null Options for the operation.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token.
-
read
public Token read(String tokenId) throws CoreTokenException
Description copied from interface:CTSPersistentStoreRead a Token from the persistent store synchronously.- Specified by:
readin interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id that the Token was created with.- Returns:
- Null if there was no matching Token. Otherwise a fully populated Token will be returned.
- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the returned Token, or if the operation itself has failed.
-
read
public Token read(String tokenId, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreRead a Token from the persistent store synchronously.- Specified by:
readin interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id that the Token was created with.options- The non null Options for the operation.- Returns:
- Null if there was no matching Token. Otherwise a fully populated Token will be returned.
- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the returned Token, or if the operation itself has failed.
-
update
public void update(Token token) throws CoreTokenException
Description copied from interface:CTSPersistentStoreUpdates an existing Token in the store synchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.- Specified by:
updatein interfaceCTSPersistentStore- Parameters:
token- Non null Token to update.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token, or if the operation itself has failed.- See Also:
Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
-
update
public void update(Token token, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreUpdates an existing Token in the store synchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.- Specified by:
updatein interfaceCTSPersistentStore- Parameters:
token- Non null Token to update.options- Non null Options for the operation.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token, or if the operation itself has failed.- See Also:
Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
-
updateAsync
public void updateAsync(Token token) throws CoreTokenException
Description copied from interface:CTSPersistentStoreUpdates an existing Token in the store asynchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.- Specified by:
updateAsyncin interfaceCTSPersistentStore- Parameters:
token- Non null Token to update.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token.- See Also:
Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
-
updateAsync
public void updateAsync(Token token, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreUpdates an existing Token in the store asynchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.- Specified by:
updateAsyncin interfaceCTSPersistentStore- Parameters:
token- Non null Token to update.options- Non null Options for the operation.- Throws:
CoreTokenException- If there was an error while performing the differentTokenBlobStrategys on the provided Token.- See Also:
Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
-
delete
public void delete(Token token) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDelete the Token from the store synchronously.- Specified by:
deletein interfaceCTSPersistentStore- Parameters:
token- Non null Token to be deleted from the store.- Throws:
CoreTokenException- If the delete operation has failed.
-
deleteAsync
public void deleteAsync(Token token) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDeletes the Token from the store asynchronously.- Specified by:
deleteAsyncin interfaceCTSPersistentStore- Parameters:
token- Non null Token to be deleted from the store.- Throws:
CoreTokenException
-
delete
public void delete(String tokenId) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDelete the Token from the store synchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.- Specified by:
deletein interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id of the token to remove.- Throws:
CoreTokenException- If the delete operation has failed.
-
delete
public void delete(String tokenId, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDelete the Token from the store synchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.- Specified by:
deletein interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id of the token to remove.options- The non null Options for the operation.- Throws:
CoreTokenException- If the delete operation has failed.
-
deleteAsync
public void deleteAsync(String tokenId) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDelete the Token from the store asynchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.- Specified by:
deleteAsyncin interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id of the token to remove.- Throws:
CoreTokenException
-
deleteAsync
public void deleteAsync(String tokenId, org.forgerock.util.Options options) throws CoreTokenException
Description copied from interface:CTSPersistentStoreDelete the Token from the store asynchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.- Specified by:
deleteAsyncin interfaceCTSPersistentStore- Parameters:
tokenId- The non null Token Id of the token to remove.options- The non null Options for the operation.- Throws:
CoreTokenException
-
delete
public int delete(Map<CoreTokenField,Object> query) throws DeleteFailedException
Description copied from interface:CTSPersistentStoreDelete a collection of Tokens from the Token Store asynchronously using a filter to narrow down the Tokens to be deleted.- Specified by:
deletein interfaceCTSPersistentStore- Parameters:
query- Non null filters which will be combined logically using AND.- Returns:
- total number of tokens deleted by query.
- Throws:
DeleteFailedException
-
addContinuousQueryListener
public void addContinuousQueryListener(ContinuousQueryListener listener, TokenFilter tokenFilter) throws CoreTokenException
Description copied from interface:CTSPersistentStorePerforms a continuous query against the persistent store using the provided TokenFilter. The filter is assembled by the TokenFilterBuilder which provides the options on how to turn the query being performed. The filter is appropriate to the underlying persistent layer type. The continuous query will begin and the listener will be attached.- Specified by:
addContinuousQueryListenerin interfaceCTSPersistentStore- Parameters:
listener- A listener which is capable of handling the results from this continuous query.tokenFilter- Non null filter.- Throws:
CoreTokenException- If there was any error whilst performing the query.- See Also:
TokenFilter,TokenFilterBuilder
-
removeContinuousQueryListener
public void removeContinuousQueryListener(ContinuousQueryListener listener, TokenFilter tokenFilter) throws CoreTokenException
Description copied from interface:CTSPersistentStoreRemoves aContinuousQueryListenerfrom a specifiedTokenFilter.- Specified by:
removeContinuousQueryListenerin interfaceCTSPersistentStore- Parameters:
listener- A listener which is already associated with a running continuous query.tokenFilter- Non null filter.- Throws:
CoreTokenException- See Also:
TokenFilter,TokenFilterBuilder
-
stopContinuousQuery
public void stopContinuousQuery(TokenFilter tokenFilter)
Description copied from interface:CTSPersistentStoreRemoves allContinuousQueryListeners and stops aContinuousQuerygenerated for a specifiedTokenFilter.- Specified by:
stopContinuousQueryin interfaceCTSPersistentStore- Parameters:
tokenFilter- Non null filter.- See Also:
ContinuousQueryListener,ContinuousQuery
-
query
public Collection<Token> query(TokenFilter tokenFilter) throws CoreTokenException
Description copied from interface:CTSPersistentStorePerforms a synchronous query against the persistent store using the provided TokenFilter. The filter is assembled by the TokenFilterBuilder which provides the options on how to turn the query being performed.- Specified by:
queryin interfaceCTSPersistentStore- Parameters:
tokenFilter- Non null filter.- Returns:
- Non null, but maybe empty.
- Throws:
CoreTokenException- If there was any error whilst performing the query.- See Also:
TokenFilter,TokenFilterBuilder
-
attributeQuery
public Collection<PartialToken> attributeQuery(TokenFilter tokenFilter) throws CoreTokenException
Description copied from interface:CTSPersistentStorePerforms a partial Token query against the store synchronously. That is, a query which is aimed at specific attributes of a Token, rather than whole Tokens. The return result will consist of PartialTokens for this purpose. This function is useful for example, finding all Token IDs that match a certain criteria.- Specified by:
attributeQueryin interfaceCTSPersistentStore- Parameters:
tokenFilter- Non null TokenFilter, with the return attributes defined.- Returns:
- Non null, but maybe empty.
- Throws:
CoreTokenException- If there was any error whilst performing the query.- See Also:
TokenFilter.addReturnAttribute(org.forgerock.openam.tokens.CoreTokenField),TokenFilterBuilder,PartialToken
-
deleteOnQueryAsync
public void deleteOnQueryAsync(TokenFilter tokenFilter) throws CoreTokenException
Description copied from interface:CTSPersistentStorePerforms an asynchronous query against the persistent store using the provided TokenFilter and then deletes the matching tokens from the store.- Specified by:
deleteOnQueryAsyncin interfaceCTSPersistentStore- Parameters:
tokenFilter- Non null filter.- Throws:
CoreTokenException- If there was a problem queuing the task to be performed.- See Also:
TokenFilterBuilder
-
-