Class SQLSession
- java.lang.Object
-
- org.nuxeo.ecm.core.model.BaseSession
-
- org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession
-
- All Implemented Interfaces:
Session<QueryFilter>
public class SQLSession extends BaseSession
This class is the bridge between the Nuxeo SPI Session and the actual low-level implementation of the SQL storage session.- Author:
- Florent Guillaume
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SQLSession.PathComparator
-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.model.BaseSession
BaseSession.VersionAclMode
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALLOW_NEGATIVE_ACL_PROPERTY
Framework property to control whether negative ACLs (deny) are allowed.static String
COPY_FINDFREENAME_DISABLED_PROP
Framework property to disabled free-name collision detection for copy.protected Log
log
protected static Pattern
ORDER_BY_PATH_ASC
protected static Pattern
ORDER_BY_PATH_DESC
-
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, USER_NAME
-
-
Constructor Summary
Constructors Constructor Description SQLSession(SessionImpl session, Repository repository)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static ACP
aclRowsToACP(ACLRow[] acls)
protected static ACLRow[]
acpToAclRows(ACP acp)
protected static void
addACLRow(List<ACLRow> aclrows, String name, ACE ace)
protected Document
addChild(Node parent, String name, Long pos, String typeName)
protected Node
addChildProperty(Node parent, String name, Long pos, String typeName)
protected boolean
addMixinType(Node node, String mixin)
protected Document
checkIn(Node node, String label, String checkinComment)
protected void
checkOut(Node node)
void
commit()
Commit the transaction.Document
copy(Document source, Document parent, String name)
Copies the source document to the given folder.Document
createProxy(Document doc, Document folder)
Creates a generic proxy to the given document inside the given folder.void
destroy()
Destroys this session.void
end()
Called just before the transaction is committed or rolled back.protected String
findFreeName(Node parentNode, String name)
protected static String
getACEkey(ACE ace)
Key to distinguish ACEsprotected static String
getACLrowKey(ACLRow aclrow)
Key to distinguish ACLRowsACP
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(Node node, String name)
protected Node
getChildProperty(Node node, String name, String typeName)
protected Node
getChildPropertyForWrite(Node node, String name, String typeName)
protected List<Document>
getChildren(Node node)
protected List<Node>
getComplexList(Node node, String name)
protected Document
getDocumentById(Serializable id)
Document
getDocumentByUUID(String uuid)
Gets a document given its ID.protected List<Document>
getDocumentsById(List<Serializable> ids)
Document
getLastVersion(String versionSeriesId)
LockManager
getLockManager()
Gets the lock manager for this session.protected Node
getNodeById(Serializable id)
Document
getNullDocument()
Gets the null document, to be used as a fake parent to add placeless children.protected Document
getParent(Node node)
protected String
getPath(Node node)
List<Document>
getProxies(Document doc)
Finds the proxies for a document.List<Document>
getProxies(Document document, Document parent)
Finds the proxies for a document.String
getRepositoryName()
Gets the repository that created this session.Document
getRootDocument()
Gets the root document in this repository.Document
getVersion(String versionableId, VersionModel versionModel)
Gets a version of a document, given its versionable id and label.protected Document
getVersionByLabel(String versionSeriesId, String label)
protected List<Document>
getVersions(String versionSeriesId)
protected boolean
hasChild(Node node, String name)
protected boolean
hasChildren(Node node)
protected Serializable
idFromString(String id)
protected String
idToString(Serializable id)
protected Document
importChild(String uuid, Node parent, String name, Long pos, String typeName, Map<String,Serializable> props)
Document
importDocument(String uuid, Document parent, String name, String typeName, Map<String,Serializable> properties)
Imports a document with a given id and parent.boolean
isChangeTokenEnabled()
boolean
isFulltextStoredInBlob()
Checks if fulltext extracted from the binary fields is internally stored as a blob.boolean
isNegativeAclAllowed()
Returnstrue
if negative ACLs are allowed.void
markUserChange(Serializable id)
Document
move(Document source, Document parent, String name)
Moves the source document to the given folder.protected void
notifyDocumentBlobManagerAfterCopy(Node node)
protected void
notifyDocumentBlobManagerBeforeRemove(Node node)
protected void
orderBefore(Node node, Node src, Node dest)
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
remove(Node node)
void
removeDocument(String id)
Removes a document.protected boolean
removeMixinType(Node node, String mixin)
protected void
removeProperty(Node node)
Document
resolvePath(String path)
Gets the document at the given path, if any.protected void
restore(Node node, Node 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 ACLRow[]
updateAclRows(ACLRow[] aclrows, ACP acp)
void
updateReadACLs(Collection<String> docIds)
Updates the Read ACLs for some documents.-
Methods inherited from class org.nuxeo.ecm.core.model.BaseSession
checkNegativeAcl, getACP, getDocumentBlobManager, getMergedACP, isReadVersionPermissionDisabled, notifyAfterCopy, updateACP
-
-
-
-
Field Detail
-
ALLOW_NEGATIVE_ACL_PROPERTY
public static final String ALLOW_NEGATIVE_ACL_PROPERTY
Framework property to control whether negative ACLs (deny) are allowed.- Since:
- 6.0
- See Also:
- Constant Field Values
-
COPY_FINDFREENAME_DISABLED_PROP
public static final String COPY_FINDFREENAME_DISABLED_PROP
Framework property to disabled free-name collision detection for copy. This is useful when constraints have been added to the database to detect collisions at the database level and raise a ConcurrentUpdateException, thus letting the high-level application deal with collisions.- Since:
- 7.3
- See Also:
- Constant Field Values
-
ORDER_BY_PATH_ASC
protected static final Pattern ORDER_BY_PATH_ASC
-
ORDER_BY_PATH_DESC
protected static final Pattern ORDER_BY_PATH_DESC
-
-
Constructor Detail
-
SQLSession
public SQLSession(SessionImpl session, Repository repository)
-
-
Method Detail
-
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
-
getRepositoryName
public String getRepositoryName()
Description copied from interface:Session
Gets the repository that created this session.- Returns:
- the repository
-
idToString
protected String idToString(Serializable id)
-
idFromString
protected Serializable idFromString(String id)
-
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.
-
getDocumentByUUID
public Document getDocumentByUUID(String uuid) throws DocumentNotFoundException
Description copied from interface:Session
Gets a document given its ID.- Parameters:
uuid
- the document id- Returns:
- the document
- Throws:
DocumentNotFoundException
- if the document doesn't exist
-
resolvePath
public Document resolvePath(String path) throws DocumentNotFoundException
Description copied from interface:Session
Gets the document at the given path, if any.- Throws:
DocumentNotFoundException
- if the document doesn't exist
-
orderBefore
protected void orderBefore(Node node, Node src, Node dest)
-
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
-
findFreeName
protected String findFreeName(Node parentNode, String name)
-
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.
-
notifyDocumentBlobManagerAfterCopy
protected void notifyDocumentBlobManagerAfterCopy(Node node)
-
getVersion
public Document getVersion(String versionableId, 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:
versionableId
- the versionable idversionModel
- the version model- Returns:
- the version, or
null
if not found
-
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
-
getProxies
public List<Document> getProxies(Document document, Document parent)
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:
document
- the document or versionparent
- 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 uuid, 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:
uuid
- 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
-
query
public PartialList<Document> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Description copied from interface:Session
Does a query.
-
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.
-
getDocumentById
protected Document getDocumentById(Serializable id)
-
getDocumentsById
protected List<Document> getDocumentsById(List<Serializable> ids)
-
getChild
protected Document getChild(Node node, String name) throws DocumentNotFoundException
- Throws:
DocumentNotFoundException
-
getChildProperty
protected Node getChildProperty(Node node, String name, String typeName)
-
getChildPropertyForWrite
protected Node getChildPropertyForWrite(Node node, String name, String typeName)
-
getChildren
protected List<Document> getChildren(Node node)
-
hasChildren
protected boolean hasChildren(Node node)
-
addChildProperty
protected Node addChildProperty(Node parent, String name, Long pos, String typeName)
-
importChild
protected Document importChild(String uuid, Node parent, String name, Long pos, String typeName, Map<String,Serializable> props)
-
addMixinType
protected boolean addMixinType(Node node, String mixin)
-
removeMixinType
protected boolean removeMixinType(Node node, String mixin)
-
getComplexList
protected List<Node> getComplexList(Node node, String name)
-
notifyDocumentBlobManagerBeforeRemove
protected void notifyDocumentBlobManagerBeforeRemove(Node node)
-
removeProperty
protected void removeProperty(Node node)
-
getVersionByLabel
protected Document getVersionByLabel(String versionSeriesId, String label)
-
getVersions
protected List<Document> getVersions(String versionSeriesId)
-
getLastVersion
public Document getLastVersion(String versionSeriesId)
-
getNodeById
protected Node getNodeById(Serializable id)
-
getLockManager
public LockManager getLockManager()
Description copied from interface:Session
Gets the lock manager for this session.- Returns:
- the lock manager
-
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
-
updateReadACLs
public void updateReadACLs(Collection<String> docIds)
Description copied from interface:Session
Updates the Read ACLs for some documents.- Parameters:
docIds
- the document ids
-
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
-
aclRowsToACP
protected static ACP aclRowsToACP(ACLRow[] acls)
-
acpToAclRows
protected static ACLRow[] acpToAclRows(ACP acp)
-
updateAclRows
protected static ACLRow[] updateAclRows(ACLRow[] aclrows, ACP acp)
-
getACLrowKey
protected static String getACLrowKey(ACLRow aclrow)
Key to distinguish ACLRows
-
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
-
isChangeTokenEnabled
public boolean isChangeTokenEnabled()
-
markUserChange
public void markUserChange(Serializable id)
-
end
public void end()
Description copied from interface:Session
Called just before the transaction is committed or rolled back.
-
-