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 aSession
for Document-Based Storage.- Since:
- 5.9.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DBSSession.DBSQueryResult
static class
DBSSession.OrderByComparator
-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.model.BaseSession
BaseSession.VersionAclMode
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
changeTokenEnabled
protected static Pattern
dotDigitsPattern
protected boolean
fulltextSearchDisabled
protected boolean
fulltextStoredInBlob
static Set<String>
ID_VALUES_KEYS
Keys for values that are ids.protected boolean
isLatestVersionDisabled
protected static Set<String>
KEYS_RETENTION_HOLD_AND_PROXIES
protected io.dropwizard.metrics5.MetricRegistry
registry
protected static Type
STRING_ARRAY_TYPE
protected DBSTransactionState
transaction
static Set<String>
TRUE_OR_NULL_BOOLEAN_KEYS
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
Constructors Constructor Description DBSSession(DBSRepository repository)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Serializable
acpToMem(ACP acp)
protected void
addBackProxyId(DBSDocumentState docState, String id)
protected DBSDocumentState
addProxyState(String id, String parentId, String name, Long pos, String targetId, String versionSeriesId)
protected Document
checkIn(String id, String label, String checkinComment)
protected void
checkNotUnder(String parentId, String id, String op)
Checks that we don't move/copy under ourselves.protected void
checkOut(String id)
void
commit()
Commit the transaction.static String
convToInternal(String name)
static String
convToInternalAce(String name)
static String
convToNXQL(String name)
protected String
copy(String sourceId, String parentId, List<String> ancestorIds, String name)
Copy source under parent, and set its ancestors.Document
copy(Document source, Document parent, String name)
Copies the source document to the given folder.protected String
copyRecurse(String sourceId, String parentId, LinkedList<String> ancestorIds, String name, boolean excludeSpecialChildren, boolean excludeRegularChildren)
Document
createChild(String id, String parentId, String name, Long pos, String typeName)
protected DBSDocumentState
createChildState(String id, String parentId, String name, Long pos, String typeName)
Document
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)
ACP
getACP(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 Document
getChild(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 DBSDocument
getDocument(String id)
protected DBSDocument
getDocument(DBSDocumentState docState)
protected DBSDocument
getDocument(DBSDocumentState docState, boolean readonly)
Document
getDocumentByUUID(String id)
Gets a document given its ID.protected String
getDocumentIdByPath(String path)
protected List<Document>
getDocuments(List<String> ids)
protected Document
getLastVersion(String versionSeriesId)
LockManager
getLockManager()
Gets the lock manager for this session.protected Long
getNextPos(String parentId)
Document
getNullDocument()
Gets the null document, to be used as a fake parent to add placeless children.protected String
getPath(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.String
getRepositoryName()
Gets the repository that created this session.Document
getRootDocument()
Gets the root document in this repository.protected String
getRootId()
static Type
getType(String name)
Document
getVersion(String versionSeriesId, VersionModel versionModel)
Gets a version of a document, given its versionable id and label.protected DBSDocumentState
getVersionByLabel(String versionSeriesId, String label)
protected List<String>
getVersionsIds(String versionSeriesId)
protected boolean
hasChild(String parentId, String name)
protected boolean
hasChildren(String parentId)
Document
importDocument(String id, Document parent, String name, String typeName, Map<String,Serializable> properties)
Imports a document with a given id and parent.boolean
isFulltextStoredInBlob()
Checks if fulltext extracted from the binary fields is internally stored as a blob.boolean
isNegativeAclAllowed()
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)
Document
move(Document source, Document parent, String name)
Moves the source document to the given folder.protected String
normalize(String path)
protected void
notifyDocumentRemove(String docId)
protected void
orderBefore(String parentId, String sourceId, String destId)
PartialList<Document>
query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Does a query.IterableQueryResult
queryAndFetch(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 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.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.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.void
setACP(Document doc, ACP acp, boolean overwrite)
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 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: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
protected String getRootId()
-
resolvePath
public Document resolvePath(String path)
Description copied from interface:Session
Gets 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:Session
Gets a document given its ID.- Parameters:
id
- the document id- Returns:
- the document
-
getRootDocument
public Document getRootDocument()
Description copied from interface:Session
Gets the root document in this repository.- Returns:
- the root document
-
getNullDocument
public 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
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:Session
Copies 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: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
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:Session
Creates 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: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
public List<Document> getProxies(Document doc)
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
public void setProxyTarget(Document proxy, Document target)
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
-
getVersion
public Document getVersion(String versionSeriesId, VersionModel versionModel)
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
protected DBSDocumentState getVersionByLabel(String versionSeriesId, String label)
-
updateReadACLs
public void updateReadACLs(Collection<String> docIds)
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
public ACP getACP(Document doc)
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
-
acpToMem
public static Serializable acpToMem(ACP acp)
-
memToAcp
protected static ACP memToAcp(String docId, Serializable acpSer)
-
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
public Map<String,String> getBinaryFulltext(String id)
Description copied from interface:Session
Gets the fulltext extracted from the binary fields.
-
removeDocument
public void removeDocument(String id)
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
protected void notifyDocumentRemove(String docId)
-
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
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: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
public ScrollResult<String> scroll(String query, 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
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
public ScrollResult<String> scroll(String scrollId)
Description copied from interface:Session
Get the next batch of result containing id of documents.
-
getLockManager
public LockManager getLockManager()
Description copied from interface:Session
Gets 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: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.
-
-