Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api
Interface CoreSession

All Known Subinterfaces:
RepositoryInstance
All Known Implementing Classes:
AbstractSession, LocalSession

public interface CoreSession

A session to the Nuxeo Core.

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.

Author:
Bogdan Stefanescu, Florent Guillaume
See Also:
DocumentModel, DocumentRef

Field Summary
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
           
 
Method Summary
<T extends DetachedAdapter>
T
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.
 List<DocumentModel> copy(List<DocumentRef> src, DocumentRef dst)
          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.
 List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src, DocumentRef dst)
          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.
 DocumentModel createProxy(DocumentRef parentRef, DocumentRef docRef, VersionModel version, boolean overwriteExistingProxy)
          Deprecated. use createProxy(DocumentRef, DocumentRef) or publishDocument(DocumentModel, DocumentModel, boolean) instead
 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.
 String generateVersionLabelFor(DocumentRef docRef)
          Deprecated. use #checkIn(DocumentRef, String) directly
 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)
          Gets an iterator to the children of the given parent filtered according to the given document type.
 DocumentModelIterator getChildrenIterator(DocumentRef parent, String type, String perm, Filter filter)
          Gets the children of the given parent filtered according to the given document type and permission.
 List<DocumentRef> getChildrenRefs(DocumentRef parentRef, String perm)
          Gets the references of the children.
 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.
 DataModel getDataModel(DocumentRef docRef, String schema)
          Deprecated. not used by client code
 Object getDataModelField(DocumentRef docRef, String schema, String field)
          Deprecated. unused
 Object[] getDataModelFields(DocumentRef docRef, String schema, String[] fields)
          Deprecated. unused
 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.
 DocumentModel getDocument(DocumentRef docRef, String[] schemas)
          Deprecated. unused
 DocumentModelList getDocuments(DocumentRef[] docRefs)
          Gets a list of documents given their references.
<T extends Serializable>
T
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)
          Same as getFiles(DocumentRef) but returns an iterator.
 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)
          Same as getFolders(DocumentRef) but returns a lazy loading iterator over the list of children.
 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. use getLastDocumentVersion(org.nuxeo.ecm.core.api.DocumentRef) instead
 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, 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.
 IterableQueryResult queryAndFetch(String query, String queryType, Object... params)
           
 DocumentModelIterator queryIt(String query, Filter filter, int max)
          Executes the given NXQL query and returns an iterators of results.
 DocumentModelList querySimpleFts(String keywords)
          Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html
 DocumentModelList querySimpleFts(String keywords, Filter filter)
          Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html
 DocumentModelIterator querySimpleFtsIt(String query, Filter filter, int pageSize)
          Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html
 DocumentModelIterator querySimpleFtsIt(String query, String startingPath, Filter filter, int pageSize)
          Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html
 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. use restoreToVersion(DocumentRef, DocumentRef, boolean, boolean) instead
<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>
void
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
 

Field Detail

IMPORT_VERSION_VERSIONABLE_ID

static final String IMPORT_VERSION_VERSIONABLE_ID
See Also:
Constant Field Values

IMPORT_VERSION_CREATED

static final String IMPORT_VERSION_CREATED
See Also:
Constant Field Values

IMPORT_VERSION_LABEL

static final String IMPORT_VERSION_LABEL
See Also:
Constant Field Values

IMPORT_VERSION_DESCRIPTION

static final String IMPORT_VERSION_DESCRIPTION
See Also:
Constant Field Values

IMPORT_VERSION_IS_LATEST

static final String IMPORT_VERSION_IS_LATEST
See Also:
Constant Field Values

IMPORT_VERSION_IS_LATEST_MAJOR

static final String IMPORT_VERSION_IS_LATEST_MAJOR
See Also:
Constant Field Values

IMPORT_IS_VERSION

static final String IMPORT_IS_VERSION
See Also:
Constant Field Values

IMPORT_VERSION_MAJOR

static final String IMPORT_VERSION_MAJOR
See Also:
Constant Field Values

IMPORT_VERSION_MINOR

static final String IMPORT_VERSION_MINOR
See Also:
Constant Field Values

IMPORT_PROXY_TARGET_ID

static final String IMPORT_PROXY_TARGET_ID
See Also:
Constant Field Values

IMPORT_PROXY_VERSIONABLE_ID

static final String IMPORT_PROXY_VERSIONABLE_ID
See Also:
Constant Field Values

IMPORT_LIFECYCLE_POLICY

static final String IMPORT_LIFECYCLE_POLICY
See Also:
Constant Field Values

IMPORT_LIFECYCLE_STATE

static final String IMPORT_LIFECYCLE_STATE
See Also:
Constant Field Values

IMPORT_LOCK

@Deprecated
static final String IMPORT_LOCK
Deprecated. since 5.4.2, use IMPORT_LOCK_OWNER and IMPORT_LOCK_CREATED instead
See Also:
Constant Field Values

IMPORT_LOCK_OWNER

static final String IMPORT_LOCK_OWNER
Since:
5.4.2
See Also:
Constant Field Values

IMPORT_LOCK_CREATED

static final String IMPORT_LOCK_CREATED
Lock creation time as a Calendar object.

Since:
5.4.2
See Also:
Constant Field Values

IMPORT_CHECKED_IN

static final String IMPORT_CHECKED_IN
See Also:
Constant Field Values

IMPORT_BASE_VERSION_ID

static final String IMPORT_BASE_VERSION_ID
See Also:
Constant Field Values

