Class SessionImpl
- All Implemented Interfaces:
AutoCloseable,Session
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.Session
Session.PathResolver -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanstatic final StringSet this system property to false if you don't want repositories to be looked up under the compatibility name "default" in the "repositories" table.final PersistenceContextprotected final FulltextDescriptorprotected final Set<SessionImpl.QueryResultContext> protected final io.dropwizard.metrics5.MetricRegistryprotected final RepositoryImpl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddChildNode(Serializable id, Node parent, String name, Long pos, String typeName, boolean complexProp) Creates a new child node with given id (used for import).addChildNode(Node parent, String name, Long pos, String typeName, boolean complexProp) Creates a new child node.booleanaddMixinType(Node node, String mixin) Adds a mixin to a node.protected NodeaddNode(Serializable id, Serializable parentId, String name, Long pos, String typeName, boolean complexProp) addProxy(Serializable targetId, Serializable versionableId, Node parent, String name, Long pos) Creates a proxy for a version node.Checks in a checked-out node: creates a new version with a copy of its information.protected voidPost transaction check invalidations processing.voidChecks out a checked-in node.intcleanupDeletedDocuments(int max, Calendar beforeTime) protected intClears all the caches.voidclose()protected voidprotected voidvoidcommit()Copies a node to a new location with a new name.protected voiddoFlush()voidend()protected voidfindPrefetchedFragments(SimpleFragment hierFragment, List<RowId> bulkRowIds, Set<Serializable> proxyIds) Finds prefetched fragments for a hierarchy fragment, takes note of the ones that are proxies.protected voidflush()protected SerializableGenerates a new id, or used a pre-generated one (import).getBinaryFulltext(Serializable id, Document doc) Gets the fulltext extracted from the binary fields.longlonglonglonggetChildNode(Node parent, String name, boolean complexProp) Gets a child node given its parent and name.getChildren(Node parent, String name, boolean complexProp) Gets the children of a node.getChildrenNames(String primaryType, List<String> mixins) Gets complex children names defined by the primary type and the list of mixins.protected Serializableprotected PersistenceContextGets the fulltext updates to do.Fetches the hierarchy fragment for the given rows and all their ancestors.getLastVersion(Serializable versionSeriesId) Gets the last version for a given version series id.Gets the lock manager for this session.Gets the low-level Mapper for this session.getModel()Gets theModelassociated to this session.Gets a node given its id.protected NodegetNodeById(Serializable id, boolean prefetch) getNodeByPath(String path, Node node) Gets a node given its absolute path, or given an existing node and a relative path.getNodes(List<Serializable> ids) Gets several nodes given their ids.getNodesByIds(Collection<Serializable> ids, boolean prefetch) getParentNode(Node node) Gets the parent of a node.Gets the absolute path of a node.getProxies(Node document) Finds the proxies for a document.getProxies(Node document, Node parent) Finds the proxies for a document.Gets the session repository name.Gets the root node of the repository.getVersionByLabel(Serializable versionSeriesId, String label) Gets a version given its version series id and label.getVersions(Serializable versionSeriesId) Gets all the versions for a given version series id.booleanhasChildNode(Node parent, String name, boolean complexProp) Checks if a child node with the given name exists.booleanhasChildren(Node parent, boolean complexProp) Checks it a node has children.booleanChecks if change token management is enabled.booleanChecks if fulltext extracted from the binary fields is internally stored as a blob.protected booleanisIdNew(Serializable id) protected voidmarkIndexingInProgress(Set<Serializable> dirtyIds) Mark indexing in progress, so that future copies (including versions) will be indexed as well.voidmarkReferencedBlobs(BiConsumer<String, String> markerCallback) voidMarks the document as being modified by a user change.Moves a node to a new location with a new name.protected Stringprotected voidnoteQueryResult(IterableQueryResult result) voidorderBefore(Node parent, Node source, Node dest) Order the given source child node before the destination child node.protected voidProcesses all invalidations accumulated.query(String query, String queryType, QueryFilter queryFilter, long countUpTo) Makes a query to the database.query(String query, QueryFilter queryFilter, boolean countTotal) Makes a NXQL query to the database.queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params) Makes a query to the database and returns an iterable (which must be closed when done).queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params) Makes a query to the database and returns an iterable (which must be closed when done).queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) Makes a query to the database.voidRebuild the read ACLs for the whole repository.booleanremoveMixinType(Node node, String mixin) Removes a mixin from a node.voidremoveNode(Node node, Consumer<Node> beforeRemove) Removes a node from the storage.voidremovePropertyNode(Node node) Removes a property node from the storage.voidRead ACLs are optimized ACLs for the read permission, they need to be updated after document creation or ACL change.voidRestores a node to a given version.voidrollback()voidsave()Saves the modifications to persistent storage.protected voidscheduleWork(List<Work> works) Get the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse.Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSecondsdelay.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 thekeepAliveSecondsdelay.protected voidPost-transaction invalidations notification.voidsetProxyTarget(Node proxy, Serializable targetId) Sets a proxies' target.voidstart()voidUpdate only the read ACLs that have changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.storage.sql.Session
copy, getBinaryFulltext, removeNode
-
Field Details
-
COMPAT_REPOSITORY_NAME_KEY
Set this system property to false if you don't want repositories to be looked up under the compatibility name "default" in the "repositories" table.Only do this if you start from an empty database, or if you have migrated the "repositories" table by hand, or if you need to create a new repository in a database already containing a "default" repository (table sharing, not recommended).
- See Also:
-
repository
-
context
-
changeTokenEnabled
protected final boolean changeTokenEnabled -
fulltextDescriptor
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry -
queryResults
-
-
Constructor Details
-
SessionImpl
-
-
Method Details
-
getMapper
Description copied from interface:SessionGets the low-level Mapper for this session. -
clearCaches
protected int clearCaches()Clears all the caches. Called by RepositoryManagement. -
getContext
-
generateNewId
Generates a new id, or used a pre-generated one (import). -
isIdNew
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSession
-
closeSession
protected void closeSession() -
getRepositoryName
Description copied from interface:SessionGets the session repository name.- Specified by:
getRepositoryNamein interfaceSession- Returns:
- the repository name
-
getModel
Description copied from interface:SessionGets theModelassociated to this session. -
getRootNode
Description copied from interface:SessionGets the root node of the repository.- Specified by:
getRootNodein interfaceSession- Returns:
- the root node
-
save
public void save()Description copied from interface:SessionSaves the modifications to persistent storage.Modifications will be actually written only upon transaction commit.
-
flush
protected void flush() -
scheduleWork
-
doFlush
protected void doFlush() -
getContainingDocument
-
getFulltextWorks
Gets the fulltext updates to do. Called at save() time.- Returns:
- a list of
Workinstances to schedule post-commit.
-
markIndexingInProgress
Mark indexing in progress, so that future copies (including versions) will be indexed as well. -
sendInvalidationsToOthers
protected void sendInvalidationsToOthers()Post-transaction invalidations notification.Called post-transaction by session commit/rollback or transactionless save.
-
processReceivedInvalidations
protected void processReceivedInvalidations()Processes all invalidations accumulated.Called pre-transaction by start or transactionless save;
-
checkInvalidationsConflict
protected void checkInvalidationsConflict()Post transaction check invalidations processing. -
getNodeById
-
getNodeById
Description copied from interface:SessionGets a node given its id.- Specified by:
getNodeByIdin interfaceSession- Parameters:
id- the id- Returns:
- the node, or
nullif not found
-
getNodesByIds
-
findPrefetchedFragments
protected void findPrefetchedFragments(SimpleFragment hierFragment, List<RowId> bulkRowIds, Set<Serializable> proxyIds) Finds prefetched fragments for a hierarchy fragment, takes note of the ones that are proxies. -
getNodesByIds
Description copied from interface:SessionGets several nodes given their ids.- Specified by:
getNodesByIdsin interfaceSession- Parameters:
ids- the ids- Returns:
- the nodes, in the same order as the ids, with elements being
nullif not found
-
getParentNode
Description copied from interface:SessionGets the parent of a node.The root has a
nullparent.- Specified by:
getParentNodein interfaceSession- Parameters:
node- the node- Returns:
- the parent node, or
nullfor the root's parent
-
getPath
Description copied from interface:SessionGets the absolute path of a node. -
normalize
-
getNodeByPath
Description copied from interface:SessionGets a node given its absolute path, or given an existing node and a relative path.- Specified by:
getNodeByPathin interfaceSession- Parameters:
path- the pathnode- the node (ignored for absolute paths)- Returns:
- the node, or
nullif not found
-
addMixinType
Description copied from interface:SessionAdds a mixin to a node.Does nothing if the mixin was already present on the node.
- Specified by:
addMixinTypein interfaceSession- Parameters:
node- the nodemixin- the mixin name- Returns:
trueif the mixin was added, orfalseif it is already present
-
removeMixinType
Description copied from interface:SessionRemoves a mixin from a node.It's not possible to remove a mixin coming from the primary type.
- Specified by:
removeMixinTypein interfaceSession- Parameters:
node- the nodemixin- the mixin- Returns:
trueif the mixin was removed, orfalseif it isn't present or is present on the type or does not exist
-
scroll
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 thekeepAliveSecondsdelay. -
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 thekeepAliveSecondsdelay. -
scroll
Description copied from interface:SessionGet the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse. -
getChildrenNames
Gets complex children names defined by the primary type and the list of mixins. -
addChildNode
Description copied from interface:SessionCreates a new child node.- Specified by:
addChildNodein interfaceSession- Parameters:
parent- the parent to which the child is addedname- the child namepos- the child position, ornulltypeName- the child typecomplexProp- whether this is a complex property (true) or a regular child (false)- Returns:
- the new node
-
addChildNode
public Node addChildNode(Serializable id, Node parent, String name, Long pos, String typeName, boolean complexProp) Description copied from interface:SessionCreates a new child node with given id (used for import).- Specified by:
addChildNodein interfaceSession- Parameters:
id- the idparent- the parent to which the child is addedname- the child namepos- the child position, ornulltypeName- the child typecomplexProp- whether this is a complex property (true) or a regular child (false)- Returns:
- the new node
-
addNode
protected Node addNode(Serializable id, Serializable parentId, String name, Long pos, String typeName, boolean complexProp) -
addProxy
public Node addProxy(Serializable targetId, Serializable versionableId, Node parent, String name, Long pos) Description copied from interface:SessionCreates a proxy for a version node. -
setProxyTarget
Description copied from interface:SessionSets a proxies' target.- Specified by:
setProxyTargetin interfaceSession- Parameters:
proxy- the proxytargetId- the new target id
-
hasChildNode
Description copied from interface:SessionChecks if a child node with the given name exists.There are two kinds of children, the regular children documents and the complex properties. The
booleancomplexPropallows a choice between those.- Specified by:
hasChildNodein interfaceSession- Parameters:
parent- the parent nodename- the child namecomplexProp- whether to check complex properties or regular children- Returns:
trueif a child node with that name exists
-
getChildNode
Description copied from interface:SessionGets a child node given its parent and name.- Specified by:
getChildNodein interfaceSession- Parameters:
parent- the parent nodename- the child namecomplexProp- whether to check complex properties or regular children- Returns:
- the child node, or
nullis not found
-
hasChildren
Description copied from interface:SessionChecks it a node has children.- Specified by:
hasChildrenin interfaceSession- Parameters:
parent- the parent nodecomplexProp- whether to check complex properties or regular children- Returns:
trueif the parent has children
-
getChildren
Description copied from interface:SessionGets the children of a node.- Specified by:
getChildrenin interfaceSession- Parameters:
parent- the parent nodename- the children name to get (for lists of complex properties), ornullfor allcomplexProp- whether to check complex properties or regular children- Returns:
- the collection of children
-
orderBefore
Description copied from interface:SessionOrder the given source child node before the destination child node. The source node will be placed before the destination one. If destination isnull, the source node will be appended at the end of the children list.- Specified by:
orderBeforein interfaceSession- Parameters:
parent- the parent nodesource- the child node to movedest- the child node before which to place the source node, ornullto move at the end
-
move
Description copied from interface:SessionMoves a node to a new location with a new name.A
Session.save()is automatically done first. -
copy
Description copied from interface:SessionCopies a node to a new location with a new name.A
Session.save()is automatically done first. -
removeNode
Description copied from interface:SessionRemoves a node from the storage.This is much more complex than removing a property node (
Session.removePropertyNode(org.nuxeo.ecm.core.storage.sql.Node)).- Specified by:
removeNodein interfaceSession- Parameters:
node- the node to removebeforeRemove- a consumer called on nodes of records before they are removed- See Also:
-
removePropertyNode
Description copied from interface:SessionRemoves a property node from the storage.This is much less complex that removing a generic document node (
Session.removeNode(org.nuxeo.ecm.core.storage.sql.Node)).- Specified by:
removePropertyNodein interfaceSession- Parameters:
node- the property node to remove- See Also:
-
checkIn
Description copied from interface:SessionChecks in a checked-out node: creates a new version with a copy of its information.A
Session.save()is automatically done first. -
checkOut
Description copied from interface:SessionChecks out a checked-in node. -
restore
Description copied from interface:SessionRestores a node to a given version.The restored node is checked in.
-
getVersionByLabel
Description copied from interface:SessionGets a version given its version series id and label.- Specified by:
getVersionByLabelin interfaceSession- Parameters:
versionSeriesId- the version series idlabel- the label- Returns:
- the version node, or
nullif not found
-
getLastVersion
Description copied from interface:SessionGets the last version for a given version series id.A
Session.save()is automatically done first.- Specified by:
getLastVersionin interfaceSession- Parameters:
versionSeriesId- the version series id- Returns:
- the last version, or
nullif no versions exist
-
getVersions
Description copied from interface:SessionGets all the versions for a given version series id.A
Session.save()is automatically done first.- Specified by:
getVersionsin interfaceSession- Parameters:
versionSeriesId- the version series id- Returns:
- the list of versions
-
getProxies
Description copied from interface:SessionFinds the proxies for a document. If the parent is not null, the search will be limited to its direct children.If the document is a version, then only proxies to that version will be looked up.
Otherwise all proxies to the same version series than the document are retrieved.
A
Session.save()is automatically done first.- Specified by:
getProxiesin interfaceSession- Parameters:
document- the documentparent- the parent, ornull- Returns:
- the list of proxies
-
getNodes
-
getProxies
Description copied from interface:SessionFinds the proxies for a document. (The document may be a version or a live document)- Specified by:
getProxiesin interfaceSession- Parameters:
document- the document- Returns:
- the list of proxies, or an empty list
-
getHierarchyAndAncestors
Fetches the hierarchy fragment for the given rows and all their ancestors.- Parameters:
ids- the fragment ids
-
query
Description copied from interface:SessionMakes a NXQL query to the database. -
query
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) Description copied from interface:SessionMakes a query to the database.- Specified by:
queryin interfaceSession- Parameters:
query- the queryqueryType- the query typequeryFilter- the query filtercountUpTo- if-1, also count the total size without offset/limit.
If0, don't count the total size.
Ifn, count the total number if there are less than n documents otherwise set the size to-1.- Returns:
- the resulting list with total size included
-
noteQueryResult
-
closeQueryResults
protected void closeQueryResults() -
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params) Description copied from interface:SessionMakes a query to the database and returns an iterable (which must be closed when done).- Specified by:
queryAndFetchin interfaceSession- Parameters:
query- the queryqueryType- the query typequeryFilter- the query filterparams- optional query-type-dependent parameters- Returns:
- an iterable, which must be closed when done
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params) Description copied from interface:SessionMakes a query to the database and returns an iterable (which must be closed when done).- Specified by:
queryAndFetchin interfaceSession- Parameters:
query- the queryqueryType- the query typequeryFilter- the query filterdistinctDocuments- iftruethen a maximum of one row per document will be returnedparams- optional query-type-dependent parameters- Returns:
- an iterable, which must be closed when done
-
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) Description copied from interface:SessionMakes a query to the database.- Specified by:
queryProjectionin interfaceSession- Parameters:
query- the queryqueryType- the query typequeryFilter- the query filterdistinctDocuments- iftruethen a maximum of one row per document will be returnedcountUpTo- if-1, also count the total size without offset/limit.
If0, don't count the total size.
Ifn, count the total number if there are less than n documents otherwise set the size to-1.params- optional query-type-dependent parameters- Returns:
- a projection
-
getLockManager
Description copied from interface:SessionGets the lock manager for this session.- Specified by:
getLockManagerin interfaceSession- Returns:
- the lock manager
-
requireReadAclsUpdate
public void requireReadAclsUpdate()Description copied from interface:SessionRead ACLs are optimized ACLs for the read permission, they need to be updated after document creation or ACL change.This method flag the current session, the read ACLs update will be done automatically at save time.
- Specified by:
requireReadAclsUpdatein interfaceSession
-
updateReadAcls
public void updateReadAcls()Description copied from interface:SessionUpdate only the read ACLs that have changed.- Specified by:
updateReadAclsin interfaceSession
-
rebuildReadAcls
public void rebuildReadAcls()Description copied from interface:SessionRebuild the read ACLs for the whole repository.- Specified by:
rebuildReadAclsin interfaceSession
-
markReferencedBlobs
-
cleanupDeletedDocuments
-
start
public void start() -
end
public void end() -
commit
public void commit() -
rollback
public void rollback() -
getCacheSize
public long getCacheSize() -
getCacheMapperSize
public long getCacheMapperSize() -
getCachePristineSize
public long getCachePristineSize() -
getCacheSelectionSize
public long getCacheSelectionSize() -
isFulltextStoredInBlob
public boolean isFulltextStoredInBlob()Description copied from interface:SessionChecks if fulltext extracted from the binary fields is internally stored as a blob.- Specified by:
isFulltextStoredInBlobin interfaceSession- Returns:
trueif fulltext from binaries is store as a blob
-
getBinaryFulltext
Description copied from interface:SessionGets the fulltext extracted from the binary fields.- Specified by:
getBinaryFulltextin interfaceSession
-
isChangeTokenEnabled
public boolean isChangeTokenEnabled()Description copied from interface:SessionChecks if change token management is enabled.- Specified by:
isChangeTokenEnabledin interfaceSession
-
markUserChange
Description copied from interface:SessionMarks the document as being modified by a user change.This causes an additional change token increment and check during save.
- Specified by:
markUserChangein interfaceSession- Parameters:
id- the document id
-