public interface CoreSession
The session is opened and closed by a client and gives the client the possibility to interact with the core.
The core a session connects to can be located in a separate (remote) JVM or in the current one.
To create remote or local sessions, you need to use a specific
CoreSessionFactory
object. These objects are usually specified using
extension points but you can also use them programatically.
DocumentModel
,
DocumentRef
Modifier and Type | Field and Description |
---|---|
static String |
IMPORT_BASE_VERSION_ID |
static String |
IMPORT_CHECKED_IN |
static String |
IMPORT_IS_VERSION |
static String |
IMPORT_LIFECYCLE_POLICY |
static String |
IMPORT_LIFECYCLE_STATE |
static String |
IMPORT_LOCK
Deprecated.
since 5.4.2, use
IMPORT_LOCK_OWNER and
IMPORT_LOCK_CREATED instead |
static String |
IMPORT_LOCK_CREATED
Lock creation time as a Calendar object.
|
static String |
IMPORT_LOCK_OWNER |
static String |
IMPORT_PROXY_TARGET_ID |
static String |
IMPORT_PROXY_TYPE
The document type to use to create a proxy by import.
|
static String |
IMPORT_PROXY_VERSIONABLE_ID |
static String |
IMPORT_VERSION_CREATED |
static String |
IMPORT_VERSION_DESCRIPTION |
static String |
IMPORT_VERSION_IS_LATEST |
static String |
IMPORT_VERSION_IS_LATEST_MAJOR |
static String |
IMPORT_VERSION_LABEL |
static String |
IMPORT_VERSION_MAJOR |
static String |
IMPORT_VERSION_MINOR |
static String |
IMPORT_VERSION_VERSIONABLE_ID |
Modifier and Type | Method and Description |
---|---|
<T extends DetachedAdapter> |
adaptFirstMatchingDocumentWithFacet(DocumentRef docRef,
String facet,
Class<T> adapterClass)
Find the first parent with the given
facet and adapt it on the
adapterClass . |
void |
afterBegin()
The container calls this when this session sees a transaction begin.
|
void |
afterCompletion(boolean committed)
The container calls this when this session sees a transaction
commit/rollback.
|
void |
applyDefaultPermissions(String userOrGroupName)
Applies default Read permissions on root JCR Document for the given user
or group name.
|
void |
beforeCompletion()
The container calls this when this session is about to see a transaction
completion.
|
void |
cancel()
Cancels any pending change made through this session.
|
boolean |
canRemoveDocument(DocumentRef docRef)
Check if a document can be removed.
|
DocumentRef |
checkIn(DocumentRef docRef,
VersioningOption option,
String checkinComment)
Checks in a modified document, creating a new version.
|
DocumentModel |
checkIn(DocumentRef docRef,
VersionModel version)
Deprecated.
use
#checkIn(DocumentRef, String) instead |
void |
checkOut(DocumentRef docRef)
Checks out a versioned document.
|
String |
connect(String repositoryUri,
Map<String,Serializable> context)
Connects to the repository given its URI.
|
DocumentModel |
copy(DocumentRef src,
DocumentRef dst,
String name)
Copies the source document to the destination folder under the given
name.
|
DocumentModel |
copy(DocumentRef src,
DocumentRef dst,
String name,
boolean resetLifeCycle)
Copies the source document to the destination folder under the given
name.
|
List<DocumentModel> |
copy(List<DocumentRef> src,
DocumentRef dst)
Bulk copy.
|
List<DocumentModel> |
copy(List<DocumentRef> src,
DocumentRef dst,
boolean resetLifeCycle)
Bulk copy.
|
DocumentModel |
copyProxyAsDocument(DocumentRef src,
DocumentRef dst,
String name)
Work like copy but in the case of a source proxy the destination will be
a new document instead of a proxy.
|
DocumentModel |
copyProxyAsDocument(DocumentRef src,
DocumentRef dst,
String name,
boolean resetLifeCycle)
Work like copy but in the case of a source proxy the destination will be
a new document instead of a proxy.
|
List<DocumentModel> |
copyProxyAsDocument(List<DocumentRef> src,
DocumentRef dst)
Bulk copyProxyAsDocument.
|
List<DocumentModel> |
copyProxyAsDocument(List<DocumentRef> src,
DocumentRef dst,
boolean resetLifeCycle)
Bulk copyProxyAsDocument.
|
DocumentModel |
createDocument(DocumentModel model)
Creates a document using given document model for initialization.
|
DocumentModel[] |
createDocument(DocumentModel[] docModels)
Bulk creation of documents.
|
DocumentModel |
createDocumentModel(String typeName)
Creates a document model using type name.
|
DocumentModel |
createDocumentModel(String typeName,
Map<String,Object> options)
Creates a document model using required information.
|
DocumentModel |
createDocumentModel(String parentPath,
String id,
String typeName)
Creates a document model using required information.
|
DocumentModel |
createProxy(DocumentRef docRef,
DocumentRef folderRef)
Creates a generic proxy to the given document inside the given folder.
|
void |
destroy()
Destroys any system resources held by this instance.
|
void |
disconnect()
Closes the current session and disconnects from the repository.
|
boolean |
exists(DocumentRef docRef)
Tests if the document pointed by the given reference exists and is
accessible.
|
boolean |
followTransition(DocumentRef docRef,
String transition)
Follows a given life cycle transition.
|
ACP |
getACP(DocumentRef docRef)
Gets the document access control policy.
|
Collection<String> |
getAllowedStateTransitions(DocumentRef docRef)
Gets the allowed state transitions for this document.
|
List<String> |
getAvailableSecurityPermissions()
Retrieves the available security permissions existing in the system.
|
DocumentRef |
getBaseVersion(DocumentRef docRef)
Gets the version to which a checked in document is linked.
|
DocumentModel |
getChild(DocumentRef parent,
String name)
Gets a child document given its name and the parent reference.
|
DocumentModelList |
getChildren(DocumentRef parent)
Gets the children of the given parent.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type)
Gets the children of the given parent filtered according to the given
document type.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type,
Filter filter,
Sorter sorter)
Same as
getChildren(DocumentRef, String, String, Filter, Sorter)
without specific permission filtering. |
DocumentModelList |
getChildren(DocumentRef parent,
String type,
String perm)
Gets the children of the given parent filtered according to the given
document type and permission.
|
DocumentModelList |
getChildren(DocumentRef parent,
String type,
String perm,
Filter filter,
Sorter sorter)
Same as
getChildren(DocumentRef, String, String) but the result
is filtered and then sorted using the specified filter and sorter. |
DocumentModelIterator |
getChildrenIterator(DocumentRef parent)
Gets an iterator to the children of the given parent.
|
DocumentModelIterator |
getChildrenIterator(DocumentRef parent,
String type)
Deprecated.
since 5.6, use
getChildren(org.nuxeo.ecm.core.api.DocumentRef) instead |
DocumentModelIterator |
getChildrenIterator(DocumentRef parent,
String type,
String perm,
Filter filter)
Gets the children of the given parent filtered according to the given
document type and permission.
|
List<DocumentRef> |
getChildrenRefs(DocumentRef parentRef,
String perm)
Gets the references of the children.
|
SerializableInputStream |
getContentData(String key)
Gets the data input stream given its key.
|
String |
getCurrentLifeCycleState(DocumentRef docRef)
Returns the life cycle of the document.
|
DataModel |
getDataModel(DocumentRef docRef,
Schema schema)
Retrieves a data model given a document reference and a schema.
|
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.
|
DocumentModelsChunk |
getDocsResultChunk(DocsQueryProviderDef def,
String type,
String perm,
Filter filter,
int start,
int count)
Method used internally to retrieve frames of a long result.
|
DocumentModel |
getDocument(DocumentRef docRef)
Gets a document model given its reference.
|
DocumentModelList |
getDocuments(DocumentRef[] docRefs)
Gets a list of documents given their references.
|
<T extends Serializable> |
getDocumentSystemProp(DocumentRef ref,
String systemProperty,
Class<T> type)
Gets system property of the specified type for the document ref.
|
DocumentType |
getDocumentType(String type)
Gets the document type object given its type name.
|
DocumentModel |
getDocumentWithVersion(DocumentRef docRef,
VersionModel version)
Returns a document that represents the specified version of the document.
|
DocumentModelList |
getFiles(DocumentRef parent)
Same as
getChildren(DocumentRef) but returns only
non-folder documents. |
DocumentModelList |
getFiles(DocumentRef parent,
Filter filter,
Sorter sorter)
Same as
getFiles(org.nuxeo.ecm.core.api.DocumentRef) but uses an optional filter and sorter on the
result. |
DocumentModelIterator |
getFilesIterator(DocumentRef parent)
Deprecated.
unused since 5.6, use
getFiles(org.nuxeo.ecm.core.api.DocumentRef) instead |
DocumentModelList |
getFolders(DocumentRef parent)
Same as
getChildren(DocumentRef) but returns only
folder documents. |
DocumentModelList |
getFolders(DocumentRef parent,
Filter filter,
Sorter sorter)
Same as
getFolders(DocumentRef) but uses an optional
filter and sorter on the result. |
DocumentModelIterator |
getFoldersIterator(DocumentRef parent)
Deprecated.
unused since 5.6, use
getFolders(org.nuxeo.ecm.core.api.DocumentRef) instead |
DocumentModel |
getLastDocumentVersion(DocumentRef docRef)
Gets the document corresponding to the last version for the given
document.
|
DocumentRef |
getLastDocumentVersionRef(DocumentRef docRef)
Gets the document reference corresponding to the last version for the
given document.
|
VersionModel |
getLastVersion(DocumentRef docRef)
Deprecated.
|
String |
getLifeCyclePolicy(DocumentRef docRef)
Returns the life cycle policy of the document.
|
String |
getLock(DocumentRef doc)
Deprecated.
since 5.4.2, use
getLockInfo(org.nuxeo.ecm.core.api.DocumentRef) instead |
Lock |
getLockInfo(DocumentRef docRef)
Gets the lock info on the given document.
|
DocumentModel |
getParentDocument(DocumentRef docRef)
Gets the parent document or null if this is the root document.
|
DocumentRef |
getParentDocumentRef(DocumentRef docRef)
Returns the parent ref of the document referenced by
docRef or
null if this is the root document. |
DocumentRef[] |
getParentDocumentRefs(DocumentRef docRef)
Creates an array with all parent refs starting from the given document up
to the root.
|
List<DocumentModel> |
getParentDocuments(DocumentRef docRef)
Gets the parent documents in path from the root to the given document or
empty list if this is the root document.
|
String[] |
getPermissionsToCheck(String permission)
Provides the full list of all permissions or groups of permissions that
contain the given one (inclusive).
|
Principal |
getPrincipal()
Gets the principal that created the client session.
|
DocumentModelList |
getProxies(DocumentRef docRef,
DocumentRef folderRef)
Finds the proxies for a document.
|
String[] |
getProxyVersions(DocumentRef docRef,
DocumentRef folderRef)
Deprecated.
since 5.4, use
getProxies(org.nuxeo.ecm.core.api.DocumentRef, org.nuxeo.ecm.core.api.DocumentRef) instead |
String |
getRepositoryName()
Returns the repository name against which this core session is bound.
|
DocumentModel |
getRootDocument()
Gets the root document of this repository.
|
List<SecuritySummaryEntry> |
getSecuritySummary(DocumentModel docModel,
Boolean includeParents)
Returns security descriptors of doc and all it's children that hold
explicit security.
|
String |
getSessionId()
Gets the current session id.
|
DocumentModel |
getSourceDocument(DocumentRef docRef)
Gets the head (live) document for this document.
|
String |
getStreamURI(String blobPropertyId)
Returns an URI identifying the stream given the blob property id.
|
String |
getSuperParentType(DocumentModel doc)
Returns the type of his parent SuperSpace (workspace, section, etc.).
|
DocumentModel |
getSuperSpace(DocumentModel doc)
Returns the parent SuperSpace (workspace, section, etc.).
|
DocumentModel |
getVersion(String versionableId,
VersionModel versionModel)
Deprecated.
use version ids directly
|
String |
getVersionLabel(DocumentModel docModel)
Gets the version label for a document, according to the versioning
service.
|
List<DocumentModel> |
getVersions(DocumentRef docRef)
Retrieves all the versions for a specified document.
|
String |
getVersionSeriesId(DocumentRef docRef)
Gets the version series id for a document.
|
List<VersionModel> |
getVersionsForDocument(DocumentRef docRef)
Retrieves all the versions for a specified document.
|
List<DocumentRef> |
getVersionsRefs(DocumentRef docRef)
Gets the references of the versions of the document.
|
DocumentModel |
getWorkingCopy(DocumentRef docRef)
Gets the working copy (live document) for a proxy or a version.
|
boolean |
hasChildren(DocumentRef docRef)
Tests if the document has any children.
|
boolean |
hasPermission(DocumentRef docRef,
String permission)
Checks if the principal that created the client session has the given
privilege on the referred document.
|
boolean |
hasPermission(Principal principal,
DocumentRef docRef,
String permission)
Checks if a given principal has the given privilege on the referred
document.
|
void |
importDocuments(List<DocumentModel> docModels)
Low-level import of documents, reserved for the administrator.
|
boolean |
isCheckedOut(DocumentRef docRef)
Returns whether the current document is checked-out or not.
|
boolean |
isDirty(DocumentRef doc)
Deprecated.
since 5.4, use
isCheckedOut(org.nuxeo.ecm.core.api.DocumentRef) instead |
boolean |
isStateSharedByAllThreadSessions()
Returns
true if all sessions in the current thread share the same
state. |
DocumentModel |
move(DocumentRef src,
DocumentRef dst,
String name)
Moves the source document to the destination folder under the given name.
|
void |
move(List<DocumentRef> src,
DocumentRef dst)
Bulk move.
|
void |
orderBefore(DocumentRef parent,
String src,
String dest)
Given a parent document, order the source child before the destination
child.
|
DocumentModel |
publishDocument(DocumentModel docToPublish,
DocumentModel section)
Publishes the document in a section overwriting any existing proxy to the
same document.
|
DocumentModel |
publishDocument(DocumentModel docToPublish,
DocumentModel section,
boolean overwriteExistingProxy)
Publishes the document in a section.
|
DocumentModelList |
query(String query)
Executes the given NXQL query an returns the result.
|
DocumentModelList |
query(String query,
Filter filter)
Executes the given NXQL query and returns the result that matches the
filter.
|
DocumentModelList |
query(String query,
Filter filter,
int max)
Executes the given NXQL query and returns the result that matches the
filter.
|
DocumentModelList |
query(String query,
Filter filter,
long limit,
long offset,
boolean countTotal)
Executes the given NXQL query and returns the result that matches the
filter.
|
DocumentModelList |
query(String query,
Filter filter,
long limit,
long offset,
long countUpTo)
Executes the given NXQL query and returns the result that matches the
filter.
|
DocumentModelList |
query(String query,
int max)
Executes the given NXQL query an returns the result.
|
DocumentModelList |
query(String query,
String queryType,
Filter filter,
long limit,
long offset,
boolean countTotal)
Executes the given query and returns the result that matches the filter.
|
DocumentModelList |
query(String query,
String queryType,
Filter filter,
long limit,
long offset,
long countUpTo)
Executes the given query and returns the result that matches the filter.
|
IterableQueryResult |
queryAndFetch(String query,
String queryType,
Object... params) |
DocumentModelIterator |
queryIt(String query,
Filter filter,
int max)
Deprecated.
unused since 5.6
|
DocumentModel.DocumentModelRefresh |
refreshDocument(DocumentRef ref,
int refreshFlags,
String[] schemas)
Internal method - it is used internally by
DocumentModel.refresh() |
void |
reinitLifeCycleState(DocumentRef docRef)
Reinitializes the life cycle state of the document to its default state.
|
void |
removeChildren(DocumentRef docRef)
Removes all children from the given document.
|
void |
removeDocument(DocumentRef docRef)
Removes this document and all its children, if any.
|
void |
removeDocuments(DocumentRef[] docRefs)
Bulk method to remove documents.
|
Lock |
removeLock(DocumentRef docRef)
Removes the lock on the given document.
|
DocumentModel |
restoreToVersion(DocumentRef docRef,
DocumentRef versionRef)
Restores the given document to the specified version.
|
DocumentModel |
restoreToVersion(DocumentRef docRef,
DocumentRef versionRef,
boolean skipSnapshotCreation,
boolean skipCheckout)
Restores the given document to the specified version.
|
DocumentModel |
restoreToVersion(DocumentRef docRef,
VersionModel version)
Deprecated.
use
restoreToVersion(DocumentRef, DocumentRef)
instead |
DocumentModel |
restoreToVersion(DocumentRef docRef,
VersionModel version,
boolean skipSnapshotCreation)
Deprecated.
|
<T> T |
run(Operation<T> cmd)
Run a command
|
<T> T |
run(Operation<T> op,
ProgressMonitor monitor)
Run a command and notify the given monitor about the execution progress
|
void |
save()
Saves any pending changes done until now through this session.
|
DocumentModel |
saveDocument(DocumentModel docModel)
Saves changes done on the given document model.
|
void |
saveDocuments(DocumentModel[] docModels)
Bulk document saving.
|
void |
setACP(DocumentRef docRef,
ACP acp,
boolean overwrite)
Sets the ACP for this document.
|
<T extends Serializable> |
setDocumentSystemProp(DocumentRef ref,
String systemProperty,
T value)
Sets given value as a system property.
|
Lock |
setLock(DocumentRef docRef)
Sets a lock on the given document.
|
void |
setLock(DocumentRef doc,
String key)
Deprecated.
since 5.4.2, use
setLock(DocumentRef) instead |
boolean |
supportsTags()
Indicates if the current repository implementation supports tags.
|
boolean |
supportsTags(String repositoryName)
Indicates if implementation of the given repositoryName supports Tags
feature
|
String |
unlock(DocumentRef docRef)
Deprecated.
since 5.4.2, use
removeLock(org.nuxeo.ecm.core.api.DocumentRef) instead |
static final String IMPORT_VERSION_VERSIONABLE_ID
static final String IMPORT_VERSION_CREATED
static final String IMPORT_VERSION_LABEL
static final String IMPORT_VERSION_DESCRIPTION
static final String IMPORT_VERSION_IS_LATEST
static final String IMPORT_VERSION_IS_LATEST_MAJOR
static final String IMPORT_IS_VERSION
static final String IMPORT_VERSION_MAJOR
static final String IMPORT_VERSION_MINOR
static final String IMPORT_PROXY_TARGET_ID
static final String IMPORT_PROXY_VERSIONABLE_ID
static final String IMPORT_LIFECYCLE_POLICY
static final String IMPORT_LIFECYCLE_STATE
@Deprecated static final String IMPORT_LOCK
static final String IMPORT_LOCK_OWNER
static final String IMPORT_LOCK_CREATED
static final String IMPORT_CHECKED_IN
static final String IMPORT_BASE_VERSION_ID
static final String IMPORT_PROXY_TYPE
void afterBegin()
void beforeCompletion()
void afterCompletion(boolean committed)
DocumentType getDocumentType(String type)
type
- the document type nameString connect(String repositoryUri, Map<String,Serializable> context) throws ClientException
This method must never be called by users. Is is indirectly called
from CoreInstance.open(String, Map)
when creating the client.
repositoryUri
- the repository URI (unique in the platform)context
- a map of properties used to initialize the session. Can be
null if no context properties are specified.ClientException
void disconnect() throws ClientException
This method must never be called by users. Is is indirectly called
from CoreInstance.close(CoreSession)
when closing the client
All pending change made on the repository through this session are saved.
ClientException
void cancel() throws ClientException
ClientException
void save() throws ClientException
ClientException
String getSessionId()
If the client is not connected returns null.
boolean isStateSharedByAllThreadSessions()
true
if all sessions in the current thread share the same
state.Principal getPrincipal()
boolean hasPermission(DocumentRef docRef, String permission) throws ClientException
docRef
- permission
- ClientException
boolean hasPermission(Principal principal, DocumentRef docRef, String permission) throws ClientException
principal
- docRef
- permission
- ClientException
DocumentModel getRootDocument() throws ClientException
ClientException
SecurityException
@NoRollbackOnException DocumentModel getDocument(DocumentRef docRef) throws ClientException
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.
docRef
- the document referenceClientException
SecurityException
@NoRollbackOnException DocumentModelList getDocuments(DocumentRef[] docRefs) throws ClientException
Documents that are not accessible are skipped.
ClientException
DocumentModel getChild(DocumentRef parent, String name) throws ClientException
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.
parent
- the reference to the parent documentname
- the name of the child document to retrieveClientException
- if there is no child with the given name@NoRollbackOnException DocumentModelList getChildren(DocumentRef parent) throws ClientException
parent
- the parent referenceClientException
DocumentModelIterator getChildrenIterator(DocumentRef parent) throws ClientException
parent
- the parent referenceClientException
@NoRollbackOnException DocumentModelList getChildren(DocumentRef parent, String type) throws ClientException
parent
- the parent referencetype
- the wanted document typeClientException
@Deprecated DocumentModelIterator getChildrenIterator(DocumentRef parent, String type) throws ClientException
getChildren(org.nuxeo.ecm.core.api.DocumentRef)
insteadClientException
@NoRollbackOnException DocumentModelList getChildren(DocumentRef parent, String type, String perm) throws ClientException
parent
- the parent referencetype
- the wanted document typetype
- the permission the user must haveClientException
@NoRollbackOnException DocumentModelList getChildren(DocumentRef parent, String type, String perm, Filter filter, Sorter sorter) throws ClientException
getChildren(DocumentRef, String, String)
but the result
is filtered and then sorted using the specified filter and sorter.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 otherwiseClientException
List<DocumentRef> getChildrenRefs(DocumentRef parentRef, String perm) throws ClientException
parentRef
- the parent referenceperm
- the permission to check on the children (usually READ); if
null, no permission is checkedClientException
DocumentModelsChunk getDocsResultChunk(DocsQueryProviderDef def, String type, String perm, Filter filter, int start, int count) throws ClientException
def
- type
- perm
- filter
- start
- count
- ClientException
DocumentModelIterator getChildrenIterator(DocumentRef parent, String type, String perm, Filter filter) throws ClientException
parent
- type
- perm
- filter
- ClientException
DocumentModelList getChildren(DocumentRef parent, String type, Filter filter, Sorter sorter) throws ClientException
getChildren(DocumentRef, String, String, Filter, Sorter)
without specific permission filtering.parent
- the parent referencetype
- the wanted typefilter
- the filter to use if any, null otherwisesorter
- the sorter to use if any, null otherwiseClientException
DocumentModelList getFolders(DocumentRef parent) throws ClientException
getChildren(DocumentRef)
but returns only
folder documents.parent
- the parent refClientException
@Deprecated DocumentModelIterator getFoldersIterator(DocumentRef parent) throws ClientException
getFolders(org.nuxeo.ecm.core.api.DocumentRef)
insteadgetFolders(DocumentRef)
but returns a lazy
loading iterator over the list of children.parent
- the parent referenceClientException
DocumentModelList getFolders(DocumentRef parent, Filter filter, Sorter sorter) throws ClientException
getFolders(DocumentRef)
but uses an optional
filter and sorter on the result.parent
- the parent referencefilter
- the filter to use or null if nonesorter
- the sorter to use or null if noneClientException
DocumentModelList getFiles(DocumentRef parent) throws ClientException
getChildren(DocumentRef)
but returns only
non-folder documents.parent
- the parent referenceClientException
@Deprecated DocumentModelIterator getFilesIterator(DocumentRef parent) throws ClientException
getFiles(org.nuxeo.ecm.core.api.DocumentRef)
insteadgetFiles(DocumentRef)
but returns an
iterator.parent
- ClientException
DocumentModelList getFiles(DocumentRef parent, Filter filter, Sorter sorter) throws ClientException
getFiles(org.nuxeo.ecm.core.api.DocumentRef)
but uses an optional filter and sorter on the
result.parent
- the parent referencefilter
- the filter to use or null if nonesorter
- the sorter to use or null if noneClientException
DocumentRef getParentDocumentRef(DocumentRef docRef) throws ClientException
docRef
or
null
if this is the root document.
This method does not check the permissions on the parent document of this
CoreSession
's Principal
.
ClientException
DocumentModel getParentDocument(DocumentRef docRef) throws ClientException
ClientException
List<DocumentModel> getParentDocuments(DocumentRef docRef) throws ClientException
Documents the principal is is not allowed to browse are filtered out the parents list.
ClientException
boolean exists(DocumentRef docRef) throws ClientException
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.
docRef
- the reference to the document to test for existenceClientException
boolean hasChildren(DocumentRef docRef) throws ClientException
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.
docRef
- the reference to the document to testClientException
DocumentModel createDocumentModel(String typeName) throws ClientException
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
typeName
- ClientException
DocumentModel createDocumentModel(String parentPath, String id, String typeName) throws ClientException
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
parentPath
- id
- typeName
- ClientException
DocumentModel createDocumentModel(String typeName, Map<String,Object> options) throws ClientException
Used to fetch initial datamodels from the type definition.
DocumentModel creation notifies a
DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED
so that core event
listener can initialize its content with computed properties.
typeName
- options
- additional contextual data provided to core event
listenersClientException
DocumentModel createDocument(DocumentModel model) throws ClientException
The model contains path of the new document, its type and optionally the initial data models of the document.
model
- the document model to use for initializationClientException
DocumentModel[] createDocument(DocumentModel[] docModels) throws ClientException
docModels
- the document models to use for intializationClientException
void importDocuments(List<DocumentModel> docModels) throws ClientException
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"
):
IMPORT_PROXY_TARGET_ID
and IMPORT_PROXY_VERSIONABLE_ID
.
For a version (no parent): IMPORT_VERSION_VERSIONABLE_ID
,
IMPORT_VERSION_CREATED
, IMPORT_VERSION_LABEL
and
IMPORT_VERSION_DESCRIPTION
.
For a live document: IMPORT_BASE_VERSION_ID
and
IMPORT_CHECKED_IN
(Boolean).
For a live document or a version: IMPORT_LIFECYCLE_POLICY
,
IMPORT_LIFECYCLE_STATE
, IMPORT_VERSION_MAJOR
(Long) and
IMPORT_VERSION_MINOR
(Long).
docModels
- the documents to createClientException
DocumentModel saveDocument(DocumentModel docModel) throws ClientException
docModel
- the document model that needs modifiedClientException
void saveDocuments(DocumentModel[] docModels) throws ClientException
docModels
- the document models that needs to be savedClientException
boolean canRemoveDocument(DocumentRef docRef) throws ClientException
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).
docRef
- the documentClientException
void removeDocument(DocumentRef docRef) throws ClientException
docRef
- the reference to the document to removeClientException
void removeDocuments(DocumentRef[] docRefs) throws ClientException
This method is safe with respect to orderings: it doesn't fail if an ancestor of a document occurs before the document.
docRefs
- the refs to the document to removeClientException
void removeChildren(DocumentRef docRef) throws ClientException
docRef
- the reference to the document to removeClientException
DocumentModel copy(DocumentRef src, DocumentRef dst, String name) throws ClientException
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.
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be
preservedClientException
SecurityException
DocumentModel copy(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle) throws ClientException
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.
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 notClientException
List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst) throws ClientException
src
- the documents to copydst
- the destination folderClientException
SecurityException
List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle) throws ClientException
src
- the documents to copydst
- the destination folderresetLifeCycle
- the property that flagged whether reset destination
document lifecycle or notClientException
DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name) throws ClientException
src
- the source document referencedst
- the destination folder referencename
- the new name of the file or null if the original name must be
preservedClientException
SecurityException
copy(DocumentRef, DocumentRef, String)
DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, boolean resetLifeCycle) throws ClientException
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 notClientException
List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst) throws ClientException
src
- the documents to copydst
- the destination folderClientException
SecurityException
List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst, boolean resetLifeCycle) throws ClientException
src
- the documents to copydst
- the destination folderresetLifeCycle
- the property that flagged whether reset destination
document lifecycle or notClientException
DocumentModel move(DocumentRef src, DocumentRef dst, String name) throws ClientException
null
or if there is a collision, a suitable new
name is found.
If the destination document is not a folder or it doesn't exists then throws an exception.
src
- the source document referencedst
- the destination folder referencename
- the new name of the file, or null
ClientException
SecurityException
void move(List<DocumentRef> src, DocumentRef dst) throws ClientException
src
- the documents to movedst
- the destination folderClientException
SecurityException
ACP getACP(DocumentRef docRef) throws ClientException
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 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.
docRef
- the doc ref to retrieve ACP or null if noneClientException
void setACP(DocumentRef docRef, ACP acp, boolean overwrite) throws ClientException
If the ACP contains an INHERITED
ACL it will be discarded.
Only ACLs relative to the current document may be changed.
If the overwrite
argument is false, the ACP is merged with
the existing one if any. The merge is done as follow:
owners
are specified then they will replace the
existing ones if any. Otherwise the old owners are preserved if any. As
for the ACL if you want to remove existing owners you need to specify an
empty owner array (and not a null one)
overwrite
argument is true, the old ACP will be
replaced by the new one.
This way if you can remove the existing ACP by specifying a null ACP and
overwrite
argument set to true.
Setting a null ACP when overwrite
is false will do nothing.
docRef
- acp
- overwrite
- ClientException
SecurityException
DataModel getDataModel(DocumentRef docRef, Schema schema) throws ClientException
For INTERNAL use by the core.
ClientException
SerializableInputStream getContentData(String key) throws ClientException
The key is implementation-dependent - this can be a property path an ID, etc.
This method is used to lazily fetch blob streams.
key
- ClientException
SecurityException
String getStreamURI(String blobPropertyId) throws ClientException
The blob is fetched from the repository and the blob stream is registered against the streaming service so the stream will be available remotely through stream service API.
After the client has called this method, it will be able to download the stream using streaming server API.
ClientException
@Deprecated VersionModel getLastVersion(DocumentRef docRef) throws ClientException
getLastDocumentVersion(org.nuxeo.ecm.core.api.DocumentRef)
insteaddocRef
- the reference to the documentClientException
- if any error occursDocumentModel getLastDocumentVersion(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
DocumentRef getLastDocumentVersionRef(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
DocumentModel getSourceDocument(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
- if any error occursList<DocumentRef> getVersionsRefs(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
List<DocumentModel> getVersions(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentDocumentModel
representing versions, empty
list if none is found.ClientException
List<VersionModel> getVersionsForDocument(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentVersionModel
representing versions, empty
list if none is found.ClientException
@Deprecated DocumentModel getVersion(String versionableId, VersionModel versionModel) throws ClientException
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.
Restricted to administrators.
versionableId
- the versionable idversionModel
- the version model holding the labelnull
if not foundClientException
String getVersionLabel(DocumentModel docModel) throws ClientException
docModel
- the documentClientException
DocumentModel getDocumentWithVersion(DocumentRef docRef, VersionModel version) throws ClientException
docRef
- the reference to the documentversion
- the version for which we want the corresponding documentClientException
DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef, boolean skipSnapshotCreation, boolean skipCheckout) throws ClientException
docRef
- the reference to the documentversionRef
- the reference to the versionskipSnapshotCreation
- true
if the document should not be
snapshotted before being restoredskipCheckout
- true
if the restored document should be kept
in a checked-in stateClientException
@Deprecated DocumentModel restoreToVersion(DocumentRef docRef, VersionModel version, boolean skipSnapshotCreation) throws ClientException
restoreToVersion(DocumentRef, DocumentRef, boolean, boolean)
insteaddocRef
- the reference to the documentversion
- the version to which the document should be restored to -
only the label is used for the momentskipSnapshotCreation
- indicates if skipping snapshot creationClientException
DocumentModel restoreToVersion(DocumentRef docRef, DocumentRef versionRef) throws ClientException
docRef
- the reference to the documentversionRef
- the reference to the versionClientException
@Deprecated DocumentModel restoreToVersion(DocumentRef docRef, VersionModel version) throws ClientException
restoreToVersion(DocumentRef, DocumentRef)
insteaddocRef
- the reference to the documentversion
- the version to which the document should be restored to -
only the label is used for the momentClientException
DocumentRef getBaseVersion(DocumentRef docRef) throws ClientException
Returns null
for a checked out document or a version or a proxy.
null
ClientException
void checkOut(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
@Deprecated DocumentModel checkIn(DocumentRef docRef, VersionModel version) throws ClientException
#checkIn(DocumentRef, String)
insteaddocRef
- the reference to the documentversion
- the version descriptorClientException
DocumentRef checkIn(DocumentRef docRef, VersioningOption option, String checkinComment) throws ClientException
docRef
- the reference to the documentoption
- whether to do create a new VersioningOption.MINOR
or VersioningOption.MAJOR
version during check incheckinComment
- the checkin commentClientException
boolean isCheckedOut(DocumentRef docRef) throws ClientException
docRef
- the reference to the documentClientException
String getVersionSeriesId(DocumentRef docRef) throws ClientException
All documents and versions derived by a check in or checkout from the same original document share the same version series id.
docRef
- the document referenceClientException
DocumentModel getWorkingCopy(DocumentRef docRef) throws ClientException
docRef
- the document referencenull
if not foundClientException
DocumentModel createProxy(DocumentRef docRef, DocumentRef folderRef) throws ClientException
The document may be a version, or a working copy (live document) in which case the proxy will be a "shortcut".
ClientException
DocumentModelList query(String query) throws ClientException
query
- the query to executeClientException
DocumentModelList query(String query, int max) throws ClientException
query
- the query to executemax
- number of document to retrieveClientException
DocumentModelList query(String query, Filter filter) throws ClientException
query
- the query to executefilter
- the filter to apply to resultClientException
DocumentModelList query(String query, Filter filter, int max) throws ClientException
query
- the query to executefilter
- the filter to apply to resultmax
- number of document to retrieveClientException
DocumentModelList query(String query, Filter filter, long limit, long offset, boolean countTotal) throws ClientException
query
- the query to executefilter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of
themoffset
- the offset (starting at 0) into the list of documentscountTotal
- if true
, return a DocumentModelList
that includes a total size of the underlying list (size if
there was no limit or offset)ClientException
DocumentModelList query(String query, Filter filter, long limit, long offset, long countUpTo) throws ClientException
query
- the query to executefilter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of
themoffset
- the offset (starting at 0) into the list of documentscountUpTo
- if -1
, count the total size without
offset/limit.0
, don't count the total size.n
, count the total number if there are less than n
documents otherwise set the size to -1
.ClientException
DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, boolean countTotal) throws ClientException
query
- the query to executequeryType
- the query type, like "NXQL"filter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of
themoffset
- the offset (starting at 0) into the list of documentscountTotal
- if true
, return a DocumentModelList
that includes a total size of the underlying list (size if
there was no limit or offset)ClientException
DocumentModelList query(String query, String queryType, Filter filter, long limit, long offset, long countUpTo) throws ClientException
query
- the query to executequeryType
- the query type, like "NXQL"filter
- the filter to apply to resultlimit
- the maximum number of documents to retrieve, or 0 for all of
themoffset
- the offset (starting at 0) into the list of documentscountUpTo
- if -1
, return a DocumentModelList
that
includes a total size of the underlying list (size if there
was no limit or offset). 0
, don't return the total size of the underlying
list. n
, return the total size of the underlying list
when the size is smaller than n
else return a total
size of -1
.ClientException
IterableQueryResult queryAndFetch(String query, String queryType, Object... params) throws ClientException
ClientException
@Deprecated DocumentModelIterator queryIt(String query, Filter filter, int max) throws ClientException
query
- the query to executefilter
- the filter to apply to resultmax
- number of document to retrieveClientException
List<String> getAvailableSecurityPermissions() throws ClientException
ClientException
String getCurrentLifeCycleState(DocumentRef docRef) throws ClientException
docRef
- the document referenceClientException
org.nuxeo.ecm.core.lifecycle
String getLifeCyclePolicy(DocumentRef docRef) throws ClientException
docRef
- the document referenceClientException
org.nuxeo.ecm.core.lifecycle
boolean followTransition(DocumentRef docRef, String transition) throws ClientException
This will update the current life cycle of the document.
docRef
- the document referencetransition
- the name of the transition to followClientException
Collection<String> getAllowedStateTransitions(DocumentRef docRef) throws ClientException
docRef
- the document referenceClientException
void reinitLifeCycleState(DocumentRef docRef) throws ClientException
docRef
- the documentClientException
Object[] getDataModelsField(DocumentRef[] docRefs, String schema, String field) throws ClientException
docRefs
- the document referencesschema
- the schemafield
- the field nameClientException
ClientException
DocumentRef[] getParentDocumentRefs(DocumentRef docRef) throws ClientException
docRef
- ClientException
Object[] getDataModelsFieldUp(DocumentRef docRef, String schema, String field) throws ClientException
docRef
- the document referenceschema
- the schemafield
- the field nameClientException
@Deprecated String getLock(DocumentRef doc) throws ClientException
getLockInfo(org.nuxeo.ecm.core.api.DocumentRef)
instead
A lock key has the form someuser:Nov 29, 2010
.
doc
- the document referenceClientException
@Deprecated void setLock(DocumentRef doc, String key) throws ClientException
setLock(DocumentRef)
instead
A lock key must have the form someuser:Nov 29, 2010
.
doc
- the document referencekey
- the lock keyClientException
- if a lock is already set or other exception
occurred@Deprecated String unlock(DocumentRef docRef) throws ClientException
removeLock(org.nuxeo.ecm.core.api.DocumentRef)
insteadThe 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.
docRef
- the document to unlockClientException
Lock setLock(DocumentRef docRef) throws ClientException
doc
- the document referenceClientException
- if a lock was already setLock getLockInfo(DocumentRef docRef) throws ClientException
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.
doc
- the document referencenull
otherwiseClientException
Lock removeLock(DocumentRef docRef) throws ClientException
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.
docRef
- the document to unlocknull
if there was no lockClientException
void applyDefaultPermissions(String userOrGroupName) throws ClientException
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.
userOrGroupName
- ClientException
void destroy()
Called when the instance is no more needed.
@Deprecated boolean isDirty(DocumentRef doc) throws ClientException
isCheckedOut(org.nuxeo.ecm.core.api.DocumentRef)
insteaddoc
- the doc referenceClientException
DocumentModel publishDocument(DocumentModel docToPublish, DocumentModel section) throws ClientException
docToPublish
- section
- ClientException
DocumentModel publishDocument(DocumentModel docToPublish, DocumentModel section, boolean overwriteExistingProxy) throws ClientException
docToPublish
- section
- overwriteExistingProxy
- ClientException
DocumentModelList getProxies(DocumentRef docRef, DocumentRef folderRef) throws ClientException
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.
docRef
- the target document for the proxiesfolderRef
- the folder where proxies are located or null
ClientException
- if any error occurs@Deprecated String[] getProxyVersions(DocumentRef docRef, DocumentRef folderRef) throws ClientException
getProxies(org.nuxeo.ecm.core.api.DocumentRef, org.nuxeo.ecm.core.api.DocumentRef)
insteadIntended to be used by UI clients to display information about proxies in sections.
docRef
- the target document for the proxiesfolderRef
- the folder where proxies are locatednull
is returned if no proxies are
found the specified folderClientException
- if any error occursString getSuperParentType(DocumentModel doc) throws ClientException
doc
- ClientException
DocumentModel getSuperSpace(DocumentModel doc) throws ClientException
doc
- ClientException
List<SecuritySummaryEntry> getSecuritySummary(DocumentModel docModel, Boolean includeParents) throws ClientException
docModel
- the document node from where the security export is doneincludeParents
- flag is the parent nodes holding security
information should be added at the top of the returned listClientException
String getRepositoryName()
<T extends Serializable> T getDocumentSystemProp(DocumentRef ref, String systemProperty, Class<T> type) throws ClientException, DocumentException
T
- ref
- systemProperty
- type
- ClientException
DocumentException
<T extends Serializable> void setDocumentSystemProp(DocumentRef ref, String systemProperty, T value) throws ClientException, DocumentException
T
- ref
- systemProperty
- value
- ClientException
DocumentException
void orderBefore(DocumentRef parent, String src, String dest) throws ClientException
docModel.getName()
) To place the source document at the end
of the children list use a null destination node.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 listClientException
- if the parent document is not an orderable folder
or other error occurs<T> T run(Operation<T> cmd) throws ClientException
T
- command result typecmd
- the command to runClientException
- if any error occurs<T> T run(Operation<T> op, ProgressMonitor monitor) throws ClientException
T
- op
- monitor
- ClientException
DocumentModel.DocumentModelRefresh refreshDocument(DocumentRef ref, int refreshFlags, String[] schemas) throws ClientException
DocumentModel.refresh()
Get fresh data from a document given a description of what kind of data should be refetched.
The refresh information is specified using a bit mask. See
DocumentModel
for all accepted flags.
When the flag DocumentModel.REFRESH_CONTENT_IF_LOADED
is
specified a third argument must be passed representing the schema names
for document parts to refresh. This argument is ignored if the flag is
not specified or no schema names are provided
ref
- the document referencerefreshFlags
- refresh flags as defined in DocumentModel
schemas
- the schema names if a partial content refresh is requiredClientException
String[] getPermissionsToCheck(String permission)
SecurityService.getPermissionsToCheck(java.lang.String)
available remote.permission
- boolean supportsTags(String repositoryName) throws ClientException
repositoryName
- the name of the repository to testClientException
boolean supportsTags() throws ClientException
ClientException
<T extends DetachedAdapter> T adaptFirstMatchingDocumentWithFacet(DocumentRef docRef, String facet, Class<T> adapterClass) throws ClientException
facet
and adapt it on the
adapterClass
.
This method does not check the permissions on the document to be adapted
of this CoreSession
's Principal
, and so the adapter must
not need other schemas from the DocumentModel
except the schemas
related to the given facet.
facet
adapted, or
null
if no parent found or the document does not support
the given adapterClass
.ClientException
Copyright © 2014 Nuxeo SA. All Rights Reserved.