IMPORT_PROXY_TYPE

static final String IMPORT_PROXY_TYPE
The document type to use to create a proxy by import.

See Also:
Constant Field Values
Method Detail

afterBegin

void afterBegin()
The container calls this when this session sees a transaction begin.


beforeCompletion

void beforeCompletion()
The container calls this when this session is about to see a transaction completion.


afterCompletion

void afterCompletion(boolean committed)
The container calls this when this session sees a transaction commit/rollback.


getDocumentType

DocumentType getDocumentType(String type)
Gets the document type object given its type name.

Parameters:
type - the document type name
Returns:
the type the doc type object

generateVersionLabelFor

@Deprecated
String generateVersionLabelFor(DocumentRef docRef)
                               throws ClientException
Deprecated. use #checkIn(DocumentRef, String) directly

Utility method to generate VersionModel labels.

Parameters:
docRef -
Returns:
the String representation of an auto-incremented counter that not used in any label of docRef
Throws:
ClientException

connect

String connect(String repositoryUri,
               Map<String,Serializable> context)
               throws ClientException
Connects to the repository given its URI. This opens a new session on the specified repository.

This method must never be called by users. Is is indirectly called from CoreInstance.open(String, Map) when creating the client.

Parameters:
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.
Returns:
the session ID if the connection succeed, null otherwise
Throws:
ClientException

disconnect

void disconnect()
                throws ClientException
Closes the current session and disconnects from the repository.

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.

Throws:
ClientException

cancel

void cancel()
            throws ClientException
Cancels any pending change made through this session.

Throws:
ClientException

save

void save()
          throws ClientException
Saves any pending changes done until now through this session.

Throws:
ClientException

getSessionId

String getSessionId()
Gets the current session id.

If the client is not connected returns null.

Returns:
the session id or null if not connected

isStateSharedByAllThreadSessions

boolean isStateSharedByAllThreadSessions()
Returns true if all sessions in the current thread share the same state.


getPrincipal

Principal getPrincipal()
Gets the principal that created the client session.

Returns:
the principal

hasPermission

boolean hasPermission(DocumentRef docRef,
                      String permission)
                      throws ClientException
Checks if the principal that created the client session has the given privilege on the referred document.

Parameters:
docRef -
permission -
Returns:
Throws:
ClientException

hasPermission

boolean hasPermission(Principal principal,
                      DocumentRef docRef,
                      String permission)
                      throws ClientException
Checks if a given principal has the given privilege on the referred document.

Parameters:
principal -
docRef -
permission -
Returns:
Throws:
ClientException

getRootDocument

DocumentModel getRootDocument()
                              throws ClientException
Gets the root document of this repository.

Returns:
the root document. cannot be null
Throws:
ClientException
SecurityException

getDocument

@NoRollbackOnException
DocumentModel getDocument(DocumentRef docRef)
                          throws ClientException
Gets 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.

Parameters:
docRef - the document reference
Returns:
the document
Throws:
ClientException
SecurityException

getDocument

@NoRollbackOnException
@Deprecated
DocumentModel getDocument(DocumentRef docRef,
                                                           String[] schemas)
                          throws ClientException
Deprecated. unused

Throws:
ClientException

getDocuments

@NoRollbackOnException
DocumentModelList getDocuments(DocumentRef[] docRefs)
                               throws ClientException
Gets a list of documents given their references.

Documents that are not accessible are skipped.

Throws:
ClientException

getChild

DocumentModel getChild(DocumentRef parent,
                       String name)
                       throws ClientException
Gets 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.

Parameters:
parent - the reference to the parent document
name - the name of the child document to retrieve
Returns:
the named child if exists, raises a ClientException otherwise
Throws:
ClientException - if there is no child with the given name

getChildren

@NoRollbackOnException
DocumentModelList getChildren(DocumentRef parent)
                              throws ClientException
Gets the children of the given parent.

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
Throws:
ClientException

getChildrenIterator

DocumentModelIterator getChildrenIterator(DocumentRef parent)
                                          throws ClientException
Gets an iterator to the children of the given parent.

Parameters:
parent - the parent reference
Returns:
iterator over the children collection or null if the specified parent document is not a folder
Throws:
ClientException

getChildren

@NoRollbackOnException
DocumentModelList getChildren(DocumentRef parent,
                                                    String type)
                              throws ClientException
Gets the children of the given parent filtered according to the given document type.

Parameters:
parent - the parent reference
type - 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
Throws:
ClientException

getChildrenIterator

DocumentModelIterator getChildrenIterator(DocumentRef parent,
                                          String type)
                                          throws ClientException
Gets an iterator to the children of the given parent filtered according to the given document type.

Throws:
ClientException

getChildren

@NoRollbackOnException
DocumentModelList getChildren(DocumentRef parent,
                                                    String type,
                                                    String perm)
                              throws ClientException
Gets the children of the given parent filtered according to the given document type and permission.

Parameters:
parent - the parent reference
type - the wanted document type
type - 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
Throws:
ClientException

getChildren

@NoRollbackOnException
DocumentModelList getChildren(DocumentRef parent,
                                                    String type,
                                                    String perm,
                                                    Filter filter,
                                                    Sorter sorter)
                              throws ClientException
Same as getChildren(DocumentRef, String, String) but the result is filtered and then sorted using the specified filter and sorter.

