Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api
Class AbstractSession

java.lang.Object
  extended by org.nuxeo.ecm.core.api.AbstractSession
All Implemented Interfaces:
Serializable, CoreSession, OperationHandler
Direct Known Subclasses:
LocalSession

public abstract class AbstractSession
extends Object
implements CoreSession, OperationHandler, Serializable

Abstract implementation of the client interface.

This handles all the aspects that are independent on the final implementation (like running inside a J2EE platform or not).

The only aspect not implemented is the session management that should be handled by subclasses.

Author:
Bogdan Stefanescu, Florent Guillaume
See Also:
Serialized Form

Field Summary
static NuxeoPrincipal ANONYMOUS
           
 
Fields inherited from interface org.nuxeo.ecm.core.api.CoreSession
IMPORT_BASE_VERSION_ID, IMPORT_CHECKED_IN, IMPORT_IS_VERSION, IMPORT_LIFECYCLE_POLICY, IMPORT_LIFECYCLE_STATE, IMPORT_LOCK, IMPORT_LOCK_CREATED, IMPORT_LOCK_OWNER, IMPORT_PROXY_TARGET_ID, IMPORT_PROXY_TYPE, IMPORT_PROXY_VERSIONABLE_ID, IMPORT_VERSION_CREATED, IMPORT_VERSION_DESCRIPTION, IMPORT_VERSION_IS_LATEST, IMPORT_VERSION_IS_LATEST_MAJOR, IMPORT_VERSION_LABEL, IMPORT_VERSION_MAJOR, IMPORT_VERSION_MINOR, IMPORT_VERSION_VERSIONABLE_ID
 
Constructor Summary
AbstractSession()
           
 
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 ver)
          Deprecated. 
 void checkOut(DocumentRef docRef)
          Checks out a versioned document.
 String connect(String repositoryName, 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 docModel)
          Creates a document using given document model for initialization.
 DocumentModel[] createDocument(DocumentModel[] docModels)
          Bulk creation of documents.
 DocumentModel createDocumentModel(String typeName)
          Creates a document model using type name.
 DocumentModel createDocumentModel(String typeName, Map<String,Object> options)
          Creates a document model using required information.
 DocumentModel createDocumentModel(String parentPath, String 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. 
 void destroy()
          Destroys any system resources held by this instance.
 void disconnect()
          Closes the current session and disconnects from the repository.
 void endOperation(Operation<?> operation)
          This method is for compatibility reasons to notify an operation end.
 boolean exists(DocumentRef docRef)
          Tests if the document pointed by the given reference exists and is accessible.
 void fireEvent(Event event)
           
 boolean followTransition(DocumentRef docRef, String transition)
          Follows a given life cycle transition.
 String generateDocumentName(Document parent, String name)
          Generate a non-null unique name within given parent's children.
 String generateVersionLabelFor(DocumentRef docRef)
          Utility method to generate VersionModel labels.
 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 CoreSession.getChildren(DocumentRef, String, String, Filter, Sorter) without specific permission filtering.
 DocumentModelList getChildren(DocumentRef parent, String type, String perm)
          Gets the children of the given parent filtered according to the given document type and permission.
 DocumentModelList getChildren(DocumentRef parent, String type, String perm, Filter filter, Sorter sorter)
          Same as CoreSession.getChildren(DocumentRef, String, String) but the result is filtered and then sorted using the specified filter and sorter.
 DocumentModelIterator getChildrenIterator(DocumentRef parent)
          Gets an iterator to the children of the given parent.
 DocumentModelIterator getChildrenIterator(DocumentRef parent, String type)
          Gets an iterator to the children of the given parent filtered according to the given document type.
 DocumentModelIterator getChildrenIterator(DocumentRef parent, String type, String perm, Filter filter)
          Gets the children of the given parent filtered according to the given document type and permission.
 List<DocumentRef> getChildrenRefs(DocumentRef parentRef, String perm)
          Gets the references of the children.
 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. 
 Object getDataModelField(DocumentRef docRef, String schema, String field)
          Deprecated. 
 Object[] getDataModelFields(DocumentRef docRef, String schema, String[] fields)
          Deprecated. 
 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 max)
          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.
 EventService getEventService()
           
 DocumentModelList getFiles(DocumentRef parent)
          Same as CoreSession.getChildren(DocumentRef) but returns only non-folder documents.
 DocumentModelList getFiles(DocumentRef parent, Filter filter, Sorter sorter)
          Same as CoreSession.getFiles(org.nuxeo.ecm.core.api.DocumentRef) but uses an optional filter and sorter on the result.
 DocumentModelIterator getFilesIterator(DocumentRef parent)
          Same as CoreSession.getFiles(DocumentRef) but returns an iterator.
 DocumentModelList getFolders(DocumentRef parent)
          Same as CoreSession.getChildren(DocumentRef) but returns only folder documents.
 DocumentModelList getFolders(DocumentRef parent, Filter filter, Sorter sorter)
          Same as CoreSession.getFolders(DocumentRef) but uses an optional filter and sorter on the result.
 DocumentModelIterator getFoldersIterator(DocumentRef parent)
          Same as CoreSession.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)
          Gets the last version of a document.
 String getLifeCyclePolicy(DocumentRef docRef)
          Returns the life cycle policy of the document.
 String getLock(DocumentRef docRef)
          Deprecated. 
 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)
          Gets all proxy versions to document docRef inside folder folderRef.
 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.
