Package de.aservo.ldap.adapter.backend
Class CachedWithPersistenceDirectoryBackend
- java.lang.Object
-
- de.aservo.ldap.adapter.backend.ProxyDirectoryBackend
-
- de.aservo.ldap.adapter.backend.CachedDirectoryBackend
-
- de.aservo.ldap.adapter.backend.CachedWithPersistenceDirectoryBackend
-
- All Implemented Interfaces:
DirectoryBackend,NestedDirectoryBackend
public class CachedWithPersistenceDirectoryBackend extends CachedDirectoryBackend
A proxy for directory backends to cache entities via SQL based persistence strategy.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_APPLY_NATIVE_SQLThe constant CONFIG_APPLY_NATIVE_SQL.static StringCONFIG_DB_DRIVERThe constant CONFIG_DB_DRIVER.static StringCONFIG_DB_ISO_LEVELThe constant CONFIG_DB_ISO_LEVEL.static StringCONFIG_DB_MAX_IDLEThe constant CONFIG_DB_MAX_IDLE.static StringCONFIG_DB_MAX_OPEN_STMTThe constant CONFIG_DB_MAX_OPEN_STMT.static StringCONFIG_DB_MAX_TOTALThe constant CONFIG_DB_MAX_TOTAL.static StringCONFIG_DB_MIN_IDLEThe constant CONFIG_DB_MIN_IDLE.static StringCONFIG_DB_PWThe constant CONFIG_DB_PW.static StringCONFIG_DB_URLThe constant CONFIG_DB_URL.static StringCONFIG_DB_USERThe constant CONFIG_DB_USER.static StringCONFIG_PASS_ACTIVE_USERS_ONLYThe constant CONFIG_PASS_ACTIVE_USERS_ONLY.static StringCONFIG_TRANSACTION_TIMEOUTThe constant CONFIG_TRANSACTION_TIMEOUT.static StringCONFIG_USE_MATERIALIZED_VIEWSThe constant CONFIG_USE_MATERIALIZED_VIEWS.-
Fields inherited from class de.aservo.ldap.adapter.backend.ProxyDirectoryBackend
config, directoryBackend
-
-
Constructor Summary
Constructors Constructor Description CachedWithPersistenceDirectoryBackend(ServerConfiguration config, NestedDirectoryBackend directoryBackend)Instantiates a new directory backend.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddropAllGroups()To reset the cache all group entities are dropped.voiddropAllUsers()To reset the cache all user entities are dropped.voiddropGroup(String id)To keep the cache up-to-date a group entity is dropped.voiddropMembership(MembershipEntity membership)To keep the cache up-to-date a membership entity is dropped.voiddropUser(String id)To keep the cache up-to-date an user entity is dropped.Set<GroupEntity>getAllGroups()Gets all groups.Set<UserEntity>getAllUsers()Gets all users.Set<GroupEntity>getDirectChildGroupsOfGroup(String id)Gets direct child groups of group.Set<GroupEntity>getDirectGroupsOfUser(String id)Gets direct groups of user.Set<GroupEntity>getDirectParentGroupsOfGroup(String id)Gets direct parent groups of group.Set<UserEntity>getDirectUsersOfGroup(String id)Gets direct users of group.GroupEntitygetGroup(String id)Gets group info.Set<GroupEntity>getTransitiveChildGroupsOfGroup(String id)Gets transitive child groups of group.Set<GroupEntity>getTransitiveGroupsOfUser(String id)Gets transitive groups of user.Set<GroupEntity>getTransitiveParentGroupsOfGroup(String id)Gets transitive parent groups of group.Set<UserEntity>getTransitiveUsersOfGroup(String id)Gets transitive users of group.UserEntitygetUser(String id)Gets user info.booleanrequireReset()Check if the caches need a reset.MappableCursor<Row>runQueryExpression(String txId, org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager, QueryExpression expression, EntityType entityType)Runs a query expression.voidshutdown()Shutdown method.voidstartup()Startup method.intupsertAllGroups()To keep the cache up-to-date all group entities are updated or inserted.intupsertAllGroups(int startIndex, int maxResults)To keep the cache up-to-date all group entities are updated or inserted.intupsertAllUsers()To keep the cache up-to-date all user entities are updated or inserted.intupsertAllUsers(int startIndex, int maxResults)To keep the cache up-to-date all user entities are updated or inserted.voidupsertGroup(String id)To keep the cache up-to-date a group entity is updated or inserted.voidupsertMembership(MembershipEntity membership)To keep the cache up-to-date a membership entity is updated or inserted.voidupsertUser(String id)To keep the cache up-to-date an user entity is updated or inserted.voidwithReadAccess(Runnable block)Check if the caches need a reset.<T> TwithReadAccess(Supplier<T> block)Check if the caches need a reset.voidwithWriteAccess(Runnable block)Check if the caches need a reset.<T> TwithWriteAccess(Supplier<T> block)Check if the caches need a reset.-
Methods inherited from class de.aservo.ldap.adapter.backend.ProxyDirectoryBackend
getAllGroups, getAllUsers, getAuthenticatedUser, getId, getMemberships
-
-
-
-
Field Detail
-
CONFIG_DB_DRIVER
public static final String CONFIG_DB_DRIVER
The constant CONFIG_DB_DRIVER.- See Also:
- Constant Field Values
-
CONFIG_DB_URL
public static final String CONFIG_DB_URL
The constant CONFIG_DB_URL.- See Also:
- Constant Field Values
-
CONFIG_DB_USER
public static final String CONFIG_DB_USER
The constant CONFIG_DB_USER.- See Also:
- Constant Field Values
-
CONFIG_DB_PW
public static final String CONFIG_DB_PW
The constant CONFIG_DB_PW.- See Also:
- Constant Field Values
-
CONFIG_DB_MIN_IDLE
public static final String CONFIG_DB_MIN_IDLE
The constant CONFIG_DB_MIN_IDLE.- See Also:
- Constant Field Values
-
CONFIG_DB_MAX_IDLE
public static final String CONFIG_DB_MAX_IDLE
The constant CONFIG_DB_MAX_IDLE.- See Also:
- Constant Field Values
-
CONFIG_DB_MAX_TOTAL
public static final String CONFIG_DB_MAX_TOTAL
The constant CONFIG_DB_MAX_TOTAL.- See Also:
- Constant Field Values
-
CONFIG_DB_MAX_OPEN_STMT
public static final String CONFIG_DB_MAX_OPEN_STMT
The constant CONFIG_DB_MAX_OPEN_STMT.- See Also:
- Constant Field Values
-
CONFIG_DB_ISO_LEVEL
public static final String CONFIG_DB_ISO_LEVEL
The constant CONFIG_DB_ISO_LEVEL.- See Also:
- Constant Field Values
-
CONFIG_TRANSACTION_TIMEOUT
public static final String CONFIG_TRANSACTION_TIMEOUT
The constant CONFIG_TRANSACTION_TIMEOUT.- See Also:
- Constant Field Values
-
CONFIG_APPLY_NATIVE_SQL
public static final String CONFIG_APPLY_NATIVE_SQL
The constant CONFIG_APPLY_NATIVE_SQL.- See Also:
- Constant Field Values
-
CONFIG_USE_MATERIALIZED_VIEWS
public static final String CONFIG_USE_MATERIALIZED_VIEWS
The constant CONFIG_USE_MATERIALIZED_VIEWS.- See Also:
- Constant Field Values
-
CONFIG_PASS_ACTIVE_USERS_ONLY
public static final String CONFIG_PASS_ACTIVE_USERS_ONLY
The constant CONFIG_PASS_ACTIVE_USERS_ONLY.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CachedWithPersistenceDirectoryBackend
public CachedWithPersistenceDirectoryBackend(ServerConfiguration config, NestedDirectoryBackend directoryBackend)
Instantiates a new directory backend.- Parameters:
config- config the config instance of the serverdirectoryBackend- the directory backend
-
-
Method Detail
-
startup
public void startup()
Description copied from interface:DirectoryBackendStartup method.- Specified by:
startupin interfaceDirectoryBackend- Overrides:
startupin classProxyDirectoryBackend
-
shutdown
public void shutdown()
Description copied from interface:DirectoryBackendShutdown method.- Specified by:
shutdownin interfaceDirectoryBackend- Overrides:
shutdownin classProxyDirectoryBackend
-
withReadAccess
public <T> T withReadAccess(Supplier<T> block)
Description copied from interface:NestedDirectoryBackendCheck if the caches need a reset.- Specified by:
withReadAccessin interfaceNestedDirectoryBackend- Overrides:
withReadAccessin classProxyDirectoryBackend- Parameters:
block- the supplier object executed within the session- Returns:
- the result of the supplier code block
-
withReadAccess
public void withReadAccess(Runnable block)
Description copied from interface:NestedDirectoryBackendCheck if the caches need a reset.- Specified by:
withReadAccessin interfaceNestedDirectoryBackend- Overrides:
withReadAccessin classProxyDirectoryBackend- Parameters:
block- the runnable object executed within the session
-
withWriteAccess
public <T> T withWriteAccess(Supplier<T> block)
Description copied from interface:NestedDirectoryBackendCheck if the caches need a reset.- Specified by:
withWriteAccessin interfaceNestedDirectoryBackend- Overrides:
withWriteAccessin classProxyDirectoryBackend- Parameters:
block- the supplier object executed within the session- Returns:
- the result of the supplier code block
-
withWriteAccess
public void withWriteAccess(Runnable block)
Description copied from interface:NestedDirectoryBackendCheck if the caches need a reset.- Specified by:
withWriteAccessin interfaceNestedDirectoryBackend- Overrides:
withWriteAccessin classProxyDirectoryBackend- Parameters:
block- the runnable object executed within the session
-
requireReset
public boolean requireReset()
Description copied from interface:NestedDirectoryBackendCheck if the caches need a reset.- Specified by:
requireResetin interfaceNestedDirectoryBackend- Overrides:
requireResetin classProxyDirectoryBackend- Returns:
- the boolean
-
upsertGroup
public void upsertGroup(String id)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date a group entity is updated or inserted.- Specified by:
upsertGroupin interfaceNestedDirectoryBackend- Overrides:
upsertGroupin classProxyDirectoryBackend- Parameters:
id- the group ID
-
upsertAllGroups
public int upsertAllGroups(int startIndex, int maxResults)Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date all group entities are updated or inserted.- Specified by:
upsertAllGroupsin interfaceNestedDirectoryBackend- Overrides:
upsertAllGroupsin classProxyDirectoryBackend- Parameters:
startIndex- the start index for paginationmaxResults- the maximum number of results for pagination- Returns:
- the number of handled entities
-
upsertAllGroups
public int upsertAllGroups()
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date all group entities are updated or inserted.- Specified by:
upsertAllGroupsin interfaceNestedDirectoryBackend- Overrides:
upsertAllGroupsin classProxyDirectoryBackend- Returns:
- the number of handled entities
-
upsertUser
public void upsertUser(String id)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date an user entity is updated or inserted.- Specified by:
upsertUserin interfaceNestedDirectoryBackend- Overrides:
upsertUserin classProxyDirectoryBackend- Parameters:
id- the user ID
-
upsertAllUsers
public int upsertAllUsers(int startIndex, int maxResults)Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date all user entities are updated or inserted.- Specified by:
upsertAllUsersin interfaceNestedDirectoryBackend- Overrides:
upsertAllUsersin classProxyDirectoryBackend- Parameters:
startIndex- the start index for paginationmaxResults- the maximum number of results for pagination- Returns:
- the number of handled entities
-
upsertAllUsers
public int upsertAllUsers()
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date all user entities are updated or inserted.- Specified by:
upsertAllUsersin interfaceNestedDirectoryBackend- Overrides:
upsertAllUsersin classProxyDirectoryBackend- Returns:
- the number of handled entities
-
upsertMembership
public void upsertMembership(MembershipEntity membership)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date a membership entity is updated or inserted.- Specified by:
upsertMembershipin interfaceNestedDirectoryBackend- Overrides:
upsertMembershipin classProxyDirectoryBackend- Parameters:
membership- the membership entity
-
dropGroup
public void dropGroup(String id)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date a group entity is dropped.- Specified by:
dropGroupin interfaceNestedDirectoryBackend- Overrides:
dropGroupin classProxyDirectoryBackend- Parameters:
id- the group ID
-
dropAllGroups
public void dropAllGroups()
Description copied from interface:NestedDirectoryBackendTo reset the cache all group entities are dropped.- Specified by:
dropAllGroupsin interfaceNestedDirectoryBackend- Overrides:
dropAllGroupsin classProxyDirectoryBackend
-
dropUser
public void dropUser(String id)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date an user entity is dropped.- Specified by:
dropUserin interfaceNestedDirectoryBackend- Overrides:
dropUserin classProxyDirectoryBackend- Parameters:
id- the user ID
-
dropAllUsers
public void dropAllUsers()
Description copied from interface:NestedDirectoryBackendTo reset the cache all user entities are dropped.- Specified by:
dropAllUsersin interfaceNestedDirectoryBackend- Overrides:
dropAllUsersin classProxyDirectoryBackend
-
dropMembership
public void dropMembership(MembershipEntity membership)
Description copied from interface:NestedDirectoryBackendTo keep the cache up-to-date a membership entity is dropped.- Specified by:
dropMembershipin interfaceNestedDirectoryBackend- Overrides:
dropMembershipin classProxyDirectoryBackend- Parameters:
membership- the membership entity
-
runQueryExpression
public MappableCursor<Row> runQueryExpression(String txId, org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager, QueryExpression expression, EntityType entityType)
Description copied from interface:DirectoryBackendRuns a query expression.- Specified by:
runQueryExpressionin interfaceDirectoryBackend- Overrides:
runQueryExpressionin classProxyDirectoryBackend- Parameters:
txId- the transaction IDschemaManager- the schema managerexpression- the query expressionentityType- the entity type- Returns:
- the query generator
-
getGroup
public GroupEntity getGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets group info.- Specified by:
getGroupin interfaceDirectoryBackend- Overrides:
getGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the group
- Throws:
EntityNotFoundException- the entry not found exception
-
getUser
public UserEntity getUser(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets user info.- Specified by:
getUserin interfaceDirectoryBackend- Overrides:
getUserin classProxyDirectoryBackend- Parameters:
id- the user ID- Returns:
- the user
- Throws:
EntityNotFoundException- the entry not found exception
-
getAllGroups
public Set<GroupEntity> getAllGroups()
Description copied from interface:DirectoryBackendGets all groups.- Specified by:
getAllGroupsin interfaceDirectoryBackend- Overrides:
getAllGroupsin classProxyDirectoryBackend- Returns:
- the groups
-
getAllUsers
public Set<UserEntity> getAllUsers()
Description copied from interface:DirectoryBackendGets all users.- Specified by:
getAllUsersin interfaceDirectoryBackend- Overrides:
getAllUsersin classProxyDirectoryBackend- Returns:
- the users
-
getDirectUsersOfGroup
public Set<UserEntity> getDirectUsersOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets direct users of group.- Specified by:
getDirectUsersOfGroupin interfaceDirectoryBackend- Overrides:
getDirectUsersOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the direct users of group
- Throws:
EntityNotFoundException- the entry not found exception
-
getDirectGroupsOfUser
public Set<GroupEntity> getDirectGroupsOfUser(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets direct groups of user.- Specified by:
getDirectGroupsOfUserin interfaceDirectoryBackend- Overrides:
getDirectGroupsOfUserin classProxyDirectoryBackend- Parameters:
id- the user ID- Returns:
- the direct groups of user
- Throws:
EntityNotFoundException- the entry not found exception
-
getDirectChildGroupsOfGroup
public Set<GroupEntity> getDirectChildGroupsOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets direct child groups of group.- Specified by:
getDirectChildGroupsOfGroupin interfaceDirectoryBackend- Overrides:
getDirectChildGroupsOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the direct child groups of group
- Throws:
EntityNotFoundException- the entry not found exception
-
getDirectParentGroupsOfGroup
public Set<GroupEntity> getDirectParentGroupsOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets direct parent groups of group.- Specified by:
getDirectParentGroupsOfGroupin interfaceDirectoryBackend- Overrides:
getDirectParentGroupsOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the direct parent groups of group
- Throws:
EntityNotFoundException- the entry not found exception
-
getTransitiveUsersOfGroup
public Set<UserEntity> getTransitiveUsersOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets transitive users of group.- Specified by:
getTransitiveUsersOfGroupin interfaceDirectoryBackend- Overrides:
getTransitiveUsersOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the transitive users of group
- Throws:
EntityNotFoundException- the entry not found exception
-
getTransitiveGroupsOfUser
public Set<GroupEntity> getTransitiveGroupsOfUser(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets transitive groups of user.- Specified by:
getTransitiveGroupsOfUserin interfaceDirectoryBackend- Overrides:
getTransitiveGroupsOfUserin classProxyDirectoryBackend- Parameters:
id- the user ID- Returns:
- the transitive groups of user
- Throws:
EntityNotFoundException- the entry not found exception
-
getTransitiveChildGroupsOfGroup
public Set<GroupEntity> getTransitiveChildGroupsOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets transitive child groups of group.- Specified by:
getTransitiveChildGroupsOfGroupin interfaceDirectoryBackend- Overrides:
getTransitiveChildGroupsOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the transitive child groups of group
- Throws:
EntityNotFoundException- the entry not found exception
-
getTransitiveParentGroupsOfGroup
public Set<GroupEntity> getTransitiveParentGroupsOfGroup(String id) throws EntityNotFoundException
Description copied from interface:DirectoryBackendGets transitive parent groups of group.- Specified by:
getTransitiveParentGroupsOfGroupin interfaceDirectoryBackend- Overrides:
getTransitiveParentGroupsOfGroupin classProxyDirectoryBackend- Parameters:
id- the group ID- Returns:
- the transitive parent groups of group
- Throws:
EntityNotFoundException- the entry not found exception
-
-