Parameters:
parent - the parent reference
type - the wanted type
perm - permission to check for. If null, defaults to READ
filter - the filter to use if any, null otherwise
sorter - 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
Throws:
ClientException

getChildrenRefs

List<DocumentRef> getChildrenRefs(DocumentRef parentRef,
                                  String perm)
                                  throws ClientException
Gets the references of the children. No permission is checked if perm is null.

Parameters:
parentRef - the parent reference
perm - the permission to check on the children (usually READ); if null, no permission is checked
Returns:
a list of children references
Throws:
ClientException
Since:
1.4.1

getDocsResultChunk

DocumentModelsChunk getDocsResultChunk(DocsQueryProviderDef def,
                                       String type,
                                       String perm,
                                       Filter filter,
                                       int start,
                                       int count)
                                       throws ClientException
Method used internally to retrieve frames of a long result.

Parameters:
def -
type -
perm -
filter -
start -
count -
Returns:
Throws:
ClientException

getChildrenIterator

DocumentModelIterator getChildrenIterator(DocumentRef parent,
                                          String type,
                                          String perm,
                                          Filter filter)
                                          throws ClientException
Gets 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.

Parameters:
parent -
type -
perm -
filter -
Returns:
Throws:
ClientException

getChildren

DocumentModelList getChildren(DocumentRef parent,
                              String type,
                              Filter filter,
                              Sorter sorter)
                              throws ClientException
Same as getChildren(DocumentRef, String, String, Filter, Sorter) without specific permission filtering.

Parameters:
parent - the parent reference
type - the wanted type
filter - the filter to use if any, null otherwise
sorter - 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
Throws:
ClientException

getFolders

DocumentModelList getFolders(DocumentRef parent)
                             throws ClientException
Same as getChildren(DocumentRef) but returns only folder documents.

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
Throws:
ClientException

getFoldersIterator

DocumentModelIterator getFoldersIterator(DocumentRef parent)
                                         throws ClientException
Same as getFolders(DocumentRef) but returns a lazy loading iterator over the list of children.

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
Throws:
ClientException

getFolders

DocumentModelList getFolders(DocumentRef parent,
                             Filter filter,
                             Sorter sorter)
                             throws ClientException
Same as getFolders(DocumentRef) but uses an optional filter and sorter on the result.

Parameters:
parent - the parent reference
filter - the filter to use or null if none
sorter - 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
Throws:
ClientException

getFiles

DocumentModelList getFiles(DocumentRef parent)
                           throws ClientException
Same as getChildren(DocumentRef) but returns only non-folder documents.

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
Throws:
ClientException

getFilesIterator

DocumentModelIterator getFilesIterator(DocumentRef parent)
                                       throws ClientException
Same as getFiles(DocumentRef) but returns an iterator.

Parameters:
parent -
Returns:
Throws:
ClientException

getFiles

DocumentModelList getFiles(DocumentRef parent,
                           Filter filter,
                           Sorter sorter)
                           throws ClientException
Same as getFiles(org.nuxeo.ecm.core.api.DocumentRef) but uses an optional filter and sorter on the result.

Parameters:
parent - the parent reference
filter - the filter to use or null if none
sorter - 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
Throws:
ClientException

getParentDocumentRef

DocumentRef getParentDocumentRef(DocumentRef docRef)
                                 throws ClientException
Returns the parent ref of the document referenced by 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.

Throws:
ClientException
Since:
5.4.2

getParentDocument

DocumentModel getParentDocument(DocumentRef docRef)
                                throws ClientException
Gets the parent document or null if this is the root document.

Returns:
the parent document or null if this is the root document
Throws:
ClientException

getParentDocuments

List<DocumentModel> getParentDocuments(DocumentRef docRef)
                                       throws ClientException
Gets 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.

Returns:
the list with parent documents or empty list if this is the root document
Throws:
ClientException

exists

boolean exists(DocumentRef docRef)
               throws ClientException
Tests 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.

Parameters:
docRef - the reference to the document to test for existence
Returns:
true if the referenced document exists, false otherwise
Throws:
ClientException

hasChildren

boolean hasChildren(DocumentRef docRef)
                    throws ClientException
Tests 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.

Parameters:
docRef - the reference to the document to test
Returns:
true if document has children, false otherwise
Throws:
ClientException

createDocumentModel

DocumentModel createDocumentModel(String typeName)
                                  throws ClientException
Creates a document model using type name.

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.

Parameters:
typeName -
Returns:
the initial document model
Throws:
ClientException

createDocumentModel

DocumentModel createDocumentModel(String parentPath,
                                  String id,
                                  String typeName)
                                  throws ClientException
Creates a document model using required information.

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.

Parameters:
parentPath -
id -
typeName -
Returns:
the initial document model
Throws:
ClientException

createDocumentModel

DocumentModel createDocumentModel(String typeName,
                                  Map<String,Object> options)
                                  throws ClientException
Creates a document model using required information.

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.

Parameters:
typeName -
options - additional contextual data provided to core event listeners
Returns:
the initial document model
Throws:
ClientException

createDocument

DocumentModel createDocument(DocumentModel model)
                             throws ClientException
Creates 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.

Parameters:
model - the document model to use for initialization
Returns:
the created document
Throws:
ClientException

createDocument

DocumentModel[] createDocument(DocumentModel[] docModels)
                               throws ClientException
Bulk creation of documents.

Parameters:
docModels - the document models to use for intialization
Returns:
the created documents
Throws:
ClientException