abstract  Session getSession()
          Internal method: Gets the current session based on the client session id.
 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)
          Gets a document version, given the versionable id and label.
 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.
 void internalCheckOut(DocumentRef docRef)
           
 boolean isCheckedOut(DocumentRef docRef)
          Returns whether the current document is checked-out or not.
 boolean isDirty(DocumentRef docRef)
          Deprecated. 
abstract  boolean isSessionAlive()
           
 DocumentModel move(DocumentRef src, DocumentRef dst, String name)
          Moves the source document to the destination folder under the given name.
 void move(List<DocumentRef> src, DocumentRef dst)
          Bulk move.
 DocumentEventContext newEventContext(DocumentModel source)
           
 void orderBefore(DocumentRef parent, String src, String dest)
          Given a parent document, order the source child before the destination child.
 DocumentModel publishDocument(DocumentModel docToPublish, DocumentModel section)
          Publishes the document in a section overwriting any existing proxy to the same document.
 DocumentModel publishDocument(DocumentModel docModel, DocumentModel section, boolean overwriteExistingProxy)
          Publishes the document in a section.
 DocumentModelList query(String query)
          Executes the given NXQL query an returns the result.
 DocumentModelList query(String query, Filter filter)
          Executes the given NXQL query and returns the result that matches the filter.
 DocumentModelList query(String query, Filter filter, int max)
          Executes the given NXQL query and returns the result that matches the filter.
 DocumentModelList query(String query, Filter filter, long limit, long offset, boolean countTotal)
          Executes the given NXQL query and returns the result that matches the filter.
 DocumentModelList query(String query, 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. 
 DocumentModelList querySimpleFts(String keywords, Filter filter)
          Deprecated. 
 DocumentModelIterator querySimpleFtsIt(String query, Filter filter, int pageSize)
          Deprecated. 
 DocumentModelIterator querySimpleFtsIt(String query, String startingPath, Filter filter, int pageSize)
          Deprecated. 
 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)
          Implementation uses the fact that the lexicographic ordering of paths is a refinement of the "contains" partial ordering.
 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. 
 DocumentModel restoreToVersion(DocumentRef docRef, VersionModel version, boolean skipSnapshotCreation)
          Deprecated. 
<T> T
run(Operation<T> op)
          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 newAcp, 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 docRef, String key)
          Deprecated. 
 void startOperation(Operation<?> operation)
          This method is for compatibility reasons to notify an operation start.
 String unlock(DocumentRef docRef)
          Deprecated. 
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuxeo.ecm.core.api.CoreSession
isStateSharedByAllThreadSessions, supportsTags, supportsTags
 

Field Detail

ANONYMOUS

public static final NuxeoPrincipal ANONYMOUS
Constructor Detail

AbstractSession

public AbstractSession()
Method Detail

getSession

public abstract Session getSession()
                            throws ClientException
Internal method: Gets the current session based on the client session id.

Returns:
the repository session
Throws:
ClientException

connect

public String connect(String repositoryName,
                      Map<String,Serializable> context)
               throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
connect in interface CoreSession
Parameters:
repositoryName - 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

getDocumentType

public DocumentType getDocumentType(String type)
Description copied from interface: CoreSession
Gets the document type object given its type name.

Specified by:
getDocumentType in interface CoreSession
Parameters:
type - the document type name
Returns:
the type the doc type object

generateVersionLabelFor

public String generateVersionLabelFor(DocumentRef docRef)
                               throws ClientException
Utility method to generate VersionModel labels.

Specified by:
generateVersionLabelFor in interface CoreSession
Returns:
the String representation of an auto-incremented counter that not used in any label of docRef
Throws:
ClientException

getSessionId

public String getSessionId()
Description copied from interface: CoreSession
Gets the current session id.

If the client is not connected returns null.

Specified by:
getSessionId in interface CoreSession
Returns:
the session id or null if not connected

getPrincipal

public Principal getPrincipal()
Description copied from interface: CoreSession
Gets the principal that created the client session.

Specified by:
getPrincipal in interface CoreSession
Returns:
the principal

newEventContext

public DocumentEventContext newEventContext(DocumentModel source)

getEventService

public EventService getEventService()

afterBegin

public void afterBegin()
Description copied from interface: CoreSession
The container calls this when this session sees a transaction begin.

Specified by:
afterBegin in interface CoreSession

beforeCompletion

public void beforeCompletion()
Description copied from interface: CoreSession
The container calls this when this session is about to see a transaction completion.

Specified by:
beforeCompletion in interface CoreSession

afterCompletion

public void afterCompletion(boolean committed)
Description copied from interface: CoreSession
The container calls this when this session sees a transaction commit/rollback.

Specified by:
afterCompletion in interface CoreSession

fireEvent

public void fireEvent(Event event)
               throws ClientException
Throws:
ClientException

hasPermission

public boolean hasPermission(Principal principal,
                             DocumentRef docRef,
                             String permission)
                      throws ClientException
Description copied from interface: CoreSession
Checks if a given principal has the given privilege on the referred document.

Specified by:
hasPermission in interface CoreSession
Returns:
Throws:
ClientException

hasPermission

public boolean hasPermission(DocumentRef docRef,
                             String permission)
                      throws ClientException
Description copied from interface: CoreSession
Checks if the principal that created the client session has the given privilege on the referred document.

Specified by:
hasPermission in interface CoreSession
Returns:
Throws:
ClientException

copy

public DocumentModel copy(DocumentRef src,
                          DocumentRef dst,
                          String name)
                   throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
copy in interface CoreSession
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

copy

public List<DocumentModel> copy(List<DocumentRef> src,
                                DocumentRef dst)
                         throws ClientException
