Class BaseSession
- All Implemented Interfaces:
AutoCloseable,EntrySource,Session
- Direct Known Subclasses:
CoreDirectorySession,LDAPSession,MemoryDirectorySession,MongoDBSession,MultiDirectorySession,SQLSession
- Since:
- 5.2M4
- Author:
- Anahide Tchertchian
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classVisitor for a query to check if it contains a reference to a given field. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected final Directoryprotected Stringprotected static final Stringprotected Stringprotected PermissionDescriptor[]protected static final Stringprotected booleanprotected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected Stringprotected static final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseSession(Directory directory, Class<? extends Reference> referenceClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected QueryBuilderaddTenantId(QueryBuilder queryBuilder) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, not useful anymore since introduction ofcreateQueryBuilderWithConfiguredFiltering(QueryBuilder)<T> List<T> applyQueryLimits(List<T> list, int limit, int offset) Applies offset and limit to a List.applyQueryLimits(DocumentModelList results, int limit, int offset) Applies offset and limit to a DocumentModelListprotected booleancanDeleteMultiTenantEntry(String entryId) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, unusedprotected booleanvoidcheckDeleteConstraints(String entryId) Checks that there are no constraints for deleting the given entry id.voidcheckPermission(String permission) Checks the current user rights for the given permission against the read-only flag and the permission descriptor.static StringcomputeMultiTenantDirectoryId(String tenantId, String id) Compute a multi tenant directory id based on the giventenantId.createEntry(Map<String, Object> fieldMap) Creates an entry in a directory.createEntry(DocumentModel documentModel) Creates an entry in a directory.static DocumentModelcreateEntryModel(String schema) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel()insteadstatic DocumentModelDeprecated, for removal: This API element is subject to removal in a future version.since 11.1, sessionId is unusedstatic DocumentModelcreateEntryModel(String sessionId, String schema, String id, Map<String, Object> values, boolean readOnly) Deprecated, for removal: This API element is subject to removal in a future version.since 11.1, sessionId is unusedstatic DocumentModelDeprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel(String, Map)insteadstatic DocumentModelDeprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel(String, Map)insteadcreateEntryModel(String id, Map<String, Object> values) Returns a bare document model suitable for directory implementations.protected DocumentModelcreateEntryWithoutReferences(Map<String, Object> fieldMap) Creates an entry to the directory without creating its references.protected DirectoryQueryBuildercreateQueryBuilderForIds(String id, String... ids) Creates aDirectoryQueryBuilderthat filter in entry having givenidoridsas directory entry id of any kind.protected DirectoryQueryBuildercreateQueryBuilderWithConfiguredFiltering(QueryBuilder queryBuilder) Turns the givenQueryBuilderto aDirectoryQueryBuilderto ease some access to directories specificities, such asDirectoryQueryBuilder.fetchReferences().protected DirectoryQueryBuildercreateQueryBuilderWithConfiguredFiltering(QueryBuilder queryBuilder, boolean includeNoTenant) Turns the givenQueryBuilderto aDirectoryQueryBuilderto ease some access to directories specificities, such asDirectoryQueryBuilder.fetchReferences().voiddeleteEntry(String idOrSysId) Deletes a directory entry by id.voiddeleteEntry(DocumentModel docModel) Deletes a directory entry.protected voiddeleteEntryWithoutReferences(String entryId) Deletes an entry from the directory without deleting its references.protected DocumentModeldoCreateEntryWithoutReferences(Map<String, Object> fieldMap) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractprotected voiddoDeleteEntryWithoutReferences(String entryId) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractprotected DocumentModelListdoQuery(DirectoryQueryBuilder queryBuilder) Deprecated.since 2021.x, the method will remain on deprecation cleanupdoQueryIds(DirectoryQueryBuilder queryBuilder) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractdoUpdateEntryWithoutReferences(DocumentModel docModel) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractprotected StringReturns the tenant id of the logged user if any,nullotherwise.abstract DirectoryTo be implemented with a more specific return type.Retrieves a directory entry using its id.getEntryFromSource(String idOrSysId, boolean fetchReferences) The Id field is the name of the field that is used a primary key: unique and not null value in the whole directory.protected StringgetPrefixedFieldName(String fieldName) Get the prefixed version of the given fieldName.protected StringgetProjection(Map<String, Serializable> filter, String columnName) Executes a query using filter and return only the column columnName.getProjection(Map<String, Serializable> filter, Set<String> fulltext, String columnName) booleanReturns true if session has an entry with given id.booleanhasPermission(String permission) Checks the current user rights for the given permission against the read-only flag and the permission descriptor.protected booleanhasPermission(String permission, String username, List<String> groups) booleanTells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).protected booleanReturnstrueif this directory supports multi tenancy,falseotherwise.booleanstatic booleanisReadOnlyEntry(DocumentModel entry) Test whether entry comes from a read-only back-end directory.query(Map<String, Serializable> filter) Executes a simple query.Executes a simple query.Executes a simple query.query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy, boolean fetchReferences) Executes a query with the possibility to fetch referencesquery(QueryBuilder queryBuilder) Deprecated.since 2021.x,BaseSessionis providing a generic implementation, you should implementdoQuery(DirectoryQueryBuilder)insteadquery(QueryBuilder queryBuilder, boolean fetchReferences) Executes a query with the possibility to fetch a subset of the results.queryIds(QueryBuilder queryBuilder) Deprecated.since 2021.x,BaseSessionis providing a generic implementation, you should implementdoQueryIds(DirectoryQueryBuilder)insteadvoidsetReadAllColumns(boolean readAllColumns) For test framework.static voidsetReadOnlyEntry(DocumentModel entry) Set the read-only flag of a directory entry.static voidsetReadWriteEntry(DocumentModel entry) Unset the read-only flag of a directory entry.toStringList(Object value) voidupdateEntry(DocumentModel docModel) Updates a directory entry.updateEntryWithoutReferences(DocumentModel docModel) Updates an entry to the directory without updating its references.Methods 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
authenticate, close, createEntryModel, getEntry, query
-
Field Details
-
POWER_USERS_GROUP
- See Also:
-
READONLY_ENTRY_FLAG
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectoryConstants.READONLY_ENTRY_FLAGinstead- See Also:
-
MULTI_TENANT_ID_FORMAT
- See Also:
-
TENANT_ID_FIELD
- See Also:
-
directory
-
permissions
-
readAllColumns
protected boolean readAllColumns -
schemaName
-
directoryName
-
substringMatchType
-
referenceClass
-
passwordHashAlgorithm
-
autoincrementId
protected boolean autoincrementId -
computeMultiTenantId
protected boolean computeMultiTenantId
-
-
Constructor Details
-
BaseSession
-
-
Method Details
-
getDirectory
To be implemented with a more specific return type. -
setReadAllColumns
public void setReadAllColumns(boolean readAllColumns) Description copied from interface:SessionFor test framework. Changes the read/query methods to return all of the entries, including the password field.- Specified by:
setReadAllColumnsin interfaceSession- Parameters:
readAllColumns- whether to read all columns
-
getIdField
Description copied from interface:SessionThe Id field is the name of the field that is used a primary key: unique and not null value in the whole directory. This field is also used as login field if the directory is authenticating.- Specified by:
getIdFieldin interfaceSession- Returns:
- the name of the id field
-
getPrefixedIdField
-
getPasswordField
- Specified by:
getPasswordFieldin interfaceSession- Returns:
- the name of the field to store the password if the directory is authenticating (can be null)
-
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- Returns:
- true is the directory is authentication aware
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceSession
-
getPrefixedFieldName
Get the prefixed version of the given fieldName.- Since:
- 2025.9
-
checkPermission
Checks the current user rights for the given permission against the read-only flag and the permission descriptor.Throws
DirectorySecurityExceptionif the user does not have adequate privileges.- Throws:
DirectorySecurityException- if access is denied- Since:
- 8.3
-
checkDeleteConstraints
Checks that there are no constraints for deleting the given entry id.- Since:
- 8.4
-
hasPermission
Checks the current user rights for the given permission against the read-only flag and the permission descriptor.Returns
falseif the user does not have adequate privileges.- Returns:
falseif access is denied- Since:
- 8.3
-
hasPermission
-
createEntryModel
@Deprecated(since="11.1", forRemoval=true) public static DocumentModel createEntryModel(String sessionId, String schema, String id, Map<String, Object> values) throws PropertyExceptionDeprecated, for removal: This API element is subject to removal in a future version.since 11.1, sessionId is unusedReturns a bare document model suitable for directory implementations.Can be used for creation screen.
- Throws:
PropertyException- Since:
- 5.2M4
-
createEntryModel
@Deprecated(since="2025.9", forRemoval=true) public static DocumentModel createEntryModel(String schema) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel()insteadReturns a bare document model suitable for directory implementations.- Parameters:
schema- the directory schema- Returns:
- the directory entry
- Since:
- 11.1
-
createEntryModel
@Deprecated(since="2025.9", forRemoval=true) public static DocumentModel createEntryModel(String schema, String id, Map<String, Object> values) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel(String, Map)insteadReturns a bare document model suitable for directory implementations.- Parameters:
schema- the directory schemaid- the entry idvalues- the entry values, ornull- Returns:
- the directory entry
- Since:
- 11.1
-
createEntryModel
@Deprecated(since="11.1", forRemoval=true) public static DocumentModel createEntryModel(String sessionId, String schema, String id, Map<String, Object> values, boolean readOnly) throws PropertyExceptionDeprecated, for removal: This API element is subject to removal in a future version.since 11.1, sessionId is unusedReturns a bare document model suitable for directory implementations.Allow setting the readonly entry flag to
Boolean.TRUE. SeeSession#isReadOnlyEntry(DocumentModel)- Throws:
PropertyException- Since:
- 5.3.1
-
createEntryModel
@Deprecated(since="2025.9", forRemoval=true) public static DocumentModel createEntryModel(String schema, String id, Map<String, Object> values, boolean readOnly) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, useDirectory.createBareDocumentModel(String, Map)insteadReturns a bare document model suitable for directory implementations.Allow setting the readonly entry flag to
Boolean.TRUE. SeeSession#isReadOnlyEntry(DocumentModel)- Parameters:
schema- the directory schemaid- the entry idvalues- the entry values, ornullreadOnly- the readonly flag- Returns:
- the directory entry
- Since:
- 11.1
-
createEntryModel
Description copied from interface:SessionReturns a bare document model suitable for directory implementations.- Specified by:
createEntryModelin interfaceSession- Parameters:
id- the entry id, ornullvalues- the entry values, ornull- Returns:
- the directory entry
-
isReadOnlyEntry
Test whether entry comes from a read-only back-end directory.- Since:
- 5.3.1
-
setReadOnlyEntry
Set the read-only flag of a directory entry. To be used by EntryAdaptor implementations for instance.- Since:
- 5.3.2
-
setReadWriteEntry
Unset the read-only flag of a directory entry. To be used by EntryAdaptor implementations for instance.- Since:
- 5.3.2
-
computeMultiTenantDirectoryId
Compute a multi tenant directory id based on the giventenantId.- Returns:
- the computed directory id
- Since:
- 5.6
-
getEntry
Description copied from interface:SessionRetrieves a directory entry using its id. -
getEntryFromSource
- Specified by:
getEntryFromSourcein interfaceEntrySource
-
hasEntry
Description copied from interface:SessionReturns true if session has an entry with given id. -
createEntry
Description copied from interface:SessionCreates an entry in a directory.- Specified by:
createEntryin interfaceSession- Parameters:
documentModel- the document model representing the entry to create- Returns:
- The new entry created in the directory
-
createEntry
Description copied from interface:SessionCreates an entry in a directory.- Specified by:
createEntryin interfaceSession- 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
-
createEntryWithoutReferences
Creates an entry to the directory without creating its references.- Since:
- 2025.9
- Implementation Note:
- it was abstract before 2025.9
-
updateEntry
Description copied from interface:SessionUpdates a directory entry.- Specified by:
updateEntryin interfaceSession- Parameters:
docModel- The entry to update
-
updateEntryWithoutReferences
Updates an entry to the directory without updating its references.- Since:
- 2025.9
- Implementation Note:
- it was abstract before 2025.9
-
toStringList
-
deleteEntry
Description copied from interface:SessionDeletes a directory entry.- Specified by:
deleteEntryin interfaceSession- Parameters:
docModel- The entry to delete
-
deleteEntry
Description copied from interface:SessionDeletes a directory entry by id.- Specified by:
deleteEntryin interfaceSession- Parameters:
idOrSysId- the id of the entry to delete
-
deleteEntryWithoutReferences
Deletes an entry from the directory without deleting its references.- Since:
- 2025.9
- Implementation Note:
- it was abstract before 2025.9
-
canDeleteMultiTenantEntry
@Deprecated(since="2025.9", forRemoval=true) protected boolean canDeleteMultiTenantEntry(String entryId) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, unused -
canDeleteMultiTenantEntry
- Since:
- 2025.9
-
applyQueryLimits
Applies offset and limit to a DocumentModelList- Parameters:
results- the query results without limit and offetlimit- maximum number of results ignored if less than 1offset- number of rows skipped before starting, will be 0 if less than 0.- Returns:
- the result with applied limit and offset
- Since:
- 10.1
- See Also:
-
applyQueryLimits
Applies offset and limit to a List.- Parameters:
list- the original listlimit- maximum number of results, ignored if less than 1offset- number of rows skipped before starting, will be 0 if less than 0- Returns:
- the result with applied limit and offset
- Since:
- 10.3
-
query
Description copied from interface:SessionExecutes a simple query. The conditions will be 'AND'-ed. Search is done with exact match.Does not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsizeon the returned list will return -2 as a special marker for truncated results. -
query
Description copied from interface:SessionExecutes a simple query. The conditions will be 'AND'-ed.fieldNames present in the fulltext set are treated as a fulltext match. Does not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsizeon the returned list will return -2 as a special marker for truncated results. -
query
public DocumentModelList query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy) Description copied from interface:SessionExecutes a simple query. The conditions will be 'AND'-ed and the result will be sorted by the orderBy criteria list.fieldNames present in the fulltext set are treated as a fulltext match. Does not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsizeon the returned list will return -2 as a special marker for truncated results.- Specified by:
queryin interfaceSession- Parameters:
filter- a filter to apply to entries in directoryfulltext- a set of field that should be treated as a fulltext searchorderBy- a LinkedHashMap with the 'order by' criterias.The key of an entry of this map represents the column name and the value of the same entry represent the column order,which may be 'asc' or 'desc'.- Returns:
- a list of document models containing the entries matched by the query
-
query
public DocumentModelList query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy, boolean fetchReferences) Description copied from interface:SessionExecutes a query with the possibility to fetch references -
query
Description copied from interface:SessionExecutes a query with the possibility to fetch a subset of the results. -
query
Deprecated.since 2021.x,BaseSessionis providing a generic implementation, you should implementdoQuery(DirectoryQueryBuilder)insteadDescription copied from interface:SessionExecutes a query with the possibility to fetch a subset of the results.You can use this API with
DirectoryQueryBuilderto fetch references.- Specified by:
queryin interfaceSession- Parameters:
queryBuilder- the query to use, including limit, offset, ordering and countTotal- Returns:
- the list of documents, where the total size may be present if countTotal was true
- Since:
- 2025.9
- See Also:
- Implementation Note:
- on deprecation removal, remove the annotations and deprecated javadoc
-
queryIds
Deprecated.since 2021.x,BaseSessionis providing a generic implementation, you should implementdoQueryIds(DirectoryQueryBuilder)insteadDescription copied from interface:SessionExecutes a query with the possibility to fetch a subset of the results. Returns the matching ids. -
createQueryBuilderForIds
protected DirectoryQueryBuilder createQueryBuilderForIds(@Nullable String id, @Nullable String... ids) Creates aDirectoryQueryBuilderthat filter in entry having givenidoridsas directory entry id of any kind.- Since:
- 2025.9
-
createQueryBuilderWithConfiguredFiltering
protected DirectoryQueryBuilder createQueryBuilderWithConfiguredFiltering(QueryBuilder queryBuilder) Turns the givenQueryBuilderto aDirectoryQueryBuilderto ease some access to directories specificities, such asDirectoryQueryBuilder.fetchReferences().Also, adds additional filters based on directory setup, such as
tenantId.- Since:
- 2025.9
-
createQueryBuilderWithConfiguredFiltering
protected DirectoryQueryBuilder createQueryBuilderWithConfiguredFiltering(QueryBuilder queryBuilder, boolean includeNoTenant) Turns the givenQueryBuilderto aDirectoryQueryBuilderto ease some access to directories specificities, such asDirectoryQueryBuilder.fetchReferences().Also, adds additional filters based on directory setup, such as
tenantId.- Parameters:
includeNoTenant- whether the entry without tenant should be included in response- Since:
- 2025.9
-
getProjection
Description copied from interface:SessionExecutes a query using filter and return only the column columnName.- Specified by:
getProjectionin interfaceSession- Parameters:
filter- the filter for the querycolumnName- the column whose content should be returned- Returns:
- the list with the values of columnName for the entries matching filter
-
getProjection
public List<String> getProjection(Map<String, Serializable> filter, Set<String> fulltext, String columnName) - Specified by:
getProjectionin interfaceSession
-
isMultiTenant
protected boolean isMultiTenant()Returnstrueif this directory supports multi tenancy,falseotherwise. -
addTenantId
@Deprecated(since="2025.9", forRemoval=true) protected QueryBuilder addTenantId(QueryBuilder queryBuilder) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.9, not useful anymore since introduction ofcreateQueryBuilderWithConfiguredFiltering(QueryBuilder)Adds the tenant id to the query if needed.- Since:
- 10.3
-
getCurrentTenantId
Returns the tenant id of the logged user if any,nullotherwise. -
doCreateEntryWithoutReferences
@Deprecated(since="2021.x") protected DocumentModel doCreateEntryWithoutReferences(Map<String, Object> fieldMap) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractTo be implemented for specific creation. -
doUpdateEntryWithoutReferences
@Deprecated(since="2021.x") protected List<String> doUpdateEntryWithoutReferences(DocumentModel docModel) Deprecated.since 2021.x, the method remains for use, but it will be turned abstractTo be implemented for specific update. -
doDeleteEntryWithoutReferences
Deprecated.since 2021.x, the method remains for use, but it will be turned abstractTo be implemented for specific deletion. -
doQuery
Deprecated.since 2021.x, the method will remain on deprecation cleanupTo be implemented for specific querying.- See Also:
- Implementation Note:
- on deprecation removal, turn this method abstract, remove the annotations and the deprecated javadoc
-
doQueryIds
Deprecated.since 2021.x, the method remains for use, but it will be turned abstractTo be implemented for specific querying.- See Also:
- Implementation Note:
- on deprecation removal, turn this method abstract, remove the annotations and the deprecated javadoc
-
DirectoryConstants.READONLY_ENTRY_FLAGinstead