Package org.ldaptive.beans.persistence
Class DefaultLdapEntryManager<T>
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.beans.persistence.DefaultLdapEntryManager<T>
-
- Type Parameters:
T- type of object to manage
- All Implemented Interfaces:
LdapEntryManager<T>,Freezable
public class DefaultLdapEntryManager<T> extends AbstractFreezable implements LdapEntryManager<T>
Default implementation of an ldap entry manager. Uses anLdapEntryMapperto convert objects to entries, then invokes LDAP operations with those objects. By default, all attributes are requested using both the '*' and '+' syntaxes. For attributes that must be requested by name, useDefaultLdapEntryManager(LdapEntryMapper, ConnectionFactory, String[]).
-
-
Field Summary
Fields Modifier and Type Field Description private AddOperationaddOperationAdd operation used to add a new entry.private ConnectionFactoryconnectionFactoryConnection factory for LDAP communication.private DeleteOperationdeleteOperationDelete operation used to remove an entry.private LdapEntryMapper<T>ldapEntryMapperMapper for converting ldap entry to object type.protected LoggerloggerLogger for this class.private MergeOperationmergeOperationMerge operation used to merge an entry.private String[]returnAttributesAdditional attributes to include in searches.private SearchOperationsearchOperationSearch operation used to find an entry.
-
Constructor Summary
Constructors Constructor Description DefaultLdapEntryManager(LdapEntryMapper<T> mapper, ConnectionFactory factory)Creates a new default ldap entry manager.DefaultLdapEntryManager(LdapEntryMapper<T> mapper, ConnectionFactory factory, String[] attrs)Creates a new default ldap entry manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddResponseadd(T object)Adds the supplied annotated object to an LDAP.AddResponseadd(T object, ResultPredicate predicate)Adds the supplied annotated object to an LDAP.DeleteResponsedelete(T object)Deletes the supplied annotated object from an LDAP.DeleteResponsedelete(T object, ResultPredicate predicate)Deletes the supplied annotated object from an LDAP.Tfind(T object)Searches for the supplied annotated object in an LDAP and returns the object mapped with its ldap attribute properties set.AddOperationgetAddOperation()ConnectionFactorygetConnectionFactory()Returns the connection factory.DeleteOperationgetDeleteOperation()LdapEntryMapper<T>getLdapEntryMapper()Returns the ldap entry mapper.MergeOperationgetMergeOperation()String[]getReturnAttributes()Returns the return attributes.SearchOperationgetSearchOperation()Resultmerge(T object)Merges the supplied annotated object in an LDAP.Resultmerge(T object, ResultPredicate predicate)Merges the supplied annotated object in an LDAP.voidsetAddOperation(AddOperation operation)voidsetDeleteOperation(DeleteOperation operation)voidsetMergeOperation(MergeOperation operation)voidsetSearchOperation(SearchOperation operation)-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
ldapEntryMapper
private final LdapEntryMapper<T> ldapEntryMapper
Mapper for converting ldap entry to object type.
-
connectionFactory
private final ConnectionFactory connectionFactory
Connection factory for LDAP communication.
-
returnAttributes
private final String[] returnAttributes
Additional attributes to include in searches.
-
searchOperation
private SearchOperation searchOperation
Search operation used to find an entry.
-
addOperation
private AddOperation addOperation
Add operation used to add a new entry.
-
mergeOperation
private MergeOperation mergeOperation
Merge operation used to merge an entry.
-
deleteOperation
private DeleteOperation deleteOperation
Delete operation used to remove an entry.
-
-
Constructor Detail
-
DefaultLdapEntryManager
public DefaultLdapEntryManager(LdapEntryMapper<T> mapper, ConnectionFactory factory)
Creates a new default ldap entry manager.- Parameters:
mapper- for object conversionfactory- for LDAP communication
-
DefaultLdapEntryManager
public DefaultLdapEntryManager(LdapEntryMapper<T> mapper, ConnectionFactory factory, String[] attrs)
Creates a new default ldap entry manager. Use of attrs is for cases where a directory does not support either the '*' or '+' syntaxes for returning all attributes of a given type.- Parameters:
mapper- for object conversionfactory- for LDAP communicationattrs- additional return attributes
-
-
Method Detail
-
getLdapEntryMapper
public LdapEntryMapper<T> getLdapEntryMapper()
Returns the ldap entry mapper.- Returns:
- ldap entry mapper
-
getConnectionFactory
public ConnectionFactory getConnectionFactory()
Returns the connection factory.- Returns:
- connection factory
-
getReturnAttributes
public String[] getReturnAttributes()
Returns the return attributes.- Returns:
- additional attributes to include in searches.
-
getSearchOperation
public SearchOperation getSearchOperation()
-
setSearchOperation
public void setSearchOperation(SearchOperation operation)
-
getAddOperation
public AddOperation getAddOperation()
-
setAddOperation
public void setAddOperation(AddOperation operation)
-
getMergeOperation
public MergeOperation getMergeOperation()
-
setMergeOperation
public void setMergeOperation(MergeOperation operation)
-
getDeleteOperation
public DeleteOperation getDeleteOperation()
-
setDeleteOperation
public void setDeleteOperation(DeleteOperation operation)
-
find
public T find(T object) throws LdapException
Description copied from interface:LdapEntryManagerSearches for the supplied annotated object in an LDAP and returns the object mapped with its ldap attribute properties set.- Specified by:
findin interfaceLdapEntryManager<T>- Parameters:
object- to find- Returns:
- mapped object
- Throws:
LdapException- if the object cannot be found
-
add
public AddResponse add(T object) throws LdapException
Description copied from interface:LdapEntryManagerAdds the supplied annotated object to an LDAP.- Specified by:
addin interfaceLdapEntryManager<T>- Parameters:
object- to add- Returns:
- LDAP response from the add operation
- Throws:
LdapException- if the add fails
-
add
public AddResponse add(T object, ResultPredicate predicate) throws LdapException
Adds the supplied annotated object to an LDAP.- Parameters:
object- to addpredicate- to test the result and throw on failure- Returns:
- LDAP response from the add operation
- Throws:
LdapException- if the add fails
-
merge
public Result merge(T object) throws LdapException
Description copied from interface:LdapEntryManagerMerges the supplied annotated object in an LDAP. SeeMergeOperation.- Specified by:
mergein interfaceLdapEntryManager<T>- Parameters:
object- to merge- Returns:
- LDAP response from the merge operation
- Throws:
LdapException- if the merge fails
-
merge
public Result merge(T object, ResultPredicate predicate) throws LdapException
Merges the supplied annotated object in an LDAP. SeeMergeOperation.- Parameters:
object- to mergepredicate- to test the result and throw on failure- Returns:
- LDAP response from the merge operation
- Throws:
LdapException- if the merge fails
-
delete
public DeleteResponse delete(T object) throws LdapException
Description copied from interface:LdapEntryManagerDeletes the supplied annotated object from an LDAP.- Specified by:
deletein interfaceLdapEntryManager<T>- Parameters:
object- to delete- Returns:
- LDAP response from the delete operation
- Throws:
LdapException- if the delete fails
-
delete
public DeleteResponse delete(T object, ResultPredicate predicate) throws LdapException
Deletes the supplied annotated object from an LDAP.- Parameters:
object- to deletepredicate- to test the result and throw on failure- Returns:
- LDAP response from the delete operation
- Throws:
LdapException- if the delete fails
-
-