importDocuments

void importDocuments(List<DocumentModel> docModels)
                     throws ClientException
Low-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"): 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).

Parameters:
docModels - the documents to create
Throws:
ClientException

saveDocument

DocumentModel saveDocument(DocumentModel docModel)
                           throws ClientException
Saves changes done on the given document model.

Parameters:
docModel - the document model that needs modified
Throws:
ClientException

saveDocuments

void saveDocuments(DocumentModel[] docModels)
                   throws ClientException
Bulk document saving.

Parameters:
docModels - the document models that needs to be saved
Throws:
ClientException

canRemoveDocument

boolean canRemoveDocument(DocumentRef docRef)
                          throws ClientException
Check if a document can be removed. This needs the REMOVE permission on the document and the REMOVE_CHILDREN permission 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).

Parameters:
docRef - the document
Returns:
true if the document can be removed
Throws:
ClientException

removeDocument

void removeDocument(DocumentRef docRef)
                    throws ClientException
Removes this document and all its children, if any.

Parameters:
docRef - the reference to the document to remove
Throws:
ClientException

removeDocuments

void removeDocuments(DocumentRef[] docRefs)
                     throws ClientException
Bulk method to remove documents.

This method is safe with respect to orderings: it doesn't fail if an ancestor of a document occurs before the document.

Parameters:
docRefs - the refs to the document to remove
Throws:
ClientException

removeChildren

void removeChildren(DocumentRef docRef)
                    throws ClientException
Removes all children from the given document.

Parameters:
docRef - the reference to the document to remove
Throws:
ClientException

copy

DocumentModel copy(DocumentRef src,
                   DocumentRef dst,
                   String name)
                   throws ClientException
Copies 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.

Parameters:
src - the source document reference
dst - the destination folder reference
name - the new name of the file or null if the original name must be preserved
Throws:
ClientException
SecurityException

copy

List<DocumentModel> copy(List<DocumentRef> src,
                         DocumentRef dst)
                         throws ClientException
Bulk copy. Destination must be a folder document.

Parameters:
src - the documents to copy
dst - the destination folder
Throws:
ClientException
SecurityException

copyProxyAsDocument

DocumentModel copyProxyAsDocument(DocumentRef src,
                                  DocumentRef dst,
                                  String name)
                                  throws ClientException
Work like copy but in the case of a source proxy the destination will be a new document instead of a proxy.

Parameters:
src - the source document reference
dst - the destination folder reference
name - the new name of the file or null if the original name must be preserved
Throws:
ClientException
SecurityException
See Also:
copy(DocumentRef, DocumentRef, String)

copyProxyAsDocument

List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src,
                                        DocumentRef dst)
                                        throws ClientException
Bulk copyProxyAsDocument. Destination must be a folder document.

Parameters:
src - the documents to copy
dst - the destination folder
Throws:
ClientException
SecurityException

move

DocumentModel move(DocumentRef src,
                   DocumentRef dst,
                   String name)
                   throws ClientException
Moves the source document to the destination folder under the given name. If the name is 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.

Parameters:
src - the source document reference
dst - the destination folder reference
name - the new name of the file, or null
Throws:
ClientException
SecurityException

move

void move(List<DocumentRef> src,
          DocumentRef dst)
          throws ClientException
Bulk move. Destination must be a folder document.

Parameters:
src - the documents to move
dst - the destination folder
Throws:
ClientException
SecurityException

getACP

ACP getACP(DocumentRef docRef)
           throws ClientException
Gets 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 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.

Parameters:
docRef - the doc ref to retrieve ACP or null if none
Returns:
the ACP
Throws:
ClientException

setACP

void setACP(DocumentRef docRef,
            ACP acp,
            boolean overwrite)
            throws ClientException
Sets the ACP for this document.

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:

If the 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.

Parameters:
docRef -
acp -
overwrite -
Throws:
ClientException
SecurityException

getDataModel

@Deprecated
DataModel getDataModel(DocumentRef docRef,
                                  String schema)
                       throws ClientException
Deprecated. not used by client code

Throws:
ClientException

getDataModel

DataModel getDataModel(DocumentRef docRef,
                       Schema schema)
                       throws ClientException
Retrieves a data model given a document reference and a schema.

For INTERNAL use by the core.

Throws:
ClientException
Since:
5.4.2

getDataModelField

@Deprecated
Object getDataModelField(DocumentRef docRef,
                                    String schema,
                                    String field)
                         throws ClientException
Deprecated. unused

Throws:
ClientException

getDataModelFields

@Deprecated
Object[] getDataModelFields(DocumentRef docRef,
                                       String schema,
                                       String[] fields)
                            throws ClientException
Deprecated. unused

Throws:
ClientException

getContentData

SerializableInputStream getContentData(String key)
                                       throws ClientException
Gets the data input stream given its key.

The key is implementation-dependent - this can be a property path an ID, etc.

This method is used to lazily fetch blob streams.

Parameters:
key -
Returns:
Throws:
ClientException
SecurityException

getStreamURI

String getStreamURI(String blobPropertyId)
                    throws ClientException
Returns an URI identifying the stream given the blob property id. This method should be used by a client to download the data of a blob property.

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.

Returns:
an URI identifying the remote stream
Throws:
ClientException

getLastVersion

@Deprecated
VersionModel getLastVersion(DocumentRef docRef)
                            throws ClientException
Deprecated. use getLastDocumentVersion(org.nuxeo.ecm.core.api.DocumentRef) instead