Description copied from interface: CoreSession
Bulk copy. Destination must be a folder document.

Specified by:
copy in interface CoreSession
Parameters:
src - the documents to copy
dst - the destination folder
Throws:
ClientException

copyProxyAsDocument

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

Specified by:
copyProxyAsDocument in interface CoreSession
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
See Also:
CoreSession.copy(DocumentRef, DocumentRef, String)

copyProxyAsDocument

public List<DocumentModel> copyProxyAsDocument(List<DocumentRef> src,
                                               DocumentRef dst)
                                        throws ClientException
Description copied from interface: CoreSession
Bulk copyProxyAsDocument. Destination must be a folder document.

Specified by:
copyProxyAsDocument in interface CoreSession
Parameters:
src - the documents to copy
dst - the destination folder
Throws:
ClientException

move

public DocumentModel move(DocumentRef src,
                          DocumentRef dst,
                          String name)
                   throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
move in interface CoreSession
Parameters:
src - the source document reference
dst - the destination folder reference
name - the new name of the file, or null
Throws:
ClientException

move

public void move(List<DocumentRef> src,
                 DocumentRef dst)
          throws ClientException
Description copied from interface: CoreSession
Bulk move. Destination must be a folder document.

Specified by:
move in interface CoreSession
Parameters:
src - the documents to move
dst - the destination folder
Throws:
ClientException

getACP

public ACP getACP(DocumentRef docRef)
           throws ClientException
Description copied from interface: CoreSession
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 CoreSession.setACP(DocumentRef, ACP, boolean)

This method will always fetch a fresh ACP from the storage. The recommended way to get the ACP is to use DocumentModel.getACP() this way the ACP will be cached at the document model level and so you can use it for multiple permission checks without fetching it each time.

Specified by:
getACP in interface CoreSession
Parameters:
docRef - the doc ref to retrieve ACP or null if none
Returns:
the ACP
Throws:
ClientException

setACP

public void setACP(DocumentRef docRef,
                   ACP newAcp,
                   boolean overwrite)
            throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
setACP in interface CoreSession
Throws:
ClientException

cancel

public void cancel()
            throws ClientException
Description copied from interface: CoreSession
Cancels any pending change made through this session.

Specified by:
cancel in interface CoreSession
Throws:
ClientException

createDocumentModel

public DocumentModel createDocumentModel(String typeName)
                                  throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
createDocumentModel in interface CoreSession
Returns:
the initial document model
Throws:
ClientException

createDocumentModel

public DocumentModel createDocumentModel(String parentPath,
                                         String id,
                                         String typeName)
                                  throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
createDocumentModel in interface CoreSession
Returns:
the initial document model
Throws:
ClientException

createDocumentModel

public DocumentModel createDocumentModel(String typeName,
                                         Map<String,Object> options)
                                  throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
createDocumentModel in interface CoreSession
options - additional contextual data provided to core event listeners
Returns:
the initial document model
Throws:
ClientException

createDocument

public DocumentModel createDocument(DocumentModel docModel)
                             throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
createDocument in interface CoreSession
Parameters:
docModel - the document model to use for initialization
Returns:
the created document
Throws:
ClientException

importDocuments

public void importDocuments(List<DocumentModel> docModels)
                     throws ClientException
Description copied from interface: CoreSession
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"): CoreSession.IMPORT_PROXY_TARGET_ID and CoreSession.IMPORT_PROXY_VERSIONABLE_ID.

For a version (no parent): CoreSession.IMPORT_VERSION_VERSIONABLE_ID, CoreSession.IMPORT_VERSION_CREATED, CoreSession.IMPORT_VERSION_LABEL and CoreSession.IMPORT_VERSION_DESCRIPTION.

For a live document: CoreSession.IMPORT_BASE_VERSION_ID and CoreSession.IMPORT_CHECKED_IN (Boolean).

For a live document or a version: CoreSession.IMPORT_LIFECYCLE_POLICY , CoreSession.IMPORT_LIFECYCLE_STATE, CoreSession.IMPORT_VERSION_MAJOR (Long) and CoreSession.IMPORT_VERSION_MINOR (Long).

Specified by:
importDocuments in interface CoreSession
Parameters:
docModels - the documents to create
Throws:
ClientException

generateDocumentName

public String generateDocumentName(Document parent,
                                   String name)
                            throws DocumentException
Generate a non-null unique name within given parent's children.

If name is null, a name is generated. If name is already used, a random suffix is appended to it.

Returns:
a unique name within given parent's children
Throws:
DocumentException

createDocument

public DocumentModel[] createDocument(DocumentModel[] docModels)
                               throws ClientException
Description copied from interface: CoreSession
Bulk creation of documents.

Specified by:
createDocument in interface CoreSession
Parameters:
docModels - the document models to use for intialization
Returns:
the created documents
Throws:
ClientException

isSessionAlive

public abstract boolean isSessionAlive()

disconnect

public void disconnect()
                throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
disconnect in interface CoreSession
Throws:
ClientException

exists

public boolean exists(DocumentRef docRef)
               throws ClientException
Description copied from interface: CoreSession
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.

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

getChild

public DocumentModel getChild(DocumentRef parent,
                              String name)
                       throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getChild in interface CoreSession
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

public DocumentModelList getChildren(DocumentRef parent)
                              throws ClientException
Description copied from interface: CoreSession
Gets the children of the given parent.

Specified by:
getChildren in interface CoreSession
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

public DocumentModelIterator getChildrenIterator(DocumentRef parent)
                                          throws ClientException
