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>
public class DBSSession extends BaseSession
Implementation of aSessionfor Document-Based Storage.- Since:
- 5.9.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDBSSession.DBSQueryResultstatic classDBSSession.OrderByComparator-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.model.BaseSession
BaseSession.VersionAclMode
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanchangeTokenEnabledprotected static PatterndotDigitsPatternprotected booleanfulltextSearchDisabledprotected booleanfulltextStoredInBlobstatic Set<String>ID_VALUES_KEYSKeys for values that are ids.protected booleanisLatestVersionDisabledprotected static Set<String>KEYS_RETENTION_HOLD_AND_PROXIESprotected io.dropwizard.metrics5.MetricRegistryregistryprotected static TypeSTRING_ARRAY_TYPEprotected DBSTransactionStatetransactionstatic Set<String>TRUE_OR_NULL_BOOLEAN_KEYSKeys 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
Constructors Constructor Description DBSSession(DBSRepository repository)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SerializableacpToMem(ACP acp)protected voidaddBackProxyId(DBSDocumentState docState, String id)protected DBSDocumentStateaddProxyState(String id, String parentId, String name, Long pos, String targetId, String versionSeriesId)protected DocumentcheckIn(String id, String label, String checkinComment)protected voidcheckNotUnder(String parentId, String id, String op)Checks that we don't move/copy under ourselves.protected voidcheckOut(String id)voidcommit()Commit the transaction.static StringconvToInternal(String name)static StringconvToInternalAce(String name)static StringconvToNXQL(String name)protected Stringcopy(String sourceId, String parentId, List<String> ancestorIds, String name)Copy source under parent, and set its ancestors.Documentcopy(Document source, Document parent, String name)Copies the source document to the given folder.protected StringcopyRecurse(String sourceId, String parentId, LinkedList<String> ancestorIds, String name, boolean excludeSpecialChildren, boolean excludeRegularChildren)DocumentcreateChild(String id, String parentId, String name, Long pos, String typeName)protected DBSDocumentStatecreateChildState(String id, String parentId, String name, Long pos, String typeName)DocumentcreateProxy(Document doc, Document folder)Creates a generic proxy to the given document inside the given folder.voiddestroy()Destroys this session.protected voiddoOrderBy(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)voidend()Called just before the transaction is committed or rolled back.protected StringfindFreeName(Document parent, String name)ACPgetACP(Document doc)Gets the ACP for the document (without any inheritance).Map<String,String>getBinaryFulltext(String id)Gets the fulltext extracted from the binary fields.protected DocumentgetChild(String parentId, String name)protected List<Document>getChildren(String parentId)protected List<String>getChildrenIds(String parentId)protected List<String>getChildrenIds(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren)protected DBSDocumentgetDocument(String id)protected DBSDocumentgetDocument(DBSDocumentState docState)protected DBSDocumentgetDocument(DBSDocumentState docState, boolean readonly)DocumentgetDocumentByUUID(String id)Gets a document given its ID.protected StringgetDocumentIdByPath(String path)protected List<Document>getDocuments(List<String> ids)protected DocumentgetLastVersion(String versionSeriesId)LockManagergetLockManager()Gets the lock manager for this session.protected LonggetNextPos(String parentId)DocumentgetNullDocument()Gets the null document, to be used as a fake parent to add placeless children.protected StringgetPath(Map<String,Serializable> projection)List<Document>getProxies(Document doc)Finds the proxies for a document.List<Document>getProxies(Document doc, Document folder)Finds the proxies for a document.StringgetRepositoryName()Gets the repository that created this session.DocumentgetRootDocument()Gets the root document in this repository.protected StringgetRootId()static TypegetType(String name)DocumentgetVersion(String versionSeriesId, VersionModel versionModel)Gets a version of a document, given its versionable id and label.protected DBSDocumentStategetVersionByLabel(String versionSeriesId, String label)protected List<String>getVersionsIds(String versionSeriesId)protected booleanhasChild(String parentId, String name)protected booleanhasChildren(String parentId)DocumentimportDocument(String id, Document parent, String name, String typeName, Map<String,Serializable> properties)Imports a document with a given id and parent.booleanisFulltextStoredInBlob()Checks if fulltext extracted from the binary fields is internally stored as a blob.booleanisNegativeAclAllowed()Returnstrueif negative ACLs are allowed.protected booleanisOrderable(String id)protected booleanisOrderByPath(OrderByClause orderByClause)Does an ORDER BY clause include ecm:pathprotected booleankeepWhenRestore(String key)voidmarkUserChange(String id)Marks this document id as belonging to a user change.protected static ACPmemToAcp(String docId, Serializable acpSer)Documentmove(Document source, Document parent, String name)Moves the source document to the given folder.protected Stringnormalize(String path)protected voidnotifyDocumentRemove(String docId)protected voidorderBefore(String parentId, String sourceId, String destId)PartialList<Document>query(String query, String queryType, QueryFilter queryFilter, long countUpTo)Does a query.IterableQueryResultqueryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params)Does a query and fetch the individual results as maps.PartialList<Map<String,Serializable>>queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object[] params)Does a query and fetch the individual results as maps.protected voidrecomputeVersionSeries(String versionSeriesId)Recomputes isLatest / isLatestMajor on all versions.protected voidremove(String rootId, NuxeoPrincipal principal)Removes a document.protected voidremoveBackProxyId(DBSDocumentState docState, String id)protected voidremoveBackProxyIds(DBSDocumentState docState, Set<String> ids)voidremoveDocument(String id)Removes a document.DocumentresolvePath(String path)Gets the document at the given path, if any.protected voidrestoreVersion(Document doc, Document version)voidrollback()Rollback the transaction.voidsave()Saves this session.ScrollResult<String>scroll(String scrollId)Get the next batch of result containing id of documents.ScrollResult<String>scroll(String query, 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.ScrollResult<String>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.voidsetACP(Document doc, ACP acp, boolean overwrite)voidsetProxyTarget(Document proxy, Document target)Sets a proxies' target.voidstart()Start the transaction.protected static BooleantrueOrNull(Object value)voidupdateReadACLs(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 Detail
-
transaction
protected final DBSTransactionState 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
protected static final Pattern dotDigitsPattern
-
STRING_ARRAY_TYPE
protected static final Type STRING_ARRAY_TYPE
-
TRUE_OR_NULL_BOOLEAN_KEYS
public static final Set<String> TRUE_OR_NULL_BOOLEAN_KEYS
Keys for boolean values that are stored as true or null (never false).- Since:
- 11.1
-
-
Constructor Detail
-
DBSSession
public DBSSession(DBSRepository repository)
-
-
Method Detail
-
getRepositoryName
public String getRepositoryName()
Description copied from interface:SessionGets the repository that created this session.- Returns:
- the repository
-
destroy
public void destroy()
Description copied from interface:SessionDestroys this session.
-
save
public void save()
Description copied from interface:SessionSaves this session.
-
getRootId
protected String getRootId()
-
resolvePath
public Document resolvePath(String path)
Description copied from interface:SessionGets the document at the given path, if any.
-
getChildrenIds
protected List<String> getChildrenIds(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren)
-
hasChildren
protected boolean hasChildren(String parentId)
-
getDocumentByUUID
public Document getDocumentByUUID(String id)
Description copied from interface:SessionGets a document given its ID.- Parameters:
id- the document id- Returns:
- the document
-
getRootDocument
public Document getRootDocument()
Description copied from interface:SessionGets the root document in this repository.- Returns:
- the root document
-
getNullDocument
public Document getNullDocument()
Description copied from interface:SessionGets the null document, to be used as a fake parent to add placeless children.- Returns:
- the null document
-
getDocument
protected DBSDocument getDocument(String id)
-
getDocument
protected DBSDocument getDocument(DBSDocumentState docState)
-
getDocument
protected DBSDocument getDocument(DBSDocumentState docState, boolean readonly)
-
createChild
public Document createChild(String id, String parentId, String name, Long pos, String typeName)
-
createChildState
protected DBSDocumentState createChildState(String id, String parentId, String name, Long pos, String typeName)
-
isOrderable
protected boolean isOrderable(String id)
-
checkOut
protected void checkOut(String id)
-
recomputeVersionSeries
protected void recomputeVersionSeries(String versionSeriesId)
Recomputes isLatest / isLatestMajor on all versions.
-
keepWhenRestore
protected boolean keepWhenRestore(String key)
-
copy
public Document copy(Document source, Document parent, String name)
Description copied from interface:SessionCopies the source document to the given folder.If the destination document is not a folder, an exception is thrown.
-
copyRecurse
protected String copyRecurse(String sourceId, String parentId, LinkedList<String> ancestorIds, String name, boolean excludeSpecialChildren, boolean excludeRegularChildren)
-
copy
protected String copy(String sourceId, String parentId, List<String> ancestorIds, String name)
Copy source under parent, and set its ancestors.
-
checkNotUnder
protected void checkNotUnder(String parentId, String id, String op)
Checks that we don't move/copy under ourselves.
-
move
public Document move(Document source, Document parent, String name)
Description copied from interface:SessionMoves 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
protected void remove(String rootId, NuxeoPrincipal principal)
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
public Document createProxy(Document doc, Document folder)
Description copied from interface:SessionCreates a generic proxy to the given document inside the given folder.- Parameters:
doc- the documentfolder- the folder- Returns:
- the proxy
-
addProxyState
protected DBSDocumentState addProxyState(String id, String parentId, String name, Long pos, String targetId, String versionSeriesId)
-
addBackProxyId
protected void addBackProxyId(DBSDocumentState docState, String id)
-
removeBackProxyId
protected void removeBackProxyId(DBSDocumentState docState, String id)
-
removeBackProxyIds
protected void removeBackProxyIds(DBSDocumentState docState, Set<String> ids)
-
getProxies
public List<Document> getProxies(Document doc, Document folder)
Description copied from interface:SessionFinds 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
public List<Document> getProxies(Document doc)
Description copied from interface:SessionFinds 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
public void setProxyTarget(Document proxy, Document target)
Description copied from interface:SessionSets 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:SessionImports 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, ornullfor a versionname- the document name in its parenttypeName- the document type, orecm:proxyfor 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
-
getVersion
public Document getVersion(String versionSeriesId, VersionModel versionModel)
Description copied from interface:SessionGets 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
nullif not found
-
getVersionByLabel
protected DBSDocumentState getVersionByLabel(String versionSeriesId, String label)
-
updateReadACLs
public void updateReadACLs(Collection<String> docIds)
Description copied from interface:SessionUpdates the Read ACLs for some documents.- Parameters:
docIds- the document ids
-
isNegativeAclAllowed
public boolean isNegativeAclAllowed()
Description copied from interface:SessionReturnstrueif 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:
trueif negative ACLs are allowed
-
getACP
public ACP getACP(Document doc)
Description copied from class:BaseSessionGets the ACP for the document (without any inheritance).- Specified by:
getACPin classBaseSession- Parameters:
doc- the document- Returns:
- the ACP
-
acpToMem
public static Serializable acpToMem(ACP acp)
-
memToAcp
protected static ACP memToAcp(String docId, Serializable acpSer)
-
isFulltextStoredInBlob
public boolean isFulltextStoredInBlob()
Description copied from interface:SessionChecks if fulltext extracted from the binary fields is internally stored as a blob.- Returns:
trueif fulltext from binaries is store as a blob
-
getBinaryFulltext
public Map<String,String> getBinaryFulltext(String id)
Description copied from interface:SessionGets the fulltext extracted from the binary fields.
-
removeDocument
public void removeDocument(String id)
Description copied from interface:SessionRemoves 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
protected void notifyDocumentRemove(String docId)
-
query
public PartialList<Document> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Description copied from interface:SessionDoes 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
protected boolean isOrderByPath(OrderByClause orderByClause)
Does an ORDER BY clause include ecm:path
-
getPath
protected String getPath(Map<String,Serializable> projection)
-
doOrderBy
protected void doOrderBy(List<Map<String,Serializable>> projections, OrderByClause orderByClause)
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params)
Description copied from interface:SessionDoes 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:SessionDoes a query and fetch the individual results as maps.
-
scroll
public ScrollResult<String> scroll(String query, int batchSize, int keepAliveSeconds)
Description copied from interface:SessionExecutes 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:SessionExecutes 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 scrollId)
Description copied from interface:SessionGet the next batch of result containing id of documents.
-
getLockManager
public LockManager getLockManager()
Description copied from interface:SessionGets the lock manager for this session.- Returns:
- the lock manager
-
markUserChange
public void markUserChange(String id)
Marks this document id as belonging to a user change.- Since:
- 9.2
-
start
public void start()
Description copied from interface:SessionStart the transaction.
-
end
public void end()
Description copied from interface:SessionCalled just before the transaction is committed or rolled back.
-
commit
public void commit()
Description copied from interface:SessionCommit the transaction.
-
rollback
public void rollback()
Description copied from interface:SessionRollback the transaction.
-
-