Package org.nuxeo.ecm.core.storage.dbs
Class DBSSession
java.lang.Object
org.nuxeo.ecm.core.model.BaseSession
org.nuxeo.ecm.core.storage.dbs.DBSSession
- All Implemented Interfaces:
Session<QueryFilter>
Implementation of a
Session
for Document-Based Storage.- Since:
- 5.9.4
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
static class
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.model.BaseSession
BaseSession.VersionAclMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected final boolean
protected static final Pattern
protected final boolean
protected final boolean
Keys for values that are ids.protected boolean
protected final io.dropwizard.metrics5.MetricRegistry
protected static final Type
protected final DBSTransactionState
Keys for boolean values that are stored as true or null (never false).Fields inherited from class org.nuxeo.ecm.core.model.BaseSession
disableReadVersionPermission, READ_VERSION_PERM_DISABLED_PROP, repository, VERSION_ACL_DISABLED_PROP, versionAclMode
Fields inherited from interface org.nuxeo.ecm.core.model.Session
PROP_ALLOW_DELETE_UNDELETABLE_DOCUMENTS, PROP_RETENTION_COMPLIANCE_MODE_ENABLED, PROP_RETENTION_STRICT_MODE_ENABLED, USER_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Serializable
protected void
addBackProxyId
(DBSDocumentState docState, String id) protected DBSDocumentState
addProxyState
(String id, String parentId, String name, Long pos, String targetId, String versionSeriesId) protected Document
protected void
checkNotUnder
(String parentId, String id, String op) Checks that we don't move/copy under ourselves.protected void
void
commit()
Commit the transaction.static String
convToInternal
(String name) static String
convToInternalAce
(String name) static String
convToNXQL
(String name) protected String
Copy source under parent, and set its ancestors.Copies the source document to the given folder.protected String
copyRecurse
(String sourceId, String parentId, LinkedList<String> ancestorIds, String name, boolean excludeSpecialChildren, boolean excludeRegularChildren) protected DBSDocumentState
createProxy
(Document doc, Document folder) Creates a generic proxy to the given document inside the given folder.void
destroy()
Destroys this session.protected void
doOrderBy
(List<Map<String, Serializable>> projections, OrderByClause orderByClause) protected PartialList<String>
doQuery
(String query, String queryType, QueryFilter queryFilter, int countUpTo) protected PartialList<Map<String,
Serializable>> doQueryAndFetch
(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, int countUpTo, org.apache.commons.lang3.mutable.Mutable<String> idKeyHolder) void
end()
Called just before the transaction is committed or rolled back.protected String
findFreeName
(Document parent, String name) Gets the ACP for the document (without any inheritance).Gets the fulltext extracted from the binary fields.protected Document
getChildren
(String parentId) getChildrenIds
(String parentId) getChildrenIds
(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren) protected DBSDocument
getDocument
(String id) protected DBSDocument
getDocument
(DBSDocumentState docState) protected DBSDocument
getDocument
(DBSDocumentState docState, boolean readonly) Gets a document given its ID.protected String
getDocumentIdByPath
(String path) getDocuments
(List<String> ids) protected Document
getLastVersion
(String versionSeriesId) Gets the lock manager for this session.protected Long
getNextPos
(String parentId) Gets the null document, to be used as a fake parent to add placeless children.protected String
getPath
(Map<String, Serializable> projection) getProxies
(Document doc) Finds the proxies for a document.getProxies
(Document doc, Document folder) Finds the proxies for a document.Gets the repository that created this session.Gets the root document in this repository.protected String
static Type
getVersion
(String versionSeriesId, VersionModel versionModel) Gets a version of a document, given its versionable id and label.protected DBSDocumentState
getVersionByLabel
(String versionSeriesId, String label) getVersionsIds
(String versionSeriesId) protected boolean
protected boolean
hasChildren
(String parentId) importDocument
(String id, Document parent, String name, String typeName, Map<String, Serializable> properties) Imports a document with a given id and parent.boolean
Checks if fulltext extracted from the binary fields is internally stored as a blob.boolean
Returnstrue
if negative ACLs are allowed.protected boolean
isOrderable
(String id) protected boolean
isOrderByPath
(OrderByClause orderByClause) Does an ORDER BY clause include ecm:pathprotected boolean
keepWhenRestore
(String key) void
markUserChange
(String id) Marks this document id as belonging to a user change.protected static ACP
memToAcp
(String docId, Serializable acpSer) Moves the source document to the given folder.protected String
protected void
notifyDocumentRemove
(String docId) protected void
orderBefore
(String parentId, String sourceId, String destId) query
(String query, String queryType, QueryFilter queryFilter, long countUpTo) Does a query.queryAndFetch
(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params) Does a query and fetch the individual results as maps.queryProjection
(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object[] params) Does a query and fetch the individual results as maps.protected void
recomputeVersionSeries
(String versionSeriesId) Recomputes isLatest / isLatestMajor on all versions.protected void
remove
(String rootId, NuxeoPrincipal principal) Removes a document.protected void
removeBackProxyId
(DBSDocumentState docState, String id) protected void
removeBackProxyIds
(DBSDocumentState docState, Set<String> ids) void
removeDocument
(String id) Removes a document.resolvePath
(String path) Gets the document at the given path, if any.protected void
restoreVersion
(Document doc, Document version) void
rollback()
Rollback the transaction.void
save()
Saves this session.Get the next batch of result containing id of documents.Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.scroll
(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.void
void
setProxyTarget
(Document proxy, Document target) Sets a proxies' target.void
start()
Start the transaction.protected static Boolean
trueOrNull
(Object value) void
updateReadACLs
(Collection<String> docIds) Updates the Read ACLs for some documents.Methods inherited from class org.nuxeo.ecm.core.model.BaseSession
canDeleteUndeletable, checkNegativeAcl, getACP, getDocumentBlobManager, getMergedACP, isReadVersionPermissionDisabled, isRetentionStricMode, notifyAfterCopy, updateACP
-
Field Details
-
KEYS_RETENTION_HOLD_AND_PROXIES
-
transaction
-
fulltextStoredInBlob
protected final boolean fulltextStoredInBlob -
fulltextSearchDisabled
protected final boolean fulltextSearchDisabled -
changeTokenEnabled
protected final boolean changeTokenEnabled -
registry
protected final io.dropwizard.metrics5.MetricRegistry registry -
isLatestVersionDisabled
protected boolean isLatestVersionDisabled -
dotDigitsPattern
-
STRING_ARRAY_TYPE
-
TRUE_OR_NULL_BOOLEAN_KEYS
Keys for boolean values that are stored as true or null (never false).- Since:
- 11.1
-
ID_VALUES_KEYS
Keys for values that are ids.- Since:
- 11.1
-
-
Constructor Details
-
DBSSession
-
-
Method Details
-
getRepositoryName
Description copied from interface:Session
Gets the repository that created this session.- Returns:
- the repository
-
destroy
public void destroy()Description copied from interface:Session
Destroys this session. -
save
public void save()Description copied from interface:Session
Saves this session. -
getRootId
-
normalize
-
resolvePath
Description copied from interface:Session
Gets the document at the given path, if any. -
getDocumentIdByPath
-
getChild
-
getChildren
-
getChildrenIds
-
getChildrenIds
-
hasChildren
-
getDocumentByUUID
Description copied from interface:Session
Gets a document given its ID.- Parameters:
id
- the document id- Returns:
- the document
-
getRootDocument
Description copied from interface:Session
Gets the root document in this repository.- Returns:
- the root document
-
getNullDocument
Description copied from interface:Session
Gets the null document, to be used as a fake parent to add placeless children.- Returns:
- the null document
-
getDocument
-
getDocuments
-
getDocument
-
getDocument
-
hasChild
-
createChild
-
createChildState
-
isOrderable
-
getNextPos
-
orderBefore
-
checkOut
-
checkIn
-
recomputeVersionSeries
Recomputes isLatest / isLatestMajor on all versions. -
restoreVersion
-
keepWhenRestore
-
copy
Description copied from interface:Session
Copies the source document to the given folder.If the destination document is not a folder, an exception is thrown.
-
copyRecurse
-
copy
Copy source under parent, and set its ancestors. -
findFreeName
-
checkNotUnder
Checks that we don't move/copy under ourselves. -
move
Description copied from interface:Session
Moves the source document to the given folder.If the destination document is not a folder an exception is thrown.
- Parameters:
source
- the source document to moveparent
- the destination foldername
- the new name of the document or null if the original name should be preserved
-
remove
Removes a document.We also have to update everything impacted by "relations":
- parent-child relations: delete all subchildren recursively,
- proxy-target relations: if a proxy is removed, update the target's PROXY_IDS; and if a target is removed, raise an error if a proxy still exists for that target.
-
createProxy
Description copied from interface:Session
Creates a generic proxy to the given document inside the given folder.- Parameters:
doc
- the documentfolder
- the folder- Returns:
- the proxy
-
addProxyState
-
addBackProxyId
-
removeBackProxyId
-
removeBackProxyIds
-
getProxies
Description copied from interface:Session
Finds the proxies for a document. If the folder is not null, the search will be limited to its children.If the document is a version, then only proxies to that version will be looked up.
- Parameters:
doc
- the document or versionfolder
- the folder, or null- Returns:
- the list of proxies if any is found otherwise an empty list
-
getProxies
Description copied from interface:Session
Finds the proxies for a document. (The document may be a version or a live document)- Parameters:
doc
- the document or version- Returns:
- the list of proxies if any is found otherwise an empty list
-
setProxyTarget
Description copied from interface:Session
Sets a proxies' target.The target must have the same version series as the proxy.
- Parameters:
proxy
- the proxytarget
- the new target
-
importDocument
public Document importDocument(String id, Document parent, String name, String typeName, Map<String, Serializable> properties) Description copied from interface:Session
Imports a document with a given id and parent.The document can then be filled with the normal imported properties.
- Parameters:
id
- the document uuidparent
- the document parent, ornull
for a versionname
- the document name in its parenttypeName
- the document type, orecm:proxy
for a proxyproperties
- system properties of the document, which will vary depending whether it's a live document, a version or a proxy (see the variousIMPORT_*
constants ofCoreSession
)- Returns:
- a writable
Document
, even for proxies and versions
-
trueOrNull
-
getVersion
Description copied from interface:Session
Gets a version of a document, given its versionable id and label.The version model contains the label of the version to look for. On return, it is filled with the version's description and creation date.
- Parameters:
versionSeriesId
- the versionable idversionModel
- the version model- Returns:
- the version, or
null
if not found
-
getVersionByLabel
-
getVersionsIds
-
getLastVersion
-
updateReadACLs
Description copied from interface:Session
Updates the Read ACLs for some documents.- Parameters:
docIds
- the document ids
-
isNegativeAclAllowed
public boolean isNegativeAclAllowed()Description copied from interface:Session
Returnstrue
if negative ACLs are allowed.Negative ACLs are ACLs that include an ACE with a deny (isGranted=false). This does not include the full-blocking ACE for Everyone/Everything, which is always allowed.
- Returns:
true
if negative ACLs are allowed
-
getACP
Description copied from class:BaseSession
Gets the ACP for the document (without any inheritance).- Specified by:
getACP
in classBaseSession
- Parameters:
doc
- the document- Returns:
- the ACP
-
setACP
-
acpToMem
-
memToAcp
-
isFulltextStoredInBlob
public boolean isFulltextStoredInBlob()Description copied from interface:Session
Checks if fulltext extracted from the binary fields is internally stored as a blob.- Returns:
true
if fulltext from binaries is store as a blob
-
getBinaryFulltext
Description copied from interface:Session
Gets the fulltext extracted from the binary fields. -
removeDocument
Description copied from interface:Session
Removes a document. In DBS, this removal is done without checking if proxies are targeting the document, or if it has any children.- Parameters:
id
- the document id
-
notifyDocumentRemove
-
query
public PartialList<Document> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) Description copied from interface:Session
Does a query. -
doQuery
protected PartialList<String> doQuery(String query, String queryType, QueryFilter queryFilter, int countUpTo) -
doQueryAndFetch
protected PartialList<Map<String,Serializable>> doQueryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, int countUpTo, org.apache.commons.lang3.mutable.Mutable<String> idKeyHolder) -
isOrderByPath
Does an ORDER BY clause include ecm:path -
getPath
-
doOrderBy
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params) Description copied from interface:Session
Does a query and fetch the individual results as maps. -
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object[] params) Description copied from interface:Session
Does a query and fetch the individual results as maps. -
scroll
Description copied from interface:Session
Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay. -
scroll
public ScrollResult<String> scroll(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) Description copied from interface:Session
Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay. -
scroll
Description copied from interface:Session
Get the next batch of result containing id of documents. -
convToInternal
-
convToInternalAce
-
convToNXQL
-
getType
-
getLockManager
Description copied from interface:Session
Gets the lock manager for this session.- Returns:
- the lock manager
-
markUserChange
Marks this document id as belonging to a user change.- Since:
- 9.2
-
start
public void start()Description copied from interface:Session
Start the transaction. -
end
public void end()Description copied from interface:Session
Called just before the transaction is committed or rolled back. -
commit
public void commit()Description copied from interface:Session
Commit the transaction. -
rollback
public void rollback()Description copied from interface:Session
Rollback the transaction.
-