Description copied from interface: CoreSession
Gets an iterator to the children of the given parent.

Specified by:
getChildrenIterator in interface CoreSession
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

public DocumentModelList getChildren(DocumentRef parent,
                                     String type)
                              throws ClientException
Description copied from interface: CoreSession
Gets the children of the given parent filtered according to the given document type.

Specified by:
getChildren in interface CoreSession
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

public DocumentModelIterator getChildrenIterator(DocumentRef parent,
                                                 String type)
                                          throws ClientException
Description copied from interface: CoreSession
Gets an iterator to the children of the given parent filtered according to the given document type.

Specified by:
getChildrenIterator in interface CoreSession
Throws:
ClientException

getChildren

public DocumentModelList getChildren(DocumentRef parent,
                                     String type,
                                     String perm)
                              throws ClientException
Description copied from interface: CoreSession
Gets the children of the given parent filtered according to the given document type and permission.

Specified by:
getChildren in interface CoreSession
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

getChildren

public DocumentModelList getChildren(DocumentRef parent,
                                     String type,
                                     Filter filter,
                                     Sorter sorter)
                              throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getChildren(DocumentRef, String, String, Filter, Sorter) without specific permission filtering.

Specified by:
getChildren in interface CoreSession
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

getChildren

public DocumentModelList getChildren(DocumentRef parent,
                                     String type,
                                     String perm,
                                     Filter filter,
                                     Sorter sorter)
                              throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getChildren(DocumentRef, String, String) but the result is filtered and then sorted using the specified filter and sorter.

Specified by:
getChildren in interface CoreSession
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

public List<DocumentRef> getChildrenRefs(DocumentRef parentRef,
                                         String perm)
                                  throws ClientException
Description copied from interface: CoreSession
Gets the references of the children. No permission is checked if perm is null.

Specified by:
getChildrenRefs in interface CoreSession
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

getDocsResultChunk

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

Specified by:
getDocsResultChunk in interface CoreSession
Returns:
Throws:
ClientException

getChildrenIterator

public DocumentModelIterator getChildrenIterator(DocumentRef parent,
                                                 String type,
                                                 String perm,
                                                 Filter filter)
                                          throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getChildrenIterator in interface CoreSession
Returns:
Throws:
ClientException

getDocument

public DocumentModel getDocument(DocumentRef docRef)
                          throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getDocument in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the document
Throws:
ClientException

getDocument

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

Specified by:
getDocument in interface CoreSession
Throws:
ClientException

getDocuments

public DocumentModelList getDocuments(DocumentRef[] docRefs)
                               throws ClientException
Description copied from interface: CoreSession
Gets a list of documents given their references.

Documents that are not accessible are skipped.

Specified by:
getDocuments in interface CoreSession
Throws:
ClientException

getFiles

public DocumentModelList getFiles(DocumentRef parent)
                           throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getChildren(DocumentRef) but returns only non-folder documents.

Specified by:
getFiles in interface CoreSession
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

public DocumentModelIterator getFilesIterator(DocumentRef parent)
                                       throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getFiles(DocumentRef) but returns an iterator.

Specified by:
getFilesIterator in interface CoreSession
Returns:
Throws:
ClientException

getFiles

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

Specified by:
getFiles in interface CoreSession
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

getFolders

public DocumentModelList getFolders(DocumentRef parent)
                             throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getChildren(DocumentRef) but returns only folder documents.

Specified by:
getFolders in interface CoreSession
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

public DocumentModelIterator getFoldersIterator(DocumentRef parent)
                                         throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getFolders(DocumentRef) but returns a lazy loading iterator over the list of children.

Specified by:
getFoldersIterator in interface CoreSession
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

public DocumentModelList getFolders(DocumentRef parent,
                                    Filter filter,
                                    Sorter sorter)
                             throws ClientException
Description copied from interface: CoreSession
Same as CoreSession.getFolders(DocumentRef) but uses an optional filter and sorter on the result.

Specified by:
getFolders in interface CoreSession
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

public DocumentRef getParentDocumentRef(DocumentRef docRef)
                                 throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getParentDocumentRef in interface CoreSession
Throws:
ClientException

getParentDocument

public DocumentModel getParentDocument(DocumentRef docRef)
                                throws ClientException
Description copied from interface: CoreSession
Gets the parent document or null if this is the root document.

Specified by:
getParentDocument in interface CoreSession
Returns:
the parent document or null if this is the root document
Throws:
ClientException

getParentDocuments

public List<DocumentModel> getParentDocuments(DocumentRef docRef)
                                       throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getParentDocuments in interface CoreSession
Returns:
the list with parent documents or empty list if this is the root document
Throws:
ClientException

getRootDocument

public DocumentModel getRootDocument()
                              throws ClientException
Description copied from interface: CoreSession
Gets the root document of this repository.

Specified by:
getRootDocument in interface CoreSession
Returns:
the root document. cannot be null
Throws:
ClientException

hasChildren

public boolean hasChildren(DocumentRef docRef)
                    throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
hasChildren in interface CoreSession
Parameters:
docRef - the reference to the document to test
Returns:
true if document has children, false otherwise
Throws:
ClientException

query

public DocumentModelList query(String query)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query an returns the result.

Specified by:
query in interface CoreSession
Parameters:
query - the query to execute
Returns:
the query result
Throws:
ClientException

query

public DocumentModelList query(String query,
                               int max)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query an returns the result.

Specified by:
query in interface CoreSession
Parameters:
query - the query to execute
max - number of document to retrieve
Returns:
the query result
Throws:
ClientException

