public class SessionImpl extends Object implements Session, XAResource
Session.PathResolver| Modifier and Type | Field and Description |
|---|---|
protected boolean |
changeTokenEnabled |
static String |
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.
|
PersistenceContext |
context |
protected com.codahale.metrics.MetricRegistry |
registry |
protected RepositoryImpl |
repository |
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY| Constructor and Description |
|---|
SessionImpl(RepositoryImpl repository,
Model model,
Mapper mapper) |
| Modifier and Type | Method and Description |
|---|---|
Node |
addChildNode(Node parent,
String name,
Long pos,
String typeName,
boolean complexProp)
Creates a new child node.
|
Node |
addChildNode(Serializable id,
Node parent,
String name,
Long pos,
String typeName,
boolean complexProp)
Creates a new child node with given id (used for import).
|
boolean |
addMixinType(Node node,
String mixin)
Adds a mixin to a node.
|
protected Node |
addNode(Serializable id,
Serializable parentId,
String name,
Long pos,
String typeName,
boolean complexProp) |
Node |
addProxy(Serializable targetId,
Serializable versionableId,
Node parent,
String name,
Long pos)
Creates a proxy for a version node.
|
Node |
checkIn(Node node,
String label,
String checkinComment)
Checks in a checked-out node: creates a new version with a copy of its information.
|
protected void |
checkInvalidationsConflict()
Post transaction check invalidations processing.
|
void |
checkLive() |
void |
checkOut(Node node)
Checks out a checked-in node.
|
void |
checkPermission(String absPath,
String actions) |
protected void |
checkThread() |
protected void |
checkThreadEnd() |
protected void |
checkThreadStart() |
int |
cleanupDeletedDocuments(int max,
Calendar beforeTime) |
protected int |
clearCaches()
Clears all the caches.
|
void |
close() |
protected void |
closeSession() |
void |
commit(Xid xid,
boolean onePhase) |
protected void |
commitDone() |
Node |
copy(Node source,
Node parent,
String name)
Copies a node to a new location with a new name.
|
javax.resource.cci.Interaction |
createInteraction() |
protected void |
doFlush() |
void |
end(Xid xid,
int flags) |
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.
|
protected void |
flush() |
void |
forget(Xid xid) |
protected Serializable |
generateNewId(Serializable id)
Generates a new id, or used a pre-generated one (import).
|
Map<String,String> |
getBinaryFulltext(Serializable id)
Gets the fulltext extracted from the binary fields.
|
long |
getCacheMapperSize() |
long |
getCachePristineSize() |
long |
getCacheSelectionSize() |
long |
getCacheSize() |
Node |
getChildNode(Node parent,
String name,
boolean complexProp)
Gets a child node given its parent and name.
|
List<Node> |
getChildren(Node parent,
String name,
boolean complexProp)
Gets the children of a node.
|
protected Set<String> |
getChildrenNames(String primaryType,
List<String> mixins)
Gets complex children names defined by the primary type and the list of mixins.
|
protected Serializable |
getContainingDocument(Serializable id) |
protected PersistenceContext |
getContext() |
protected List<Work> |
getFulltextWorks()
Gets the fulltext updates to do.
|
protected List<Fragment> |
getHierarchyAndAncestors(Collection<Serializable> ids)
Fetches the hierarchy fragment for the given rows and all their ancestors.
|
Node |
getLastVersion(Serializable versionSeriesId)
Gets the last version for a given version series id.
|
javax.resource.cci.LocalTransaction |
getLocalTransaction() |
LockManager |
getLockManager()
Gets the lock manager for this session.
|
Mapper |
getMapper()
Gets the low-level Mapper for this session.
|
javax.resource.cci.ConnectionMetaData |
getMetaData() |
Model |
getModel()
Gets the
Model associated to this session. |
Node |
getNodeById(Serializable id)
Gets a node given its id.
|
protected Node |
getNodeById(Serializable id,
boolean prefetch) |
Node |
getNodeByPath(String path,
Node node)
Gets a node given its absolute path, or given an existing node and a relative path.
|
protected List<Node> |
getNodes(List<Serializable> ids) |
List<Node> |
getNodesByIds(Collection<Serializable> ids)
Gets several nodes given their ids.
|
List<Node> |
getNodesByIds(Collection<Serializable> ids,
boolean prefetch) |
Node |
getParentNode(Node node)
Gets the parent of a node.
|
String |
getPath(Node node)
Gets the absolute path of a node.
|
List<Node> |
getProxies(Node document)
Finds the proxies for a document.
|
List<Node> |
getProxies(Node document,
Node parent)
Finds the proxies for a document.
|
String |
getRepositoryName()
Gets the session repository name.
|
javax.resource.cci.ResultSetInfo |
getResultSetInfo() |
Node |
getRootNode()
Gets the root node of the repository.
|
int |
getTransactionTimeout() |
Node |
getVersionByLabel(Serializable versionSeriesId,
String label)
Gets a version given its version series id and label.
|
List<Node> |
getVersions(Serializable versionSeriesId)
Gets all the versions for a given version series id.
|
XAResource |
getXAResource()
Gets the XAResource.
|
boolean |
hasChildNode(Node parent,
String name,
boolean complexProp)
Checks if a child node with the given name exists.
|
boolean |
hasChildren(Node parent,
boolean complexProp)
Checks it a node has children.
|
boolean |
hasPendingChanges() |
boolean |
isChangeTokenEnabled()
Checks if change token management is enabled.
|
protected boolean |
isIdNew(Serializable id) |
boolean |
isLive()
Checks if the session is live (not closed).
|
boolean |
isSameRM(XAResource xaresource) |
protected void |
markIndexingInProgress(Set<Serializable> dirtyIds)
Mark indexing in progress, so that future copies (including versions) will be indexed as well.
|
void |
markReferencedBinaries() |
void |
markUserChange(Serializable id)
Marks the document as being modified by a user change.
|
Node |
move(Node source,
Node parent,
String name)
Moves a node to a new location with a new name.
|
protected String |
normalize(String path) |
void |
orderBefore(Node parent,
Node source,
Node dest)
Order the given source child node before the destination child node.
|
int |
prepare(Xid xid) |
protected void |
processReceivedInvalidations()
Processes all invalidations accumulated.
|
PartialList<Serializable> |
query(String query,
QueryFilter queryFilter,
boolean countTotal)
Makes a NXQL query to the database.
|
PartialList<Serializable> |
query(String query,
String queryType,
QueryFilter queryFilter,
long countUpTo)
Makes a query to the database.
|
IterableQueryResult |
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).
|
IterableQueryResult |
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).
|
PartialList<Map<String,Serializable>> |
queryProjection(String query,
String queryType,
QueryFilter queryFilter,
boolean distinctDocuments,
long countUpTo,
Object... params)
Makes a query to the database.
|
void |
rebuildReadAcls()
Rebuild the read ACLs for the whole repository.
|
Xid[] |
recover(int flag) |
boolean |
removeMixinType(Node node,
String mixin)
Removes a mixin from a node.
|
void |
removeNode(Node node)
Removes a node from the storage.
|
void |
removePropertyNode(Node node)
Removes a property node from the storage.
|
void |
requireReadAclsUpdate()
Read ACLs are optimized ACLs for the read permission, they need to be updated after document creation or ACL
change.
|
void |
restore(Node node,
Node version)
Restores a node to a given version.
|
protected void |
rollback() |
void |
rollback(Xid xid) |
void |
save()
Saves the modifications to persistent storage.
|
protected void |
scheduleWork(List<Work> works) |
ScrollResult<String> |
scroll(String scrollId)
Get the next batch of results containing id of documents, the
scrollId is part of the previous
ScrollResult response. |
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. |
protected void |
sendInvalidationsToOthers()
Post-transaction invalidations notification.
|
void |
setProxyTarget(Node proxy,
Serializable targetId)
Sets a proxies' target.
|
boolean |
setTransactionTimeout(int seconds) |
void |
start(Xid xid,
int flags) |
void |
updateReadAcls()
Update only the read ACLs that have changed.
|
public static final String COMPAT_REPOSITORY_NAME_KEY
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).
protected final RepositoryImpl repository
public final PersistenceContext context
protected final boolean changeTokenEnabled
protected final com.codahale.metrics.MetricRegistry registry
public SessionImpl(RepositoryImpl repository, Model model, Mapper mapper)
public void checkLive()
public Mapper getMapper()
Sessionpublic XAResource getXAResource()
protected int clearCaches()
protected PersistenceContext getContext()
protected void rollback()
protected void checkThread()
protected void checkThreadStart()
protected void checkThreadEnd()
protected Serializable generateNewId(Serializable id)
protected boolean isIdNew(Serializable id)
public void close() throws javax.resource.ResourceException
close in interface javax.resource.cci.Connectionjavax.resource.ResourceExceptionprotected void closeSession()
public javax.resource.cci.Interaction createInteraction() throws javax.resource.ResourceException
createInteraction in interface javax.resource.cci.Connectionjavax.resource.ResourceExceptionpublic javax.resource.cci.LocalTransaction getLocalTransaction() throws javax.resource.ResourceException
getLocalTransaction in interface javax.resource.cci.Connectionjavax.resource.ResourceExceptionpublic javax.resource.cci.ConnectionMetaData getMetaData() throws javax.resource.ResourceException
getMetaData in interface javax.resource.cci.Connectionjavax.resource.ResourceExceptionpublic javax.resource.cci.ResultSetInfo getResultSetInfo() throws javax.resource.ResourceException
getResultSetInfo in interface javax.resource.cci.Connectionjavax.resource.ResourceExceptionpublic boolean isLive()
Sessionpublic String getRepositoryName()
SessiongetRepositoryName in interface Sessionpublic Model getModel()
SessionModel associated to this session.public Node getRootNode()
SessiongetRootNode in interface Sessionpublic void save()
SessionModifications will be actually written only upon transaction commit.
protected void flush()
protected void scheduleWork(List<Work> works)
protected void doFlush()
protected Serializable getContainingDocument(Serializable id)
protected List<Work> getFulltextWorks()
Work instances to schedule post-commit.protected void markIndexingInProgress(Set<Serializable> dirtyIds)
protected void sendInvalidationsToOthers()
Called post-transaction by session commit/rollback or transactionless save.
protected void processReceivedInvalidations()
Called pre-transaction by start or transactionless save;
protected void checkInvalidationsConflict()
protected Node getNodeById(Serializable id, boolean prefetch)
public Node getNodeById(Serializable id)
SessiongetNodeById in interface Sessionid - the idnull if not foundpublic List<Node> getNodesByIds(Collection<Serializable> ids, boolean prefetch)
protected void findPrefetchedFragments(SimpleFragment hierFragment, List<RowId> bulkRowIds, Set<Serializable> proxyIds)
public List<Node> getNodesByIds(Collection<Serializable> ids)
SessiongetNodesByIds in interface Sessionids - the idsnull if not foundpublic Node getParentNode(Node node)
Session
The root has a null parent.
getParentNode in interface Sessionnode - the nodenull for the root's parentpublic String getPath(Node node)
Sessionpublic Node getNodeByPath(String path, Node node)
SessiongetNodeByPath in interface Sessionpath - the pathnode - the node (ignored for absolute paths)null if not foundpublic boolean addMixinType(Node node, String mixin)
SessionDoes nothing if the mixin was already present on the node.
addMixinType in interface Sessionnode - the nodemixin - the mixin nametrue if the mixin was added, or false if it is already presentpublic boolean removeMixinType(Node node, String mixin)
SessionIt's not possible to remove a mixin coming from the primary type.
removeMixinType in interface Sessionnode - the nodemixin - the mixintrue if the mixin was removed, or false if it isn't present or is present on the type or
does not existpublic ScrollResult<String> scroll(String query, int batchSize, int keepAliveSeconds)
SessionkeepAliveSeconds delay.public ScrollResult<String> scroll(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds)
SessionkeepAliveSeconds delay.public ScrollResult<String> scroll(String scrollId)
SessionscrollId is part of the previous
ScrollResult response.protected Set<String> getChildrenNames(String primaryType, List<String> mixins)
public Node addChildNode(Node parent, String name, Long pos, String typeName, boolean complexProp)
SessionaddChildNode in interface Sessionparent - the parent to which the child is addedname - the child namepos - the child position, or nulltypeName - the child typecomplexProp - whether this is a complex property (true) or a regular child (false)public Node addChildNode(Serializable id, Node parent, String name, Long pos, String typeName, boolean complexProp)
SessionaddChildNode in interface Sessionid - the idparent - the parent to which the child is addedname - the child namepos - the child position, or nulltypeName - the child typecomplexProp - whether this is a complex property (true) or a regular child (false)protected Node addNode(Serializable id, Serializable parentId, String name, Long pos, String typeName, boolean complexProp)
public Node addProxy(Serializable targetId, Serializable versionableId, Node parent, String name, Long pos)
Sessionpublic void setProxyTarget(Node proxy, Serializable targetId)
SessionsetProxyTarget in interface Sessionproxy - the proxytargetId - the new target idpublic boolean hasChildNode(Node parent, String name, boolean complexProp)
Session
There are two kinds of children, the regular children documents and the complex properties. The boolean
allows a choice between those.
hasChildNode in interface Sessionparent - the parent nodename - the child namecomplexProp - whether to check complex properties or regular childrentrue if a child node with that name existspublic Node getChildNode(Node parent, String name, boolean complexProp)
SessiongetChildNode in interface Sessionparent - the parent nodename - the child namecomplexProp - whether to check complex properties or regular childrennull is not foundpublic boolean hasChildren(Node parent, boolean complexProp)
SessionhasChildren in interface Sessionparent - the parent nodecomplexProp - whether to check complex properties or regular childrentrue if the parent has childrenpublic List<Node> getChildren(Node parent, String name, boolean complexProp)
SessiongetChildren in interface Sessionparent - the parent nodename - the children name to get (for lists of complex properties), or null for allcomplexProp - whether to check complex properties or regular childrenpublic void orderBefore(Node parent, Node source, Node dest)
Sessionnull, the source node will be appended at the end of the children
list.orderBefore in interface Sessionparent - the parent nodesource - the child node to movedest - the child node before which to place the source node, or null to move at the endpublic Node move(Node source, Node parent, String name)
Session
A Session.save() is automatically done first.
public Node copy(Node source, Node parent, String name)
Session
A Session.save() is automatically done first.
public void removeNode(Node node)
Session
This is much more complex that removing a property node ( Session.removePropertyNode(org.nuxeo.ecm.core.storage.sql.Node)).
removeNode in interface Sessionnode - the node to remove#removePropertyNode}public void removePropertyNode(Node node)
Session
This is much less complex that removing a generic document node ( Session.removeNode(org.nuxeo.ecm.core.storage.sql.Node)).
removePropertyNode in interface Sessionnode - the property node to remove#removeNode}public Node checkIn(Node node, String label, String checkinComment)
Session
A Session.save() is automatically done first.
public void checkOut(Node node)
Sessionpublic void restore(Node node, Node version)
SessionThe restored node is checked in.
public Node getVersionByLabel(Serializable versionSeriesId, String label)
SessiongetVersionByLabel in interface SessionversionSeriesId - the version series idlabel - the labelnull if not foundpublic Node getLastVersion(Serializable versionSeriesId)
Session
A Session.save() is automatically done first.
getLastVersion in interface SessionversionSeriesId - the version series idnull if no versions existpublic List<Node> getVersions(Serializable versionSeriesId)
Session
A Session.save() is automatically done first.
getVersions in interface SessionversionSeriesId - the version series idpublic List<Node> getProxies(Node document, Node parent)
SessionIf 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.
getProxies in interface Sessiondocument - the documentparent - the parent, or nullprotected List<Node> getNodes(List<Serializable> ids)
public List<Node> getProxies(Node document)
SessiongetProxies in interface Sessiondocument - the documentprotected List<Fragment> getHierarchyAndAncestors(Collection<Serializable> ids)
ids - the fragment idspublic PartialList<Serializable> query(String query, QueryFilter queryFilter, boolean countTotal)
Sessionpublic PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Sessionquery in interface Sessionquery - the queryqueryType - the query typequeryFilter - the query filtercountUpTo - if -1, also count the total size without offset/limit.0, don't count the total size.n, count the total number if there are less than n documents otherwise set the size to
-1.public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params)
SessionqueryAndFetch in interface Sessionquery - the queryqueryType - the query typequeryFilter - the query filterparams - optional query-type-dependent parameterspublic IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params)
SessionqueryAndFetch in interface Sessionquery - the queryqueryType - the query typequeryFilter - the query filterdistinctDocuments - if true then a maximum of one row per document will be returnedparams - optional query-type-dependent parameterspublic PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params)
SessionqueryProjection in interface Sessionquery - the queryqueryType - the query typequeryFilter - the query filterdistinctDocuments - if true then a maximum of one row per document will be returnedcountUpTo - if -1, also count the total size without offset/limit.0, don't count the total size.n, count the total number if there are less than n documents otherwise set the size to
-1.params - optional query-type-dependent parameterspublic LockManager getLockManager()
SessiongetLockManager in interface Sessionpublic void requireReadAclsUpdate()
SessionThis method flag the current session, the read ACLs update will be done automatically at save time.
requireReadAclsUpdate in interface Sessionpublic void updateReadAcls()
SessionupdateReadAcls in interface Sessionpublic void rebuildReadAcls()
SessionrebuildReadAcls in interface Sessionpublic void checkPermission(String absPath, String actions)
public boolean hasPendingChanges()
public void markReferencedBinaries()
public int cleanupDeletedDocuments(int max, Calendar beforeTime)
public boolean isSameRM(XAResource xaresource)
isSameRM in interface XAResourcepublic void start(Xid xid, int flags) throws XAException
start in interface XAResourceXAExceptionpublic void end(Xid xid, int flags) throws XAException
end in interface XAResourceXAExceptionpublic int prepare(Xid xid) throws XAException
prepare in interface XAResourceXAExceptionpublic void commit(Xid xid, boolean onePhase) throws XAException
commit in interface XAResourceXAExceptionprotected void commitDone() throws XAException
XAExceptionpublic void rollback(Xid xid) throws XAException
rollback in interface XAResourceXAExceptionpublic void forget(Xid xid) throws XAException
forget in interface XAResourceXAExceptionpublic Xid[] recover(int flag) throws XAException
recover in interface XAResourceXAExceptionpublic boolean setTransactionTimeout(int seconds) throws XAException
setTransactionTimeout in interface XAResourceXAExceptionpublic int getTransactionTimeout() throws XAException
getTransactionTimeout in interface XAResourceXAExceptionpublic long getCacheSize()
public long getCacheMapperSize()
public long getCachePristineSize()
public long getCacheSelectionSize()
public Map<String,String> getBinaryFulltext(Serializable id)
SessiongetBinaryFulltext in interface Sessionpublic boolean isChangeTokenEnabled()
SessionisChangeTokenEnabled in interface Sessionpublic void markUserChange(Serializable id)
SessionThis causes an additional change token increment and check during save.
markUserChange in interface Sessionid - the document idCopyright © 2019 Nuxeo. All rights reserved.