Package org.nuxeo.directory.mongodb
Class MongoDBSession
- java.lang.Object
-
- org.nuxeo.ecm.directory.BaseSession
-
- org.nuxeo.directory.mongodb.MongoDBSession
-
- All Implemented Interfaces:
AutoCloseable,EntrySource,Session
public class MongoDBSession extends BaseSession
MongoDB implementation of aSession- Since:
- 9.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMongoDBSession.MongoDBDirectoryQueryBuilderMongoDB Query Builder that knows how to resolved directory properties.-
Nested classes/interfaces inherited from class org.nuxeo.ecm.directory.BaseSession
BaseSession.FieldDetector
-
-
Field Summary
-
Fields 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 Constructor Description MongoDBSession(MongoDBDirectory directory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddField(org.bson.Document bson, String key, Object value)booleanauthenticate(String username, String password)Checks that the credentials provided by the UserManager match those registered in the directory.protected org.bson.DocumentbuildQuery(Map<String,Serializable> fieldMap, Set<String> fulltext)protected booleancheckEntryTenantId(String entryTenantId)voidclose()Closes the session and all open result sets obtained from this session.protected ObjectconvertToType(Object value, Type type)protected DocumentModelcreateEntryWithoutReferences(Map<String,Object> fieldMap)To be implemented for specific creation.voiddeleteEntryWithoutReferences(String id)To be implemented for specific deletion.protected DocumentModelListdoQuery(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset, boolean checkTenantId)protected DocumentModelfieldMapToDocumentModel(Map<String,Object> fieldMap)protected com.mongodb.client.MongoCollection<org.bson.Document>getCollection()Retrieve the collection associated to this directoryprotected com.mongodb.client.MongoCollection<org.bson.Document>getCountersCollection()Retrieve the counters collection associated to this directoryMongoDBDirectorygetDirectory()To be implemented with a more specific return type.DocumentModelgetEntryFromSource(String id, boolean fetchReferences)protected TypegetIdFieldType()protected StringgetIdFromState(State state)protected StringgetPrefixedIdField()protected StringgetPrefixedPasswordField()booleanhasEntry(String id)Returns true if session has an entry with given id.protected booleanhasEntry0(Object id)booleanisAuthenticating()Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).DocumentModelListquery(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.DocumentModelListquery(QueryBuilder queryBuilder, boolean fetchReferences)Executes a query with the possibility to fetch a subset of the results.List<String>queryIds(QueryBuilder queryBuilder)Executes a query with the possibility to fetch a subset of the results.protected List<String>updateEntryWithoutReferences(DocumentModel docModel)To be implemented for specific update.-
Methods inherited from class org.nuxeo.ecm.directory.BaseSession
addTenantId, applyQueryLimits, applyQueryLimits, canDeleteMultiTenantEntry, checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntry, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, deleteEntry, deleteEntry, deleteEntry, getCurrentTenantId, getEntries, getEntry, getEntry, getIdField, getPasswordField, getProjection, getProjection, hasPermission, hasPermission, isMultiTenant, isReadOnly, isReadOnlyEntry, query, query, query, query, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, toStringList, updateEntry
-
-
-
-
Constructor Detail
-
MongoDBSession
public MongoDBSession(MongoDBDirectory directory)
-
-
Method Detail
-
getDirectory
public MongoDBDirectory getDirectory()
Description copied from class:BaseSessionTo be implemented with a more specific return type.- Specified by:
getDirectoryin classBaseSession
-
getEntryFromSource
public DocumentModel getEntryFromSource(String id, boolean fetchReferences)
- Specified by:
getEntryFromSourcein interfaceEntrySource- Overrides:
getEntryFromSourcein classBaseSession
-
createEntryWithoutReferences
protected DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap)
Description copied from class:BaseSessionTo be implemented for specific creation.- Specified by:
createEntryWithoutReferencesin classBaseSession
-
convertToType
protected Object convertToType(Object value, Type type)
-
updateEntryWithoutReferences
protected List<String> updateEntryWithoutReferences(DocumentModel docModel)
Description copied from class:BaseSessionTo be implemented for specific update.- Specified by:
updateEntryWithoutReferencesin classBaseSession
-
deleteEntryWithoutReferences
public void deleteEntryWithoutReferences(String id)
Description copied from class:BaseSessionTo be implemented for specific deletion.- Specified by:
deleteEntryWithoutReferencesin classBaseSession
-
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:
Session.query(Map, Set, Map, boolean)
-
doQuery
protected DocumentModelList doQuery(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset, boolean checkTenantId)
-
buildQuery
protected org.bson.Document buildQuery(Map<String,Serializable> fieldMap, Set<String> fulltext)
-
query
public DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences)
Description copied from interface:SessionExecutes a query with the possibility to fetch a subset of the results.- Parameters:
queryBuilder- the query to use, including limit, offset, ordering and countTotalfetchReferences- boolean stating if references have to be fetched- Returns:
- the list of documents, where the total size may be present if countTotal was true
-
queryIds
public List<String> queryIds(QueryBuilder queryBuilder)
Description copied from interface:SessionExecutes a query with the possibility to fetch a subset of the results. Returns the matching ids.- Parameters:
queryBuilder- the query to use, including limit, offset and ordering- Returns:
- the list of document ids
-
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?
-
authenticate
public boolean authenticate(String username, String password)
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
-
isAuthenticating
public boolean isAuthenticating()
Description copied from interface:SessionTells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).- Specified by:
isAuthenticatingin interfaceSession- Overrides:
isAuthenticatingin classBaseSession- Returns:
- true is the directory is authentication aware
-
hasEntry
public boolean hasEntry(String id)
Description copied from interface:SessionReturns true if session has an entry with given id.
-
getCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection()
Retrieve the collection associated to this directory- Returns:
- the MongoDB collection
-
getCountersCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCountersCollection()
Retrieve the counters collection associated to this directory- Returns:
- the MongoDB counters collection
-
fieldMapToDocumentModel
protected DocumentModel fieldMapToDocumentModel(Map<String,Object> fieldMap)
-
getIdFromState
protected String getIdFromState(State state)
-
checkEntryTenantId
protected boolean checkEntryTenantId(String entryTenantId)
-
getPrefixedIdField
protected String getPrefixedIdField()
-
getPrefixedPasswordField
protected String getPrefixedPasswordField()
-
getIdFieldType
protected Type getIdFieldType()
-
-