Package org.nuxeo.ecm.directory.memory
Class MemoryDirectorySession
java.lang.Object
org.nuxeo.ecm.directory.BaseSession
org.nuxeo.ecm.directory.memory.MemoryDirectorySession
- All Implemented Interfaces:
AutoCloseable,EntrySource,Session
Trivial in-memory implementation of a Directory to use in unit tests.
- Author:
- Florent Guillaume
-
Nested Class Summary
Nested classes/interfaces inherited from class org.nuxeo.ecm.directory.BaseSession
BaseSession.FieldDetector -
Field Summary
FieldsFields inherited from class org.nuxeo.ecm.directory.BaseSession
autoincrementId, computeMultiTenantId, directory, directoryName, MULTI_TENANT_ID_FORMAT, passwordHashAlgorithm, permissions, POWER_USERS_GROUP, readAllColumns, READONLY_ENTRY_FLAG, referenceClass, schemaName, substringMatchType, TENANT_ID_FIELD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticate(String username, String password) Checks that the credentials provided by the UserManager match those registered in the directory.protected voidvoidclose()Closes the session and all open result sets obtained from this session.voidcommit()createEntry(Map<String, Object> fieldMap) Creates an entry in a directory.protected DocumentModelcreateEntryWithoutReferences(Map<String, Object> fieldMap) Creates an entry to the directory without creating its references.voiddeleteEntry(String idOrSysId) Deletes a directory entry by id.voiddeleteEntry(DocumentModel docModel) Deletes a directory entry.doCreateEntryWithoutReferences(Map<String, Object> fieldMap) To be implemented for specific creation.protected voiddoDeleteEntryWithoutReferences(String entryId) To be implemented for specific deletion.protected DocumentModelListdoQuery(DirectoryQueryBuilder queryBuilder) To be implemented for specific querying.doQueryIds(DirectoryQueryBuilder queryBuilder) To be implemented for specific querying.doUpdateEntryWithoutReferences(DocumentModel docModel) To be implemented for specific update.To be implemented with a more specific type.Retrieves a directory entry using its id.booleanReturns true if session has an entry with given id.query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy, boolean fetchReferences, int limit, int offset) 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.voidrollback()voidupdateEntry(DocumentModel docModel) Updates a directory entry.Methods inherited from class org.nuxeo.ecm.directory.BaseSession
addTenantId, applyQueryLimits, applyQueryLimits, canDeleteMultiTenantEntry, canDeleteMultiTenantEntry, checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createQueryBuilderForIds, createQueryBuilderWithConfiguredFiltering, createQueryBuilderWithConfiguredFiltering, deleteEntryWithoutReferences, getCurrentTenantId, getEntryFromSource, getIdField, getPasswordField, getPrefixedFieldName, getPrefixedIdField, getProjection, getProjection, hasPermission, hasPermission, isAuthenticating, isMultiTenant, isReadOnly, isReadOnlyEntry, query, query, query, query, query, query, queryIds, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, toStringList, updateEntryWithoutReferencesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.directory.Session
createEntryModel, getEntry
-
Field Details
-
data
-
passwordField
-
closeStackTrace
-
-
Constructor Details
-
MemoryDirectorySession
-
-
Method Details
-
getDirectory
To be implemented with a more specific type.- Specified by:
getDirectoryin classBaseSession
-
authenticate
Description copied from interface:SessionChecks 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:SessionCloses 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
Description copied from class:BaseSessionCreates an entry to the directory without creating its references.- Overrides:
createEntryWithoutReferencesin classBaseSession- Implementation Note:
- Memory directory does not support prefixed schema like MongoDB or SQL directories, so do not leverage generic code
-
doCreateEntryWithoutReferences
Description copied from class:BaseSessionTo be implemented for specific creation.- Overrides:
doCreateEntryWithoutReferencesin classBaseSession
-
doUpdateEntryWithoutReferences
Description copied from class:BaseSessionTo be implemented for specific update.- Overrides:
doUpdateEntryWithoutReferencesin classBaseSession
-
doDeleteEntryWithoutReferences
Description copied from class:BaseSessionTo be implemented for specific deletion.- Overrides:
doDeleteEntryWithoutReferencesin classBaseSession
-
createEntry
Description copied from interface:SessionCreates an entry in a directory.- Specified by:
createEntryin interfaceSession- Overrides:
createEntryin classBaseSession- Parameters:
fieldMap- A map with (prefixed) keys and values that should be stored in a directoryNote: The values in the map should be of type String
- Returns:
- The new entry created in the directory
-
updateEntry
Description copied from interface:SessionUpdates a directory entry.- Specified by:
updateEntryin interfaceSession- Overrides:
updateEntryin classBaseSession- Parameters:
docModel- The entry to update
-
deleteEntry
Description copied from interface:SessionDeletes a directory entry by id.- Specified by:
deleteEntryin interfaceSession- Overrides:
deleteEntryin classBaseSession- Parameters:
idOrSysId- the id of the entry to delete
-
getEntry
Description copied from interface:SessionRetrieves a directory entry using its id.- Specified by:
getEntryin interfaceSession- Overrides:
getEntryin classBaseSession- Parameters:
idOrSysId- the entry idfetchReferences- boolean stating if references have to be fetched- Returns:
- a DocumentModel representing the entry
-
deleteEntry
Description copied from interface:SessionDeletes a directory entry.- Specified by:
deleteEntryin interfaceSession- Overrides:
deleteEntryin classBaseSession- 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:SessionExecutes 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 1offset- number of rows skipped before starting, will be 0 if less than 0.- See Also:
-
doQuery
Description copied from class:BaseSessionTo be implemented for specific querying.- Overrides:
doQueryin classBaseSession- See Also:
-
doQueryIds
Description copied from class:BaseSessionTo be implemented for specific querying.- Overrides:
doQueryIdsin classBaseSession- See Also:
-
hasEntry
Description copied from interface:SessionReturns true if session has an entry with given id.- Specified by:
hasEntryin interfaceSession- Overrides:
hasEntryin classBaseSession
-