Gets the last version of a document.

Parameters:
docRef - the reference to the document
Returns:
the version
Throws:
ClientException - if any error occurs

getLastDocumentVersion

DocumentModel getLastDocumentVersion(DocumentRef docRef)
                                     throws ClientException
Gets the document corresponding to the last version for the given document.

Parameters:
docRef - the reference to the document
Returns:
the document model corresponding to the version
Throws:
ClientException

getLastDocumentVersionRef

DocumentRef getLastDocumentVersionRef(DocumentRef docRef)
                                      throws ClientException
Gets the document reference corresponding to the last version for the given document.

Parameters:
docRef - the reference to the document
Returns:
the document reference corresponding to the last version
Throws:
ClientException

getSourceDocument

DocumentModel getSourceDocument(DocumentRef docRef)
                                throws ClientException
Gets the head (live) document for this document.

Parameters:
docRef - the reference to the document
Returns:
the version
Throws:
ClientException - if any error occurs

getVersionsRefs

List<DocumentRef> getVersionsRefs(DocumentRef docRef)
                                  throws ClientException
Gets the references of the versions of the document.

Parameters:
docRef - the reference to the document
Returns:
a list of version references
Throws:
ClientException
Since:
1.4.1

getVersions

List<DocumentModel> getVersions(DocumentRef docRef)
                                throws ClientException
Retrieves all the versions for a specified document.

Parameters:
docRef - the reference to the document
Returns:
the list of DocumentModel representing versions, empty list if none is found.
Throws:
ClientException

getVersionsForDocument

List<VersionModel> getVersionsForDocument(DocumentRef docRef)
                                          throws ClientException
Retrieves all the versions for a specified document.

Parameters:
docRef - the reference to the document
Returns:
the list of VersionModel representing versions, empty list if none is found.
Throws:
ClientException

getVersion

@Deprecated
DocumentModel getVersion(String versionableId,
                                    VersionModel versionModel)
                         throws ClientException
Deprecated. use version ids directly

Gets 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.

Restricted to administrators.

Parameters:
versionableId - the versionable id
versionModel - the version model holding the label
Returns:
the version, or null if not found
Throws:
ClientException

getVersionLabel

String getVersionLabel(DocumentModel docModel)
                       throws ClientException
Gets the version label for a document, according to the versioning service.

Parameters:
docModel - the document
Returns:
the version label
Throws:
ClientException

getDocumentWithVersion

DocumentModel getDocumentWithVersion(DocumentRef docRef,
                                     VersionModel version)
                                     throws ClientException
Returns a document that represents the specified version of the document.

Parameters:
docRef - the reference to the document
version - the version for which we want the corresponding document
Returns:
Throws:
ClientException

restoreToVersion

DocumentModel restoreToVersion(DocumentRef docRef,
                               DocumentRef versionRef,
                               boolean skipSnapshotCreation,
                               boolean skipCheckout)
                               throws ClientException
Restores the given document to the specified version.

Parameters:
docRef - the reference to the document
versionRef - the reference to the version
skipSnapshotCreation - true if the document should not be snapshotted before being restored
skipCheckout - true if the restored document should be kept in a checked-in state
Throws:
ClientException
Since:
5.4

restoreToVersion

@Deprecated
DocumentModel restoreToVersion(DocumentRef docRef,
                                          VersionModel version,
                                          boolean skipSnapshotCreation)
                               throws ClientException
Deprecated. use restoreToVersion(DocumentRef, DocumentRef, boolean, boolean) instead

Restores the given document to the specified version permitting to skip the creation of the snapshot for current document.

Parameters:
docRef - the reference to the document
version - the version to which the document should be restored to - only the label is used for the moment
skipSnapshotCreation - indicates if skipping snapshot creation
Throws:
ClientException

restoreToVersion

DocumentModel restoreToVersion(DocumentRef docRef,
                               DocumentRef versionRef)
                               throws ClientException
Restores the given document to the specified version.

Parameters:
docRef - the reference to the document
versionRef - the reference to the version
Throws:
ClientException
Since:
5.4

restoreToVersion

@Deprecated
DocumentModel restoreToVersion(DocumentRef docRef,
                                          VersionModel version)
                               throws ClientException
Deprecated. use restoreToVersion(DocumentRef, DocumentRef) instead

Restores the given document to the specified version.

Parameters:
docRef - the reference to the document
version - the version to which the document should be restored to - only the label is used for the moment
Throws:
ClientException

getBaseVersion

DocumentRef getBaseVersion(DocumentRef docRef)
                           throws ClientException
Gets the version to which a checked in document is linked.

Returns null for a checked out document or a version or a proxy.

Returns:
the version, or null
Throws:
ClientException

checkOut

void checkOut(DocumentRef docRef)
              throws ClientException
Checks out a versioned document.

Parameters:
docRef - the reference to the document
Throws:
ClientException

checkIn

@Deprecated
DocumentModel checkIn(DocumentRef docRef,
                                 VersionModel version)
                      throws ClientException
Deprecated. use #checkIn(DocumentRef, String) instead

Checks in a modified document, creating a new version.

Parameters:
docRef - the reference to the document
version - the version descriptor
Returns:
the version document just created
Throws:
ClientException

checkIn

DocumentRef checkIn(DocumentRef docRef,
                    VersioningOption option,
                    String checkinComment)
                    throws ClientException
Checks in a modified document, creating a new version.