query

public DocumentModelList query(String query,
                               Filter filter)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query and returns the result that matches the filter.

Specified by:
query in interface CoreSession
Parameters:
query - the query to execute
filter - the filter to apply to result
Returns:
the query result
Throws:
ClientException

query

public DocumentModelList query(String query,
                               Filter filter,
                               int max)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query and returns the result that matches the filter.

Specified by:
query in interface CoreSession
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

public DocumentModelList query(String query,
                               Filter filter,
                               long limit,
                               long offset,
                               boolean countTotal)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query and returns the result that matches the filter.

Specified by:
query in interface CoreSession
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

public DocumentModelList query(String query,
                               String queryType,
                               Filter filter,
                               long limit,
                               long offset,
                               boolean countTotal)
                        throws ClientException
Description copied from interface: CoreSession
Executes the given query and returns the result that matches the filter.

Specified by:
query in interface CoreSession
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

public IterableQueryResult queryAndFetch(String query,
                                         String queryType,
                                         Object... params)
                                  throws ClientException
Specified by:
queryAndFetch in interface CoreSession
Throws:
ClientException

queryIt

public DocumentModelIterator queryIt(String query,
                                     Filter filter,
                                     int max)
                              throws ClientException
Description copied from interface: CoreSession
Executes the given NXQL query and returns an iterators of results.

Specified by:
queryIt in interface CoreSession
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
public DocumentModelList querySimpleFts(String keywords)
                                 throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Executes a specific FULLTEXT enabled query for the given keywords.

Specified by:
querySimpleFts in interface CoreSession
Throws:
ClientException

querySimpleFts

@Deprecated
public DocumentModelList querySimpleFts(String keywords,
                                                   Filter filter)
                                 throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Executes a specific FULLTEXT enabled query for the given keywords, returning only results that match the specified filter.

Specified by:
querySimpleFts in interface CoreSession
Throws:
ClientException

querySimpleFtsIt

@Deprecated
public DocumentModelIterator querySimpleFtsIt(String query,
                                                         Filter filter,
                                                         int pageSize)
                                       throws ClientException
Deprecated. 

Specified by:
querySimpleFtsIt in interface CoreSession
Throws:
ClientException

querySimpleFtsIt

@Deprecated
public DocumentModelIterator querySimpleFtsIt(String query,
                                                         String startingPath,
                                                         Filter filter,
                                                         int pageSize)
                                       throws ClientException
Deprecated. 

Specified by:
querySimpleFtsIt in interface CoreSession
Throws:
ClientException

removeChildren

public void removeChildren(DocumentRef docRef)
                    throws ClientException
Description copied from interface: CoreSession
Removes all children from the given document.

Specified by:
removeChildren in interface CoreSession
Parameters:
docRef - the reference to the document to remove
Throws:
ClientException

canRemoveDocument

public boolean canRemoveDocument(DocumentRef docRef)
                          throws ClientException
Description copied from interface: CoreSession
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).

Specified by:
canRemoveDocument in interface CoreSession
Parameters:
docRef - the document
Returns:
true if the document can be removed
Throws:
ClientException

removeDocument

public void removeDocument(DocumentRef docRef)
                    throws ClientException
Description copied from interface: CoreSession
Removes this document and all its children, if any.

Specified by:
removeDocument in interface CoreSession
Parameters:
docRef - the reference to the document to remove
Throws:
ClientException

removeDocuments

public void removeDocuments(DocumentRef[] docRefs)
                     throws ClientException
Implementation uses the fact that the lexicographic ordering of paths is a refinement of the "contains" partial ordering.

Specified by:
removeDocuments in interface CoreSession
Parameters:
docRefs - the refs to the document to remove
Throws:
ClientException

save

public void save()
          throws ClientException
Description copied from interface: CoreSession
Saves any pending changes done until now through this session.

Specified by:
save in interface CoreSession
Throws:
ClientException

saveDocument

public DocumentModel saveDocument(DocumentModel docModel)
                           throws ClientException
Description copied from interface: CoreSession
Saves changes done on the given document model.

Specified by:
saveDocument in interface CoreSession
Parameters:
docModel - the document model that needs modified
Throws:
ClientException

isDirty

@Deprecated
public boolean isDirty(DocumentRef docRef)
                throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Checks if the given document is dirty.

Specified by:
isDirty in interface CoreSession
Parameters:
docRef - the doc reference
Returns:
true if dirty false otherwise
Throws:
ClientException

saveDocuments

public void saveDocuments(DocumentModel[] docModels)
                   throws ClientException
Description copied from interface: CoreSession
Bulk document saving.

Specified by:
saveDocuments in interface CoreSession
Parameters:
docModels - the document models that needs to be saved
Throws:
ClientException

getSourceDocument

public DocumentModel getSourceDocument(DocumentRef docRef)
                                throws ClientException
Description copied from interface: CoreSession
Gets the head (live) document for this document.

Specified by:
getSourceDocument in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the version
Throws:
ClientException - if any error occurs

getLastVersion

public VersionModel getLastVersion(DocumentRef docRef)
                            throws ClientException
Description copied from interface: CoreSession
Gets the last version of a document.

Specified by:
getLastVersion in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the version
Throws:
ClientException - if any error occurs

getLastDocumentVersion

public DocumentModel getLastDocumentVersion(DocumentRef docRef)
                                     throws ClientException
Description copied from interface: CoreSession
Gets the document corresponding to the last version for the given document.

Specified by:
getLastDocumentVersion in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the document model corresponding to the version
Throws:
ClientException

