Class DefaultLdapEntryManager<T>

java.lang.Object
org.ldaptive.beans.persistence.DefaultLdapEntryManager<T>
Type Parameters:
T - type of object to manage
All Implemented Interfaces:
LdapEntryManager<T>

public class DefaultLdapEntryManager<T> extends Object implements LdapEntryManager<T>
Default implementation of an ldap entry manager. Uses an LdapEntryMapper to 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, use DefaultLdapEntryManager(LdapEntryMapper, ConnectionFactory, String[]).
  • Field Details

    • logger

      protected final org.slf4j.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.
  • Constructor Details

    • DefaultLdapEntryManager

      public DefaultLdapEntryManager(LdapEntryMapper<T> mapper, ConnectionFactory factory)
      Creates a new default ldap entry manager.
      Parameters:
      mapper - for object conversion
      factory - 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 conversion
      factory - for LDAP communication
      attrs - additional return attributes
  • Method Details

    • 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.
    • find

      public T find(T object) throws LdapException
      Description copied from interface: LdapEntryManager
      Searches for the supplied annotated object in an LDAP and returns the object mapped with it's ldap attribute properties set.
      Specified by:
      find in interface LdapEntryManager<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: LdapEntryManager
      Adds the supplied annotated object to an LDAP.
      Specified by:
      add in interface LdapEntryManager<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 add
      predicate - 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: LdapEntryManager
      Merges the supplied annotated object in an LDAP. See MergeOperation.
      Specified by:
      merge in interface LdapEntryManager<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. See MergeOperation.
      Parameters:
      object - to merge
      predicate - 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: LdapEntryManager
      Deletes the supplied annotated object from an LDAP.
      Specified by:
      delete in interface LdapEntryManager<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 delete
      predicate - to test the result and throw on failure
      Returns:
      LDAP response from the delete operation
      Throws:
      LdapException - if the delete fails