public interface Session extends AutoCloseable
This class is used to create, obtain, modify and delete entries in a directory.
Directory.getSession()
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(String username,
String password)
Checks that the credentials provided by the UserManager match those registered in the directory.
|
void |
close()
Closes the session and all open result sets obtained from this session.
|
DocumentModel |
createEntry(DocumentModel entry)
Creates an entry in a directory.
|
DocumentModel |
createEntry(Map<String,Object> fieldMap)
Creates an entry in a directory.
|
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.
since 9.2 (unused), use
deleteEntry(String) instead. |
DocumentModelList |
getEntries()
Deprecated.
since 6.0 Use query method instead with parameters
|
DocumentModel |
getEntry(String id)
Retrieves a directory entry using its id.
|
DocumentModel |
getEntry(String id,
boolean fetchReferences)
Retrieves a directory entry using its id.
|
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 |
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 |
isReadOnly() |
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.
|
DocumentModelList |
query(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.
|
void |
setReadAllColumns(boolean readAllColumns)
For test framework.
|
void |
updateEntry(DocumentModel docModel)
Updates a directory entry.
|
DocumentModel getEntry(String id)
TODO what happens when the entry is not found? return null if not found?
id
- the entry idDocumentModel getEntry(String id, boolean fetchReferences)
id
- the entry idfetchReferences
- boolean stating if references have to be fetched@Deprecated DocumentModelList getEntries()
DocumentModelList#totalsize
on the returned list will return
-2 as a special marker for truncated results.SizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.DocumentModel createEntry(Map<String,Object> fieldMap)
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
UnsupportedOperationException
- if the directory does not allow the creation of new entriesvoid updateEntry(DocumentModel docModel)
docModel
- The entry to updateUnsupportedOperationException
- if the directory does not support entry updatingvoid deleteEntry(DocumentModel docModel)
docModel
- The entry to deleteUnsupportedOperationException
- if the directory does not support entry deletingvoid deleteEntry(String id)
id
- the id of the entry to deleteUnsupportedOperationException
- if the directory does not support entry deleting@Deprecated void deleteEntry(String id, Map<String,String> map)
deleteEntry(String)
instead.This is used for hierarchical vocabularies, where the actual unique key is the couple (parent, id).
id
- the id of the entry to delete.map
- a map of secondary key values.DocumentModelList query(Map<String,Serializable> filter)
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.filter
- a filter to apply to entries in directorySizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext)
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.filter
- a filter to apply to entries in directoryfulltext
- a set of field that should be treated as a fulltext searchSizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy)
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.filter
- a filter to apply to entries in directoryorderBy
- 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'.fulltext
- a set of field that should be treated as a fulltext searchSizeLimitExceededException
- if the number of results is larger than the limit configured for the directory
and the server does not send partial results.DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences)
query(Map, Set, Map)
DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset)
limit
- maximum number of results ignored if less than 1offset
- number of rows skipped before starting, will be 0 if less than 0.query(Map, Set, Map, boolean)
DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences)
queryBuilder
- the query to use, including limit, offset, ordering and countTotalfetchReferences
- boolean stating if references have to be fetchedList<String> queryIds(QueryBuilder queryBuilder)
queryBuilder
- the query to use, including limit, offset and orderingvoid close()
Releases this Connection object's resources immediately instead of waiting for them to be automatically released.
TODO: should this operation auto-commit pending changes?
close
in interface AutoCloseable
List<String> getProjection(Map<String,Serializable> filter, String columnName)
filter
- the filter for the querycolumnName
- the column whose content should be returnedSizeLimitExceededException
- if the number of results is larger than the limit configured for the directoryList<String> getProjection(Map<String,Serializable> filter, Set<String> fulltext, String columnName)
boolean isAuthenticating()
boolean authenticate(String username, String password)
username
- password
- String getIdField()
String getPasswordField()
boolean isReadOnly()
boolean hasEntry(String id)
DocumentModel createEntry(DocumentModel entry)
entry
- the document model representing the entry to createUnsupportedOperationException
- if the directory does not allow the creation of new entriesvoid setReadAllColumns(boolean readAllColumns)
readAllColumns
- whether to read all columnsCopyright © 2018 Nuxeo. All rights reserved.