public class SessionImpl extends Object implements Session, XAResource
Session.PathResolver
Modifier and Type | Field and Description |
---|---|
PersistenceContext |
context |
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
Constructor and Description |
---|
SessionImpl(RepositoryImpl repository,
Model model,
Mapper mapper,
Credentials credentials) |
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).
|
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.
|
void |
checkOut(Node node)
Checks out a checked-in node.
|
void |
checkPermission(String absPath,
String actions) |
void |
close() |
void |
commit(Xid xid,
boolean onePhase) |
Node |
copy(Node source,
Node parent,
String name)
Copies a node to a new location with a new name.
|
Interaction |
createInteraction() |
void |
end(Xid xid,
int flags) |
void |
forget(Xid xid) |
Binary |
getBinary(InputStream in)
Creates a binary value given an input stream.
|
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.
|
Node |
getLastVersion(Serializable versionSeriesId)
Gets the last version for a given version series id.
|
LocalTransaction |
getLocalTransaction() |
Lock |
getLock(Serializable id)
Gets the lock state of a document.
|
Mapper |
getMapper()
Gets the low-level Mapper for this session.
|
ConnectionMetaData |
getMetaData() |
Model |
getModel()
Gets the
Model associated to this session. |
Node |
getNodeById(Serializable id)
Gets a node given its id.
|
Node |
getNodeByPath(String path,
Node node)
Gets a node given its absolute path, or given an existing node and a
relative path.
|
List<Node> |
getNodesByIds(List<Serializable> ids)
Gets several nodes given their ids.
|
List<Node> |
getNodesByIds(List<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,
Node parent)
Finds the proxies for a document.
|
String |
getRepositoryName()
Gets the session repository name.
|
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 |
isLive()
Checks if the session is live (not closed).
|
boolean |
isSameRM(XAResource xaresource) |
void |
markReferencedBinaries(BinaryGarbageCollector gc) |
Node |
move(Node source,
Node parent,
String name)
Moves a node to a new location with a new name.
|
void |
orderBefore(Node parent,
Node source,
Node dest)
Order the given source child node before the destination child node.
|
int |
prepare(Xid xid) |
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,
boolean countTotal)
Makes a query to the database.
|
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).
|
void |
rebuildReadAcls()
Rebuild the read ACLs for the whole repository.
|
Xid[] |
recover(int flag) |
Lock |
removeLock(Serializable id,
String owner,
boolean force)
Removes a lock from a document.
|
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.
|
void |
rollback(Xid xid) |
void |
save()
Saves the modifications to persistent storage.
|
Lock |
setLock(Serializable id,
Lock lock)
Sets a lock on a document.
|
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 final PersistenceContext context
public SessionImpl(RepositoryImpl repository, Model model, Mapper mapper, Credentials credentials) throws StorageException
StorageException
public Mapper getMapper()
Session
public XAResource getXAResource()
public void close() throws ResourceException
close
in interface Connection
ResourceException
public Interaction createInteraction() throws ResourceException
createInteraction
in interface Connection
ResourceException
public LocalTransaction getLocalTransaction() throws ResourceException
getLocalTransaction
in interface Connection
ResourceException
public ConnectionMetaData getMetaData() throws ResourceException
getMetaData
in interface Connection
ResourceException
public ResultSetInfo getResultSetInfo() throws ResourceException
getResultSetInfo
in interface Connection
ResourceException
public boolean isLive()
Session
public String getRepositoryName()
Session
getRepositoryName
in interface Session
public Model getModel()
Session
Model
associated to this session.public Node getRootNode()
Session
getRootNode
in interface Session
public Binary getBinary(InputStream in) throws StorageException
Session
getBinary
in interface Session
in
- the input streamStorageException
public void save() throws StorageException
Session
Modifications will be actually written only upon transaction commit.
save
in interface Session
StorageException
public Node getNodeById(Serializable id) throws StorageException
Session
getNodeById
in interface Session
id
- the idnull
if not foundStorageException
public List<Node> getNodesByIds(List<Serializable> ids, boolean prefetch) throws StorageException
StorageException
public List<Node> getNodesByIds(List<Serializable> ids) throws StorageException
Session
getNodesByIds
in interface Session
ids
- the idsnull
if not foundStorageException
public Node getParentNode(Node node) throws StorageException
Session
The root has a null
parent.
getParentNode
in interface Session
node
- the nodenull
for the root's parentStorageException
public String getPath(Node node) throws StorageException
Session
getPath
in interface Session
node
- the nodeStorageException
public Node getNodeByPath(String path, Node node) throws StorageException
Session
getNodeByPath
in interface Session
path
- the pathnode
- the node (ignored for absolute paths)null
if not foundStorageException
public Node addChildNode(Node parent, String name, Long pos, String typeName, boolean complexProp) throws StorageException
Session
addChildNode
in interface Session
parent
- the parent to which the child is addedname
- the child namepos
- the child position, or null
typeName
- the child typecomplexProp
- whether this is a complex property (true
) or a
regular child (false
)StorageException
public Node addChildNode(Serializable id, Node parent, String name, Long pos, String typeName, boolean complexProp) throws StorageException
Session
addChildNode
in interface Session
id
- the idparent
- the parent to which the child is addedname
- the child namepos
- the child position, or null
typeName
- the child typecomplexProp
- whether this is a complex property (true
) or a
regular child (false
)StorageException
public Node addProxy(Serializable targetId, Serializable versionableId, Node parent, String name, Long pos) throws StorageException
Session
addProxy
in interface Session
targetId
- the target idversionableId
- the version series idparent
- the parent to which the proxy is addedname
- the proxy namepos
- the proxy positionStorageException
public void setProxyTarget(Node proxy, Serializable targetId) throws StorageException
Session
setProxyTarget
in interface Session
proxy
- the proxytargetId
- the new target idStorageException
public boolean hasChildNode(Node parent, String name, boolean complexProp) throws StorageException
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 Session
parent
- the parent nodename
- the child namecomplexProp
- whether to check complex properties or regular
childrentrue
if a child node with that name existsStorageException
public Node getChildNode(Node parent, String name, boolean complexProp) throws StorageException
Session
getChildNode
in interface Session
parent
- the parent nodename
- the child namecomplexProp
- whether to check complex properties or regular
childrennull
is not foundStorageException
public boolean hasChildren(Node parent, boolean complexProp) throws StorageException
Session
hasChildren
in interface Session
parent
- the parent nodecomplexProp
- whether to check complex properties or regular
childrentrue
if the parent has childrenStorageException
public List<Node> getChildren(Node parent, String name, boolean complexProp) throws StorageException
Session
getChildren
in interface Session
parent
- the parent nodename
- the children name to get (for lists of complex properties),
or null
for allcomplexProp
- whether to check complex properties or regular
childrenStorageException
public void orderBefore(Node parent, Node source, Node dest) throws StorageException
Session
null
, the source node will be appended at the end of the children
list.orderBefore
in interface Session
parent
- the parent nodesource
- the child node to movedest
- the child node before which to place the source node, or
null
to move at the endStorageException
public Node move(Node source, Node parent, String name) throws StorageException
Session
A Session.save()
is automatically done first.
move
in interface Session
source
- the node to moveparent
- the new parent to which the node is movedname
- the new node nameStorageException
public Node copy(Node source, Node parent, String name) throws StorageException
Session
A Session.save()
is automatically done first.
copy
in interface Session
source
- the node to copyparent
- the new parent to which the node is copiedname
- the new node nameStorageException
public void removeNode(Node node) throws StorageException
Session
This is much more complex that removing a property node (
Session.removePropertyNode(org.nuxeo.ecm.core.storage.sql.Node)
).
removeNode
in interface Session
node
- the node to removeStorageException
#removePropertyNode}
public void removePropertyNode(Node node) throws StorageException
Session
This is much less complex that removing a generic document node (
Session.removeNode(org.nuxeo.ecm.core.storage.sql.Node)
).
removePropertyNode
in interface Session
node
- the property node to removeStorageException
#removeNode}
public Node checkIn(Node node, String label, String checkinComment) throws StorageException
Session
A Session.save()
is automatically done first.
checkIn
in interface Session
node
- the node to check inlabel
- the label for the versioncheckinComment
- the description for the versionStorageException
public void checkOut(Node node) throws StorageException
Session
checkOut
in interface Session
node
- the node to check outStorageException
public void restore(Node node, Node version) throws StorageException
Session
The restored node is checked in.
restore
in interface Session
node
- the node to restoreversion
- the version to restore fromStorageException
public Node getVersionByLabel(Serializable versionSeriesId, String label) throws StorageException
Session
getVersionByLabel
in interface Session
versionSeriesId
- the version series idlabel
- the labelnull
if not foundStorageException
public Node getLastVersion(Serializable versionSeriesId) throws StorageException
Session
A Session.save()
is automatically done first.
getLastVersion
in interface Session
versionSeriesId
- the version series idnull
if no versions existStorageException
public List<Node> getVersions(Serializable versionSeriesId) throws StorageException
Session
A Session.save()
is automatically done first.
getVersions
in interface Session
versionSeriesId
- the version series idStorageException
public List<Node> getProxies(Node document, Node parent) throws StorageException
Session
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.
getProxies
in interface Session
document
- the documentparent
- the parent, or null
StorageException
public PartialList<Serializable> query(String query, QueryFilter queryFilter, boolean countTotal) throws StorageException
Session
query
in interface Session
query
- the queryqueryFilter
- the query filtercountTotal
- if true
, also count the total size without
offset/limitStorageException
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, boolean countTotal) throws StorageException
Session
query
in interface Session
query
- the queryqueryFilter
- the query filtercountTotal
- if true
, also count the total size without
offset/limitStorageException
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params) throws StorageException
Session
queryAndFetch
in interface Session
query
- the queryqueryType
- the query typequeryFilter
- the query filterparams
- optional query-type-dependent parametersStorageException
public Lock getLock(Serializable id) throws StorageException
Session
If the document does not exist, null
is returned.
getLock
in interface Session
id
- the document idnull
when there is no lockStorageException
public Lock setLock(Serializable id, Lock lock) throws StorageException
Session
If the document is already locked, returns its existing lock status
(there is no re-locking, Session.removeLock(java.io.Serializable, java.lang.String, boolean)
must be called first).
setLock
in interface Session
id
- the document idlock
- the lock object to setnull
if locking succeeded, or the existing lock if
locking failedStorageException
public Lock removeLock(Serializable id, String owner, boolean force) throws StorageException
Session
The previous lock is returned.
If owner
is null
then the lock is unconditionally
removed.
If owner
is not null
, it must match the existing lock
owner for the lock to be removed. If it doesn't match, the returned lock
will return true
for Lock.getFailed()
.
removeLock
in interface Session
id
- the document idforce
- true
to just do the remove and not return the
previous lockStorageException
public void requireReadAclsUpdate()
Session
This method flag the current session, the read ACLs update will be done automatically at save time.
requireReadAclsUpdate
in interface Session
public void updateReadAcls() throws StorageException
Session
updateReadAcls
in interface Session
StorageException
public void rebuildReadAcls() throws StorageException
Session
rebuildReadAcls
in interface Session
StorageException
public void checkPermission(String absPath, String actions) throws StorageException
StorageException
public boolean hasPendingChanges() throws StorageException
StorageException
public void markReferencedBinaries(BinaryGarbageCollector gc)
public boolean isSameRM(XAResource xaresource)
isSameRM
in interface XAResource
public void start(Xid xid, int flags) throws XAException
start
in interface XAResource
XAException
public void end(Xid xid, int flags) throws XAException
end
in interface XAResource
XAException
public int prepare(Xid xid) throws XAException
prepare
in interface XAResource
XAException
public void commit(Xid xid, boolean onePhase) throws XAException
commit
in interface XAResource
XAException
public void rollback(Xid xid) throws XAException
rollback
in interface XAResource
XAException
public void forget(Xid xid) throws XAException
forget
in interface XAResource
XAException
public Xid[] recover(int flag) throws XAException
recover
in interface XAResource
XAException
public boolean setTransactionTimeout(int seconds) throws XAException
setTransactionTimeout
in interface XAResource
XAException
public int getTransactionTimeout() throws XAException
getTransactionTimeout
in interface XAResource
XAException
Copyright © 2011 Nuxeo SA. All Rights Reserved.