public class SQLSession extends BaseSession
Modifier and Type | Field and Description |
---|---|
protected JDBCLogger |
logger |
protected SQLStaticFilter[] |
staticFilters |
autoincrementId, directory, directoryName, MULTI_TENANT_ID_FORMAT, passwordHashAlgorithm, permissions, POWER_USERS_GROUP, readAllColumns, READONLY_ENTRY_FLAG, referenceClass, schemaFieldMap, schemaName, substringMatchType
Constructor and Description |
---|
SQLSession(SQLDirectory directory,
SQLDirectoryDescriptor config) |
Modifier and Type | Method and Description |
---|---|
protected void |
addFilterValues(PreparedStatement ps,
int startIdx) |
protected void |
addFilterValuesForLog(List<Serializable> values) |
protected String |
addFilterWhereClause(String whereClause) |
boolean |
authenticate(String username,
String password)
Checks that the credentials provided by the UserManager match those registered in the directory.
|
protected boolean |
canDeleteMultiTenantEntry(String entryId) |
protected void |
checkConcurrentUpdate(Throwable e)
Checks the SQL error we got and determine if a concurrent update happened.
|
void |
close()
Closes the session and all open result sets obtained from this session.
|
protected DocumentModel |
createEntryWithoutReferences(Map<String,Object> fieldMap)
To be implemented for specific creation.
|
void |
deleteEntry(String id)
Deletes a directory entry by id.
|
void |
deleteEntry(String id,
Map<String,String> map)
Deletes a directory entry by id and secondary ids.
|
void |
deleteEntryWithoutReferences(String id)
To be implemented for specific deletion.
|
protected DocumentModel |
fieldMapToDocumentModel(Map<String,Object> fieldMap) |
protected Serializable |
fieldValueForWrite(Object value,
Column column) |
protected void |
fillPreparedStatementFields(Map<String,Object> filterMap,
List<Column> orderedColumns,
PreparedStatement ps) |
protected String |
getCurrentTenantId()
Returns the tenant id of the logged user if any,
null otherwise. |
SQLDirectory |
getDirectory()
To be implemented with a more specific return type.
|
DocumentModel |
getEntryFromSource(String id,
boolean fetchReferences) |
protected String |
getPassword(String id)
Internal method to read the hashed password for authentication.
|
protected List<Column> |
getReadColumns() |
protected String |
getReadColumnsSQL() |
boolean |
hasEntry(String id)
Returns true if session has an entry with given id.
|
boolean |
isAuthenticating()
Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on
login / password check).
|
boolean |
isLive()
Enable connection status checking on SQL directory connections
|
protected boolean |
isMultiTenant()
Returns
true if this directory supports multi tenancy, false otherwise. |
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext,
Map<String,String> orderBy,
boolean fetchReferences)
Executes a query with the possibility to fetch references
|
DocumentModelList |
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.
|
String |
toString() |
protected List<String> |
updateEntryWithoutReferences(DocumentModel docModel)
To be implemented for specific update.
|
checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntry, createEntryModel, createEntryModel, deleteEntry, getEntries, getEntry, getEntry, getIdField, getPasswordField, getProjection, getProjection, hasPermission, hasPermission, isReadOnly, isReadOnlyEntry, query, query, query, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, updateEntry
protected SQLStaticFilter[] staticFilters
protected JDBCLogger logger
public SQLSession(SQLDirectory directory, SQLDirectoryDescriptor config) throws DirectoryException
DirectoryException
public SQLDirectory getDirectory()
BaseSession
getDirectory
in class BaseSession
public DocumentModel getEntryFromSource(String id, boolean fetchReferences) throws DirectoryException
getEntryFromSource
in interface EntrySource
getEntryFromSource
in class BaseSession
DirectoryException
protected List<Column> getReadColumns()
protected String getReadColumnsSQL()
protected DocumentModel fieldMapToDocumentModel(Map<String,Object> fieldMap)
protected void checkConcurrentUpdate(Throwable e) throws ConcurrentUpdateException
e
- the exceptionConcurrentUpdateException
protected String addFilterWhereClause(String whereClause) throws DirectoryException
DirectoryException
protected void addFilterValues(PreparedStatement ps, int startIdx) throws DirectoryException
DirectoryException
protected void addFilterValuesForLog(List<Serializable> values)
protected String getPassword(String id)
public void deleteEntry(String id)
Session
deleteEntry
in interface Session
deleteEntry
in class BaseSession
id
- the id of the entry to deleteprotected boolean canDeleteMultiTenantEntry(String entryId) throws DirectoryException
DirectoryException
public void deleteEntry(String id, Map<String,String> map) throws DirectoryException
Session
This is used for hierarchical vocabularies, where the actual unique key is the couple (parent, id).
deleteEntry
in interface Session
deleteEntry
in class BaseSession
id
- the id of the entry to delete.map
- a map of secondary key values.DirectoryException
- if a communication error occurs.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences)
Session
query
in interface Session
query
in class BaseSession
Session.query(Map, Set, Map)
public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset) throws DirectoryException
Session
query
in interface Session
query
in class BaseSession
limit
- maximum number of results ignored if less than 1offset
- number of rows skipped before starting, will be 0 if less than 0.DirectoryException
Session.query(Map, Set, Map, boolean)
protected DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap)
BaseSession
createEntryWithoutReferences
in class BaseSession
protected List<String> updateEntryWithoutReferences(DocumentModel docModel) throws DirectoryException
BaseSession
updateEntryWithoutReferences
in class BaseSession
DirectoryException
public void deleteEntryWithoutReferences(String id) throws DirectoryException
BaseSession
deleteEntryWithoutReferences
in class BaseSession
DirectoryException
protected void fillPreparedStatementFields(Map<String,Object> filterMap, List<Column> orderedColumns, PreparedStatement ps) throws DirectoryException
DirectoryException
protected Serializable fieldValueForWrite(Object value, Column column)
public void close() throws DirectoryException
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?
DirectoryException
- if a communication error occurspublic boolean isLive() throws DirectoryException
DirectoryException
public boolean authenticate(String username, String password)
Session
public boolean isAuthenticating()
Session
isAuthenticating
in interface Session
isAuthenticating
in class BaseSession
public boolean hasEntry(String id)
Session
protected boolean isMultiTenant()
true
if this directory supports multi tenancy, false
otherwise.protected String getCurrentTenantId()
null
otherwise.Copyright © 2017 Nuxeo. All rights reserved.