Package org.nuxeo.ecm.directory.sql
Class SQLSession
java.lang.Object
org.nuxeo.ecm.directory.BaseSession
org.nuxeo.ecm.directory.sql.SQLSession
- All Implemented Interfaces:
AutoCloseable,EntrySource,Session
This class represents a session against an SQLDirectory.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.nuxeo.ecm.directory.BaseSession
BaseSession.FieldDetector -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Dialectprotected JDBCLoggerprotected SQLStaticFilter[]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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFilterValues(PreparedStatement ps, int startIdx) protected voidaddFilterValuesForLog(List<Serializable> values) protected StringaddFilterWhereClause(String whereClause) protected voidaddFilterWhereClause(StringBuilder clause, List<SQLQueryBuilder.ColumnAndValue> params) booleanauthenticate(String username, String password) Checks that the credentials provided by the UserManager match those registered in the directory.protected Stringprotected voidChecks the SQL error we got and determine if a concurrent update happened.voidclose()Closes the session and all open result sets obtained from this session.protected DocumentModelcreateEntryWithoutReferences(Map<String, Object> fieldMap) Creates an entry to the directory without creating its references.protected DocumentModeldoCreateEntryWithoutReferences(Map<String, Object> fieldMap) To be implemented for specific creation.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.protected DocumentModelfieldMapToDocumentModel(Map<String, Object> fieldMap) protected SerializablefieldValueForWrite(Object value, Column column) protected voidfillPreparedStatementFields(Map<String, Object> filterMap, List<Column> orderedColumns, PreparedStatement ps) To be implemented with a more specific return type.getEntryFromSource(String idOrSysId, boolean fetchReferences) protected Columnprotected StringgetPassword(String id) Internal method to read the hashed password for authentication.protected StringbooleanReturns true if session has an entry with given id.booleanTells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).booleanisLive()Enable connection status checking on SQL directory connectionsprotected PreparedStatementCreate aPreparedStatementreturning the id key if it is auto-incremented and dialect has identity generated key (Dialect.hasIdentityGeneratedKey()).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.protected voidtoString()Methods inherited from class org.nuxeo.ecm.directory.BaseSession
addTenantId, applyQueryLimits, applyQueryLimits, canDeleteMultiTenantEntry, canDeleteMultiTenantEntry, checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntry, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createQueryBuilderForIds, createQueryBuilderWithConfiguredFiltering, createQueryBuilderWithConfiguredFiltering, deleteEntry, deleteEntry, deleteEntryWithoutReferences, getCurrentTenantId, getEntry, getIdField, getPasswordField, getPrefixedFieldName, getPrefixedIdField, getProjection, getProjection, hasPermission, hasPermission, isMultiTenant, isReadOnly, isReadOnlyEntry, query, query, query, query, query, query, queryIds, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, toStringList, updateEntry, updateEntryWithoutReferencesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.directory.Session
createEntryModel, getEntry
-
Field Details
-
staticFilters
-
dialect
-
logger
-
-
Constructor Details
-
SQLSession
-
-
Method Details
-
getDirectory
Description copied from class:BaseSessionTo be implemented with a more specific return type.- Specified by:
getDirectoryin classBaseSession
-
getEntryFromSource
- Specified by:
getEntryFromSourcein interfaceEntrySource- Overrides:
getEntryFromSourcein classBaseSession
-
getReadColumns
-
getReadColumnsSQL
-
getIdColumn
-
fieldMapToDocumentModel
-
checkConcurrentUpdate
Checks the SQL error we got and determine if a concurrent update happened. Throws if that's the case.- Parameters:
e- the exception- Throws:
ConcurrentUpdateException- Since:
- 7.10-HF04, 8.2
-
buildIdWhereClause
-
addFilterWhereClause
-
addFilterWhereClause
protected void addFilterWhereClause(StringBuilder clause, List<SQLQueryBuilder.ColumnAndValue> params) -
addFilterValues
-
addFilterValuesForLog
-
getPassword
Internal method to read the hashed password for authentication.- Since:
- 9.1
-
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.- Parameters:
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:
-
createEntryWithoutReferences
Description copied from class:BaseSessionCreates an entry to the directory without creating its references.- Overrides:
createEntryWithoutReferencesin classBaseSession
-
doCreateEntryWithoutReferences
Description copied from class:BaseSessionTo be implemented for specific creation.- Overrides:
doCreateEntryWithoutReferencesin classBaseSession
-
setIdFieldInMap
protected void setIdFieldInMap(ResultSet rs, Column column, String idFieldName, Map<String, Object> fieldMap) throws SQLException- Throws:
SQLException
-
prepareStatementWithAutoKeys
Create aPreparedStatementreturning the id key if it is auto-incremented and dialect has identity generated key (Dialect.hasIdentityGeneratedKey()).- Throws:
SQLException- Since:
- 10.1
-
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
-
fillPreparedStatementFields
-
fieldValueForWrite
-
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?
-
isLive
public boolean isLive()Enable connection status checking on SQL directory connections- Since:
- 5.7.2
-
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
-
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
Description copied from interface:SessionReturns true if session has an entry with given id.- Specified by:
hasEntryin interfaceSession- Overrides:
hasEntryin classBaseSession
-
toString
-