Class LDAPSession

java.lang.Object
com.netscape.cmscore.dbs.DBSSession
com.netscape.cmscore.dbs.LDAPSession
All Implemented Interfaces:
AutoCloseable

public class LDAPSession extends DBSSession
A class represents the database session. Operations can be performed with a session. Transaction and Caching support can be integrated into session.
Version:
$Revision$, $Date$
Author:
thomask
  • Field Details

    • logger

      public static final org.slf4j.Logger logger
    • MAX_PAGED_SEARCH_SIZE

      public static final int MAX_PAGED_SEARCH_SIZE
      See Also:
  • Constructor Details

    • LDAPSession

      public LDAPSession(DBSubsystem dbSubsystem, netscape.ldap.LDAPConnection c) throws EDBException
      Constructs a database session.
      Parameters:
      dbSubsystem - the database subsytem
      c - the ldap connection
      Throws:
      EDBException
  • Method Details

    • getConnection

      public netscape.ldap.LDAPConnection getConnection()
    • close

      public void close() throws EDBException
      Closes this session.
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class DBSSession
      Throws:
      EDBException - failed to close session
    • add

      public void add(String name, IDBObj obj) throws EBaseException
      Adds object to backend database. For example,
       session.add("cn=123459,o=certificate repository,o=airius.com",
                   certRec);
       
      Overrides:
      add in class DBSSession
      Parameters:
      name - the name of the ldap entry
      obj - the DBobj that can be mapped to ldap attrubute set
      Throws:
      EBaseException
    • read

      public IDBObj read(String name) throws EBaseException
      Reads an object from the database. all attributes will be returned
      Overrides:
      read in class DBSSession
      Parameters:
      name - the name of the ldap entry
      Returns:
      database object
      Throws:
      EBaseException - failed to read object
    • read

      public IDBObj read(String name, String[] attrs) throws EBaseException
      Reads an object from the database, and only populates the selected attributes.
      Overrides:
      read in class DBSSession
      Parameters:
      name - the name of the ldap entry
      attrs - the attributes to be selected
      Returns:
      database object
      Throws:
      EBaseException - failed to read object
    • delete

      public void delete(String name) throws EBaseException
      Deletes object from database.
      Overrides:
      delete in class DBSSession
      Parameters:
      name - name of the object that is to be deleted
      Throws:
      EBaseException - failed to delete object
    • modify

      public void modify(String name, ModificationSet mods) throws EBaseException
      Modify an object in the database.
      Overrides:
      modify in class DBSSession
      Parameters:
      name - name of the object that is to be modified
      mods - modifications
      Throws:
      EBaseException - failed to modify
    • search

      public DBSearchResults search(String base, String filter) throws EBaseException
      Searchs for a list of objects that match the filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • search

      public DBSearchResults search(String base, String filter, int maxSize) throws EBaseException
      Description copied from class: DBSSession
      Searchs for a list of objects that match the filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      maxSize - max number of entries
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • search

      public DBSearchResults search(String base, String filter, int maxSize, String sortAttribute) throws EBaseException
      Description copied from class: DBSSession
      Searchs for a list of objects that match the filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      maxSize - max number of entries
      sortAttribute - Field to sort the records on
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • search

      public DBSearchResults search(String base, String filter, int maxSize, int timeLimit) throws EBaseException
      Description copied from class: DBSSession
      Searchs for a list of objects that match the filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      maxSize - max number of entries
      timeLimit - timeout limit
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • search

      public DBSearchResults search(String base, String filter, int maxSize, int timeLimit, String sortAttribute) throws EBaseException
      Description copied from class: DBSSession
      Searchs for a list of objects that match the filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      maxSize - max number of entries
      timeLimit - timeout limit
      sortAttribute - Field to sort the records on
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • search

      public DBSearchResults search(String base, String filter, String[] attrs) throws EBaseException
      Retrieves a list of object that satifies the given filter.
      Overrides:
      search in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • pagedSearch

      public DBSearchResults pagedSearch(String base, String filter, int start, int size, int timeLimit) throws EBaseException
      Description copied from class: DBSSession
      Retrieves a list of object that satifies the given filter.
      Overrides:
      pagedSearch in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      start - index of the first element
      size - max number of element in the page
      timeLimit - timeout limit
      Returns:
      search results
      Throws:
      EBaseException - failed to search
    • countEntries

      public <T extends IDBObj> int countEntries(Class<T> classResults, String base, String filter, int timeLimit) throws EBaseException
      Description copied from class: DBSSession
      Retrieves a list of object that satisfies the given filter.
      Overrides:
      countEntries in class DBSSession
      Parameters:
      classResults - the class representing the entries in the paged list
      base - starting point of the search
      filter - search filter
      timeLimit - timeout limit
      Returns:
      the number of certificates
      Throws:
      EBaseException - failed to search
    • persistentSearch

      public netscape.ldap.LDAPSearchResults persistentSearch(String base, String filter, String[] attrs) throws EBaseException
      Description copied from class: DBSSession
      Sets persistent search to retrieve modified certificate records.
      Overrides:
      persistentSearch in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      Returns:
      LDAP search results
      Throws:
      EBaseException - failed to search
    • abandon

      public void abandon(netscape.ldap.LDAPSearchResults results) throws EBaseException
      Overrides:
      abandon in class DBSSession
      Throws:
      EBaseException
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs) throws EBaseException
      Retrieves a list of objects.
      Overrides:
      createVirtualList in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      Returns:
      search results in virtual list
      Throws:
      EBaseException - failed to search
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs, String[] sortKey) throws EBaseException
      Retrieves a list of objects.
      Throws:
      EBaseException
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs, String sortKey) throws EBaseException
      Retrieves a list of objects.
      Throws:
      EBaseException
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs, String[] sortKey, int pageSize) throws EBaseException
      Retrieves a list of objects.
      Overrides:
      createVirtualList in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      sortKey - keys used to sort the list
      pageSize - page size in the virtual list
      Returns:
      search results in virtual list
      Throws:
      EBaseException - failed to search
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs, String sortKey, int pageSize) throws EBaseException
      Retrieves a list of objects.
      Overrides:
      createVirtualList in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      sortKey - key used to sort the list
      pageSize - page size in the virtual list
      Returns:
      search results in virtual list
      Throws:
      EBaseException - failed to search
    • createVirtualList

      public <T extends IDBObj> DBVirtualList<T> createVirtualList(String base, String filter, String[] attrs, String startFrom, String sortKey, int pageSize) throws EBaseException
      Description copied from class: DBSSession
      Retrieves a list of objects.
      Overrides:
      createVirtualList in class DBSSession
      Parameters:
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      startFrom - starting point
      sortKey - key used to sort the list
      pageSize - page size in the virtual list
      Returns:
      search results in virtual list
      Throws:
      EBaseException - failed to search
    • createPagedSearch

      public <T extends IDBObj> DBPagedSearch<T> createPagedSearch(Class<T> classResults, String base, String filter, String[] attrs, String sortKey) throws EBaseException
      Description copied from class: DBSSession
      Retrieves a paged search of objects.
      Overrides:
      createPagedSearch in class DBSSession
      Parameters:
      classResults - the class representing the entries in the paged list
      base - starting point of the search
      filter - search filter
      attrs - selected attributes
      sortKey - key used to sort the list
      Returns:
      search results in virtual list
      Throws:
      EBaseException - failed to search
    • release

      public void release(Object obj)
      Releases object to this interface. This allows us to use memory more efficiently.