public class DBSSession extends Object implements Session
Session
for Document-Based Storage.Modifier and Type | Class and Description |
---|---|
protected static class |
DBSSession.DBSQueryResult |
static class |
DBSSession.OrderByComparator |
Modifier and Type | Field and Description |
---|---|
protected boolean |
changeTokenEnabled |
protected boolean |
closed |
protected static Pattern |
dotDigitsPattern |
protected boolean |
fulltextSearchDisabled |
protected boolean |
isLatestVersionDisabled |
protected static Set<String> |
KEYS_RETENTION_ACTIVE_AND_PROXIES |
protected com.codahale.metrics.MetricRegistry |
registry |
protected DBSRepository |
repository |
protected static Type |
STRING_ARRAY_TYPE |
protected DBSTransactionState |
transaction |
Constructor and Description |
---|
DBSSession(DBSRepository repository) |
Modifier and Type | Method and Description |
---|---|
protected static Serializable |
acpToMem(ACP acp) |
protected void |
addBackProxyId(DBSDocumentState docState,
String id) |
protected DBSDocumentState |
addProxyState(String id,
String parentId,
String name,
Long pos,
String targetId,
String versionSeriesId) |
void |
begin() |
protected Document |
checkIn(String id,
String label,
String checkinComment) |
protected void |
checkNegativeAcl(ACP acp) |
protected void |
checkNotUnder(String parentId,
String id,
String op)
Checks that we don't move/copy under ourselves.
|
protected void |
checkOut(String id) |
void |
close()
Closes this session.
|
void |
commit() |
static String |
convToInternal(String name) |
static String |
convToInternalAce(String name) |
static String |
convToNXQL(String name) |
Document |
copy(Document source,
Document parent,
String name)
Copies the source document to the given folder.
|
protected String |
copy(String sourceId,
String parentId,
List<String> ancestorIds,
String name)
Copy source under parent, and set its ancestors.
|
protected String |
copyRecurse(String sourceId,
String parentId,
LinkedList<String> ancestorIds,
String name) |
Document |
createChild(String id,
String parentId,
String name,
Long pos,
String typeName) |
protected DBSDocumentState |
createChildState(String id,
String parentId,
String name,
Long pos,
String typeName) |
Document |
createProxy(Document doc,
Document folder)
Creates a generic proxy to the given document inside the given folder.
|
protected void |
doOrderBy(List<Map<String,Serializable>> projections,
OrderByClause orderByClause) |
protected PartialList<String> |
doQuery(String query,
String queryType,
QueryFilter queryFilter,
int countUpTo) |
protected PartialList<Map<String,Serializable>> |
doQueryAndFetch(String query,
String queryType,
QueryFilter queryFilter,
boolean distinctDocuments,
int countUpTo,
org.apache.commons.lang3.mutable.Mutable<String> idKeyHolder) |
protected String |
findFreeName(Document parent,
String name) |
protected ACP |
getACP(Document doc) |
Map<String,String> |
getBinaryFulltext(String id)
Gets the fulltext extracted from the binary fields.
|
protected BlobManager |
getBlobManager() |
protected Document |
getChild(String parentId,
String name) |
protected List<Document> |
getChildren(String parentId) |
protected List<String> |
getChildrenIds(String parentId) |
protected DBSDocument |
getDocument(DBSDocumentState docState) |
protected DBSDocument |
getDocument(DBSDocumentState docState,
boolean readonly) |
protected DBSDocument |
getDocument(String id) |
Document |
getDocumentByUUID(String id)
Gets a document given its ID.
|
protected String |
getDocumentIdByPath(String path) |
protected List<Document> |
getDocuments(List<String> ids) |
protected ACL |
getInheritedACLs(Document doc) |
protected Document |
getLastVersion(String versionSeriesId) |
LockManager |
getLockManager()
Gets the lock manager for this session.
|
ACP |
getMergedACP(Document doc) |
protected Long |
getNextPos(String parentId) |
Document |
getNullDocument()
Gets the null document, to be used as a fake parent to add placeless children.
|
protected String |
getPath(Map<String,Serializable> projection) |
List<Document> |
getProxies(Document doc,
Document folder)
Finds the proxies for a document.
|
String |
getRepositoryName()
Gets the repository that created this session.
|
Document |
getRootDocument()
Gets the root document in this repository.
|
protected String |
getRootId() |
static Type |
getType(String name) |
Document |
getVersion(String versionSeriesId,
VersionModel versionModel)
Gets a version of a document, given its versionable id and label.
|
protected DBSDocumentState |
getVersionByLabel(String versionSeriesId,
String label) |
protected List<String> |
getVersionsIds(String versionSeriesId) |
protected boolean |
hasChild(String parentId,
String name) |
protected boolean |
hasChildren(String parentId) |
Document |
importDocument(String id,
Document parent,
String name,
String typeName,
Map<String,Serializable> properties)
Imports a document with a given id and parent.
|
boolean |
isLive()
Checks whether the session is alive.
|
boolean |
isNegativeAclAllowed()
Returns
true if negative ACLs are allowed. |
protected boolean |
isOrderable(String id) |
protected boolean |
isOrderByPath(OrderByClause orderByClause)
Does an ORDER BY clause include ecm:path
|
protected boolean |
keepWhenRestore(String key) |
void |
markUserChange(String id)
Marks this document id as belonging to a user change.
|
protected static ACP |
memToAcp(Serializable acpSer) |
Document |
move(Document source,
Document parent,
String name)
Moves the source document to the given folder.
|
protected String |
normalize(String path) |
protected void |
orderBefore(String parentId,
String sourceId,
String destId) |
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 |
recomputeVersionSeries(String versionSeriesId)
Recomputes isLatest / isLatestMajor on all versions.
|
protected void |
remove(String rootId)
Removes a document.
|
protected void |
removeBackProxyId(DBSDocumentState docState,
String id) |
protected void |
removeBackProxyIds(DBSDocumentState docState,
Set<String> ids) |
Document |
resolvePath(String path)
Gets the document at the given path, if any.
|
protected void |
restoreVersion(Document doc,
Document version) |
void |
rollback() |
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.
|
void |
setACP(Document doc,
ACP acp,
boolean overwrite) |
void |
setProxyTarget(Document proxy,
Document target)
Sets a proxies' target.
|
protected static Boolean |
trueOrNull(Object value) |
protected static ACP |
updateACP(ACP curAcp,
ACP addAcp)
Returns the merge of two ACPs.
|
void |
updateReadACLs(Collection<String> docIds)
Updates the Read ACLs for some documents.
|
protected static final Set<String> KEYS_RETENTION_ACTIVE_AND_PROXIES
protected final DBSRepository repository
protected final DBSTransactionState transaction
protected final boolean fulltextSearchDisabled
protected final boolean changeTokenEnabled
protected boolean closed
protected final com.codahale.metrics.MetricRegistry registry
protected boolean isLatestVersionDisabled
protected static final Pattern dotDigitsPattern
protected static final Type STRING_ARRAY_TYPE
public DBSSession(DBSRepository repository)
public String getRepositoryName()
Session
getRepositoryName
in interface Session
public void close()
Session
public boolean isLive()
Session
public void begin()
public void commit()
public void rollback()
protected BlobManager getBlobManager()
public Document resolvePath(String path)
Session
resolvePath
in interface Session
protected String getDocumentIdByPath(String path)
protected List<Document> getChildren(String parentId)
protected List<String> getChildrenIds(String parentId)
protected boolean hasChildren(String parentId)
public Document getDocumentByUUID(String id)
Session
getDocumentByUUID
in interface Session
id
- the document idpublic Document getRootDocument()
Session
getRootDocument
in interface Session
public Document getNullDocument()
Session
getNullDocument
in interface Session
protected DBSDocument getDocument(String id)
protected List<Document> getDocuments(List<String> ids)
protected DBSDocument getDocument(DBSDocumentState docState)
protected DBSDocument getDocument(DBSDocumentState docState, boolean readonly)
public Document createChild(String id, String parentId, String name, Long pos, String typeName)
protected DBSDocumentState createChildState(String id, String parentId, String name, Long pos, String typeName)
protected boolean isOrderable(String id)
protected Long getNextPos(String parentId)
protected void orderBefore(String parentId, String sourceId, String destId)
protected void recomputeVersionSeries(String versionSeriesId)
protected void restoreVersion(Document doc, Document version)
protected boolean keepWhenRestore(String key)
public Document copy(Document source, Document parent, String name)
Session
If the destination document is not a folder, an exception is thrown.
protected String copyRecurse(String sourceId, String parentId, LinkedList<String> ancestorIds, String name)
protected String copy(String sourceId, String parentId, List<String> ancestorIds, String name)
protected String findFreeName(Document parent, String name)
protected void checkNotUnder(String parentId, String id, String op)
public Document move(Document source, Document parent, String name)
Session
If the destination document is not a folder an exception is thrown.
protected void remove(String rootId)
We also have to update everything impacted by "relations":
public Document createProxy(Document doc, Document folder)
Session
createProxy
in interface Session
doc
- the documentfolder
- the folderprotected DBSDocumentState addProxyState(String id, String parentId, String name, Long pos, String targetId, String versionSeriesId)
protected void addBackProxyId(DBSDocumentState docState, String id)
protected void removeBackProxyId(DBSDocumentState docState, String id)
protected void removeBackProxyIds(DBSDocumentState docState, Set<String> ids)
public List<Document> getProxies(Document doc, Document folder)
Session
If the document is a version, then only proxies to that version will be looked up.
getProxies
in interface Session
doc
- the document or versionfolder
- the folder, or nullpublic void setProxyTarget(Document proxy, Document target)
Session
The target must have the same version series as the proxy.
setProxyTarget
in interface Session
proxy
- the proxytarget
- the new targetpublic Document importDocument(String id, Document parent, String name, String typeName, Map<String,Serializable> properties)
Session
The document can then be filled with the normal imported properties.
importDocument
in interface Session
id
- the document uuidparent
- the document parent, or null
for a versionname
- the document name in its parenttypeName
- the document type, or ecm: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 various IMPORT_*
constants of CoreSession
)Document
, even for proxies and versionsprotected static Boolean trueOrNull(Object value)
public Document getVersion(String versionSeriesId, VersionModel versionModel)
Session
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.
getVersion
in interface Session
versionSeriesId
- the versionable idversionModel
- the version modelnull
if not foundprotected DBSDocumentState getVersionByLabel(String versionSeriesId, String label)
protected List<String> getVersionsIds(String versionSeriesId)
protected Document getLastVersion(String versionSeriesId)
public void updateReadACLs(Collection<String> docIds)
Session
updateReadACLs
in interface Session
docIds
- the document idspublic boolean isNegativeAclAllowed()
Session
true
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.
isNegativeAclAllowed
in interface Session
true
if negative ACLs are allowedpublic ACP getMergedACP(Document doc)
getMergedACP
in interface Session
protected ACL getInheritedACLs(Document doc)
protected void checkNegativeAcl(ACP acp)
protected static Serializable acpToMem(ACP acp)
protected static ACP memToAcp(Serializable acpSer)
public Map<String,String> getBinaryFulltext(String id)
Session
getBinaryFulltext
in interface Session
public PartialList<Document> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Session
protected PartialList<String> doQuery(String query, String queryType, QueryFilter queryFilter, int countUpTo)
protected PartialList<Map<String,Serializable>> doQueryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, int countUpTo, org.apache.commons.lang3.mutable.Mutable<String> idKeyHolder)
protected boolean isOrderByPath(OrderByClause orderByClause)
protected String getPath(Map<String,Serializable> projection)
protected void doOrderBy(List<Map<String,Serializable>> projections, OrderByClause orderByClause)
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params)
Session
queryAndFetch
in interface Session
public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object[] params)
Session
queryProjection
in interface Session
public ScrollResult<String> scroll(String query, int batchSize, int keepAliveSeconds)
Session
public ScrollResult<String> scroll(String scrollId)
Session
public static String convToInternal(String name)
public static String convToInternalAce(String name)
public static String convToNXQL(String name)
public LockManager getLockManager()
Session
getLockManager
in interface Session
public void markUserChange(String id)
Copyright © 2018 Nuxeo. All rights reserved.