Parameters:
docRef - the reference to the document
option - whether to do create a new VersioningOption.MINOR or VersioningOption.MAJOR version during check in
checkinComment - the checkin comment
Returns:
the version just created
Throws:
ClientException
Since:
5.4

isCheckedOut

boolean isCheckedOut(DocumentRef docRef)
                     throws ClientException
Returns whether the current document is checked-out or not.

Parameters:
docRef - the reference to the document
Returns:
Throws:
ClientException

getVersionSeriesId

String getVersionSeriesId(DocumentRef docRef)
                          throws ClientException
Gets 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.

Parameters:
docRef - the document reference
Returns:
the version series id
Throws:
ClientException
Since:
5.4

getWorkingCopy

DocumentModel getWorkingCopy(DocumentRef docRef)
                             throws ClientException
Gets the working copy (live document) for a proxy or a version.

Parameters:
docRef - the document reference
Returns:
the working copy, or null if not found
Throws:
ClientException
Since:
5.4

createProxy

DocumentModel createProxy(DocumentRef docRef,
                          DocumentRef folderRef)
                          throws ClientException
Creates 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".

Throws:
ClientException
Since:
1.6.1 (5.3.1)

createProxy

@Deprecated
DocumentModel createProxy(DocumentRef parentRef,
                                     DocumentRef docRef,
                                     VersionModel version,
                                     boolean overwriteExistingProxy)
                          throws ClientException
Deprecated. use createProxy(DocumentRef, DocumentRef) or publishDocument(DocumentModel, DocumentModel, boolean) instead

Creates a proxy for the given version of the given document.

Parameters:
docRef - the reference to the document
version - the version
Returns:
the proxy
Throws:
ClientException - if any error occurs

query

DocumentModelList query(String query)
                        throws ClientException
Executes the given NXQL query an returns the result.

Parameters:
query - the query to execute
Returns:
the query result
Throws:
ClientException

query

DocumentModelList query(String query,
                        int max)
                        throws ClientException
Executes the given NXQL query an returns the result.

Parameters:
query - the query to execute
max - number of document to retrieve
Returns:
the query result
Throws:
ClientException

query

DocumentModelList query(String query,
                        Filter filter)
                        throws ClientException
Executes the given NXQL query and returns the result that matches the filter.

Parameters:
query - the query to execute
filter - the filter to apply to result
Returns:
the query result
Throws:
ClientException

query

DocumentModelList query(String query,
                        Filter filter,
                        int max)
                        throws ClientException
Executes the given NXQL query and returns the result that matches the filter.

Parameters:
query - the query to execute
filter - the filter to apply to result
max - number of document to retrieve
Returns:
the query result
Throws:
ClientException

query

DocumentModelList query(String query,
                        Filter filter,
                        long limit,
                        long offset,
                        boolean countTotal)
                        throws ClientException
Executes the given NXQL query and returns the result that matches the filter.

Parameters:
query - the query to execute
filter - the filter to apply to result
limit - the maximum number of documents to retrieve, or 0 for all of them
offset - the offset (starting at 0) into the list of documents
countTotal - if true, return a DocumentModelList that includes a total size of the underlying list (size if there was no limit or offset)
Returns:
the query result
Throws:
ClientException

query

DocumentModelList query(String query,
                        String queryType,
                        Filter filter,
                        long limit,
                        long offset,
                        boolean countTotal)
                        throws ClientException
Executes the given query and returns the result that matches the filter.

Parameters:
query - the query to execute
queryType - the query type, like "NXQL"
filter - the filter to apply to result
limit - the maximum number of documents to retrieve, or 0 for all of them
offset - the offset (starting at 0) into the list of documents
countTotal - if true, return a DocumentModelList that includes a total size of the underlying list (size if there was no limit or offset)
Returns:
the query result
Throws:
ClientException

queryAndFetch

IterableQueryResult queryAndFetch(String query,
                                  String queryType,
                                  Object... params)
                                  throws ClientException
Throws:
ClientException

queryIt

DocumentModelIterator queryIt(String query,
                              Filter filter,
                              int max)
                              throws ClientException
Executes the given NXQL query and returns an iterators of results.

Parameters:
query - the query to execute
filter - the filter to apply to result
max - number of document to retrieve
Returns:
the query result iterator
Throws:
ClientException

querySimpleFts

@Deprecated
DocumentModelList querySimpleFts(String keywords)
                                 throws ClientException
Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html

Executes a specific FULLTEXT enabled query for the given keywords.

Throws:
ClientException

querySimpleFts

@Deprecated
DocumentModelList querySimpleFts(String keywords,
                                            Filter filter)
                                 throws ClientException
Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html

Executes a specific FULLTEXT enabled query for the given keywords, returning only results that match the specified filter.

Throws:
ClientException

querySimpleFtsIt

@Deprecated
DocumentModelIterator querySimpleFtsIt(String query,
                                                  Filter filter,
                                                  int pageSize)
                                       throws ClientException
Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html

Throws:
ClientException

querySimpleFtsIt

@Deprecated
DocumentModelIterator querySimpleFtsIt(String query,
                                                  String startingPath,
                                                  Filter filter,
                                                  int pageSize)
                                       throws ClientException
Deprecated. use SearchService instead. See ://doc.nuxeo.org/reference/html/search-service.html

Throws:
ClientException

getAvailableSecurityPermissions

List<String> getAvailableSecurityPermissions()
                                             throws ClientException
