public abstract class AbstractSession extends Object implements CoreSession, Serializable
This handles all the aspects that are independent on the final implementation (like running inside a J2EE platform or not).
The only aspect not implemented is the session management that should be handled by subclasses.
CoreSession.CopyOption
Modifier and Type | Field and Description |
---|---|
static NuxeoPrincipal |
ANONYMOUS |
static String |
BINARY_TEXT_SYS_PROP |
protected com.codahale.metrics.Counter |
createDocumentCount |
static String |
DEFAULT_MAX_RESULTS |
protected com.codahale.metrics.Counter |
deleteDocumentCount |
static String |
DISABLED_ISLATESTVERSION_PROPERTY |
protected static PathRef |
EMPTY_PATH |
static String |
LIMIT_RESULTS_PROPERTY |
static String |
MAX_RESULTS_PROPERTY |
protected com.codahale.metrics.MetricRegistry |
registry |
static String |
TRASH_KEEP_CHECKED_IN_PROPERTY |
protected com.codahale.metrics.Counter |
updateDocumentCount |
ALLOW_VERSION_WRITE, CHANGE_TOKEN, IMPORT_BASE_VERSION_ID, IMPORT_CHECKED_IN, IMPORT_IS_RETENTION_ACTIVE, IMPORT_IS_VERSION, IMPORT_LIFECYCLE_POLICY, IMPORT_LIFECYCLE_STATE, IMPORT_LOCK_CREATED, IMPORT_LOCK_OWNER, IMPORT_PROXY_TARGET_ID, IMPORT_PROXY_TYPE, IMPORT_PROXY_VERSIONABLE_ID, IMPORT_VERSION_CREATED, IMPORT_VERSION_DESCRIPTION, IMPORT_VERSION_IS_LATEST, IMPORT_VERSION_IS_LATEST_MAJOR, IMPORT_VERSION_LABEL, IMPORT_VERSION_MAJOR, IMPORT_VERSION_MINOR, IMPORT_VERSION_VERSIONABLE_ID, SKIP_DESTINATION_CHECK_ON_CREATE, SOURCE, USER_CHANGE
Constructor and Description |
---|
AbstractSession() |
Modifier and Type | Method and Description |
---|---|
<T extends DetachedAdapter> |
adaptFirstMatchingDocumentWithFacet(DocumentRef docRef,
String facet,
Class<T> adapterClass)
Find the first parent with the given
facet and adapt it on the adapterClass . |
void |
applyDefaultPermissions(String userOrGroupName)
Applies default Read permissions on root JCR Document for the given user or group name.
|
void |
cancel()
Cancels any pending change made through this session.
|
protected String |
canRemoveDocument(Document doc)
Checks if a document can be removed, and returns a failure reason if not.
|
boolean |
canRemoveDocument(DocumentRef docRef)
Check if a document can be removed.
|
DocumentRef |
checkIn(DocumentRef docRef,
VersioningOption option,
String checkinComment)
Checks in a modified document, creating a new version.
|
void |
checkOut(DocumentRef docRef)
Checks out a versioned document.
|
protected void |
checkPermission(Document doc,
String permission) |
protected long |
computeCountUpTo(boolean countTotal) |
protected String |
computeKeyForAtomicCreation(DocumentModel docModel) |
DocumentModel |
copy(DocumentRef src,
DocumentRef dst,
String name,
boolean resetLifeCycle)
Deprecated.
|
DocumentModel |
copy(DocumentRef src,
DocumentRef dst,
String name,
CoreSession.CopyOption... copyOptions)
Copies the source document to the destination folder under the given name.
|
List<DocumentModel> |
copy(List<DocumentRef> src,
DocumentRef dst,
boolean resetLifeCycle)
Deprecated.
|
List<DocumentModel> |
copy(List<DocumentRef> src,
DocumentRef dst,
CoreSession.CopyOption... opts)
Bulk copy.
|
DocumentModel |
copyProxyAsDocument(DocumentRef src,
DocumentRef dst,
String name,
boolean resetLifeCycle)
Deprecated.
|
DocumentModel |
copyProxyAsDocument(DocumentRef src,
DocumentRef dst,
String name,
CoreSession.CopyOption... copyOptions)
Work like copy but in the case of a source proxy the destination will be a new document instead of a proxy.
|
List<DocumentModel> |
copyProxyAsDocument(List<DocumentRef> src,
DocumentRef dst,
boolean resetLifeCycle)
Deprecated.
|
List<DocumentModel> |
copyProxyAsDocument(List<DocumentRef> src,
DocumentRef dst,
CoreSession.CopyOption... opts)
Bulk copyProxyAsDocument.
|
DocumentModel |
createDocument(DocumentModel docModel)
Creates a document using given document model for initialization.
|
DocumentModel[] |
createDocument(DocumentModel[] docModels)
Bulk creation of documents.
|
DocumentModel |
createDocumentModel(String typeName)
Creates a document model using type name.
|
DocumentModel |
createDocumentModel(String typeName,
Map<String,Object> options)
Creates a document model using required information.
|
DocumentModel |
createDocumentModel(String parentPath,
String name,
String typeName)
Creates a document model using required information.
|
protected void |
createMetrics() |
DocumentModel |
createProxy(DocumentRef docRef,
DocumentRef folderRef)
Creates a generic proxy to the given document inside the given folder.
|
protected DocumentModel |
createProxyInternal(Document doc,
Document folder,
Map<String,Serializable> options) |
boolean |
exists(DocumentRef docRef)
Tests if the document pointed by the given reference exists and is accessible.
|
protected Document |
fillCreateOptions(DocumentRef parentRef,
String childName,
Map<String,Serializable> options) |
Collection<String> |
filterGrantedPermissions(Principal principal,
DocumentRef docRef,
Collection<String> permissions)
Filters the supplied permissions based on whether they are granted to a given principal for a given document.
|
boolean |
followTransition(DocumentModel docModel,
String transition)
Follows a given life cycle transition.
|
boolean |
followTransition(DocumentRef docRef,
String transition)
Follows a given life cycle transition.
|
ACP |
getACP(DocumentRef docRef)
Gets the document access control policy.
|
Collection<String> |
getAllowedStateTransitions(DocumentRef docRef)
Gets the allowed state transitions for this document.
|
List<String> |
getAvailableSecurityPermissions()
Retrieves the available security permissions existing in the system.
|
DocumentRef |
getBaseVersion(DocumentRef docRef)
Gets the version to which a checked in document is linked.
|
Map<String,String> |
getBinaryFulltext(DocumentRef ref)
Gets the fulltext extracted from the binary fields.
|
String |
getChangeToken(DocumentRef ref)
Gets the current change token for the document.
|
DocumentModel |
getChild(DocumentRef parent,
String name)
Gets a child document given its name and the parent reference.
|
DocumentModelList |
getChildren(DocumentRef parent)
Gets the children of the given parent.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type)
Gets the children of the given parent filtered according to the given document type.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type,
Filter filter,
Sorter sorter)
Same as
CoreSession.getChildren(DocumentRef, String, String, Filter, Sorter) without specific permission filtering. |
DocumentModelList |
getChildren(DocumentRef parent,
String type,
String perm)
Gets the children of the given parent filtered according to the given document type and permission.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type,
String perm,
Filter filter,
Sorter sorter)
Same as
CoreSession.getChildren(DocumentRef, String, String) but the result is filtered and then sorted using the
specified filter and sorter. |
DocumentModelIterator |
getChildrenIterator(DocumentRef parent)
Gets an iterator to the children of the given parent.
|
DocumentModelIterator |
getChildrenIterator(DocumentRef parent,
String type)
Gets an iterator to the children of the given parent filtered according to the given document type.
|
DocumentModelIterator |
getChildrenIterator(DocumentRef parent,
String type,
String perm,
Filter filter)
Gets the children of the given parent filtered according to the given document type and permission.
|
List<DocumentRef> |
getChildrenRefs(DocumentRef parentRef,
String perm)
Gets the references of the children.
|
protected Map<String,Serializable> |
getContextMapEventInfo(DocumentModel doc) |
String |
getCurrentLifeCycleState(DocumentRef docRef)
Returns the life cycle of the document.
|
DataModel |
getDataModel(DocumentRef docRef,
Schema schema)
Retrieves a data model given a document reference and a schema.
|
protected Object |
getDataModelField(DocumentRef docRef,
String schema,
String field) |
Object[] |
getDataModelsField(DocumentRef[] docRefs,
String schema,
String field)
Retrieves the given field value from the given schema for all the given documents.
|
Object[] |
getDataModelsFieldUp(DocumentRef docRef,
String schema,
String field)
Retrieves the given field value from the given schema for the given document along with all its parent documents.
|
DocumentModel |
getDocument(DocumentRef docRef)
Gets a document model given its reference.
|
DocumentModelList |
getDocuments(DocumentRef[] docRefs)
Gets a list of documents given their references.
|
<T extends Serializable> |
getDocumentSystemProp(DocumentRef ref,
String systemProperty,
Class<T> type)
Gets system property of the specified type for the document ref.
|
DocumentType |
getDocumentType(String type)
Gets the document type object given its type name.
|
DocumentModel |
getDocumentWithVersion(DocumentRef docRef,
VersionModel version)
Returns a document that represents the specified version of the document.
|
DocumentModelList |
getFiles(DocumentRef parent)
Same as
CoreSession.getChildren(DocumentRef) but returns only non-folder documents. |
DocumentModelList |
getFiles(DocumentRef parent,
Filter filter,
Sorter sorter)
Same as
CoreSession.getFiles(org.nuxeo.ecm.core.api.DocumentRef) but uses an optional filter and sorter on the result. |
protected Document |
getFirstParentDocumentWithFacet(DocumentRef docRef,
String facet)
Returns the first
Document with the given facet , recursively going up the parent hierarchy. |
DocumentModelList |
getFolders(DocumentRef parent)
Same as
CoreSession.getChildren(DocumentRef) but returns only folder documents. |
DocumentModelList |
getFolders(DocumentRef parent,
Filter filter,
Sorter sorter)
Same as
CoreSession.getFolders(DocumentRef) but uses an optional filter and sorter on the result. |
DocumentModel |
getLastDocumentVersion(DocumentRef docRef)
Gets the document corresponding to the last version for the given document.
|
DocumentRef |
getLastDocumentVersionRef(DocumentRef docRef)
Gets the document reference corresponding to the last version for the given document.
|
String |
getLifeCyclePolicy(DocumentRef docRef)
Returns the life cycle policy of the document.
|
Lock |
getLockInfo(DocumentRef docRef)
Gets the lock info on the given document.
|
protected long |
getMaxResults() |
DocumentModel |
getOrCreateDocument(DocumentModel docModel)
Gets a document if it exists, otherwise creates it.
|
DocumentModel |
getOrCreateDocument(DocumentModel docModel,
Function<DocumentModel,DocumentModel> postCreate)
Gets a document if it exists, otherwise creates it.
|
DocumentModel |
getParentDocument(DocumentRef docRef)
Gets the parent document or null if this is the root document.
|
DocumentRef |
getParentDocumentRef(DocumentRef docRef)
Returns the parent ref of the document referenced by
docRef or null if this is the root document. |
DocumentRef[] |
getParentDocumentRefs(DocumentRef docRef)
Creates an array with all parent refs starting from the given document up to the root.
|
List<DocumentModel> |
getParentDocuments(DocumentRef docRef)
Gets the parent documents in path from the root to the given document or empty list if this is the root document.
|
String[] |
getPermissionsToCheck(String permission)
Provides the full list of all permissions or groups of permissions that contain the given one (inclusive).
|
protected Collection<SQLQuery.Transformer> |
getPoliciesQueryTransformers(String queryType) |
protected String[] |
getPrincipalsToCheck() |
DocumentModelList |
getProxies(DocumentRef docRef,
DocumentRef folderRef)
Finds the proxies for a document.
|
DocumentModel |
getRootDocument()
Gets the root document of this repository.
|
protected SecurityService |
getSecurityService() |
abstract Session |
getSession()
Internal method: Gets the current session based on the client session id.
|
DocumentModel |
getSourceDocument(DocumentRef docRef)
Gets the head (live) document for this document.
|
String |
getSuperParentType(DocumentModel doc)
Returns the type of his parent SuperSpace (workspace, section, etc.).
|
DocumentModel |
getSuperSpace(DocumentModel doc)
Returns the parent SuperSpace (workspace, section, etc.).
|
protected DocumentValidationService |
getValidationService() |
DocumentModel |
getVersion(String versionableId,
VersionModel versionModel)
Gets a document version, given the versionable id and label.
|
protected VersioningService |
getVersioningService() |
String |
getVersionLabel(DocumentModel docModel)
Gets the version label for a document, according to the versioning service.
|
protected VersionModel |
getVersionModel(Document version) |
List<DocumentModel> |
getVersions(DocumentRef docRef)
Retrieves all the versions for a specified document.
|
String |
getVersionSeriesId(DocumentRef docRef)
Gets the version series id for a document.
|
List<VersionModel> |
getVersionsForDocument(DocumentRef docRef)
Retrieves all the versions for a specified document.
|
List<DocumentRef> |
getVersionsRefs(DocumentRef docRef)
Gets the references of the versions of the document.
|
DocumentModel |
getWorkingCopy(DocumentRef docRef)
Gets the working copy (live document) for a proxy or a version.
|
boolean |
hasChild(DocumentRef parent,
String name)
Tests if the document has a child with the given name.
|
boolean |
hasChildren(DocumentRef docRef)
Tests if the document has any children.
|
boolean |
hasPermission(DocumentRef docRef,
String permission)
Checks if the principal that created the client session has the given privilege on the referred document.
|
protected boolean |
hasPermission(Document doc,
String permission) |
boolean |
hasPermission(Principal principal,
DocumentRef docRef,
String permission)
Checks if a given principal has the given privilege on the referred document.
|
protected boolean |
hasPermission(Principal principal,
Document doc,
String permission) |
protected void |
importDocument(DocumentModel docModel) |
void |
importDocuments(List<DocumentModel> docModels)
Low-level import of documents, reserved for the administrator.
|
protected boolean |
isAdministrator() |
boolean |
isCheckedOut(DocumentRef docRef)
Returns whether the current document is checked-out or not.
|
protected boolean |
isLimitedResults() |
boolean |
isNegativeAclAllowed()
Returns
true if negative ACLs are allowed. |
boolean |
isRetentionActive(DocumentRef docRef)
Checks whether a document is under active retention.
|
protected void |
loadDataModelsForFacet(DocumentModel docModel,
Document doc,
String facetName) |
DocumentModel |
move(DocumentRef src,
DocumentRef dst,
String name)
Moves the source document to the destination folder under the given name.
|
void |
move(List<DocumentRef> src,
DocumentRef dst)
Bulk move.
|
DocumentEventContext |
newEventContext(DocumentModel source) |
protected void |
notifyCheckedInVersion(DocumentModel docModel,
DocumentRef checkedInVersionRef,
Map<String,Serializable> options,
String checkinComment)
Send a core event for the creation of a new check in version.
|
protected void |
notifyEvent(String eventId,
DocumentModel source,
Map<String,Serializable> options,
String category,
String comment,
boolean withLifeCycle,
boolean inline) |
protected void |
notifyVersionChange(DocumentModel oldDocument,
DocumentModel newDocument,
Map<String,Serializable> options)
Copied from obsolete VersionChangeNotifier.
|
void |
orderBefore(DocumentRef parent,
String src,
String dest)
Given a parent document, order the source child before the destination child.
|
DocumentModel |
publishDocument(DocumentModel docToPublish,
DocumentModel section)
Publishes the document in a section overwriting any existing proxy to the same document.
|
DocumentModel |
publishDocument(DocumentModel docModel,
DocumentModel section,
boolean overwriteExistingProxy)
Publishes the document in a section.
|
DocumentModelList |
query(String query)
Executes the given NXQL query an returns the result.
|
DocumentModelList |
query(String query,
Filter filter)
Executes the given NXQL query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
Filter filter,
int max)
Executes the given NXQL query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
Filter filter,
long limit,
long offset,
boolean countTotal)
Executes the given NXQL query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
Filter filter,
long limit,
long offset,
long countUpTo)
Executes the given NXQL query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
int max)
Executes the given NXQL query an returns the result.
|
DocumentModelList |
query(String query,
String queryType,
Filter filter,
long limit,
long offset,
boolean countTotal)
Executes the given query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
String queryType,
Filter filter,
long limit,
long offset,
long countUpTo)
Executes the given query and returns the result that matches the filter.
|
IterableQueryResult |
queryAndFetch(String query,
String queryType,
boolean distinctDocuments,
Object... params)
Executes the given query and returns an iterable of maps containing the requested properties (which must be
closed when done).
|
IterableQueryResult |
queryAndFetch(String query,
String queryType,
Object... params)
Executes the given query and returns an iterable of maps containing the requested properties (which must be
closed when done).
|
PartialList<Map<String,Serializable>> |
queryProjection(String query,
long limit,
long offset)
Executes the given NXQL query and returns the result that matches the filter.
|
PartialList<Map<String,Serializable>> |
queryProjection(String query,
long limit,
long offset,
boolean countTotal)
Executes the given NXQL query and returns the result that matches the filter.
|
PartialList<Map<String,Serializable>> |
queryProjection(String query,
String queryType,
boolean distinctDocuments,
long limit,
long offset,
long countUpTo,
Object... params)
Executes the given NXQL query and returns the result that matches the filter.
|
protected DocumentModel |
readModel(Document doc)
Gets the document model for the given core document.
|
protected DocumentModel |
readModel(Document doc,
DocumentModel docModel)
Gets the document model for the given core document, preserving the contextData.
|
DocumentModel.DocumentModelRefresh |
refreshDocument(DocumentRef ref,
int refreshFlags,
String[] schemas)
Internal method - it is used internally by
DocumentModel.refresh() |
void |
reinitLifeCycleState(DocumentRef docRef)
Reinitializes the life cycle state of the document to its default state.
|
void |
removeChildren(DocumentRef docRef)
Removes all children from the given document.
|
protected void |
removeDocument(Document doc) |
void |
removeDocument(DocumentRef docRef)
Removes this document and all its children, if any.
|
void |
removeDocuments(DocumentRef[] docRefs)
Implementation uses the fact that the lexicographic ordering of paths is a refinement of the "contains" partial
ordering.
|
protected List<String> |
removeExistingProxies(Document doc,
Document folder)
Remove proxies for the same base document in the folder.
|
Lock |
removeLock(DocumentRef docRef)
Removes the lock on the given document.
|
protected void |
removeNotifyOneDoc(Document doc) |
void |
replaceACE(DocumentRef docRef,
String aclName,
ACE oldACE,
ACE newACE)
Replace the
oldACE with the newACE on the given aclName . |
protected Document |
resolveReference(DocumentRef docRef) |
protected DocumentModel |
restoreToVersion(Document doc,
Document version,
boolean skipSnapshotCreation,
boolean skipCheckout) |
DocumentModel |
restoreToVersion(DocumentRef docRef,
DocumentRef versionRef)
Restores the given document to the specified version.
|
DocumentModel |
restoreToVersion(DocumentRef docRef,
DocumentRef versionRef,
boolean skipSnapshotCreation,
boolean skipCheckout)
Restores the given document to the specified version.
|
void |
save()
Saves any pending changes done until now through this session.
|
DocumentModel |
saveDocument(DocumentModel docModel)
Saves changes done on the given document model.
|
void |
saveDocuments(DocumentModel[] docModels)
Bulk document saving.
|
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. |
protected void |
setACP(Document doc,
ACP newAcp,
boolean overwrite,
Map<String,Serializable> options) |
void |
setACP(DocumentRef docRef,
ACP newAcp,
boolean overwrite)
Sets the ACP for this document.
|
<T extends Serializable> |
setDocumentSystemProp(DocumentRef ref,
String systemProperty,
T value)
Sets given value as a system property.
|
protected void |
setLimitedResults(boolean limitedResults) |
Lock |
setLock(DocumentRef docRef)
Sets a lock on the given document.
|
protected void |
setMaxResults(long maxResults) |
void |
setRetentionActive(DocumentRef docRef,
boolean retentionActive)
Sets or unsets a document as under active retention.
|
protected DocumentModel |
updateExistingProxies(Document doc,
Document folder,
Document target)
Update the proxy for doc in the given section to point to the new target.
|
void |
updateReadACLs(Collection<String> docIds)
Updates the Read ACLs for some documents.
|
protected DocumentModel |
writeModel(Document doc,
DocumentModel docModel) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, destroy, getPrincipal, getRepositoryName, getSessionId, isLive, isStateSharedByAllThreadSessions
public static final NuxeoPrincipal ANONYMOUS
public static final String DEFAULT_MAX_RESULTS
public static final String MAX_RESULTS_PROPERTY
public static final String LIMIT_RESULTS_PROPERTY
public static final String TRASH_KEEP_CHECKED_IN_PROPERTY
public static final String DISABLED_ISLATESTVERSION_PROPERTY
public static final String BINARY_TEXT_SYS_PROP
protected final com.codahale.metrics.MetricRegistry registry
protected com.codahale.metrics.Counter createDocumentCount
protected com.codahale.metrics.Counter deleteDocumentCount
protected com.codahale.metrics.Counter updateDocumentCount
protected static final PathRef EMPTY_PATH
public AbstractSession()
protected void createMetrics()
protected SecurityService getSecurityService()
protected VersioningService getVersioningService()
protected DocumentValidationService getValidationService()
public abstract Session getSession()
public DocumentType getDocumentType(String type)
CoreSession
getDocumentType
in interface CoreSession
type
- the document type nameprotected final void checkPermission(Document doc, String permission) throws DocumentSecurityException
DocumentSecurityException
protected Map<String,Serializable> getContextMapEventInfo(DocumentModel doc)
public DocumentEventContext newEventContext(DocumentModel source)
protected void notifyEvent(String eventId, DocumentModel source, Map<String,Serializable> options, String category, String comment, boolean withLifeCycle, boolean inline)
protected void notifyVersionChange(DocumentModel oldDocument, DocumentModel newDocument, Map<String,Serializable> options)
Sends change notifications to core event listeners. The event contains info with older document (before version change) and newer doc (current document).
options
- additional info to pass to the eventpublic boolean hasPermission(Principal principal, DocumentRef docRef, String permission)
CoreSession
hasPermission
in interface CoreSession
protected final boolean hasPermission(Principal principal, Document doc, String permission)
public boolean hasPermission(DocumentRef docRef, String permission)
CoreSession
hasPermission
in interface CoreSession
public Collection<String> filterGrantedPermissions(Principal principal, DocumentRef docRef, Collection<String> permissions)
CoreSession
filterGrantedPermissions
in interface CoreSession
protected final boolean hasPermission(Document doc, String permission)
protected Document resolveReference(DocumentRef docRef)
protected DocumentModel readModel(Document doc)
doc
- the documentprotected DocumentModel readModel(Document doc, DocumentModel docModel)
doc
- the documentprotected DocumentModel writeModel(Document doc, DocumentModel docModel)
@Deprecated public DocumentModel copy(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)
CoreSession
If the destination document is not a folder or it doesn't exists then throws an exception.
If the source is a proxy the destination will be a copy of the proxy.
copy
in interface CoreSession
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be preservedresetLifeCycle
- the property that flagged whether reset destination document lifecycle or notpublic DocumentModel copy(DocumentRef src, DocumentRef dst, String name, CoreSession.CopyOption... copyOptions)
CoreSession
If the destination document is not a folder or it doesn't exists then throws an exception.
If the source is a proxy the destination will be a copy of the proxy.
copy
in interface CoreSession
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be preservedcopyOptions
- the options for copy@Deprecated public List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)
CoreSession
copy
in interface CoreSession
src
- the documents to copydst
- the destination folderresetLifeCycle
- the property that flagged whether reset destination document lifecycle or notpublic List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)
CoreSession
copy
in interface CoreSession
src
- the documents to copydst
- the destination folderopts
- the options for copy@Deprecated public DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)
CoreSession
copyProxyAsDocument
in interface CoreSession
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be preservedresetLifeCycle
- the property that flagged whether reset destination document lifecycle or notpublic DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, CoreSession.CopyOption... copyOptions)
CoreSession
copyProxyAsDocument
in interface CoreSession
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be preservedcopyOptions
- the options for copyCoreSession.copy(DocumentRef, DocumentRef, String, CopyOption...)
@Deprecated public List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)
CoreSession
copyProxyAsDocument
in interface CoreSession
src
- the documents to copydst
- the destination folderresetLifeCycle
- the property that flagged whether reset destination document lifecycle or notpublic List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)
CoreSession
copyProxyAsDocument
in interface CoreSession
src
- the documents to copydst
- the destination folderopts
- the options of copypublic DocumentModel move(DocumentRef src, DocumentRef dst, String name)
CoreSession
null
or if there
is a collision, a suitable new name is found.
If the destination document is not a folder or it doesn't exists then throws an exception.
move
in interface CoreSession
src
- the source document referencedst
- the destination folder referencename
- the new name of the file, or null
public void move(List<DocumentRef> src, DocumentRef dst)
CoreSession
move
in interface CoreSession
src
- the documents to movedst
- the destination folderpublic ACP getACP(DocumentRef docRef)
CoreSession
The returned ACP is the ACP defined on that document if any + the inherited ACL if any. If neither a local ACP nor inherited ACL exists null is returned.
Note that modifying the returned ACP will not affect in any way the stored document ACP. To modify the ACP you
must explicitely set it by calling CoreSession.setACP(DocumentRef, ACP, boolean)
This method will always fetch a fresh ACP from the storage. The recommended way to get the ACP is to use
DocumentModel.getACP()
this way the ACP will be cached at the document model level and so you can use it
for multiple permission checks without fetching it each time.
getACP
in interface CoreSession
docRef
- the doc ref to retrieve ACP or null if nonepublic void setACP(DocumentRef docRef, ACP newAcp, boolean overwrite)
CoreSession
If the ACP contains an INHERITED
ACL it will be discarded. Only ACLs relative to the current
document may be changed.
If the overwrite
argument is false, the ACP is merged with the existing one if any. The merge is
done as follow:
owners
are specified then they will replace the existing ones if any. Otherwise the old
owners are preserved if any. As for the ACL if you want to remove existing owners you need to specify an empty
owner array (and not a null one)
overwrite
argument is true, the old ACP will be replaced by the new one.
This way if you can remove the existing ACP by specifying a null ACP and overwrite
argument set to
true.
Setting a null ACP when overwrite
is false will do nothing.
setACP
in interface CoreSession
protected void setACP(Document doc, ACP newAcp, boolean overwrite, Map<String,Serializable> options)
public void replaceACE(DocumentRef docRef, String aclName, ACE oldACE, ACE newACE)
CoreSession
oldACE
with the newACE
on the given aclName
.
replaceACE
in interface CoreSession
public void updateReadACLs(Collection<String> docIds)
CoreSession
For INTERNAL use by the core.
updateReadACLs
in interface CoreSession
docIds
- the document idspublic boolean isNegativeAclAllowed()
CoreSession
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 CoreSession
true
if negative ACLs are allowedpublic void cancel()
CoreSession
cancel
in interface CoreSession
public DocumentModel createDocumentModel(String typeName)
CoreSession
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
createDocumentModel
in interface CoreSession
public DocumentModel createDocumentModel(String parentPath, String name, String typeName)
CoreSession
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
createDocumentModel
in interface CoreSession
parentPath
- the parent pathname
- The destination nametypeName
- the type namepublic DocumentModel createDocumentModel(String typeName, Map<String,Object> options)
CoreSession
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
createDocumentModel
in interface CoreSession
typeName
- the type nameoptions
- additional contextual data provided to core event listenerspublic DocumentModel createDocument(DocumentModel docModel)
CoreSession
The model contains path of the new document, its type and optionally the initial data models of the document.
createDocument
in interface CoreSession
docModel
- the document model to use for initializationprotected Document fillCreateOptions(DocumentRef parentRef, String childName, Map<String,Serializable> options) throws DocumentSecurityException
DocumentSecurityException
public void importDocuments(List<DocumentModel> docModels)
CoreSession
This method is used to import documents with given ids, or directly import versions and proxies.
The id, parent, name and typeName must be present in each docModel.
The context data needs to be filled with values depending on the type of the document:
For a proxy (type = "ecm:proxyType"
): CoreSession.IMPORT_PROXY_TARGET_ID
and
CoreSession.IMPORT_PROXY_VERSIONABLE_ID
.
For a version (no parent): CoreSession.IMPORT_VERSION_VERSIONABLE_ID
, CoreSession.IMPORT_VERSION_CREATED
,
CoreSession.IMPORT_VERSION_LABEL
and CoreSession.IMPORT_VERSION_DESCRIPTION
.
For a live document: CoreSession.IMPORT_BASE_VERSION_ID
and CoreSession.IMPORT_CHECKED_IN
(Boolean).
For a live document or a version: CoreSession.IMPORT_LIFECYCLE_POLICY
, CoreSession.IMPORT_LIFECYCLE_STATE
,
CoreSession.IMPORT_VERSION_MAJOR
(Long) and CoreSession.IMPORT_VERSION_MINOR
(Long).
importDocuments
in interface CoreSession
docModels
- the documents to createprotected void importDocument(DocumentModel docModel)
public DocumentModel[] createDocument(DocumentModel[] docModels)
CoreSession
createDocument
in interface CoreSession
docModels
- the document models to use for intializationpublic boolean exists(DocumentRef docRef)
CoreSession
This operation makes no difference between non-existence and permission problems.
If the parent is null or its path is null, then root is considered.
exists
in interface CoreSession
docRef
- the reference to the document to test for existencepublic DocumentModel getChild(DocumentRef parent, String name)
CoreSession
Throws an exception if the document could not be found.
If the supplied id is null, returns the default child of the document if any, otherwise raises an exception.
If the parent is null or its path is null, then root is considered.
getChild
in interface CoreSession
parent
- the reference to the parent documentname
- the name of the child document to retrievepublic boolean hasChild(DocumentRef parent, String name)
CoreSession
This operation silently ignores non-folder documents: If the document is not a folder then returns false.
hasChild
in interface CoreSession
parent
- the documentname
- the child nametrue
if the document has a child with the given namepublic DocumentModelList getChildren(DocumentRef parent)
CoreSession
getChildren
in interface CoreSession
parent
- the parent referencepublic DocumentModelList getChildren(DocumentRef parent, String type)
CoreSession
getChildren
in interface CoreSession
parent
- the parent referencetype
- the wanted document typepublic DocumentModelList getChildren(DocumentRef parent, String type, String perm)
CoreSession
getChildren
in interface CoreSession
parent
- the parent referencetype
- the wanted document typeperm
- the permission the user must havepublic DocumentModelList getChildren(DocumentRef parent, String type, Filter filter, Sorter sorter)
CoreSession
CoreSession.getChildren(DocumentRef, String, String, Filter, Sorter)
without specific permission filtering.getChildren
in interface CoreSession
parent
- the parent referencetype
- the wanted typefilter
- the filter to use if any, null otherwisesorter
- the sorter to use if any, null otherwisepublic DocumentModelList getChildren(DocumentRef parent, String type, String perm, Filter filter, Sorter sorter)
CoreSession
CoreSession.getChildren(DocumentRef, String, String)
but the result is filtered and then sorted using the
specified filter and sorter.getChildren
in interface CoreSession
parent
- the parent referencetype
- the wanted typeperm
- permission to check for. If null, defaults to READfilter
- the filter to use if any, null otherwisesorter
- the sorter to use if any, null otherwisepublic List<DocumentRef> getChildrenRefs(DocumentRef parentRef, String perm)
CoreSession
getChildrenRefs
in interface CoreSession
parentRef
- the parent referenceperm
- the permission to check on the children (usually READ); if null, no permission is checkedpublic DocumentModelIterator getChildrenIterator(DocumentRef parent)
CoreSession
getChildrenIterator
in interface CoreSession
parent
- the parent referencepublic DocumentModelIterator getChildrenIterator(DocumentRef parent, String type)
CoreSession
getChildrenIterator
in interface CoreSession
public DocumentModelIterator getChildrenIterator(DocumentRef parent, String type, String perm, Filter filter)
CoreSession
getChildrenIterator
in interface CoreSession
public DocumentModel getDocument(DocumentRef docRef)
CoreSession
The default schemas are used to populate the returned document model. Default schemas are configured via the document type manager.
Any other data model not part of the default schemas will be lazily loaded as needed.
getDocument
in interface CoreSession
docRef
- the document referencepublic DocumentModelList getDocuments(DocumentRef[] docRefs)
CoreSession
Documents that are not accessible are skipped.
getDocuments
in interface CoreSession
public DocumentModelList getFiles(DocumentRef parent)
CoreSession
CoreSession.getChildren(DocumentRef)
but returns only non-folder documents.getFiles
in interface CoreSession
parent
- the parent referencepublic DocumentModelList getFiles(DocumentRef parent, Filter filter, Sorter sorter)
CoreSession
CoreSession.getFiles(org.nuxeo.ecm.core.api.DocumentRef)
but uses an optional filter and sorter on the result.getFiles
in interface CoreSession
parent
- the parent referencefilter
- the filter to use or null if nonesorter
- the sorter to use or null if nonepublic DocumentModelList getFolders(DocumentRef parent)
CoreSession
CoreSession.getChildren(DocumentRef)
but returns only folder documents.getFolders
in interface CoreSession
parent
- the parent refpublic DocumentModelList getFolders(DocumentRef parent, Filter filter, Sorter sorter)
CoreSession
CoreSession.getFolders(DocumentRef)
but uses an optional filter and sorter on the result.getFolders
in interface CoreSession
parent
- the parent referencefilter
- the filter to use or null if nonesorter
- the sorter to use or null if nonepublic DocumentRef getParentDocumentRef(DocumentRef docRef)
CoreSession
docRef
or null
if this is the root document.
This method does not check the permissions on the parent document of this CoreSession
's Principal
.
getParentDocumentRef
in interface CoreSession
public DocumentModel getParentDocument(DocumentRef docRef)
CoreSession
getParentDocument
in interface CoreSession
public List<DocumentModel> getParentDocuments(DocumentRef docRef)
CoreSession
Documents the principal is is not allowed to browse are filtered out the parents list.
getParentDocuments
in interface CoreSession
public DocumentModel getRootDocument()
CoreSession
getRootDocument
in interface CoreSession
public boolean hasChildren(DocumentRef docRef)
CoreSession
This operation silently ignores non-folder documents: If the document is not a folder then returns false.
If the parent is null or its path is null, then root is considered.
hasChildren
in interface CoreSession
docRef
- the reference to the document to testpublic DocumentModelList query(String query)
CoreSession
query
in interface CoreSession
query
- the query to executepublic DocumentModelList query(String query, int max)
CoreSession
query
in interface CoreSession
query
- the query to executemax
- number of document to retrievepublic DocumentModelList query(String query, Filter filter)
CoreSession
query
in interface CoreSession
query
- the query to executefilter
- the filter to apply to resultpublic DocumentModelList query(String query, Filter filter, int max)
CoreSession
query
in interface CoreSession
query
- the query to executefilter
- the filter to apply to resultmax
- number of document to retrievepublic DocumentModelList query(String query, Filter filter, long limit, long offset, boolean countTotal)
CoreSession
query
in interface CoreSession
query
- the query to executefilter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountTotal
- if true
, return a DocumentModelList
that includes a total size of the
underlying list (size if there was no limit or offset)public DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, boolean countTotal)
CoreSession
query
in interface CoreSession
query
- the query to executequeryType
- the query type, like "NXQL"filter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountTotal
- if true
, return a DocumentModelList
that includes a total size of the
underlying list (size if there was no limit or offset)protected long computeCountUpTo(boolean countTotal)
countTotal
and configuration.protected long getMaxResults()
protected boolean isLimitedResults()
protected void setMaxResults(long maxResults)
protected void setLimitedResults(boolean limitedResults)
public DocumentModelList query(String query, Filter filter, long limit, long offset, long countUpTo)
CoreSession
query
in interface CoreSession
query
- the query to executefilter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountUpTo
- if -1
, 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 DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, long countUpTo)
CoreSession
query
in interface CoreSession
query
- the query to executequeryType
- the query type, like "NXQL"filter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountUpTo
- if -1
, return a DocumentModelList
that includes a total size of the underlying
list (size if there was no limit or offset). 0
, don't return the total size of the underlying list. n
, return the total size of the underlying list when the size is smaller than n
else return a total size of -1
.public IterableQueryResult queryAndFetch(String query, String queryType, Object... params)
CoreSession
queryAndFetch
in interface CoreSession
query
- the query to executequeryType
- the query type, usually "NXQL"params
- optional query-type-dependent parametersIterableQueryResult
, which must be closed after usepublic IterableQueryResult queryAndFetch(String query, String queryType, boolean distinctDocuments, Object... params)
CoreSession
It's possible to specify distinctDocuments = true
to get a maximum of one row of results per document,
this will behave differently only when the WHERE
clause contains wildcards.
queryAndFetch
in interface CoreSession
query
- the query to executequeryType
- the query type, usually "NXQL"distinctDocuments
- if true
then a maximum of one row per document will be returnedparams
- optional query-type-dependent parametersIterableQueryResult
, which must be closed after usepublic PartialList<Map<String,Serializable>> queryProjection(String query, long limit, long offset)
CoreSession
queryProjection
in interface CoreSession
query
- the query to executelimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentspublic PartialList<Map<String,Serializable>> queryProjection(String query, long limit, long offset, boolean countTotal)
CoreSession
queryProjection
in interface CoreSession
query
- the query to executelimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountTotal
- if true
, return a PartialList
that includes a total size of the underlying list
(size if there was no limit or offset)public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, boolean distinctDocuments, long limit, long offset, long countUpTo, Object... params)
CoreSession
queryProjection
in interface CoreSession
query
- the query to executequeryType
- the query type, like "NXQL"distinctDocuments
- if true
then a maximum of one row per document will be returnedlimit
- the maximum number of documents to retrieve, or 0 for all of themoffset
- the offset (starting at 0) into the list of documentscountUpTo
- if -1
, return a PartialList
that includes a total size of the underlying list
(size if there was no limit or offset). 0
, don't return the total size of the underlying list. n
, return the total size of the underlying list when the size is smaller than n
else return a total size of -1
.params
- optional query-type-dependent parametersprotected String[] getPrincipalsToCheck()
protected Collection<SQLQuery.Transformer> getPoliciesQueryTransformers(String queryType)
public ScrollResult<String> scroll(String query, int batchSize, int keepAliveSeconds)
CoreSession
keepAliveSeconds
delay.scroll
in interface CoreSession
query
- The NXQL query to executebatchSize
- The expected result batch size, note that more results can be returned when the backend don't
implement properly this featurekeepAliveSeconds
- The scroll context lifetime in secondsScrollResult
including the search results and a scroll id, to be passed to the subsequent calls
to CoreSession.scroll(String)
public ScrollResult<String> scroll(String scrollId)
CoreSession
scrollId
is part of the previous
ScrollResult
response.scroll
in interface CoreSession
public void removeChildren(DocumentRef docRef)
CoreSession
removeChildren
in interface CoreSession
docRef
- the reference to the document to removepublic boolean canRemoveDocument(DocumentRef docRef)
CoreSession
For an archived version to be removeable, it must not be referenced from any proxy or be the base of a working document, and the REMOVE permission must be available on the working document (or the user must be an administrator if no working document exists).
canRemoveDocument
in interface CoreSession
docRef
- the documentprotected String canRemoveDocument(Document doc)
public void removeDocument(DocumentRef docRef)
CoreSession
removeDocument
in interface CoreSession
docRef
- the reference to the document to removeprotected void removeDocument(Document doc)
protected void removeNotifyOneDoc(Document doc)
public void removeDocuments(DocumentRef[] docRefs)
removeDocuments
in interface CoreSession
docRefs
- the refs to the document to removepublic void save()
CoreSession
save
in interface CoreSession
public DocumentModel saveDocument(DocumentModel docModel)
CoreSession
saveDocument
in interface CoreSession
docModel
- the document model that needs modifiedpublic void saveDocuments(DocumentModel[] docModels)
CoreSession
saveDocuments
in interface CoreSession
docModels
- the document models that needs to be savedpublic DocumentModel getSourceDocument(DocumentRef docRef)
CoreSession
getSourceDocument
in interface CoreSession
docRef
- the reference to the documentprotected VersionModel getVersionModel(Document version)
public DocumentModel getLastDocumentVersion(DocumentRef docRef)
CoreSession
getLastDocumentVersion
in interface CoreSession
docRef
- the reference to the documentpublic DocumentRef getLastDocumentVersionRef(DocumentRef docRef)
CoreSession
getLastDocumentVersionRef
in interface CoreSession
docRef
- the reference to the documentpublic List<DocumentRef> getVersionsRefs(DocumentRef docRef)
CoreSession
getVersionsRefs
in interface CoreSession
docRef
- the reference to the documentpublic List<DocumentModel> getVersions(DocumentRef docRef)
CoreSession
getVersions
in interface CoreSession
docRef
- the reference to the documentDocumentModel
representing versions, empty list if none is found.public List<VersionModel> getVersionsForDocument(DocumentRef docRef)
CoreSession
getVersionsForDocument
in interface CoreSession
docRef
- the reference to the documentVersionModel
representing versions, empty list if none is found.public DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef)
CoreSession
restoreToVersion
in interface CoreSession
docRef
- the reference to the documentversionRef
- the reference to the versionpublic DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef, boolean skipSnapshotCreation, boolean skipCheckout)
CoreSession
restoreToVersion
in interface CoreSession
docRef
- the reference to the documentversionRef
- the reference to the versionskipSnapshotCreation
- true
if the document should not be snapshotted before being restoredskipCheckout
- true
if the restored document should be kept in a checked-in stateprotected DocumentModel restoreToVersion(Document doc, Document version, boolean skipSnapshotCreation, boolean skipCheckout)
public DocumentRef getBaseVersion(DocumentRef docRef)
CoreSession
Returns null
for a checked out document or a version or a proxy.
getBaseVersion
in interface CoreSession
null
public DocumentRef checkIn(DocumentRef docRef, VersioningOption option, String checkinComment)
CoreSession
checkIn
in interface CoreSession
docRef
- the reference to the documentoption
- whether to do create a new VersioningOption.MINOR
or VersioningOption.MAJOR
version
during check incheckinComment
- the checkin commentprotected void notifyCheckedInVersion(DocumentModel docModel, DocumentRef checkedInVersionRef, Map<String,Serializable> options, String checkinComment)
docModel
- work document that has been checked-in as a versioncheckedInVersionRef
- document ref of the new checked-in versionoptions
- initial option map, or nullpublic void checkOut(DocumentRef docRef)
CoreSession
checkOut
in interface CoreSession
docRef
- the reference to the documentpublic boolean isCheckedOut(DocumentRef docRef)
CoreSession
isCheckedOut
in interface CoreSession
docRef
- the reference to the documentpublic String getVersionSeriesId(DocumentRef docRef)
CoreSession
All documents and versions derived by a check in or checkout from the same original document share the same version series id.
getVersionSeriesId
in interface CoreSession
docRef
- the document referencepublic DocumentModel getWorkingCopy(DocumentRef docRef)
CoreSession
getWorkingCopy
in interface CoreSession
docRef
- the document referencenull
if not foundpublic DocumentModel getVersion(String versionableId, VersionModel versionModel)
CoreSession
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 CoreSession
versionableId
- the versionable idversionModel
- the version model holding the labelnull
if not foundpublic String getVersionLabel(DocumentModel docModel)
CoreSession
getVersionLabel
in interface CoreSession
docModel
- the documentpublic DocumentModel getDocumentWithVersion(DocumentRef docRef, VersionModel version)
CoreSession
getDocumentWithVersion
in interface CoreSession
docRef
- the reference to the documentversion
- the version for which we want the corresponding documentpublic DocumentModel createProxy(DocumentRef docRef, DocumentRef folderRef)
CoreSession
The document may be a version, or a working copy (live document) in which case the proxy will be a "shortcut".
createProxy
in interface CoreSession
protected DocumentModel createProxyInternal(Document doc, Document folder, Map<String,Serializable> options)
protected List<String> removeExistingProxies(Document doc, Document folder)
protected DocumentModel updateExistingProxies(Document doc, Document folder, Document target)
null
if none or several were foundpublic DocumentModelList getProxies(DocumentRef docRef, DocumentRef folderRef)
CoreSession
If the document is a version, then only proxies to that version will be looked up.
If the document is a proxy, then all similar proxies (pointing to any version of the same versionable) are retrieved.
getProxies
in interface CoreSession
docRef
- the target document for the proxiesfolderRef
- the folder where proxies are located or null
public List<String> getAvailableSecurityPermissions()
CoreSession
getAvailableSecurityPermissions
in interface CoreSession
public DataModel getDataModel(DocumentRef docRef, Schema schema)
CoreSession
For INTERNAL use by the core.
getDataModel
in interface CoreSession
protected Object getDataModelField(DocumentRef docRef, String schema, String field)
public boolean isRetentionActive(DocumentRef docRef)
CoreSession
isRetentionActive
in interface CoreSession
docRef
- the document referencetrue
if the document is under active retentionpublic void setRetentionActive(DocumentRef docRef, boolean retentionActive)
CoreSession
setRetentionActive
in interface CoreSession
docRef
- the document referenceretentionActive
- whether the retention should be set or unset as activepublic String getCurrentLifeCycleState(DocumentRef docRef)
CoreSession
getCurrentLifeCycleState
in interface CoreSession
docRef
- the document referenceorg.nuxeo.ecm.core.lifecycle
public String getLifeCyclePolicy(DocumentRef docRef)
CoreSession
getLifeCyclePolicy
in interface CoreSession
docRef
- the document referenceorg.nuxeo.ecm.core.lifecycle
public boolean followTransition(DocumentModel docModel, String transition) throws LifeCycleException
CoreSession
This will update the current life cycle of the document.
followTransition
in interface CoreSession
docModel
- the document modeltransition
- the name of the transition to followLifeCycleException
- if the transition cannot be followedpublic boolean followTransition(DocumentRef docRef, String transition) throws LifeCycleException
CoreSession
This will update the current life cycle of the document.
followTransition
in interface CoreSession
docRef
- the document referencetransition
- the name of the transition to followLifeCycleException
- if the transition cannot be followedpublic Collection<String> getAllowedStateTransitions(DocumentRef docRef)
CoreSession
getAllowedStateTransitions
in interface CoreSession
docRef
- the document referencepublic void reinitLifeCycleState(DocumentRef docRef)
CoreSession
reinitLifeCycleState
in interface CoreSession
docRef
- the documentpublic Object[] getDataModelsField(DocumentRef[] docRefs, String schema, String field)
CoreSession
getDataModelsField
in interface CoreSession
docRefs
- the document referencesschema
- the schemafield
- the field namepublic DocumentRef[] getParentDocumentRefs(DocumentRef docRef)
CoreSession
getParentDocumentRefs
in interface CoreSession
public Object[] getDataModelsFieldUp(DocumentRef docRef, String schema, String field)
CoreSession
getDataModelsFieldUp
in interface CoreSession
docRef
- the document referenceschema
- the schemafield
- the field namepublic Lock setLock(DocumentRef docRef) throws LockException
CoreSession
setLock
in interface CoreSession
docRef
- the document referenceLockException
- if the document is already lockedpublic Lock getLockInfo(DocumentRef docRef)
CoreSession
Lock info is never cached, and needs to use a separate transaction in a separate thread, so care should be taken to not call this method needlessly.
getLockInfo
in interface CoreSession
docRef
- the document referencenull
otherwisepublic Lock removeLock(DocumentRef docRef) throws LockException
CoreSession
The caller principal should be the same as the one who set the lock or to belongs to the administrator group, otherwise an exception will be throw.
If the document was not locked, does nothing.
Returns the previous lock info.
removeLock
in interface CoreSession
docRef
- the document to unlocknull
if there was no lockLockException
- if the document is locked by someone elseprotected boolean isAdministrator()
public void applyDefaultPermissions(String userOrGroupName)
CoreSession
Usage: As an administrator, you may want to add new users or groups. This method needs to be called to grand default reading permissions on the root document of the repository for the newly created users/groups.
applyDefaultPermissions
in interface CoreSession
public DocumentModel publishDocument(DocumentModel docToPublish, DocumentModel section)
CoreSession
publishDocument
in interface CoreSession
public DocumentModel publishDocument(DocumentModel docModel, DocumentModel section, boolean overwriteExistingProxy)
CoreSession
publishDocument
in interface CoreSession
public String getSuperParentType(DocumentModel doc)
CoreSession
getSuperParentType
in interface CoreSession
public DocumentModel getSuperSpace(DocumentModel doc)
CoreSession
getSuperSpace
in interface CoreSession
public <T extends Serializable> T getDocumentSystemProp(DocumentRef ref, String systemProperty, Class<T> type)
CoreSession
getDocumentSystemProp
in interface CoreSession
public <T extends Serializable> void setDocumentSystemProp(DocumentRef ref, String systemProperty, T value)
CoreSession
setDocumentSystemProp
in interface CoreSession
public String getChangeToken(DocumentRef ref)
CoreSession
The change token is an opaque string which is modified every time the document is changed.
Before saving a document through CoreSession.saveDocument(org.nuxeo.ecm.core.api.DocumentModel)
it's possible to pass an expected change token
in the document context data through doc.putContextData(CoreSession.CHANGE_TOKEN, expectedChangeToken)
.
If the change token does not match the stored one, it means that a concurrent update happened, and a
ConcurrentUpdateException
will be thrown.
getChangeToken
in interface CoreSession
ref
- the document referenceDocumentModel.putContextData(org.nuxeo.common.collections.ScopeType, java.lang.String, java.io.Serializable)
,
CoreSession.CHANGE_TOKEN
,
CoreSession.getChangeToken(org.nuxeo.ecm.core.api.DocumentRef)
public void orderBefore(DocumentRef parent, String src, String dest)
CoreSession
docModel.getName()
) To place the source document at the end of the children list use a null
destination node.orderBefore
in interface CoreSession
parent
- the parent documentsrc
- the document to be moved (ordered)dest
- the document before which the reordered document will be placed If null the source document will be
placed at the end of the children listpublic DocumentModel.DocumentModelRefresh refreshDocument(DocumentRef ref, int refreshFlags, String[] schemas)
CoreSession
DocumentModel.refresh()
Get fresh data from a document given a description of what kind of data should be refetched.
The refresh information is specified using a bit mask. See DocumentModel
for all accepted flags.
When the flag DocumentModel.REFRESH_CONTENT_IF_LOADED
is specified a third argument must be passed
representing the schema names for document parts to refresh. This argument is ignored if the flag is not
specified or no schema names are provided
refreshDocument
in interface CoreSession
ref
- the document referencerefreshFlags
- refresh flags as defined in DocumentModel
schemas
- the schema names if a partial content refresh is requiredpublic String[] getPermissionsToCheck(String permission)
CoreSession
SecurityService.getPermissionsToCheck(java.lang.String)
available remote.getPermissionsToCheck
in interface CoreSession
public <T extends DetachedAdapter> T adaptFirstMatchingDocumentWithFacet(DocumentRef docRef, String facet, Class<T> adapterClass)
CoreSession
facet
and adapt it on the adapterClass
.
This method does not check the permissions on the document to be adapted of this CoreSession
's
Principal
, and so the adapter must not need other schemas from the DocumentModel
except the
schemas related to the given facet.
adaptFirstMatchingDocumentWithFacet
in interface CoreSession
facet
adapted, or null
if no parent found or the document
does not support the given adapterClass
.protected void loadDataModelsForFacet(DocumentModel docModel, Document doc, String facetName)
protected Document getFirstParentDocumentWithFacet(DocumentRef docRef, String facet)
Document
with the given facet
, recursively going up the parent hierarchy.
Returns null
if there is no more parent.
This method does not check security rights.
public Map<String,String> getBinaryFulltext(DocumentRef ref)
CoreSession
getBinaryFulltext
in interface CoreSession
ref
- the document referencenull
if not supported.public DocumentModel getOrCreateDocument(DocumentModel docModel)
CoreSession
WARNING: As the current transaction is impacted, using this method instead of
CoreSession.createDocument(DocumentModel)
could lead to inconsistent behaviour in case of rollback.
getOrCreateDocument
in interface CoreSession
docModel
- the document modelpublic DocumentModel getOrCreateDocument(DocumentModel docModel, Function<DocumentModel,DocumentModel> postCreate)
CoreSession
WARNING: As the current transaction is impacted, using this method instead of
CoreSession.createDocument(DocumentModel)
could lead to inconsistent behaviour in case of rollback.
getOrCreateDocument
in interface CoreSession
docModel
- the document modelpostCreate
- the function to apply after creating the documentprotected String computeKeyForAtomicCreation(DocumentModel docModel)
Copyright © 2018 Nuxeo. All rights reserved.