getLastDocumentVersionRef

public DocumentRef getLastDocumentVersionRef(DocumentRef docRef)
                                      throws ClientException
Description copied from interface: CoreSession
Gets the document reference corresponding to the last version for the given document.

Specified by:
getLastDocumentVersionRef in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the document reference corresponding to the last version
Throws:
ClientException

getVersionsRefs

public List<DocumentRef> getVersionsRefs(DocumentRef docRef)
                                  throws ClientException
Description copied from interface: CoreSession
Gets the references of the versions of the document.

Specified by:
getVersionsRefs in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
a list of version references
Throws:
ClientException

getVersions

public List<DocumentModel> getVersions(DocumentRef docRef)
                                throws ClientException
Description copied from interface: CoreSession
Retrieves all the versions for a specified document.

Specified by:
getVersions in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the list of DocumentModel representing versions, empty list if none is found.
Throws:
ClientException

getVersionsForDocument

public List<VersionModel> getVersionsForDocument(DocumentRef docRef)
                                          throws ClientException
Description copied from interface: CoreSession
Retrieves all the versions for a specified document.

Specified by:
getVersionsForDocument in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
the list of VersionModel representing versions, empty list if none is found.
Throws:
ClientException

restoreToVersion

public DocumentModel restoreToVersion(DocumentRef docRef,
                                      DocumentRef versionRef)
                               throws ClientException
Description copied from interface: CoreSession
Restores the given document to the specified version.

Specified by:
restoreToVersion in interface CoreSession
Parameters:
docRef - the reference to the document
versionRef - the reference to the version
Throws:
ClientException

restoreToVersion

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

Description copied from interface: CoreSession
Restores the given document to the specified version.

Specified by:
restoreToVersion in interface CoreSession
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

restoreToVersion

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

Description copied from interface: CoreSession
Restores the given document to the specified version permitting to skip the creation of the snapshot for current document.

Specified by:
restoreToVersion in interface CoreSession
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

public DocumentModel restoreToVersion(DocumentRef docRef,
                                      DocumentRef versionRef,
                                      boolean skipSnapshotCreation,
                                      boolean skipCheckout)
                               throws ClientException
Description copied from interface: CoreSession
Restores the given document to the specified version.

Specified by:
restoreToVersion in interface CoreSession
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

getBaseVersion

public DocumentRef getBaseVersion(DocumentRef docRef)
                           throws ClientException
Description copied from interface: CoreSession
Gets the version to which a checked in document is linked.

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

Specified by:
getBaseVersion in interface CoreSession
Returns:
the version, or null
Throws:
ClientException

checkIn

@Deprecated
public DocumentModel checkIn(DocumentRef docRef,
                                        VersionModel ver)
                      throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Checks in a modified document, creating a new version.

Specified by:
checkIn in interface CoreSession
Parameters:
docRef - the reference to the document
ver - the version descriptor
Returns:
the version document just created
Throws:
ClientException

checkIn

public DocumentRef checkIn(DocumentRef docRef,
                           VersioningOption option,
                           String checkinComment)
                    throws ClientException
Description copied from interface: CoreSession
Checks in a modified document, creating a new version.

Specified by:
checkIn in interface CoreSession
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

checkOut

public void checkOut(DocumentRef docRef)
              throws ClientException
Description copied from interface: CoreSession
Checks out a versioned document.

Specified by:
checkOut in interface CoreSession
Parameters:
docRef - the reference to the document
Throws:
ClientException

internalCheckOut

public void internalCheckOut(DocumentRef docRef)
                      throws ClientException
Throws:
ClientException

isCheckedOut

public boolean isCheckedOut(DocumentRef docRef)
                     throws ClientException
Description copied from interface: CoreSession
Returns whether the current document is checked-out or not.

Specified by:
isCheckedOut in interface CoreSession
Parameters:
docRef - the reference to the document
Returns:
Throws:
ClientException

getVersionSeriesId

public String getVersionSeriesId(DocumentRef docRef)
                          throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getVersionSeriesId in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the version series id
Throws:
ClientException

getWorkingCopy

public DocumentModel getWorkingCopy(DocumentRef docRef)
                             throws ClientException
Description copied from interface: CoreSession
Gets the working copy (live document) for a proxy or a version.

Specified by:
getWorkingCopy in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the working copy, or null if not found
Throws:
ClientException

getVersion

public DocumentModel getVersion(String versionableId,
                                VersionModel versionModel)
                         throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getVersion in interface CoreSession
Parameters:
versionableId - the versionable id
versionModel - the version model holding the label
Returns:
the version, or null if not found
Throws:
ClientException

getVersionLabel

public String getVersionLabel(DocumentModel docModel)
                       throws ClientException
Description copied from interface: CoreSession
Gets the version label for a document, according to the versioning service.

Specified by:
getVersionLabel in interface CoreSession
Parameters:
docModel - the document
Returns:
the version label
Throws:
ClientException

getDocumentWithVersion

public DocumentModel getDocumentWithVersion(DocumentRef docRef,
                                            VersionModel version)
                                     throws ClientException
Description copied from interface: CoreSession
Returns a document that represents the specified version of the document.

Specified by:
getDocumentWithVersion in interface CoreSession
Parameters:
docRef - the reference to the document
version - the version for which we want the corresponding document
Returns:
Throws:
ClientException

createProxy

public DocumentModel createProxy(DocumentRef docRef,
                                 DocumentRef folderRef)
                          throws ClientException
Description copied from interface: CoreSession
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".

