public abstract class BaseSession extends Object implements Session, EntrySource
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoincrementId |
protected Directory |
directory |
protected String |
directoryName |
protected static String |
MULTI_TENANT_ID_FORMAT |
protected String |
passwordHashAlgorithm |
protected PermissionDescriptor[] |
permissions |
protected static String |
POWER_USERS_GROUP |
protected boolean |
readAllColumns |
protected static String |
READONLY_ENTRY_FLAG |
protected Class<? extends Reference> |
referenceClass |
protected String |
schemaName |
protected BaseDirectoryDescriptor.SubstringMatchType |
substringMatchType |
Modifier | Constructor and Description |
---|---|
protected |
BaseSession(Directory directory,
Class<? extends Reference> referenceClass) |
Modifier and Type | Method and Description |
---|---|
void |
checkDeleteConstraints(String entryId)
Checks that there are no constraints for deleting the given entry id.
|
void |
checkPermission(String permission)
Checks the current user rights for the given permission against the read-only flag and the permission descriptor.
|
static String |
computeMultiTenantDirectoryId(String tenantId,
String id)
Compute a multi tenant directory id based on the given
tenantId . |
DocumentModel |
createEntry(DocumentModel documentModel)
Creates an entry in a directory.
|
DocumentModel |
createEntry(Map<String,Object> fieldMap)
Creates an entry in a directory.
|
static DocumentModel |
createEntryModel(String sessionId,
String schema,
String id,
Map<String,Object> values)
Returns a bare document model suitable for directory implementations.
|
static DocumentModel |
createEntryModel(String sessionId,
String schema,
String id,
Map<String,Object> values,
boolean readOnly)
Returns a bare document model suitable for directory implementations.
|
protected abstract DocumentModel |
createEntryWithoutReferences(Map<String,Object> fieldMap)
To be implemented for specific creation.
|
void |
deleteEntry(DocumentModel docModel)
Deletes a directory entry.
|
void |
deleteEntry(String id)
Deletes a directory entry by id.
|
void |
deleteEntry(String id,
Map<String,String> map)
Deprecated.
|
protected abstract void |
deleteEntryWithoutReferences(String id)
To be implemented for specific deletion.
|
abstract Directory |
getDirectory()
To be implemented with a more specific return type.
|
DocumentModelList |
getEntries()
Retrieves all the entries in the directory.
|
DocumentModel |
getEntry(String id)
Retrieves a directory entry using its id.
|
DocumentModel |
getEntry(String id,
boolean fetchReferences)
Retrieves a directory entry using its id.
|
DocumentModel |
getEntryFromSource(String id,
boolean fetchReferences) |
String |
getIdField()
The Id field is the name of the field that is used a primary key: unique and not null value in the whole
directory.
|
String |
getPasswordField() |
List<String> |
getProjection(Map<String,Serializable> filter,
Set<String> fulltext,
String columnName) |
List<String> |
getProjection(Map<String,Serializable> filter,
String columnName)
Executes a query using filter and return only the column columnName.
|
boolean |
hasPermission(String permission)
Checks the current user rights for the given permission against the read-only flag and the permission descriptor.
|
protected boolean |
hasPermission(String permission,
String username,
List<String> groups) |
boolean |
isAuthenticating()
Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on
login / password check).
|
boolean |
isReadOnly() |
static boolean |
isReadOnlyEntry(DocumentModel entry)
Test whether entry comes from a read-only back-end directory.
|
DocumentModelList |
query(Map<String,Serializable> filter)
Executes a simple query.
|
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext)
Executes a simple query.
|
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext,
Map<String,String> orderBy)
Executes a simple query.
|
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.
|
void |
setReadAllColumns(boolean readAllColumns)
For test framework.
|
static void |
setReadOnlyEntry(DocumentModel entry)
Set the read-only flag of a directory entry.
|
static void |
setReadWriteEntry(DocumentModel entry)
Unset the read-only flag of a directory entry.
|
void |
updateEntry(DocumentModel docModel)
Updates a directory entry.
|
protected abstract List<String> |
updateEntryWithoutReferences(DocumentModel docModel)
To be implemented for specific update.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
authenticate, close, hasEntry
protected static final String POWER_USERS_GROUP
protected static final String READONLY_ENTRY_FLAG
protected static final String MULTI_TENANT_ID_FORMAT
protected PermissionDescriptor[] permissions
protected boolean readAllColumns
protected String schemaName
protected String directoryName
protected BaseDirectoryDescriptor.SubstringMatchType substringMatchType
protected Class<? extends Reference> referenceClass
protected String passwordHashAlgorithm
protected boolean autoincrementId
protected BaseSession(Directory directory, Class<? extends Reference> referenceClass)
public abstract Directory getDirectory()
public void setReadAllColumns(boolean readAllColumns)
Session
setReadAllColumns
in interface Session
readAllColumns
- whether to read all columnspublic String getIdField()
Session
getIdField
in interface Session
public String getPasswordField()
getPasswordField
in interface Session
public boolean isAuthenticating()
Session
isAuthenticating
in interface Session
public boolean isReadOnly()
isReadOnly
in interface Session
public void checkPermission(String permission)
Throws DirectorySecurityException
if the user does not have adequate privileges.
DirectorySecurityException
- if access is deniedpublic void checkDeleteConstraints(String entryId)
public boolean hasPermission(String permission)
Returns false
if the user does not have adequate privileges.
false
if access is deniedprotected boolean hasPermission(String permission, String username, List<String> groups)
public static DocumentModel createEntryModel(String sessionId, String schema, String id, Map<String,Object> values) throws PropertyException
Can be used for creation screen.
PropertyException
public static DocumentModel createEntryModel(String sessionId, String schema, String id, Map<String,Object> values, boolean readOnly) throws PropertyException
Allow setting the readonly entry flag to Boolean.TRUE
. See Session#isReadOnlyEntry(DocumentModel)
PropertyException
public static boolean isReadOnlyEntry(DocumentModel entry)
public static void setReadOnlyEntry(DocumentModel entry)
public static void setReadWriteEntry(DocumentModel entry)
public static String computeMultiTenantDirectoryId(String tenantId, String id)
tenantId
.public DocumentModel getEntry(String id) throws DirectoryException
Session
TODO what happens when the entry is not found? return null if not found?
getEntry
in interface Session
id
- the entry idDirectoryException
public DocumentModel getEntry(String id, boolean fetchReferences) throws DirectoryException
Session
getEntry
in interface Session
id
- the entry idfetchReferences
- boolean stating if references have to be fetchedDirectoryException
public DocumentModelList getEntries() throws DirectoryException
Session
DocumentModelList#totalsize
on the returned list will return
-2 as a special marker for truncated results.getEntries
in interface Session
DirectoryException
SizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModel getEntryFromSource(String id, boolean fetchReferences) throws DirectoryException
getEntryFromSource
in interface EntrySource
DirectoryException
public DocumentModel createEntry(DocumentModel documentModel)
Session
createEntry
in interface Session
documentModel
- the document model representing the entry to createpublic DocumentModel createEntry(Map<String,Object> fieldMap) throws DirectoryException
Session
createEntry
in interface Session
fieldMap
- A map with keys and values that should be stored in a directory
Note: The values in the map should be of type String
DirectoryException
- if a communication exception occurs or if an entry with the same id already exists.public void updateEntry(DocumentModel docModel) throws DirectoryException
Session
updateEntry
in interface Session
docModel
- The entry to updateDirectoryException
- if a communication error occurspublic void deleteEntry(DocumentModel docModel) throws DirectoryException
Session
deleteEntry
in interface Session
docModel
- The entry to deleteDirectoryException
- if a communication error occurs@Deprecated 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
id
- the id of the entry to delete.map
- a map of secondary key values.DirectoryException
- if a communication error occurs.public void deleteEntry(String id) throws DirectoryException
Session
deleteEntry
in interface Session
id
- the id of the entry to deleteDirectoryException
- if a communication error occurspublic DocumentModelList query(Map<String,Serializable> filter) throws DirectoryException
Session
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#totalsize
on the returned list will return -2 as a special marker for truncated
results.query
in interface Session
filter
- a filter to apply to entries in directoryDirectoryException
- if a communication error occursSizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext) throws DirectoryException
Session
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#totalsize
on the returned list will return -2 as a special marker for truncated
results.query
in interface Session
filter
- a filter to apply to entries in directoryfulltext
- a set of field that should be treated as a fulltext searchDirectoryException
- if a communication error occursSizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy) throws DirectoryException
Session
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#totalsize
on the returned list will return -2 as a special marker for truncated
results.query
in interface Session
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'.DirectoryException
- if a communication error occursSizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences) throws DirectoryException
Session
query
in interface Session
DirectoryException
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
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)
public List<String> getProjection(Map<String,Serializable> filter, String columnName) throws DirectoryException
Session
getProjection
in interface Session
filter
- the filter for the querycolumnName
- the column whose content should be returnedDirectoryException
SizeLimitExceededException
- if the number of results is larger than the limit configured for the directorypublic List<String> getProjection(Map<String,Serializable> filter, Set<String> fulltext, String columnName) throws DirectoryException
getProjection
in interface Session
DirectoryException
protected abstract DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap)
protected abstract List<String> updateEntryWithoutReferences(DocumentModel docModel) throws DirectoryException
DirectoryException
protected abstract void deleteEntryWithoutReferences(String id) throws DirectoryException
DirectoryException
Copyright © 2018 Nuxeo. All rights reserved.