Retrieves the available security permissions existing in the system.

Returns:
a raw list of permission names, either basic or group names
Throws:
ClientException

getCurrentLifeCycleState

String getCurrentLifeCycleState(DocumentRef docRef)
                                throws ClientException
Returns the life cycle of the document.

Parameters:
docRef - the document reference
Returns:
the life cycle as a string
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

getLifeCyclePolicy

String getLifeCyclePolicy(DocumentRef docRef)
                          throws ClientException
Returns the life cycle policy of the document.

Parameters:
docRef - the document reference
Returns:
the life cycle policy
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

followTransition

boolean followTransition(DocumentRef docRef,
                         String transition)
                         throws ClientException
Follows a given life cycle transition.

This will update the current life cycle of the document.

Parameters:
docRef - the document reference
transition - the name of the transition to follow
Returns:
a boolean representing the status if the operation
Throws:
ClientException

getAllowedStateTransitions

Collection<String> getAllowedStateTransitions(DocumentRef docRef)
                                              throws ClientException
Gets the allowed state transitions for this document.

Parameters:
docRef - the document reference
Returns:
a collection of state transitions as string
Throws:
ClientException

reinitLifeCycleState

void reinitLifeCycleState(DocumentRef docRef)
                          throws ClientException
Reinitializes the life cycle state of the document to its default state.

Parameters:
docRef - the document
Throws:
ClientException
Since:
5.4.2

getDataModelsField

Object[] getDataModelsField(DocumentRef[] docRefs,
                            String schema,
                            String field)
                            throws ClientException
Retrieves the given field value from the given schema for all the given documents.

Parameters:
docRefs - the document references
schema - the schema
field - the field name
Returns:
the field values in the same order as the given docRefs
Throws:
ClientException
ClientException

getParentDocumentRefs

DocumentRef[] getParentDocumentRefs(DocumentRef docRef)
                                    throws ClientException
Creates 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.

Parameters:
docRef -
Returns:
an array with ancestor documents ref
Throws:
ClientException

getDataModelsFieldUp

Object[] getDataModelsFieldUp(DocumentRef docRef,
                              String schema,
                              String field)
                              throws ClientException
Retrieves the given field value from the given schema for the given document along with all its parent documents.

Parameters:
docRef - the document reference
schema - the schema
field - the field name
Returns:
an array with field values of all documents on the path from the given document to the root
Throws:
ClientException

getLock

@Deprecated
String getLock(DocumentRef doc)
               throws ClientException
Deprecated. since 5.4.2, use getLockInfo(org.nuxeo.ecm.core.api.DocumentRef) instead

Gets the lock key on the given document if a lock exists or null otherwise.

A lock key has the form someuser:Nov 29, 2010.

Parameters:
doc - the document reference
Returns:
the lock key if the document is locked, null otherwise
Throws:
ClientException

setLock

@Deprecated
void setLock(DocumentRef doc,
                        String key)
             throws ClientException
Deprecated. since 5.4.2, use setLock(DocumentRef) instead

Sets a lock on the given document using the given key.

A lock key must have the form someuser:Nov 29, 2010.

Parameters:
doc - the document reference
key - the lock key
Throws:
ClientException - if a lock is already set or other exception occurred

unlock

@Deprecated
String unlock(DocumentRef docRef)
              throws ClientException
Deprecated. since 5.4.2, use removeLock(org.nuxeo.ecm.core.api.DocumentRef) instead

Removes the lock if one exists.

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.

Parameters:
docRef - the document to unlock
Returns:
the lock key that was removed
Throws:
ClientException

setLock

Lock setLock(DocumentRef docRef)
             throws ClientException
Sets a lock on the given document.

Parameters:
doc - the document reference
Returns:
the lock info that was set
Throws:
ClientException - if a lock was already set
Since:
5.4.2

getLockInfo

Lock getLockInfo(DocumentRef docRef)
                 throws ClientException
Gets 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.

Parameters:
doc - the document reference
Returns:
the lock info if the document is locked, or null otherwise
Throws:
ClientException
Since:
5.4.2

removeLock

Lock removeLock(DocumentRef docRef)
                throws ClientException
Removes 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.

Parameters:
docRef - the document to unlock
Returns:
the removed lock info, or null if there was no lock
Throws:
ClientException
Since:
5.4.2

applyDefaultPermissions

void applyDefaultPermissions(String userOrGroupName)
                             throws ClientException
Applies 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.

Parameters:
userOrGroupName -
Throws:
ClientException

destroy

void destroy()
Destroys any system resources held by this instance.

Called when the instance is no more needed.


isDirty

@Deprecated
boolean isDirty(DocumentRef doc)
                throws ClientException
Deprecated. since 5.4, use isCheckedOut(org.nuxeo.ecm.core.api.DocumentRef) instead

Checks if the given document is dirty.

Parameters:
doc - the doc reference
Returns:
true if dirty false otherwise
Throws:
ClientException

publishDocument

DocumentModel publishDocument(DocumentModel docToPublish,
                              DocumentModel section)
                              throws ClientException
Publishes the document in a section overwriting any existing proxy to the same document. This is simmilar to publishDocument(docToPublish, section, true);

Parameters:
docToPublish -
section -
Returns:
The proxy document that was created
Throws:
ClientException
Since:
1.4.1 for the case where docToPublish is a proxy

publishDocument