Specified by:
createProxy in interface CoreSession
Throws:
ClientException

createProxy

@Deprecated
public DocumentModel createProxy(DocumentRef parentRef,
                                            DocumentRef docRef,
                                            VersionModel version,
                                            boolean overwriteExistingProxy)
                          throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Creates a proxy for the given version of the given document.

Specified by:
createProxy in interface CoreSession
docRef - the reference to the document
version - the version
Returns:
the proxy
Throws:
ClientException - if any error occurs

getProxies

public DocumentModelList getProxies(DocumentRef docRef,
                                    DocumentRef folderRef)
                             throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getProxies in interface CoreSession
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

getProxyVersions

public String[] getProxyVersions(DocumentRef docRef,
                                 DocumentRef folderRef)
                          throws ClientException
Description copied from interface: CoreSession
Gets all proxy versions to document docRef inside folder folderRef.

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

Specified by:
getProxyVersions in interface CoreSession
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

getAvailableSecurityPermissions

public List<String> getAvailableSecurityPermissions()
                                             throws ClientException
Description copied from interface: CoreSession
Retrieves the available security permissions existing in the system.

Specified by:
getAvailableSecurityPermissions in interface CoreSession
Returns:
a raw list of permission names, either basic or group names
Throws:
ClientException

getDataModel

@Deprecated
public DataModel getDataModel(DocumentRef docRef,
                                         String schema)
                       throws ClientException
Deprecated. 

Specified by:
getDataModel in interface CoreSession
Throws:
ClientException

getDataModel

public DataModel getDataModel(DocumentRef docRef,
                              Schema schema)
                       throws ClientException
Description copied from interface: CoreSession
Retrieves a data model given a document reference and a schema.

For INTERNAL use by the core.

Specified by:
getDataModel in interface CoreSession
Throws:
ClientException

getDataModelField

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

Specified by:
getDataModelField in interface CoreSession
Throws:
ClientException

getDataModelFields

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

Specified by:
getDataModelFields in interface CoreSession
Throws:
ClientException

getContentData

public SerializableInputStream getContentData(String key)
                                       throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getContentData in interface CoreSession
Returns:
Throws:
ClientException

getStreamURI

public String getStreamURI(String blobPropertyId)
                    throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getStreamURI in interface CoreSession
Returns:
an URI identifying the remote stream
Throws:
ClientException

getCurrentLifeCycleState

public String getCurrentLifeCycleState(DocumentRef docRef)
                                throws ClientException
Description copied from interface: CoreSession
Returns the life cycle of the document.

Specified by:
getCurrentLifeCycleState in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the life cycle as a string
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

getLifeCyclePolicy

public String getLifeCyclePolicy(DocumentRef docRef)
                          throws ClientException
Description copied from interface: CoreSession
Returns the life cycle policy of the document.

Specified by:
getLifeCyclePolicy in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the life cycle policy
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

followTransition

public boolean followTransition(DocumentRef docRef,
                                String transition)
                         throws ClientException
Description copied from interface: CoreSession
Follows a given life cycle transition.

This will update the current life cycle of the document.

Specified by:
followTransition in interface CoreSession
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

public Collection<String> getAllowedStateTransitions(DocumentRef docRef)
                                              throws ClientException
Description copied from interface: CoreSession
Gets the allowed state transitions for this document.

Specified by:
getAllowedStateTransitions in interface CoreSession
Parameters:
docRef - the document reference
Returns:
a collection of state transitions as string
Throws:
ClientException

reinitLifeCycleState

public void reinitLifeCycleState(DocumentRef docRef)
                          throws ClientException
Description copied from interface: CoreSession
Reinitializes the life cycle state of the document to its default state.

Specified by:
reinitLifeCycleState in interface CoreSession
Parameters:
docRef - the document
Throws:
ClientException

getDataModelsField

public Object[] getDataModelsField(DocumentRef[] docRefs,
                                   String schema,
                                   String field)
                            throws ClientException
Description copied from interface: CoreSession
Retrieves the given field value from the given schema for all the given documents.

Specified by:
getDataModelsField in interface CoreSession
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

getParentDocumentRefs

public DocumentRef[] getParentDocumentRefs(DocumentRef docRef)
                                    throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getParentDocumentRefs in interface CoreSession
Returns:
an array with ancestor documents ref
Throws:
ClientException

getDataModelsFieldUp

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

Specified by:
getDataModelsFieldUp in interface CoreSession
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
public String getLock(DocumentRef docRef)
               throws ClientException
Deprecated. 

Description copied from interface: CoreSession
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.

Specified by:
getLock in interface CoreSession
Parameters:
docRef - the document reference
Returns:
the lock key if the document is locked, null otherwise
Throws:
ClientException

setLock

@Deprecated
public void setLock(DocumentRef docRef,
                               String key)
             throws ClientException
Deprecated. 

Description copied from interface: CoreSession
Sets a lock on the given document using the given key.

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

Specified by:
setLock in interface CoreSession
Parameters:
docRef - the document reference
key - the lock key
Throws:
ClientException - if a lock is already set or other exception occurred

unlock

@Deprecated
public String unlock(DocumentRef docRef)
              throws ClientException
Deprecated. 

Description copied from interface: CoreSession
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.

Specified by:
unlock in interface CoreSession
Parameters:
docRef - the document to unlock
Returns:
the lock key that was removed
Throws:
ClientException

setLock

public Lock setLock(DocumentRef docRef)
             throws ClientException
Description copied from interface: CoreSession
Sets a lock on the given document.

