public class ConnectionImpl extends Object implements Session
ConnectionFactory
to application
code.
The actual link to the underlying storage (Session
) is provided by the
ManagedConnection
which created this Connection
.
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionImpl.QueryResultContextException |
Session.PathResolver
Modifier and Type | Field and Description |
---|---|
protected Throwable |
closeTrace |
protected Set<ConnectionImpl.QueryResultContextException> |
queryResults |
Constructor and Description |
---|
ConnectionImpl(ManagedConnectionImpl managedConnection) |
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.
|
Node |
addProxy(Serializable targetId,
Serializable versionSeriesId,
Node parent,
String name,
Long pos)
Creates a proxy for a version node.
|
protected void |
associate(SessionImpl session)
|
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 |
close() |
protected void |
closeStillOpenQueryResults() |
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 |
disassociate()
|
Map<String,String> |
getBinaryFulltext(Serializable id)
Gets the fulltext extracted from the binary fields.
|
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.
|
javax.resource.cci.LocalTransaction |
getLocalTransaction() |
LockManager |
getLockManager()
Gets the lock manager for this session.
|
protected ManagedConnectionImpl |
getManagedConnection()
|
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.
|
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.
|
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.
|
javax.resource.cci.ResultSetInfo |
getResultSetInfo() |
Node |
getRootNode()
Gets the root node of the repository.
|
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.
|
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 |
isLive()
Checks if the session is live (not closed).
|
boolean |
isStateSharedByAllThreadSessions()
Returns
true if all sessions in the current thread share the same state. |
Node |
move(Node source,
Node parent,
String name)
Moves a node to a new location with a new name.
|
protected void |
noteQueryResult(IterableQueryResult result) |
void |
orderBefore(Node node,
Node src,
Node dest)
Order the given source child node before the destination child node.
|
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,
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.
|
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.
|
void |
save()
Saves the modifications to persistent storage.
|
protected void |
setManagedConnection(ManagedConnectionImpl managedConnection)
|
void |
setProxyTarget(Node proxy,
Serializable targetId)
Sets a proxies' target.
|
void |
updateReadAcls()
Update only the read ACLs that have changed.
|
protected Throwable closeTrace
protected final Set<ConnectionImpl.QueryResultContextException> queryResults
public ConnectionImpl(ManagedConnectionImpl managedConnection)
protected ManagedConnectionImpl getManagedConnection()
protected void setManagedConnection(ManagedConnectionImpl managedConnection)
protected void associate(SessionImpl session)
protected void disassociate()
public void close() throws javax.resource.ResourceException
close
in interface javax.resource.cci.Connection
javax.resource.ResourceException
public javax.resource.cci.Interaction createInteraction() throws javax.resource.ResourceException
createInteraction
in interface javax.resource.cci.Connection
javax.resource.ResourceException
public javax.resource.cci.LocalTransaction getLocalTransaction() throws javax.resource.ResourceException
getLocalTransaction
in interface javax.resource.cci.Connection
javax.resource.ResourceException
public javax.resource.cci.ConnectionMetaData getMetaData() throws javax.resource.ResourceException
getMetaData
in interface javax.resource.cci.Connection
javax.resource.ResourceException
public javax.resource.cci.ResultSetInfo getResultSetInfo() throws javax.resource.ResourceException
getResultSetInfo
in interface javax.resource.cci.Connection
javax.resource.ResourceException
public Mapper getMapper()
Session
public boolean isLive()
Session
public boolean isStateSharedByAllThreadSessions()
Session
true
if all sessions in the current thread share the same state.isStateSharedByAllThreadSessions
in interface Session
public String getRepositoryName()
Session
getRepositoryName
in interface Session
public Model getModel()
Session
Model
associated to this session.public void save()
Session
Modifications will be actually written only upon transaction commit.
public Node getRootNode()
Session
getRootNode
in interface Session
public Node getNodeById(Serializable id)
Session
getNodeById
in interface Session
id
- the idnull
if not foundpublic List<Node> getNodesByIds(List<Serializable> ids)
Session
getNodesByIds
in interface Session
ids
- the idsnull
if not foundpublic Node getNodeByPath(String path, Node node)
Session
getNodeByPath
in interface Session
path
- the pathnode
- the node (ignored for absolute paths)null
if not foundpublic boolean addMixinType(Node node, String mixin)
Session
Does nothing if the mixin was already present on the node.
addMixinType
in interface Session
node
- the nodemixin
- the mixin nametrue
if the mixin was added, or false
if it is already presentpublic boolean removeMixinType(Node node, String mixin)
Session
It's not possible to remove a mixin coming from the primary type.
removeMixinType
in interface Session
node
- 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 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 Session
parent
- 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)
Session
getChildNode
in interface Session
parent
- the parent nodename
- the child namecomplexProp
- whether to check complex properties or regular childrennull
is not foundpublic boolean hasChildren(Node parent, boolean complexProp)
Session
hasChildren
in interface Session
parent
- 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)
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 childrenpublic Node addChildNode(Node parent, String name, Long pos, String typeName, boolean complexProp)
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
)public Node addChildNode(Serializable id, Node parent, String name, Long pos, String typeName, boolean complexProp)
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
)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 Session
node
- 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 Session
node
- the property node to remove#removeNode}
public Node getParentNode(Node node)
Session
The root has a null
parent.
getParentNode
in interface Session
node
- the nodenull
for the root's parentpublic String getPath(Node node)
Session
public void orderBefore(Node node, Node src, Node dest)
Session
null
, the source node will be appended at the end of the children
list.orderBefore
in interface Session
node
- the parent nodesrc
- 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 Node checkIn(Node node, String label, String checkinComment)
Session
A Session.save()
is automatically done first.
public void checkOut(Node node)
Session
public void restore(Node node, Node version)
Session
The restored node is checked in.
public Node getVersionByLabel(Serializable versionSeriesId, String label)
Session
getVersionByLabel
in interface Session
versionSeriesId
- the version series idlabel
- the labelnull
if not foundpublic List<Node> getVersions(Serializable versionSeriesId)
Session
A Session.save()
is automatically done first.
getVersions
in interface Session
versionSeriesId
- the version series idpublic Node getLastVersion(Serializable versionSeriesId)
Session
A Session.save()
is automatically done first.
getLastVersion
in interface Session
versionSeriesId
- the version series idnull
if no versions existpublic List<Node> getProxies(Node document, Node parent)
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
public void setProxyTarget(Node proxy, Serializable targetId)
Session
setProxyTarget
in interface Session
proxy
- the proxytargetId
- the new target idpublic Node addProxy(Serializable targetId, Serializable versionSeriesId, Node parent, String name, Long pos)
Session
public PartialList<Serializable> query(String query, QueryFilter queryFilter, boolean countTotal)
Session
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Session
query
in interface Session
query
- the queryqueryFilter
- 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)
Session
queryAndFetch
in interface Session
query
- the queryqueryType
- the query typequeryFilter
- the query filterparams
- optional query-type-dependent parametersprotected void noteQueryResult(IterableQueryResult result)
protected void closeStillOpenQueryResults()
public LockManager getLockManager()
Session
getLockManager
in interface Session
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()
Session
updateReadAcls
in interface Session
public void rebuildReadAcls()
Session
rebuildReadAcls
in interface Session
public Map<String,String> getBinaryFulltext(Serializable id)
Session
getBinaryFulltext
in interface Session
Copyright © 2015 Nuxeo SA. All rights reserved.