Class AbstractSession
- java.lang.Object
-
- org.nuxeo.ecm.core.api.AbstractSession
-
- All Implemented Interfaces:
Serializable,CoreSession
- Direct Known Subclasses:
LocalSession
public abstract class AbstractSession extends Object implements CoreSession, Serializable
Abstract implementation of the client interface.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.
- Author:
- Bogdan Stefanescu, Florent Guillaume
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.api.CoreSession
CoreSession.CopyOption
-
-
Field Summary
Fields Modifier and Type Field Description static StringBINARY_TEXT_SYS_PROPstatic StringBLOCKED_PERMISSION_QUERYprotected static Map<String,io.dropwizard.metrics5.Counter>CREATE_DOC_COUNTprotected io.dropwizard.metrics5.CountercreateDocumentCountstatic StringDEFAULT_MAX_RESULTSprotected static Map<String,io.dropwizard.metrics5.Counter>DELETE_DOC_COUNTprotected io.dropwizard.metrics5.CounterdeleteDocumentCountstatic StringDISABLED_ISLATESTVERSION_PROPERTYprotected static PathRefEMPTY_PATHstatic StringFIND_PROXIES_QUERYstatic StringFIND_VERSIONS_QUERYstatic StringLEGAL_HOLD_QUERYstatic StringLIMIT_RESULTS_PROPERTYstatic StringMAX_RESULTS_PROPERTYprotected static io.dropwizard.metrics5.MetricRegistryregistrystatic StringRESTRICT_PROXY_CREATION_PROPERTYstatic StringRETENTION_QUERYstatic StringTRASH_KEEP_CHECKED_IN_PROPERTYDeprecated.since 10.1, new trash behavior is: always keep checkedIn stateprotected static Map<String,io.dropwizard.metrics5.Counter>UPDATE_DOC_COUNTprotected io.dropwizard.metrics5.CounterupdateDocumentCount-
Fields inherited from interface org.nuxeo.ecm.core.api.CoreSession
ALLOW_VERSION_WRITE, BINARY_FULLTEXT_MAIN_KEY, CHANGE_TOKEN, DISABLE_AUDIT_LOGGER, IMPORT_BASE_VERSION_ID, IMPORT_CHECKED_IN, IMPORT_HAS_LEGAL_HOLD, IMPORT_IS_RECORD, 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_RETAIN_UNTIL, 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, RETAIN_UNTIL_INDETERMINATE, RETAIN_UNTIL_INDETERMINATE_ISO, SKIP_DESTINATION_CHECK_ON_CREATE, SOURCE, USER_CHANGE
-
-
Constructor Summary
Constructors Constructor Description AbstractSession()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T extends DetachedAdapter>
TadaptFirstMatchingDocumentWithFacet(DocumentRef docRef, String facet, Class<T> adapterClass)Find the first parent with the givenfacetand adapt it on theadapterClass.voidapplyDefaultPermissions(String userOrGroupName)Applies default Read permissions on root JCR Document for the given user or group name.voidcancel()Cancels any pending change made through this session.booleancanRemoveDocument(DocumentRef docRef)Check if a document can be removed.protected StringcanRemoveDocument(Document doc)Deprecated.since 2023, better usecheckCanRemoveDocument(Document)protected voidcheckBlockedDescendants(Document doc)protected voidcheckCanRemoveDocument(Document doc)DocumentRefcheckIn(DocumentRef docRef, VersioningOption option, String checkinComment)Checks in a modified document, creating a new version.voidcheckOut(DocumentRef docRef)Checks out a versioned document.protected voidcheckPermission(Document doc, String permission)protected voidcheckRetainedDescendants(Document doc)protected longcomputeCountUpTo(boolean countTotal)protected StringcomputeKeyForAtomicCreation(DocumentModel docModel)List<DocumentModel>copy(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)Deprecated.List<DocumentModel>copy(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)Bulk copy.DocumentModelcopy(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)Deprecated.DocumentModelcopy(DocumentRef src, DocumentRef dst, String name, CoreSession.CopyOption... copyOptions)Copies the source document to the destination folder under the given name.List<DocumentModel>copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)Deprecated.List<DocumentModel>copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)Bulk copyProxyAsDocument.DocumentModelcopyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)Deprecated.DocumentModelcopyProxyAsDocument(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.DocumentModelcreateDocument(DocumentModel docModel)Creates a document using given document model for initialization.DocumentModel[]createDocument(DocumentModel[] docModels)Bulk creation of documents.protected voidcreateDocumentCountInc()DocumentModelcreateDocumentModel(String typeName)Creates a document model using type name.DocumentModelcreateDocumentModel(String parentPath, String name, String typeName)Creates a document model using required information.DocumentModelcreateDocumentModel(String typeName, Map<String,Object> options)Creates a document model using required information.DocumentModelcreateProxy(DocumentRef docRef, DocumentRef folderRef)Creates a generic proxy to the given document inside the given folder.protected DocumentModelcreateProxyInternal(Document doc, Document folder, Map<String,Serializable> options)protected voiddeleteDocumentCountInc()booleanexists(DocumentRef docRef)Tests if the document pointed by the given reference exists and is accessible.protected DocumentfillCreateOptions(DocumentRef parentRef, String childName, Map<String,Serializable> options)Collection<String>filterGrantedPermissions(NuxeoPrincipal principal, DocumentRef docRef, Collection<String> permissions)Filters the supplied permissions based on whether they are granted to a given principal for a given document.booleanfollowTransition(DocumentModel docModel, String transition)Follows a given life cycle transition.booleanfollowTransition(DocumentRef docRef, String transition)Follows a given life cycle transition.ACPgetACP(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.DocumentRefgetBaseVersion(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.StringgetChangeToken(DocumentRef ref)Gets the current change token for the document.DocumentModelgetChild(DocumentRef parent, String name)Gets a child document given its name and the parent reference.DocumentModelListgetChildren(DocumentRef parent)Gets the children of the given parent.DocumentModelListgetChildren(DocumentRef parent, String type)Gets the children of the given parent filtered according to the given document type.DocumentModelListgetChildren(DocumentRef parent, String type, String perm)Gets the children of the given parent filtered according to the given document type and permission.DocumentModelListgetChildren(DocumentRef parent, String type, String perm, Filter filter, Sorter sorter)Same asCoreSession.getChildren(DocumentRef, String, String)but the result is filtered and then sorted using the specified filter and sorter.DocumentModelListgetChildren(DocumentRef parent, String type, Filter filter, Sorter sorter)Same asCoreSession.getChildren(DocumentRef, String, String, Filter, Sorter)without specific permission filtering.DocumentModelIteratorgetChildrenIterator(DocumentRef parent)Gets an iterator to the children of the given parent.DocumentModelIteratorgetChildrenIterator(DocumentRef parent, String type)Gets an iterator to the children of the given parent filtered according to the given document type.DocumentModelIteratorgetChildrenIterator(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)StringgetCurrentLifeCycleState(DocumentRef docRef)Returns the life cycle of the document.DataModelgetDataModel(DocumentRef docRef, Schema schema)Retrieves a data model given a document reference and a schema.protected ObjectgetDataModelField(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.DocumentModelgetDocument(DocumentRef docRef)Gets a document model given its reference.DocumentModelListgetDocuments(DocumentRef[] docRefs)Gets a list of documents given their references.<T extends Serializable>
TgetDocumentSystemProp(DocumentRef ref, String systemProperty, Class<T> type)Gets system property of the specified type for the document ref.DocumentTypegetDocumentType(String type)Gets the document type object given its type name.DocumentModelgetDocumentWithVersion(DocumentRef docRef, VersionModel version)Returns a document that represents the specified version of the document.DocumentModelListgetFiles(DocumentRef parent)Same asCoreSession.getChildren(DocumentRef)but returns only non-folder documents.DocumentModelListgetFiles(DocumentRef parent, Filter filter, Sorter sorter)Same asCoreSession.getFiles(org.nuxeo.ecm.core.api.DocumentRef)but uses an optional filter and sorter on the result.protected DocumentgetFirstParentDocumentWithFacet(DocumentRef docRef, String facet)Returns the firstDocumentwith the givenfacet, recursively going up the parent hierarchy.DocumentModelListgetFolders(DocumentRef parent)Same asCoreSession.getChildren(DocumentRef)but returns only folder documents.DocumentModelListgetFolders(DocumentRef parent, Filter filter, Sorter sorter)Same asCoreSession.getFolders(DocumentRef)but uses an optional filter and sorter on the result.DocumentModelgetLastDocumentVersion(DocumentRef docRef)Gets the document corresponding to the last version for the given document.DocumentRefgetLastDocumentVersionRef(DocumentRef docRef)Gets the document reference corresponding to the last version for the given document.StringgetLifeCyclePolicy(DocumentRef docRef)Returns the life cycle policy of the document.LockgetLockInfo(DocumentRef docRef)Gets the lock info on the given document.protected longgetMaxResults()DocumentModelgetOrCreateDocument(DocumentModel docModel)Gets a document if it exists, otherwise creates it.DocumentModelgetOrCreateDocument(DocumentModel docModel, Function<DocumentModel,DocumentModel> postCreate)Gets a document if it exists, otherwise creates it.DocumentModelgetParentDocument(DocumentRef docRef)Gets the parent document or null if this is the root document.DocumentRefgetParentDocumentRef(DocumentRef docRef)Returns the parent ref of the document referenced bydocRefornullif 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()DocumentModelListgetProxies(DocumentRef docRef, DocumentRef folderRef)Finds the proxies for a document.List<String>getRetainedProperties(DocumentRef docRef)Gets the retained property xpaths of this document at the time it became a record.CalendargetRetainUntil(DocumentRef docRef)Gets the retention date for the document.DocumentModelgetRootDocument()Gets the root document of this repository.protected SecurityServicegetSecurityService()abstract SessiongetSession()Internal method: Gets the current session based on the client session id.DocumentModelgetSourceDocument(DocumentRef docRef)Gets the head (live) document for this document.StringgetSuperParentType(DocumentModel doc)Returns the type of his parent SuperSpace (workspace, section, etc.).DocumentModelgetSuperSpace(DocumentModel doc)Returns the parent SuperSpace (workspace, section, etc.).protected DocumentValidationServicegetValidationService()DocumentModelgetVersion(String versionableId, VersionModel versionModel)Gets a document version, given the versionable id and label.protected VersioningServicegetVersioningService()StringgetVersionLabel(DocumentModel docModel)Gets the version label for a document, according to the versioning service.protected VersionModelgetVersionModel(Document version)List<DocumentModel>getVersions(DocumentRef docRef)Retrieves all the versions for a specified document.StringgetVersionSeriesId(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.DocumentModelgetWorkingCopy(DocumentRef docRef)Gets the working copy (live document) for a proxy or a version.booleanhasChild(DocumentRef parent, String name)Tests if the document has a child with the given name.booleanhasChildren(DocumentRef docRef)Tests if the document has any children.booleanhasLegalHold(DocumentRef docRef)Checks if the document has a legal hold set.booleanhasPermission(DocumentRef docRef, String permission)Checks if the principal that created the client session has the given privilege on the referred document.booleanhasPermission(NuxeoPrincipal principal, DocumentRef docRef, String permission)Checks if a given principal has the given privilege on the referred document.protected booleanhasPermission(NuxeoPrincipal principal, Document doc, String permission)protected booleanhasPermission(Document doc, String permission)protected voidimportDocument(DocumentModel docModel)voidimportDocuments(List<DocumentModel> docModels)Low-level import of documents, reserved for the administrator.protected booleanisAdministrator()booleanisCheckedOut(DocumentRef docRef)Returns whether the current document is checked-out or not.booleanisEnforcedRecord(DocumentRef docRef)Checks if the document is an enforced record.booleanisFlexibleRecord(DocumentRef docRef)Checks if the document is a flexible record.protected booleanisLimitedResults()booleanisNegativeAclAllowed()Returnstrueif negative ACLs are allowed.booleanisRecord(DocumentRef docRef)Checks if the document is a record.booleanisRetentionActive(DocumentRef docRef)Checks whether a document is under active retention.booleanisTrashed(DocumentRef docRef)Checks if this document is in the trash.booleanisUnderRetentionOrLegalHold(DocumentRef docRef)Checks if the document has a retention date in the future or has a legal hold.protected voidloadDataModelsForFacet(DocumentModel docModel, Document doc, String facetName)voidmakeFlexibleRecord(DocumentRef docRef)Turns the document into a flexible record.voidmakeRecord(DocumentRef docRef)Turns the document into an enforced record.protected voidmakeRecord(DocumentRef docRef, boolean flexible)voidmove(List<DocumentRef> src, DocumentRef dst)Bulk move.DocumentModelmove(DocumentRef src, DocumentRef dst, String name)Moves the source document to the destination folder under the given name.DocumentModelnewDocumentModel(DocumentRef parentRef, String name, String typeName)Creates a new document model using required information.DocumentEventContextnewEventContext(DocumentModel source)protected voidnotifyCheckedInVersion(DocumentModel docModel, DocumentRef checkedInVersionRef, Map<String,Serializable> options, String checkinComment)Send a core event for the creation of a new check in version.protected voidnotifyEvent(String eventId, DocumentModel source, Map<String,Serializable> options, String category, String comment, boolean withLifeCycle, boolean inline)protected voidnotifyVersionChange(DocumentModel oldDocument, DocumentModel newDocument, Map<String,Serializable> options)Copied from obsolete VersionChangeNotifier.voidorderBefore(DocumentRef parent, String src, String dest)Given a parent document, order the source child before the destination child.DocumentModelpublishDocument(DocumentModel docToPublish, DocumentModel section)Publishes the document in a section overwriting any existing proxy to the same document.DocumentModelpublishDocument(DocumentModel docModel, DocumentModel section, boolean overwriteExistingProxy)Publishes the document in a section.DocumentModelListquery(String query)Executes the given NXQL query an returns the result.DocumentModelListquery(String query, int max)Executes the given NXQL query an returns the result.DocumentModelListquery(String query, String queryType, Filter filter, long limit, long offset, boolean countTotal)Executes the given query and returns the result that matches the filter.DocumentModelListquery(String query, String queryType, Filter filter, long limit, long offset, long countUpTo)Executes the given query and returns the result that matches the filter.DocumentModelListquery(String query, Filter filter)Executes the given NXQL query and returns the result that matches the filter.DocumentModelListquery(String query, Filter filter, int max)Executes the given NXQL query and returns the result that matches the filter.DocumentModelListquery(String query, Filter filter, long limit, long offset, boolean countTotal)Executes the given NXQL query and returns the result that matches the filter.DocumentModelListquery(String query, Filter filter, long limit, long offset, long countUpTo)Executes the given NXQL query and returns the result that matches the filter.IterableQueryResultqueryAndFetch(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).IterableQueryResultqueryAndFetch(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 DocumentModelreadModel(Document doc)Gets the document model for the given core document.protected DocumentModelreadModel(Document doc, DocumentModel docModel)Gets the document model for the given core document, preserving the contextData.DocumentModel.DocumentModelRefreshrefreshDocument(DocumentRef ref, int refreshFlags, String[] schemas)Internal method - it is used internally byDocumentModel.refresh()voidreinitLifeCycleState(DocumentRef docRef)Reinitializes the life cycle state of the document to its default state.voidremoveChildren(DocumentRef docRef)Removes all children from the given document.voidremoveDocument(DocumentRef docRef)Removes this document and all its children, if any.protected voidremoveDocument(Document doc)voidremoveDocuments(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.LockremoveLock(DocumentRef docRef)Removes the lock on the given document.protected voidremoveNotifyOneDoc(Document doc)List<DocumentRef>removeOrphanVersions(DocumentRef docRef)Removes orphan versions when the live document doesn't exist and there is no proxy pointing to this document.voidreplaceACE(DocumentRef docRef, String aclName, ACE oldACE, ACE newACE)Replace theoldACEwith thenewACEon the givenaclName.StringreplaceBlobDigest(DocumentRef docRef, String key, String newKey, String newDigest)Visits the blobs of a document and, for those with a matching key, replace their key and digest with new ones.protected DocumentresolveParentReference(DocumentRef docRef)protected DocumentresolveReference(DocumentRef docRef)DocumentModelrestoreToVersion(DocumentRef docRef, DocumentRef versionRef)Restores the given document to the specified version.DocumentModelrestoreToVersion(DocumentRef docRef, DocumentRef versionRef, boolean skipSnapshotCreation, boolean skipCheckout)Restores the given document to the specified version.protected DocumentModelrestoreToVersion(Document doc, Document version, boolean skipSnapshotCreation, boolean skipCheckout)voidsave()Saves any pending changes done until now through this session.DocumentModelsaveDocument(DocumentModel docModel)Saves changes done on the given document model.voidsaveDocuments(DocumentModel[] docModels)Bulk document saving.ScrollResult<String>scroll(String scrollId)Get the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse.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 thekeepAliveSecondsdelay.voidsetACP(DocumentRef docRef, ACP newAcp, boolean overwrite)Sets the ACP for this document.protected voidsetACP(Document doc, ACP newAcp, boolean overwrite, Map<String,Serializable> options)<T extends Serializable>
voidsetDocumentSystemProp(DocumentRef ref, String systemProperty, T value)Sets given value as a system property.voidsetLegalHold(DocumentRef docRef, boolean hold, String comment)Sets or removes the legal hold on the document (a record).protected voidsetLimitedResults(boolean limitedResults)LocksetLock(DocumentRef docRef)Sets a lock on the given document.protected voidsetMaxResults(long maxResults)voidsetRetainUntil(DocumentRef docRef, Calendar retainUntil, String comment)Sets the retention date on the document (a record).voidsetRetentionActive(DocumentRef docRef, boolean retentionActive)Sets or unsets a document as under active retention.protected DocumentModelListtracedQuery(String query, String queryType, Filter filter, long limit, long offset, long countUpTo)voidunsetRetainUntil(DocumentRef docRef)Removes the retainUntil date, this operation is allowed only for a flexible record.protected voidupdateDocumentCountInc()protected DocumentModelupdateExistingProxies(Document doc, Document folder, Document target)Update the proxy for doc in the given section to point to the new target.voidupdateReadACLs(Collection<String> docIds)Updates the Read ACLs for some documents.protected voidupdateVersionsReadACLs(Collection<String> docIds)protected DocumentModelwriteModel(Document doc, DocumentModel docModel)protected DocumentModelwriteModel(Document doc, DocumentModel docModel, boolean create)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.api.CoreSession
close, getPrincipal, getRepositoryName, getSessionId, isStateSharedByAllThreadSessions
-
-
-
-
Field Detail
-
DEFAULT_MAX_RESULTS
public static final String DEFAULT_MAX_RESULTS
- See Also:
- Constant Field Values
-
MAX_RESULTS_PROPERTY
public static final String MAX_RESULTS_PROPERTY
- See Also:
- Constant Field Values
-
LIMIT_RESULTS_PROPERTY
public static final String LIMIT_RESULTS_PROPERTY
- See Also:
- Constant Field Values
-
TRASH_KEEP_CHECKED_IN_PROPERTY
@Deprecated public static final String TRASH_KEEP_CHECKED_IN_PROPERTY
Deprecated.since 10.1, new trash behavior is: always keep checkedIn state- See Also:
- Constant Field Values
-
DISABLED_ISLATESTVERSION_PROPERTY
public static final String DISABLED_ISLATESTVERSION_PROPERTY
- See Also:
- Constant Field Values
-
BINARY_TEXT_SYS_PROP
public static final String BINARY_TEXT_SYS_PROP
- See Also:
- Constant Field Values
-
RESTRICT_PROXY_CREATION_PROPERTY
public static final String RESTRICT_PROXY_CREATION_PROPERTY
- See Also:
- Constant Field Values
-
BLOCKED_PERMISSION_QUERY
public static final String BLOCKED_PERMISSION_QUERY
- Since:
- 2023
- See Also:
- Constant Field Values
-
RETENTION_QUERY
public static final String RETENTION_QUERY
- Since:
- 2023
- See Also:
- Constant Field Values
-
LEGAL_HOLD_QUERY
public static final String LEGAL_HOLD_QUERY
- Since:
- 2023
- See Also:
- Constant Field Values
-
FIND_VERSIONS_QUERY
public static final String FIND_VERSIONS_QUERY
- See Also:
- Constant Field Values
-
FIND_PROXIES_QUERY
public static final String FIND_PROXIES_QUERY
- See Also:
- Constant Field Values
-
registry
protected static final io.dropwizard.metrics5.MetricRegistry registry
-
CREATE_DOC_COUNT
protected static final Map<String,io.dropwizard.metrics5.Counter> CREATE_DOC_COUNT
-
DELETE_DOC_COUNT
protected static final Map<String,io.dropwizard.metrics5.Counter> DELETE_DOC_COUNT
-
UPDATE_DOC_COUNT
protected static final Map<String,io.dropwizard.metrics5.Counter> UPDATE_DOC_COUNT
-
createDocumentCount
protected io.dropwizard.metrics5.Counter createDocumentCount
-
deleteDocumentCount
protected io.dropwizard.metrics5.Counter deleteDocumentCount
-
updateDocumentCount
protected io.dropwizard.metrics5.Counter updateDocumentCount
-
EMPTY_PATH
protected static final PathRef EMPTY_PATH
-
-
Method Detail
-
createDocumentCountInc
protected void createDocumentCountInc()
-
deleteDocumentCountInc
protected void deleteDocumentCountInc()
-
updateDocumentCountInc
protected void updateDocumentCountInc()
-
getSecurityService
protected SecurityService getSecurityService()
-
getVersioningService
protected VersioningService getVersioningService()
-
getValidationService
protected DocumentValidationService getValidationService()
-
getSession
public abstract Session getSession()
Internal method: Gets the current session based on the client session id.- Returns:
- the repository session
-
getDocumentType
public DocumentType getDocumentType(String type)
Description copied from interface:CoreSessionGets the document type object given its type name.- Specified by:
getDocumentTypein interfaceCoreSession- Parameters:
type- the document type name- Returns:
- the type the doc type object
-
checkPermission
protected final void checkPermission(Document doc, String permission) throws DocumentSecurityException
- Throws:
DocumentSecurityException
-
getContextMapEventInfo
protected Map<String,Serializable> getContextMapEventInfo(DocumentModel doc)
-
newEventContext
public DocumentEventContext newEventContext(DocumentModel source)
-
notifyEvent
protected void notifyEvent(String eventId, DocumentModel source, Map<String,Serializable> options, String category, String comment, boolean withLifeCycle, boolean inline)
-
notifyVersionChange
protected void notifyVersionChange(DocumentModel oldDocument, DocumentModel newDocument, Map<String,Serializable> options)
Copied from obsolete VersionChangeNotifier.Sends change notifications to core event listeners. The event contains info with older document (before version change) and newer doc (current document).
- Parameters:
options- additional info to pass to the event
-
hasPermission
public boolean hasPermission(NuxeoPrincipal principal, DocumentRef docRef, String permission)
Description copied from interface:CoreSessionChecks if a given principal has the given privilege on the referred document.- Specified by:
hasPermissionin interfaceCoreSession
-
hasPermission
protected final boolean hasPermission(NuxeoPrincipal principal, Document doc, String permission)
-
hasPermission
public boolean hasPermission(DocumentRef docRef, String permission)
Description copied from interface:CoreSessionChecks if the principal that created the client session has the given privilege on the referred document.- Specified by:
hasPermissionin interfaceCoreSession
-
filterGrantedPermissions
public Collection<String> filterGrantedPermissions(NuxeoPrincipal principal, DocumentRef docRef, Collection<String> permissions)
Description copied from interface:CoreSessionFilters the supplied permissions based on whether they are granted to a given principal for a given document.- Specified by:
filterGrantedPermissionsin interfaceCoreSession
-
resolveReference
protected Document resolveReference(DocumentRef docRef)
-
resolveParentReference
protected Document resolveParentReference(DocumentRef docRef)
-
readModel
protected DocumentModel readModel(Document doc)
Gets the document model for the given core document.- Parameters:
doc- the document- Returns:
- the document model
-
readModel
protected DocumentModel readModel(Document doc, DocumentModel docModel)
Gets the document model for the given core document, preserving the contextData.- Parameters:
doc- the document- Returns:
- the document model
-
writeModel
protected DocumentModel writeModel(Document doc, DocumentModel docModel)
-
writeModel
protected DocumentModel writeModel(Document doc, DocumentModel docModel, boolean create)
-
copy
@Deprecated public DocumentModel copy(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)
Deprecated.Description copied from interface:CoreSessionCopies the source document to the destination folder under the given name. If the name is null the original name is preserved.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.
- Specified by:
copyin interfaceCoreSession- Parameters:
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 not
-
copy
public DocumentModel copy(DocumentRef src, DocumentRef dst, String name, CoreSession.CopyOption... copyOptions)
Description copied from interface:CoreSessionCopies the source document to the destination folder under the given name. If the name is null the original name is preserved.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.
- Specified by:
copyin interfaceCoreSession- Parameters:
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
-
copy
@Deprecated public List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)
Deprecated.Description copied from interface:CoreSessionBulk copy. Destination must be a folder document.- Specified by:
copyin interfaceCoreSession- Parameters:
src- the documents to copydst- the destination folderresetLifeCycle- the property that flagged whether reset destination document lifecycle or not
-
copy
public List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)
Description copied from interface:CoreSessionBulk copy. Destination must be a folder document.- Specified by:
copyin interfaceCoreSession- Parameters:
src- the documents to copydst- the destination folderopts- the options for copy
-
copyProxyAsDocument
@Deprecated public DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle)
Deprecated.Description copied from interface:CoreSessionWork like copy but in the case of a source proxy the destination will be a new document instead of a proxy.- Specified by:
copyProxyAsDocumentin interfaceCoreSession- Parameters:
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 not
-
copyProxyAsDocument
public DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, CoreSession.CopyOption... copyOptions)
Description copied from interface:CoreSessionWork like copy but in the case of a source proxy the destination will be a new document instead of a proxy.- Specified by:
copyProxyAsDocumentin interfaceCoreSession- Parameters:
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- See Also:
CoreSession.copy(DocumentRef, DocumentRef, String, CopyOption...)
-
copyProxyAsDocument
@Deprecated public List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle)
Deprecated.Description copied from interface:CoreSessionBulk copyProxyAsDocument. Destination must be a folder document.- Specified by:
copyProxyAsDocumentin interfaceCoreSession- Parameters:
src- the documents to copydst- the destination folderresetLifeCycle- the property that flagged whether reset destination document lifecycle or not
-
copyProxyAsDocument
public List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, CoreSession.CopyOption... opts)
Description copied from interface:CoreSessionBulk copyProxyAsDocument. Destination must be a folder document.- Specified by:
copyProxyAsDocumentin interfaceCoreSession- Parameters:
src- the documents to copydst- the destination folderopts- the options of copy
-
move
public DocumentModel move(DocumentRef src, DocumentRef dst, String name)
Description copied from interface:CoreSessionMoves the source document to the destination folder under the given name. If the name isnullor if there is a collision, a suitable new name is found.- Specified by:
movein interfaceCoreSession- Parameters:
src- the source document referencedst- the destination folder referencename- the new name of the file, ornull
-
move
public void move(List<DocumentRef> src, DocumentRef dst)
Description copied from interface:CoreSessionBulk move. Destination must be a folder document.- Specified by:
movein interfaceCoreSession- Parameters:
src- the documents to movedst- the destination folder
-
getACP
public ACP getACP(DocumentRef docRef)
Description copied from interface:CoreSessionGets the document access control policy.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.- Specified by:
getACPin interfaceCoreSession- Parameters:
docRef- the doc ref to retrieve ACP or null if none- Returns:
- the ACP
-
setACP
public void setACP(DocumentRef docRef, ACP newAcp, boolean overwrite)
Description copied from interface:CoreSessionSets the ACP for this document.If the ACP contains an
INHERITEDACL it will be discarded. Only ACLs relative to the current document may be changed.If the
overwriteargument is false, the ACP is merged with the existing one if any. The merge is done as follow:- If any ACL is that already exists on the document ACp is redefined by the new ACO then it will be replaced by the new one. So if you want to remove an ACl in this mode you need to specify an empty ACL.
- If the new ACP contains an ACl that is not defined by the old one the it will be added to the merged ACP.
- If the
ownersare 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)
overwriteargument 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
overwriteargument set to true.Setting a null ACP when
overwriteis false will do nothing.- Specified by:
setACPin interfaceCoreSession
-
setACP
protected void setACP(Document doc, ACP newAcp, boolean overwrite, Map<String,Serializable> options)
-
replaceACE
public void replaceACE(DocumentRef docRef, String aclName, ACE oldACE, ACE newACE)
Description copied from interface:CoreSessionReplace theoldACEwith thenewACEon the givenaclName.- Specified by:
replaceACEin interfaceCoreSession
-
updateReadACLs
public void updateReadACLs(Collection<String> docIds)
Description copied from interface:CoreSessionUpdates the Read ACLs for some documents.For INTERNAL use by the core.
- Specified by:
updateReadACLsin interfaceCoreSession- Parameters:
docIds- the document ids
-
updateVersionsReadACLs
protected void updateVersionsReadACLs(Collection<String> docIds)
-
isNegativeAclAllowed
public boolean isNegativeAclAllowed()
Description copied from interface:CoreSessionReturnstrueif 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.
- Specified by:
isNegativeAclAllowedin interfaceCoreSession- Returns:
trueif negative ACLs are allowed
-
cancel
public void cancel()
Description copied from interface:CoreSessionCancels any pending change made through this session.- Specified by:
cancelin interfaceCoreSession
-
createDocumentModel
public DocumentModel createDocumentModel(String typeName)
Description copied from interface:CoreSessionCreates a document model using type name.Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATEDso that core event listener can initialize its content with computed properties.- Specified by:
createDocumentModelin interfaceCoreSession- Returns:
- the initial document model
-
createDocumentModel
public DocumentModel createDocumentModel(String parentPath, String name, String typeName)
Description copied from interface:CoreSessionCreates a document model using required information.Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATEDso that core event listener can initialize its content with computed properties.- Specified by:
createDocumentModelin interfaceCoreSession- Parameters:
parentPath- the parent pathname- The destination nametypeName- the type name- Returns:
- the initial document model
-
createDocumentModel
public DocumentModel createDocumentModel(String typeName, Map<String,Object> options)
Description copied from interface:CoreSessionCreates a document model using required information.Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATEDso that core event listener can initialize its content with computed properties.- Specified by:
createDocumentModelin interfaceCoreSession- Parameters:
typeName- the type nameoptions- additional contextual data provided to core event listeners- Returns:
- the initial document model
-
createDocument
public DocumentModel createDocument(DocumentModel docModel)
Description copied from interface:CoreSessionCreates a document using given document model for initialization.The model contains path of the new document, its type and optionally the initial data models of the document.
- Specified by:
createDocumentin interfaceCoreSession- Parameters:
docModel- the document model to use for initialization- Returns:
- the created document
-
fillCreateOptions
protected Document fillCreateOptions(DocumentRef parentRef, String childName, Map<String,Serializable> options) throws DocumentSecurityException
- Throws:
DocumentSecurityException
-
importDocuments
public void importDocuments(List<DocumentModel> docModels)
Description copied from interface:CoreSessionLow-level import of documents, reserved for the administrator.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_IDandCoreSession.IMPORT_PROXY_VERSIONABLE_ID.For a version (no parent):
CoreSession.IMPORT_VERSION_VERSIONABLE_ID,CoreSession.IMPORT_VERSION_CREATED,CoreSession.IMPORT_VERSION_LABELandCoreSession.IMPORT_VERSION_DESCRIPTION.For a live document:
CoreSession.IMPORT_BASE_VERSION_IDandCoreSession.IMPORT_CHECKED_IN(Boolean).For a live document or a version:
CoreSession.IMPORT_LIFECYCLE_POLICY,CoreSession.IMPORT_LIFECYCLE_STATE,CoreSession.IMPORT_VERSION_MAJOR(Long) andCoreSession.IMPORT_VERSION_MINOR(Long).- Specified by:
importDocumentsin interfaceCoreSession- Parameters:
docModels- the documents to create
-
importDocument
protected void importDocument(DocumentModel docModel)
-
createDocument
public DocumentModel[] createDocument(DocumentModel[] docModels)
Description copied from interface:CoreSessionBulk creation of documents.- Specified by:
createDocumentin interfaceCoreSession- Parameters:
docModels- the document models to use for intialization- Returns:
- the created documents
-
exists
public boolean exists(DocumentRef docRef)
Description copied from interface:CoreSessionTests if the document pointed by the given reference exists and is accessible.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.
- Specified by:
existsin interfaceCoreSession- Parameters:
docRef- the reference to the document to test for existence- Returns:
- true if the referenced document exists, false otherwise
-
getChild
public DocumentModel getChild(DocumentRef parent, String name)
Description copied from interface:CoreSessionGets a child document given its name and the parent reference.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.
- Specified by:
getChildin interfaceCoreSession- Parameters:
parent- the reference to the parent documentname- the name of the child document to retrieve- Returns:
- the named child if exists
-
hasChild
public boolean hasChild(DocumentRef parent, String name)
Description copied from interface:CoreSessionTests if the document has a child with the given name.This operation silently ignores non-folder documents: If the document is not a folder then returns false.
- Specified by:
hasChildin interfaceCoreSession- Parameters:
parent- the documentname- the child name- Returns:
trueif the document has a child with the given name
-
getChildren
public DocumentModelList getChildren(DocumentRef parent)
Description copied from interface:CoreSessionGets the children of the given parent.- Specified by:
getChildrenin interfaceCoreSession- Parameters:
parent- the parent reference- Returns:
- the children if any, an empty list if no children or null if the specified parent document is not a folder
-
getChildren
public DocumentModelList getChildren(DocumentRef parent, String type)
Description copied from interface:CoreSessionGets the children of the given parent filtered according to the given document type.- Specified by:
getChildrenin interfaceCoreSession- Parameters:
parent- the parent referencetype- the wanted document type- Returns:
- the documents if any, an empty list if none were found or null if the parent document is not a folder
-
getChildren
public DocumentModelList getChildren(DocumentRef parent, String type, String perm)
Description copied from interface:CoreSessionGets the children of the given parent filtered according to the given document type and permission.- Specified by:
getChildrenin interfaceCoreSession- Parameters:
parent- the parent referencetype- the wanted document typeperm- the permission the user must have- Returns:
- the documents if any, an empty list if none were found or null if the parent document is not a folder
-
getChildren
public DocumentModelList getChildren(DocumentRef parent, String type, Filter filter, Sorter sorter)
Description copied from interface:CoreSessionSame asCoreSession.getChildren(DocumentRef, String, String, Filter, Sorter)without specific permission filtering.- Specified by:
getChildrenin interfaceCoreSession- Parameters:
parent- the parent referencetype- the wanted typefilter- the filter to use if any, null otherwisesorter- the sorter to use if any, null otherwise- Returns:
- the list of the children or an empty list if no children were found or null if the given parent is not a folder
-
getChildren
public DocumentModelList getChildren(DocumentRef parent, String type, String perm, Filter filter, Sorter sorter)
Description copied from interface:CoreSessionSame asCoreSession.getChildren(DocumentRef, String, String)but the result is filtered and then sorted using the specified filter and sorter.- Specified by:
getChildrenin interfaceCoreSession- Parameters:
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 otherwise- Returns:
- the list of the children or an empty list if no children were found or null if the given parent is not a folder
-
getChildrenRefs
public List<DocumentRef> getChildrenRefs(DocumentRef parentRef, String perm)
Description copied from interface:CoreSessionGets the references of the children. No permission is checked if perm is null.- Specified by:
getChildrenRefsin interfaceCoreSession- Parameters:
parentRef- the parent referenceperm- the permission to check on the children (usually READ); if null, no permission is checked- Returns:
- a list of children references
-
getChildrenIterator
public DocumentModelIterator getChildrenIterator(DocumentRef parent)
Description copied from interface:CoreSessionGets an iterator to the children of the given parent.- Specified by:
getChildrenIteratorin interfaceCoreSession- Parameters:
parent- the parent reference- Returns:
- iterator over the children collection or null if the specified parent document is not a folder
-
getChildrenIterator
public DocumentModelIterator getChildrenIterator(DocumentRef parent, String type)
Description copied from interface:CoreSessionGets an iterator to the children of the given parent filtered according to the given document type.- Specified by:
getChildrenIteratorin interfaceCoreSession
-
getChildrenIterator
public DocumentModelIterator getChildrenIterator(DocumentRef parent, String type, String perm, Filter filter)
Description copied from interface:CoreSessionGets the children of the given parent filtered according to the given document type and permission. Long result sets are loaded frame by frame transparently by the DocumentModelIterator.- Specified by:
getChildrenIteratorin interfaceCoreSession
-
getDocument
public DocumentModel getDocument(DocumentRef docRef)
Description copied from interface:CoreSessionGets a document model given its reference.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.
- Specified by:
getDocumentin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the document
-
getDocuments
public DocumentModelList getDocuments(DocumentRef[] docRefs)
Description copied from interface:CoreSessionGets a list of documents given their references.Documents that are not accessible are skipped.
- Specified by:
getDocumentsin interfaceCoreSession
-
getFiles
public DocumentModelList getFiles(DocumentRef parent)
Description copied from interface:CoreSessionSame asCoreSession.getChildren(DocumentRef)but returns only non-folder documents.- Specified by:
getFilesin interfaceCoreSession- Parameters:
parent- the parent reference- Returns:
- a list of children if any, an empty one if none or null if the given parent is not a folder
-
getFiles
public DocumentModelList getFiles(DocumentRef parent, Filter filter, Sorter sorter)
Description copied from interface:CoreSessionSame asCoreSession.getFiles(org.nuxeo.ecm.core.api.DocumentRef)but uses an optional filter and sorter on the result.- Specified by:
getFilesin interfaceCoreSession- Parameters:
parent- the parent referencefilter- the filter to use or null if nonesorter- the sorter to use or null if none- Returns:
- a list of children if any, an empty one if none or null if the given parent is not a folder
-
getFolders
public DocumentModelList getFolders(DocumentRef parent)
Description copied from interface:CoreSessionSame asCoreSession.getChildren(DocumentRef)but returns only folder documents.- Specified by:
getFoldersin interfaceCoreSession- Parameters:
parent- the parent ref- Returns:
- a list of children if any, an empty one if none or null if the given parent is not a folder
-
getFolders
public DocumentModelList getFolders(DocumentRef parent, Filter filter, Sorter sorter)
Description copied from interface:CoreSessionSame asCoreSession.getFolders(DocumentRef)but uses an optional filter and sorter on the result.- Specified by:
getFoldersin interfaceCoreSession- Parameters:
parent- the parent referencefilter- the filter to use or null if nonesorter- the sorter to use or null if none- Returns:
- a list of children if any, an empty one if none or null if the given parent is not a folder
-
getParentDocumentRef
public DocumentRef getParentDocumentRef(DocumentRef docRef)
Description copied from interface:CoreSessionReturns the parent ref of the document referenced bydocRefornullif this is the root document.This method does not check the permissions on the parent document of this
CoreSession'sPrincipal.- Specified by:
getParentDocumentRefin interfaceCoreSession
-
getParentDocument
public DocumentModel getParentDocument(DocumentRef docRef)
Description copied from interface:CoreSessionGets the parent document or null if this is the root document.- Specified by:
getParentDocumentin interfaceCoreSession- Returns:
- the parent document or null if this is the root document
-
getParentDocuments
public List<DocumentModel> getParentDocuments(DocumentRef docRef)
Description copied from interface:CoreSessionGets the parent documents in path from the root to the given document or empty list if this is the root document.Documents the principal is is not allowed to browse are filtered out the parents list.
- Specified by:
getParentDocumentsin interfaceCoreSession- Returns:
- the list with parent documents or empty list if this is the root document
-
getRootDocument
public DocumentModel getRootDocument()
Description copied from interface:CoreSessionGets the root document of this repository.- Specified by:
getRootDocumentin interfaceCoreSession- Returns:
- the root document. cannot be null
-
hasChildren
public boolean hasChildren(DocumentRef docRef)
Description copied from interface:CoreSessionTests if the document has any children.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.
- Specified by:
hasChildrenin interfaceCoreSession- Parameters:
docRef- the reference to the document to test- Returns:
- true if document has children, false otherwise
-
query
public DocumentModelList query(String query)
Description copied from interface:CoreSessionExecutes the given NXQL query an returns the result.- Specified by:
queryin interfaceCoreSession- Parameters:
query- the query to execute- Returns:
- the query result
-
query
public DocumentModelList query(String query, int max)
Description copied from interface:CoreSessionExecutes the given NXQL query an returns the result.- Specified by:
queryin interfaceCoreSession- Parameters:
query- the query to executemax- number of document to retrieve- Returns:
- the query result
-
query
public DocumentModelList query(String query, Filter filter)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
query- the query to executefilter- the filter to apply to result- Returns:
- the query result
-
query
public DocumentModelList query(String query, Filter filter, int max)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
query- the query to executefilter- the filter to apply to resultmax- number of document to retrieve- Returns:
- the query result
-
query
public DocumentModelList query(String query, Filter filter, long limit, long offset, boolean countTotal)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
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- iftrue, return aDocumentModelListthat includes a total size of the underlying list (size if there was no limit or offset)- Returns:
- the query result
-
query
public DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, boolean countTotal)
Description copied from interface:CoreSessionExecutes the given query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
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- iftrue, return aDocumentModelListthat includes a total size of the underlying list (size if there was no limit or offset)- Returns:
- the query result
-
computeCountUpTo
protected long computeCountUpTo(boolean countTotal)
- Returns:
- the appropriate countUpTo value depending on input
countTotaland configuration.
-
getMaxResults
protected long getMaxResults()
-
isLimitedResults
protected boolean isLimitedResults()
-
setMaxResults
protected void setMaxResults(long maxResults)
-
setLimitedResults
protected void setLimitedResults(boolean limitedResults)
-
query
public DocumentModelList query(String query, Filter filter, long limit, long offset, long countUpTo)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
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.
If0, don't count the total size.
Ifn, count the total number if there are less than n documents otherwise set the size to-1.- Returns:
- the query result
-
query
public DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, long countUpTo)
Description copied from interface:CoreSessionExecutes the given query and returns the result that matches the filter.- Specified by:
queryin interfaceCoreSession- Parameters:
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 aDocumentModelListthat includes a total size of the underlying list (size if there was no limit or offset).
If0, don't return the total size of the underlying list.
Ifn, return the total size of the underlying list when the size is smaller thannelse return a total size of-1.- Returns:
- the query result
-
tracedQuery
protected DocumentModelList tracedQuery(String query, String queryType, Filter filter, long limit, long offset, long countUpTo)
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, Object... params)
Description copied from interface:CoreSessionExecutes the given query and returns an iterable of maps containing the requested properties (which must be closed when done).- Specified by:
queryAndFetchin interfaceCoreSession- Parameters:
query- the query to executequeryType- the query type, usually "NXQL"params- optional query-type-dependent parameters- Returns:
- an
IterableQueryResult, which must be closed after use
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, boolean distinctDocuments, Object... params)
Description copied from interface:CoreSessionExecutes the given query and returns an iterable of maps containing the requested properties (which must be closed when done).It's possible to specify
distinctDocuments = trueto get a maximum of one row of results per document, this will behave differently only when theWHEREclause contains wildcards.- Specified by:
queryAndFetchin interfaceCoreSession- Parameters:
query- the query to executequeryType- the query type, usually "NXQL"distinctDocuments- iftruethen a maximum of one row per document will be returnedparams- optional query-type-dependent parameters- Returns:
- an
IterableQueryResult, which must be closed after use
-
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, long limit, long offset)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryProjectionin interfaceCoreSession- Parameters:
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 documents- Returns:
- the query result
-
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, long limit, long offset, boolean countTotal)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryProjectionin interfaceCoreSession- Parameters:
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- iftrue, return aPartialListthat includes a total size of the underlying list (size if there was no limit or offset)- Returns:
- the query result
-
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, boolean distinctDocuments, long limit, long offset, long countUpTo, Object... params)
Description copied from interface:CoreSessionExecutes the given NXQL query and returns the result that matches the filter.- Specified by:
queryProjectionin interfaceCoreSession- Parameters:
query- the query to executequeryType- the query type, like "NXQL"distinctDocuments- iftruethen 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 aPartialListthat includes a total size of the underlying list (size if there was no limit or offset).
If0, don't return the total size of the underlying list.
Ifn, return the total size of the underlying list when the size is smaller thannelse return a total size of-1.params- optional query-type-dependent parameters- Returns:
- the query result
-
getPrincipalsToCheck
protected String[] getPrincipalsToCheck()
-
getPoliciesQueryTransformers
protected Collection<SQLQuery.Transformer> getPoliciesQueryTransformers(String queryType)
-
scroll
public ScrollResult<String> scroll(String query, int batchSize, int keepAliveSeconds)
Description copied from interface:CoreSessionExecutes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSecondsdelay.- Specified by:
scrollin interfaceCoreSession- Parameters:
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 seconds- Returns:
- A
ScrollResultincluding the search results and a scroll id, to be passed to the subsequent calls toCoreSession.scroll(String)
-
scroll
public ScrollResult<String> scroll(String scrollId)
Description copied from interface:CoreSessionGet the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse.- Specified by:
scrollin interfaceCoreSession
-
removeChildren
public void removeChildren(DocumentRef docRef)
Description copied from interface:CoreSessionRemoves all children from the given document.- Specified by:
removeChildrenin interfaceCoreSession- Parameters:
docRef- the reference to the document to remove
-
canRemoveDocument
public boolean canRemoveDocument(DocumentRef docRef)
Description copied from interface:CoreSessionCheck if a document can be removed. This needs theSecurityConstants.REMOVEpermission on the document and theSecurityConstants.REMOVE_CHILDRENpermission on the parent.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).
If the
SecurityConstants.REMOVEpermissions is blocked on a descendant of the document for the current principal, then the document cannot be removed.If a descendant of the document is retained or under legal hold, then the document cannot be removed.
- Specified by:
canRemoveDocumentin interfaceCoreSession- Parameters:
docRef- the document- Returns:
- true if the document can be removed
-
canRemoveDocument
@Deprecated protected String canRemoveDocument(Document doc)
Deprecated.since 2023, better usecheckCanRemoveDocument(Document)Checks if a document can be removed, and returns a failure reason if not.
-
checkCanRemoveDocument
protected void checkCanRemoveDocument(Document doc)
-
checkBlockedDescendants
protected void checkBlockedDescendants(Document doc)
- Throws:
DocumentSecurityException- if a descendant has blocked permission for current user- Since:
- 2023
-
checkRetainedDescendants
protected void checkRetainedDescendants(Document doc)
- Throws:
DocumentExistsException- if a descendant is retained- Since:
- 2023
-
removeDocument
public void removeDocument(DocumentRef docRef)
Description copied from interface:CoreSessionRemoves this document and all its children, if any.- Specified by:
removeDocumentin interfaceCoreSession- Parameters:
docRef- the reference to the document to remove
-
removeDocument
protected void removeDocument(Document doc)
-
removeNotifyOneDoc
protected void removeNotifyOneDoc(Document doc)
-
removeDocuments
public void removeDocuments(DocumentRef[] docRefs)
Implementation uses the fact that the lexicographic ordering of paths is a refinement of the "contains" partial ordering.- Specified by:
removeDocumentsin interfaceCoreSession- Parameters:
docRefs- the refs to the document to remove
-
save
public void save()
Description copied from interface:CoreSessionSaves any pending changes done until now through this session.- Specified by:
savein interfaceCoreSession
-
saveDocument
public DocumentModel saveDocument(DocumentModel docModel)
Description copied from interface:CoreSessionSaves changes done on the given document model.- Specified by:
saveDocumentin interfaceCoreSession- Parameters:
docModel- the document model that needs modified
-
saveDocuments
public void saveDocuments(DocumentModel[] docModels)
Description copied from interface:CoreSessionBulk document saving.- Specified by:
saveDocumentsin interfaceCoreSession- Parameters:
docModels- the document models that needs to be saved
-
getSourceDocument
public DocumentModel getSourceDocument(DocumentRef docRef)
Description copied from interface:CoreSessionGets the head (live) document for this document.- Specified by:
getSourceDocumentin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- the version
-
getVersionModel
protected VersionModel getVersionModel(Document version)
-
getLastDocumentVersion
public DocumentModel getLastDocumentVersion(DocumentRef docRef)
Description copied from interface:CoreSessionGets the document corresponding to the last version for the given document.- Specified by:
getLastDocumentVersionin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- the document model corresponding to the version
-
getLastDocumentVersionRef
public DocumentRef getLastDocumentVersionRef(DocumentRef docRef)
Description copied from interface:CoreSessionGets the document reference corresponding to the last version for the given document.- Specified by:
getLastDocumentVersionRefin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- the document reference corresponding to the last version
-
getVersionsRefs
public List<DocumentRef> getVersionsRefs(DocumentRef docRef)
Description copied from interface:CoreSessionGets the references of the versions of the document.- Specified by:
getVersionsRefsin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- a list of version references
-
getVersions
public List<DocumentModel> getVersions(DocumentRef docRef)
Description copied from interface:CoreSessionRetrieves all the versions for a specified document.- Specified by:
getVersionsin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- the list of
DocumentModelrepresenting versions, empty list if none is found.
-
getVersionsForDocument
public List<VersionModel> getVersionsForDocument(DocumentRef docRef)
Description copied from interface:CoreSessionRetrieves all the versions for a specified document.- Specified by:
getVersionsForDocumentin interfaceCoreSession- Parameters:
docRef- the reference to the document- Returns:
- the list of
VersionModelrepresenting versions, empty list if none is found.
-
restoreToVersion
public DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef)
Description copied from interface:CoreSessionRestores the given document to the specified version.- Specified by:
restoreToVersionin interfaceCoreSession- Parameters:
docRef- the reference to the documentversionRef- the reference to the version
-
restoreToVersion
public DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef, boolean skipSnapshotCreation, boolean skipCheckout)
Description copied from interface:CoreSessionRestores the given document to the specified version.- Specified by:
restoreToVersionin interfaceCoreSession- Parameters:
docRef- the reference to the documentversionRef- the reference to the versionskipSnapshotCreation-trueif the document should not be snapshotted before being restoredskipCheckout-trueif the restored document should be kept in a checked-in state
-
restoreToVersion
protected DocumentModel restoreToVersion(Document doc, Document version, boolean skipSnapshotCreation, boolean skipCheckout)
-
getBaseVersion
public DocumentRef getBaseVersion(DocumentRef docRef)
Description copied from interface:CoreSessionGets the version to which a checked in document is linked.Returns
nullfor a checked out document or a version or a proxy.- Specified by:
getBaseVersionin interfaceCoreSession- Returns:
- the version, or
null
-
checkIn
public DocumentRef checkIn(DocumentRef docRef, VersioningOption option, String checkinComment)
Description copied from interface:CoreSessionChecks in a modified document, creating a new version.- Specified by:
checkInin interfaceCoreSession- Parameters:
docRef- the reference to the documentoption- whether to do create a newVersioningOption.MINORorVersioningOption.MAJORversion during check incheckinComment- the checkin comment- Returns:
- the version just created
-
notifyCheckedInVersion
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. The source document is the live document model used as the source for the checkin, not the archived version it-self.- Parameters:
docModel- work document that has been checked-in as a versioncheckedInVersionRef- document ref of the new checked-in versionoptions- initial option map, or null
-
checkOut
public void checkOut(DocumentRef docRef)
Description copied from interface:CoreSessionChecks out a versioned document.- Specified by:
checkOutin interfaceCoreSession- Parameters:
docRef- the reference to the document
-
isCheckedOut
public boolean isCheckedOut(DocumentRef docRef)
Description copied from interface:CoreSessionReturns whether the current document is checked-out or not.- Specified by:
isCheckedOutin interfaceCoreSession- Parameters:
docRef- the reference to the document
-
getVersionSeriesId
public String getVersionSeriesId(DocumentRef docRef)
Description copied from interface:CoreSessionGets the version series id for a document.All documents and versions derived by a check in or checkout from the same original document share the same version series id.
- Specified by:
getVersionSeriesIdin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the version series id
-
getWorkingCopy
public DocumentModel getWorkingCopy(DocumentRef docRef)
Description copied from interface:CoreSessionGets the working copy (live document) for a proxy or a version.- Specified by:
getWorkingCopyin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the working copy, or
nullif not found
-
getVersion
public DocumentModel getVersion(String versionableId, VersionModel versionModel)
Description copied from interface:CoreSessionGets a document version, given the 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.
- Specified by:
getVersionin interfaceCoreSession- Parameters:
versionableId- the versionable idversionModel- the version model holding the label- Returns:
- the version, or
nullif not found
-
removeOrphanVersions
public List<DocumentRef> removeOrphanVersions(DocumentRef docRef)
Description copied from interface:CoreSessionRemoves orphan versions when the live document doesn't exist and there is no proxy pointing to this document. A version stays referenced, and therefore is not removed, if any proxy points to a version in the version history of any live document, or in the case of tree snapshot if there is a snapshot containing a version in the version history of any live document.- Specified by:
removeOrphanVersionsin interfaceCoreSession- Parameters:
docRef- of the live document- Returns:
- the list of orphan version deleted.
-
getVersionLabel
public String getVersionLabel(DocumentModel docModel)
Description copied from interface:CoreSessionGets the version label for a document, according to the versioning service.- Specified by:
getVersionLabelin interfaceCoreSession- Parameters:
docModel- the document- Returns:
- the version label
-
getDocumentWithVersion
public DocumentModel getDocumentWithVersion(DocumentRef docRef, VersionModel version)
Description copied from interface:CoreSessionReturns a document that represents the specified version of the document.- Specified by:
getDocumentWithVersionin interfaceCoreSession- Parameters:
docRef- the reference to the documentversion- the version for which we want the corresponding document
-
createProxy
public DocumentModel createProxy(DocumentRef docRef, DocumentRef folderRef)
Description copied from interface:CoreSessionCreates a generic proxy to the given document inside the given folder.The document may be a version, or a working copy (live document) in which case the proxy will be a "shortcut".
- Specified by:
createProxyin interfaceCoreSession
-
createProxyInternal
protected DocumentModel createProxyInternal(Document doc, Document folder, Map<String,Serializable> options)
-
removeExistingProxies
protected List<String> removeExistingProxies(Document doc, Document folder)
Remove proxies for the same base document in the folder. doc may be a normal document or a proxy.
-
updateExistingProxies
protected DocumentModel updateExistingProxies(Document doc, Document folder, Document target)
Update the proxy for doc in the given section to point to the new target. Do nothing if there are several proxies.- Returns:
- the proxy if it was updated, or
nullif none or several were found
-
getProxies
public DocumentModelList getProxies(DocumentRef docRef, DocumentRef folderRef)
Description copied from interface:CoreSessionFinds the proxies for a document. If the parent is not null, the search will be limited to its direct children.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.
- Specified by:
getProxiesin interfaceCoreSession- Parameters:
docRef- the target document for the proxiesfolderRef- the folder where proxies are located ornull- Returns:
- the list of the proxies. An empty list is returned if no proxy are found
-
getAvailableSecurityPermissions
public List<String> getAvailableSecurityPermissions()
Description copied from interface:CoreSessionRetrieves the available security permissions existing in the system.- Specified by:
getAvailableSecurityPermissionsin interfaceCoreSession- Returns:
- a raw list of permission names, either basic or group names
-
getDataModel
public DataModel getDataModel(DocumentRef docRef, Schema schema)
Description copied from interface:CoreSessionRetrieves a data model given a document reference and a schema.For INTERNAL use by the core.
- Specified by:
getDataModelin interfaceCoreSession
-
getDataModelField
protected Object getDataModelField(DocumentRef docRef, String schema, String field)
-
makeRecord
public void makeRecord(DocumentRef docRef)
Description copied from interface:CoreSessionTurns the document into an enforced record.A record is a document with specific capabilities related to mandatory retention until a given date, and legal holds. In addition, its main blob receives special treatment from the document blob manager to make sure it's never shared with another blob at the storage level, and is deleted as soon as the record is deleted.
If the document is already a record, this method has no effect.
The permission "MakeRecord" is required.
- Specified by:
makeRecordin interfaceCoreSession- Parameters:
docRef- the document- See Also:
CoreSession.isRecord(org.nuxeo.ecm.core.api.DocumentRef)
-
makeFlexibleRecord
public void makeFlexibleRecord(DocumentRef docRef)
Description copied from interface:CoreSessionTurns the document into a flexible record.A record is a document with specific capabilities related to mandatory retention until a given date. Unlike the enforced record, the flexible record blob has no special treatment.
Setting a legal hold (
CoreSession.setLegalHold(DocumentRef, boolean, String)on a flexible record will turn it into an enforced record.If the document is already a flexible record, this method has no effect. It is not allowed to turn an enforced record into a flexible record and an IllegalStateException will be raised.
The permission "MakeRecord" is required.
- Specified by:
makeFlexibleRecordin interfaceCoreSession- Parameters:
docRef- the document- See Also:
CoreSession.isFlexibleRecord(org.nuxeo.ecm.core.api.DocumentRef)
-
makeRecord
protected void makeRecord(DocumentRef docRef, boolean flexible)
-
isRecord
public boolean isRecord(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if the document is a record.- Specified by:
isRecordin interfaceCoreSession- Parameters:
docRef- the document- Returns:
trueif the document is a record,falseotherwise- See Also:
CoreSession.makeRecord(org.nuxeo.ecm.core.api.DocumentRef)
-
isEnforcedRecord
public boolean isEnforcedRecord(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if the document is an enforced record.- Specified by:
isEnforcedRecordin interfaceCoreSession- Parameters:
docRef- the document- Returns:
trueif the document is an enforced record,falseotherwise- See Also:
CoreSession.makeRecord(org.nuxeo.ecm.core.api.DocumentRef)
-
isFlexibleRecord
public boolean isFlexibleRecord(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if the document is a flexible record.- Specified by:
isFlexibleRecordin interfaceCoreSession- Parameters:
docRef- the document- Returns:
trueif the document is a flexible record,falseotherwise- See Also:
CoreSession.makeFlexibleRecord(org.nuxeo.ecm.core.api.DocumentRef)
-
getRetainedProperties
public List<String> getRetainedProperties(DocumentRef docRef)
Description copied from interface:CoreSessionGets the retained property xpaths of this document at the time it became a record.- Specified by:
getRetainedPropertiesin interfaceCoreSession- Returns:
- the retained properties
-
setRetainUntil
public void setRetainUntil(DocumentRef docRef, Calendar retainUntil, String comment) throws PropertyException
Description copied from interface:CoreSessionSets the retention date on the document (a record).If no previous retention date was set, or if the previous retention date was indeterminate, or if the previous retention date was before the given value, then the retention date is set to the given value.
If the previous retention date was after the given value (that is, if trying to reduce the retention time), an exception is thrown.
If the given value is
nulland the previous retention date is in the past (it has already expired), then the retention date is set tonull.The permission "SetRetention" is required.
- Specified by:
setRetainUntilin interfaceCoreSession- Parameters:
docRef- the document (a record)retainUntil- the new retention datecomment- an optional comment passed to the associated events- Throws:
PropertyException- if trying to reduce the retention time, or if the document is not a record- See Also:
CoreSession.getRetainUntil(org.nuxeo.ecm.core.api.DocumentRef),CoreSession.RETAIN_UNTIL_INDETERMINATE
-
unsetRetainUntil
public void unsetRetainUntil(DocumentRef docRef) throws PropertyException
Description copied from interface:CoreSessionRemoves the retainUntil date, this operation is allowed only for a flexible record.- Specified by:
unsetRetainUntilin interfaceCoreSession- Parameters:
docRef- the document (a flexible record)- Throws:
PropertyException- if the document is not a flexible record
-
getRetainUntil
public Calendar getRetainUntil(DocumentRef docRef)
Description copied from interface:CoreSessionGets the retention date for the document.- Specified by:
getRetainUntilin interfaceCoreSession- Parameters:
docRef- the document- Returns:
- the retention date, or "SetRetention" for a
retention in the indeterminate future, or
nullif there is no retention date - See Also:
CoreSession.setRetainUntil(org.nuxeo.ecm.core.api.DocumentRef, java.util.Calendar, java.lang.String),CoreSession.RETAIN_UNTIL_INDETERMINATE
-
setLegalHold
public void setLegalHold(DocumentRef docRef, boolean hold, String comment)
Description copied from interface:CoreSessionSets or removes the legal hold on the document (a record).Setting a legal hold on a flexible record will turn it into an enforced record. It will remain enforced even after unsetting the legal hold.
The permission "ManageLegalHold" is required.
- Specified by:
setLegalHoldin interfaceCoreSession- Parameters:
docRef- the document (a record)hold-trueto set a legal hold,falseto remove itcomment- an optional comment passed to the associated events- See Also:
CoreSession.hasLegalHold(org.nuxeo.ecm.core.api.DocumentRef)
-
hasLegalHold
public boolean hasLegalHold(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if the document has a legal hold set.- Specified by:
hasLegalHoldin interfaceCoreSession- Parameters:
docRef- the document- Returns:
trueif a legal hold has been set on the document,falseotherwise- See Also:
CoreSession.setLegalHold(org.nuxeo.ecm.core.api.DocumentRef, boolean, java.lang.String)
-
isUnderRetentionOrLegalHold
public boolean isUnderRetentionOrLegalHold(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if the document has a retention date in the future or has a legal hold.- Specified by:
isUnderRetentionOrLegalHoldin interfaceCoreSession- Parameters:
docRef- the document- Returns:
trueif the document has a retention date in the future or if it has a legal hold,falseotherwise- See Also:
CoreSession.getRetainUntil(org.nuxeo.ecm.core.api.DocumentRef),CoreSession.hasLegalHold(org.nuxeo.ecm.core.api.DocumentRef)
-
isRetentionActive
public boolean isRetentionActive(DocumentRef docRef)
Description copied from interface:CoreSessionChecks whether a document is under active retention.- Specified by:
isRetentionActivein interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
trueif the document is under active retention
-
setRetentionActive
public void setRetentionActive(DocumentRef docRef, boolean retentionActive)
Description copied from interface:CoreSessionSets or unsets a document as under active retention.- Specified by:
setRetentionActivein interfaceCoreSession- Parameters:
docRef- the document referenceretentionActive- whether the retention should be set or unset as active
-
isTrashed
public boolean isTrashed(DocumentRef docRef)
Description copied from interface:CoreSessionChecks if this document is in the trash.- Specified by:
isTrashedin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- true if the document is in the trash, false otherwise.
-
getCurrentLifeCycleState
public String getCurrentLifeCycleState(DocumentRef docRef)
Description copied from interface:CoreSessionReturns the life cycle of the document.- Specified by:
getCurrentLifeCycleStatein interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the life cycle as a string
-
getLifeCyclePolicy
public String getLifeCyclePolicy(DocumentRef docRef)
Description copied from interface:CoreSessionReturns the life cycle policy of the document.- Specified by:
getLifeCyclePolicyin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the life cycle policy
-
followTransition
public boolean followTransition(DocumentModel docModel, String transition) throws LifeCycleException
Description copied from interface:CoreSessionFollows a given life cycle transition.This will update the current life cycle of the document.
- Specified by:
followTransitionin interfaceCoreSession- Parameters:
docModel- the document modeltransition- the name of the transition to follow- Returns:
- a boolean representing the status if the operation
- Throws:
LifeCycleException- if the transition cannot be followed
-
followTransition
public boolean followTransition(DocumentRef docRef, String transition) throws LifeCycleException
Description copied from interface:CoreSessionFollows a given life cycle transition.This will update the current life cycle of the document.
- Specified by:
followTransitionin interfaceCoreSession- Parameters:
docRef- the document referencetransition- the name of the transition to follow- Returns:
- a boolean representing the status if the operation
- Throws:
LifeCycleException- if the transition cannot be followed
-
getAllowedStateTransitions
public Collection<String> getAllowedStateTransitions(DocumentRef docRef)
Description copied from interface:CoreSessionGets the allowed state transitions for this document.- Specified by:
getAllowedStateTransitionsin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- a collection of state transitions as string
-
reinitLifeCycleState
public void reinitLifeCycleState(DocumentRef docRef)
Description copied from interface:CoreSessionReinitializes the life cycle state of the document to its default state.- Specified by:
reinitLifeCycleStatein interfaceCoreSession- Parameters:
docRef- the document
-
getDataModelsField
public Object[] getDataModelsField(DocumentRef[] docRefs, String schema, String field)
Description copied from interface:CoreSessionRetrieves the given field value from the given schema for all the given documents.- Specified by:
getDataModelsFieldin interfaceCoreSession- Parameters:
docRefs- the document referencesschema- the schemafield- the field name- Returns:
- the field values in the same order as the given docRefs
-
getParentDocumentRefs
public DocumentRef[] getParentDocumentRefs(DocumentRef docRef)
Description copied from interface:CoreSessionCreates an array with all parent refs starting from the given document up to the root. So the return value will have [0] = parent ref; [1] = parent parent ref... etc.- Specified by:
getParentDocumentRefsin interfaceCoreSession- Returns:
- an array with ancestor documents ref
-
getDataModelsFieldUp
public Object[] getDataModelsFieldUp(DocumentRef docRef, String schema, String field)
Description copied from interface:CoreSessionRetrieves the given field value from the given schema for the given document along with all its parent documents.- Specified by:
getDataModelsFieldUpin interfaceCoreSession- Parameters:
docRef- the document referenceschema- the schemafield- the field name- Returns:
- an array with field values of all documents on the path from the given document to the root
-
setLock
public Lock setLock(DocumentRef docRef) throws LockException
Description copied from interface:CoreSessionSets a lock on the given document.- Specified by:
setLockin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the lock info that was set
- Throws:
LockException- if the document is already locked by another user
-
getLockInfo
public Lock getLockInfo(DocumentRef docRef)
Description copied from interface:CoreSessionGets the lock info on the given document.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.
- Specified by:
getLockInfoin interfaceCoreSession- Parameters:
docRef- the document reference- Returns:
- the lock info if the document is locked, or
nullotherwise
-
removeLock
public Lock removeLock(DocumentRef docRef) throws LockException
Description copied from interface:CoreSessionRemoves the lock on the given document.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.
- Specified by:
removeLockin interfaceCoreSession- Parameters:
docRef- the document to unlock- Returns:
- the removed lock info, or
nullif there was no lock - Throws:
LockException- if the document is locked by someone else
-
isAdministrator
protected boolean isAdministrator()
-
applyDefaultPermissions
public void applyDefaultPermissions(String userOrGroupName)
Description copied from interface:CoreSessionApplies default Read permissions on root JCR Document for the given user or group name. It can only be called by Administrators.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.
- Specified by:
applyDefaultPermissionsin interfaceCoreSession
-
publishDocument
public DocumentModel publishDocument(DocumentModel docToPublish, DocumentModel section)
Description copied from interface:CoreSessionPublishes the document in a section overwriting any existing proxy to the same document. This is simmilar to publishDocument(docToPublish, section, true);- Specified by:
publishDocumentin interfaceCoreSession- Returns:
- The proxy document that was created
-
publishDocument
public DocumentModel publishDocument(DocumentModel docModel, DocumentModel section, boolean overwriteExistingProxy)
Description copied from interface:CoreSessionPublishes the document in a section.- Specified by:
publishDocumentin interfaceCoreSession- Returns:
- The proxy document that was created
-
getSuperParentType
public String getSuperParentType(DocumentModel doc)
Description copied from interface:CoreSessionReturns the type of his parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.- Specified by:
getSuperParentTypein interfaceCoreSession
-
getSuperSpace
public DocumentModel getSuperSpace(DocumentModel doc)
Description copied from interface:CoreSessionReturns the parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.- Specified by:
getSuperSpacein interfaceCoreSession- Returns:
- DocumentModel of SuperSpace
-
getDocumentSystemProp
public <T extends Serializable> T getDocumentSystemProp(DocumentRef ref, String systemProperty, Class<T> type)
Description copied from interface:CoreSessionGets system property of the specified type for the document ref.- Specified by:
getDocumentSystemPropin interfaceCoreSession
-
setDocumentSystemProp
public <T extends Serializable> void setDocumentSystemProp(DocumentRef ref, String systemProperty, T value)
Description copied from interface:CoreSessionSets given value as a system property.- Specified by:
setDocumentSystemPropin interfaceCoreSession
-
getChangeToken
public String getChangeToken(DocumentRef ref)
Description copied from interface:CoreSessionGets the current change token for the document.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 throughdoc.putContextData(CoreSession.CHANGE_TOKEN, expectedChangeToken). If the change token does not match the stored one, it means that a concurrent update happened, and aConcurrentUpdateExceptionwill be thrown.- Specified by:
getChangeTokenin interfaceCoreSession- Parameters:
ref- the document reference- Returns:
- the change token
- See Also:
DocumentModel.putContextData(java.lang.String, java.io.Serializable),CoreSession.CHANGE_TOKEN,CoreSession.getChangeToken(org.nuxeo.ecm.core.api.DocumentRef)
-
orderBefore
public void orderBefore(DocumentRef parent, String src, String dest)
Description copied from interface:CoreSessionGiven a parent document, order the source child before the destination child. The source and destination must be name of child documents of the given parent document. (a document name can be retrieved usingdocModel.getName()) To place the source document at the end of the children list use a null destination node.- Specified by:
orderBeforein interfaceCoreSession- Parameters:
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 list
-
refreshDocument
public DocumentModel.DocumentModelRefresh refreshDocument(DocumentRef ref, int refreshFlags, String[] schemas)
Description copied from interface:CoreSessionInternal method - it is used internally byDocumentModel.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
DocumentModelfor all accepted flags.When the flag
DocumentModel.REFRESH_CONTENT_IF_LOADEDis 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- Specified by:
refreshDocumentin interfaceCoreSession- Parameters:
ref- the document referencerefreshFlags- refresh flags as defined inDocumentModelschemas- the schema names if a partial content refresh is required- Returns:
- a DocumentModelRefresh object
-
getPermissionsToCheck
public String[] getPermissionsToCheck(String permission)
Description copied from interface:CoreSessionProvides the full list of all permissions or groups of permissions that contain the given one (inclusive). It makes the methodorg.nuxeo.ecm.core.security.SecurityService#getPermissionsToCheck(String)available remotely.- Specified by:
getPermissionsToCheckin interfaceCoreSession- Returns:
- the list, as an array of strings.
-
adaptFirstMatchingDocumentWithFacet
public <T extends DetachedAdapter> T adaptFirstMatchingDocumentWithFacet(DocumentRef docRef, String facet, Class<T> adapterClass)
Description copied from interface:CoreSessionFind the first parent with the givenfacetand adapt it on theadapterClass.This method does not check the permissions on the document to be adapted of this
CoreSession'sPrincipal, and so the adapter must not need other schemas from theDocumentModelexcept the schemas related to the given facet.- Specified by:
adaptFirstMatchingDocumentWithFacetin interfaceCoreSession- Returns:
- the first parent with the given
facetadapted, ornullif no parent found or the document does not support the givenadapterClass.
-
loadDataModelsForFacet
protected void loadDataModelsForFacet(DocumentModel docModel, Document doc, String facetName)
-
getFirstParentDocumentWithFacet
protected Document getFirstParentDocumentWithFacet(DocumentRef docRef, String facet)
Returns the firstDocumentwith the givenfacet, recursively going up the parent hierarchy. Returnsnullif there is no more parent.This method does not check security rights.
-
getBinaryFulltext
public Map<String,String> getBinaryFulltext(DocumentRef ref)
Description copied from interface:CoreSessionGets the fulltext extracted from the binary fields. We defined a new API for that to avoid to store in the cache the fulltext properties which could be huge. This method handle if document is a proxy or not. Historically, VCS doesn't store fulltext properties for proxies (note that DBS does).- Specified by:
getBinaryFulltextin interfaceCoreSession- Parameters:
ref- the document reference- Returns:
- the fulltext map or
nullif not supported.
-
getOrCreateDocument
public DocumentModel getOrCreateDocument(DocumentModel docModel)
Description copied from interface:CoreSessionGets a document if it exists, otherwise creates it. This is done atomically to prevent different threads from trying to create the same document. If the document did not exist and is therefore created, the current transaction is committed and the newly-created document is also committed in its own transaction.WARNING: As the current transaction is impacted, using this method instead of
CoreSession.createDocument(DocumentModel)could lead to inconsistent behaviour in case of rollback.- Specified by:
getOrCreateDocumentin interfaceCoreSession- Parameters:
docModel- the document model- Returns:
- the existing or created document
-
getOrCreateDocument
public DocumentModel getOrCreateDocument(DocumentModel docModel, Function<DocumentModel,DocumentModel> postCreate)
Description copied from interface:CoreSessionGets a document if it exists, otherwise creates it. This is done atomically to prevent different threads from trying to create the same document. If the document did not exist and is therefore created, the current transaction is committed and the newly-created document is also committed in its own transaction.WARNING: As the current transaction is impacted, using this method instead of
CoreSession.createDocument(DocumentModel)could lead to inconsistent behaviour in case of rollback.- Specified by:
getOrCreateDocumentin interfaceCoreSession- Parameters:
docModel- the document modelpostCreate- the function to apply after creating the document- Returns:
- the existing or created document
-
newDocumentModel
public DocumentModel newDocumentModel(DocumentRef parentRef, String name, String typeName)
Description copied from interface:CoreSessionCreates a new document model using required information.Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATEDso that core event listener can initialize its content with computed properties.- Specified by:
newDocumentModelin interfaceCoreSession- Parameters:
parentRef- the parent document refDocumentRefname- The destination nametypeName- the type name- Returns:
- the initial document model
-
computeKeyForAtomicCreation
protected String computeKeyForAtomicCreation(DocumentModel docModel)
-
replaceBlobDigest
public String replaceBlobDigest(DocumentRef docRef, String key, String newKey, String newDigest)
Description copied from interface:CoreSessionVisits the blobs of a document and, for those with a matching key, replace their key and digest with new ones.- Specified by:
replaceBlobDigestin interfaceCoreSession- Parameters:
docRef- the document referencekey- the bob key to look fornewKey- the new keynewDigest- the new digest- Returns:
- the old digest if at least one replacement was done,
nullotherwise
-
-