DocumentModel publishDocument(DocumentModel docToPublish,
                              DocumentModel section,
                              boolean overwriteExistingProxy)
                              throws ClientException
Publishes the document in a section.

Parameters:
docToPublish -
section -
overwriteExistingProxy -
Returns:
The proxy document that was created
Throws:
ClientException

getProxies

DocumentModelList getProxies(DocumentRef docRef,
                             DocumentRef folderRef)
                             throws ClientException
Finds 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.

Parameters:
docRef - the target document for the proxies
folderRef - the folder where proxies are located or null
Returns:
the list of the proxies. An empty list is returned if no proxy are found
Throws:
ClientException - if any error occurs
Since:
1.4.1 for the case where docRef is a proxy

getProxyVersions

@Deprecated
String[] getProxyVersions(DocumentRef docRef,
                                     DocumentRef folderRef)
                          throws ClientException
Deprecated. since 5.4, use getProxies(org.nuxeo.ecm.core.api.DocumentRef, org.nuxeo.ecm.core.api.DocumentRef) instead

Gets all proxy versions to document docRef inside folder folderRef.

Intended to be used by UI clients to display information about proxies in sections.

Parameters:
docRef - the target document for the proxies
folderRef - the folder where proxies are located
Returns:
an array of the proxy versions, with an empty string being used for a live proxy. null is returned if no proxies are found the specified folder
Throws:
ClientException - if any error occurs

getSuperParentType

String getSuperParentType(DocumentModel doc)
                          throws ClientException
Returns the type of his parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.

Parameters:
doc -
Returns:
Throws:
ClientException

getSuperSpace

DocumentModel getSuperSpace(DocumentModel doc)
                            throws ClientException
Returns the parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.

Parameters:
doc -
Returns:
DocumentModel of SuperSpace
Throws:
ClientException

getSecuritySummary

List<SecuritySummaryEntry> getSecuritySummary(DocumentModel docModel,
                                              Boolean includeParents)
                                              throws ClientException
Returns security descriptors of doc and all it's children that hold explicit security.

Parameters:
docModel - the document node from where the security export is done
includeParents - flag is the parent nodes holding security information should be added at the top of the returned list
Returns:
a list of SecuritySummaryEntry
Throws:
ClientException

getRepositoryName

String getRepositoryName()
Returns the repository name against which this core session is bound.

Returns:
the repository name used currently used as an identifier

getDocumentSystemProp

<T extends Serializable> T getDocumentSystemProp(DocumentRef ref,
                                                 String systemProperty,
                                                 Class<T> type)
                                             throws ClientException,
                                                    DocumentException
Gets system property of the specified type for the document ref.

Type Parameters:
T -
Parameters:
ref -
systemProperty -
type -
Returns:
Throws:
ClientException
DocumentException

setDocumentSystemProp

<T extends Serializable> void setDocumentSystemProp(DocumentRef ref,
                                                    String systemProperty,
                                                    T value)
                           throws ClientException,
                                  DocumentException
Sets given value as a system property.

Type Parameters:
T -
Parameters:
ref -
systemProperty -
value -
Throws:
ClientException
DocumentException

orderBefore

void orderBefore(DocumentRef parent,
                 String src,
                 String dest)
                 throws ClientException
Given 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 using docModel.getName()) To place the source document at the end of the children list use a null destination node.

Parameters:
parent - the parent document
src - 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
Throws:
ClientException - if the parent document is not an orderable folder or other error occurs

run

<T> T run(Operation<T> cmd)
      throws ClientException
Run a command

Type Parameters:
T - command result type
Parameters:
cmd - the command to run
Returns:
the command result
Throws:
ClientException - if any error occurs

run

<T> T run(Operation<T> op,
          ProgressMonitor monitor)
      throws ClientException
Run a command and notify the given monitor about the execution progress

Type Parameters:
T -
Parameters:
op -
monitor -
Returns:
Throws:
ClientException

refreshDocument

DocumentModel.DocumentModelRefresh refreshDocument(DocumentRef ref,
                                                   int refreshFlags,
                                                   String[] schemas)
                                                   throws ClientException
Internal method - it is used internally by 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

Parameters:
ref - the document reference
refreshFlags - refresh flags as defined in DocumentModel
schemas - the schema names if a partial content refresh is required
Returns:
a DocumentModelRefresh object
Throws:
ClientException

getPermissionsToCheck

String[] getPermissionsToCheck(String permission)
Provides the full list of all permissions or groups of permissions that contain the given one (inclusive). It makes the method SecurityService.getPermissionsToCheck(java.lang.String) available remote.

Parameters:
permission -
Returns:
the list, as an array of strings.

supportsTags

boolean supportsTags(String repositoryName)
                     throws ClientException
Indicates if implementation of the given repositoryName supports Tags feature

Parameters:
repositoryName - the name of the repository to test
Returns:
Throws:
ClientException

supportsTags

boolean supportsTags()
                     throws ClientException
Indicates if the current repository implementation supports tags.

Returns:
true if tags are supported
Throws:
ClientException

adaptFirstMatchingDocumentWithFacet

<T extends DetachedAdapter> T adaptFirstMatchingDocumentWithFacet(DocumentRef docRef,
                                                                  String facet,
                                                                  Class<T> adapterClass)
                                                              throws ClientException
Find the first parent with the given 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.

Returns:
the first parent with the given facet adapted, or null if no parent found or the document does not support the given adapterClass.
Throws:
ClientException
Since:
5.4.2

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.