Specified by:
setLock in interface CoreSession
Returns:
the lock info that was set
Throws:
ClientException - if a lock was already set

getLockInfo

public Lock getLockInfo(DocumentRef docRef)
                 throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
getLockInfo in interface CoreSession
Returns:
the lock info if the document is locked, or null otherwise
Throws:
ClientException

removeLock

public Lock removeLock(DocumentRef docRef)
                throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
removeLock in interface CoreSession
Parameters:
docRef - the document to unlock
Returns:
the removed lock info, or null if there was no lock
Throws:
ClientException

applyDefaultPermissions

public void applyDefaultPermissions(String userOrGroupName)
                             throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
applyDefaultPermissions in interface CoreSession
Throws:
ClientException

destroy

public void destroy()
Description copied from interface: CoreSession
Destroys any system resources held by this instance.

Called when the instance is no more needed.

Specified by:
destroy in interface CoreSession

publishDocument

public DocumentModel publishDocument(DocumentModel docToPublish,
                                     DocumentModel section)
                              throws ClientException
Description copied from interface: CoreSession
Publishes the document in a section overwriting any existing proxy to the same document. This is simmilar to publishDocument(docToPublish, section, true);

Specified by:
publishDocument in interface CoreSession
Returns:
The proxy document that was created
Throws:
ClientException

publishDocument

public DocumentModel publishDocument(DocumentModel docModel,
                                     DocumentModel section,
                                     boolean overwriteExistingProxy)
                              throws ClientException
Description copied from interface: CoreSession
Publishes the document in a section.

Specified by:
publishDocument in interface CoreSession
Returns:
The proxy document that was created
Throws:
ClientException

getSuperParentType

public String getSuperParentType(DocumentModel doc)
                          throws ClientException
Description copied from interface: CoreSession
Returns the type of his parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.

Specified by:
getSuperParentType in interface CoreSession
Returns:
Throws:
ClientException

getSuperSpace

public DocumentModel getSuperSpace(DocumentModel doc)
                            throws ClientException
Description copied from interface: CoreSession
Returns the parent SuperSpace (workspace, section, etc.). SuperSpace is qualified by the SuperSpace facet.

Specified by:
getSuperSpace in interface CoreSession
Returns:
DocumentModel of SuperSpace
Throws:
ClientException

getSecuritySummary

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

Specified by:
getSecuritySummary in interface CoreSession
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

public String getRepositoryName()
Description copied from interface: CoreSession
Returns the repository name against which this core session is bound.

Specified by:
getRepositoryName in interface CoreSession
Returns:
the repository name used currently used as an identifier

getDocumentSystemProp

public <T extends Serializable> T getDocumentSystemProp(DocumentRef ref,
                                                        String systemProperty,
                                                        Class<T> type)
                                             throws ClientException,
                                                    DocumentException
Description copied from interface: CoreSession
Gets system property of the specified type for the document ref.

Specified by:
getDocumentSystemProp in interface CoreSession
Returns:
Throws:
ClientException
DocumentException

setDocumentSystemProp

public <T extends Serializable> void setDocumentSystemProp(DocumentRef ref,
                                                           String systemProperty,
                                                           T value)
                           throws ClientException,
                                  DocumentException
Description copied from interface: CoreSession
Sets given value as a system property.

Specified by:
setDocumentSystemProp in interface CoreSession
Throws:
ClientException
DocumentException

orderBefore

public void orderBefore(DocumentRef parent,
                        String src,
                        String dest)
                 throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
orderBefore in interface CoreSession
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

public <T> T run(Operation<T> op)
      throws ClientException
Description copied from interface: CoreSession
Run a command

Specified by:
run in interface CoreSession
Type Parameters:
T - command result type
Parameters:
op - the command to run
Returns:
the command result
Throws:
ClientException - if any error occurs

run

public <T> T run(Operation<T> op,
                 ProgressMonitor monitor)
      throws ClientException
Description copied from interface: CoreSession
Run a command and notify the given monitor about the execution progress

Specified by:
run in interface CoreSession
Returns:
Throws:
ClientException

startOperation

public void startOperation(Operation<?> operation)
This method is for compatibility reasons to notify an operation start. Operations must be reworked to use the new event model. In order for operation notification to work the event compatibility bundle must be deployed.

Specified by:
startOperation in interface OperationHandler
See Also:
in nuxeo-core-event-compat

endOperation

public void endOperation(Operation<?> operation)
This method is for compatibility reasons to notify an operation end. Operations must be reworked to use the new event model. In order for operation notification to work the event compatibility bundle must be deployed.

Specified by:
endOperation in interface OperationHandler
See Also:
in nuxeo-core-event-compat

refreshDocument

public DocumentModel.DocumentModelRefresh refreshDocument(DocumentRef ref,
                                                          int refreshFlags,
                                                          String[] schemas)
                                                   throws ClientException
Description copied from interface: CoreSession
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

Specified by:
refreshDocument in interface CoreSession
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

public String[] getPermissionsToCheck(String permission)
Description copied from interface: CoreSession
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.

Specified by:
getPermissionsToCheck in interface CoreSession
Returns:
the list, as an array of strings.

adaptFirstMatchingDocumentWithFacet

public <T extends DetachedAdapter> T adaptFirstMatchingDocumentWithFacet(DocumentRef docRef,
                                                                         String facet,
                                                                         Class<T> adapterClass)
                                                              throws ClientException
Description copied from interface: CoreSession
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.

Specified by:
adaptFirstMatchingDocumentWithFacet in interface CoreSession
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

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.