Class MemoryDirectorySession

java.lang.Object
org.nuxeo.ecm.directory.BaseSession
org.nuxeo.ecm.directory.memory.MemoryDirectorySession
All Implemented Interfaces:
AutoCloseable, EntrySource, Session

public class MemoryDirectorySession extends BaseSession
Trivial in-memory implementation of a Directory to use in unit tests.
Author:
Florent Guillaume
  • Field Details

  • Constructor Details

    • MemoryDirectorySession

      public MemoryDirectorySession(MemoryDirectory directory)
  • Method Details

    • getDirectory

      public MemoryDirectory getDirectory()
      To be implemented with a more specific type.
      Specified by:
      getDirectory in class BaseSession
    • authenticate

      public boolean authenticate(String username, String password)
      Description copied from interface: Session
      Checks that the credentials provided by the UserManager match those registered in the directory. If username is not in the directory, this should return false instead of throrwing an exception.
      Returns:
      true is the credentials match those stored in the directory
    • close

      public void close()
      Description copied from interface: Session
      Closes the session and all open result sets obtained from this session.

      Releases this Connection object's resources immediately instead of waiting for them to be automatically released.

      TODO: should this operation auto-commit pending changes?

    • checkClose

      protected void checkClose()
    • commit

      public void commit()
    • rollback

      public void rollback()
    • createEntryWithoutReferences

      protected DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap)
      Description copied from class: BaseSession
      Creates an entry to the directory without creating its references.
      Overrides:
      createEntryWithoutReferences in class BaseSession
      Implementation Note:
      Memory directory does not support prefixed schema like MongoDB or SQL directories, so do not leverage generic code
    • doCreateEntryWithoutReferences

      public DocumentModel doCreateEntryWithoutReferences(Map<String,Object> fieldMap)
      Description copied from class: BaseSession
      To be implemented for specific creation.
      Overrides:
      doCreateEntryWithoutReferences in class BaseSession
    • doUpdateEntryWithoutReferences

      protected List<String> doUpdateEntryWithoutReferences(DocumentModel docModel)
      Description copied from class: BaseSession
      To be implemented for specific update.
      Overrides:
      doUpdateEntryWithoutReferences in class BaseSession
    • doDeleteEntryWithoutReferences

      protected void doDeleteEntryWithoutReferences(String entryId)
      Description copied from class: BaseSession
      To be implemented for specific deletion.
      Overrides:
      doDeleteEntryWithoutReferences in class BaseSession
    • createEntry

      public DocumentModel createEntry(Map<String,Object> fieldMap)
      Description copied from interface: Session
      Creates an entry in a directory.
      Specified by:
      createEntry in interface Session
      Overrides:
      createEntry in class BaseSession
      Parameters:
      fieldMap - A map with (prefixed) keys and values that should be stored in a directory

      Note: The values in the map should be of type String

      Returns:
      The new entry created in the directory
    • updateEntry

      public void updateEntry(DocumentModel docModel)
      Description copied from interface: Session
      Updates a directory entry.
      Specified by:
      updateEntry in interface Session
      Overrides:
      updateEntry in class BaseSession
      Parameters:
      docModel - The entry to update
    • deleteEntry

      public void deleteEntry(String idOrSysId)
      Description copied from interface: Session
      Deletes a directory entry by id.
      Specified by:
      deleteEntry in interface Session
      Overrides:
      deleteEntry in class BaseSession
      Parameters:
      idOrSysId - the id of the entry to delete
    • getEntry

      public DocumentModel getEntry(String idOrSysId, boolean fetchReferences)
      Description copied from interface: Session
      Retrieves a directory entry using its id.
      Specified by:
      getEntry in interface Session
      Overrides:
      getEntry in class BaseSession
      Parameters:
      idOrSysId - the entry id
      fetchReferences - boolean stating if references have to be fetched
      Returns:
      a DocumentModel representing the entry
    • deleteEntry

      public void deleteEntry(DocumentModel docModel)
      Description copied from interface: Session
      Deletes a directory entry.
      Specified by:
      deleteEntry in interface Session
      Overrides:
      deleteEntry in class BaseSession
      Parameters:
      docModel - The entry to delete
    • query

      public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset)
      Description copied from interface: Session
      Executes a query with the possibility to fetch a subset of the results. org.nuxeo.ecm.directory.BaseSession provides a default implementation fetching all results to return the subset. Not recommended.
      limit - maximum number of results ignored if less than 1
      offset - number of rows skipped before starting, will be 0 if less than 0.
      See Also:
    • doQuery

      protected DocumentModelList doQuery(DirectoryQueryBuilder queryBuilder)
      Description copied from class: BaseSession
      To be implemented for specific querying.
      Overrides:
      doQuery in class BaseSession
      See Also:
    • doQueryIds

      protected List<String> doQueryIds(DirectoryQueryBuilder queryBuilder)
      Description copied from class: BaseSession
      To be implemented for specific querying.
      Overrides:
      doQueryIds in class BaseSession
      See Also:
    • hasEntry

      public boolean hasEntry(String idOrSysId)
      Description copied from interface: Session
      Returns true if session has an entry with given id.
      Specified by:
      hasEntry in interface Session
      Overrides:
      hasEntry in class BaseSession