Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.model
Interface Session

All Known Implementing Classes:
SQLSession

public interface Session

Author:
Bogdan Stefanescu

Field Summary
static String USER_NAME
           
 
Method Summary
 void cancel()
          Cancels changes done in this session.
 void close()
          Closes this session and saves changes on the workspace, if any.
 Document copy(Document src, Document dst, String name)
          Copies the source document to the given folder.
 Document createProxy(Document doc, Document folder)
          Creates a generic proxy to the given document inside the given folder.
 Document createProxyForVersion(Document parent, Document doc, String versionLabel)
          Deprecated.  
 Query createQuery(String query, Query.Type qType, String... params)
          Creates a query object given a SQL like query string.
 Query createQuery(String query, String queryType, String... params)
          Creates a query object given a SQL like query string.
 void dispose()
          Closes the session and cancel changes on workspace, if any.
 InputStream getDataStream(String key)
          Gets a blob stream using the given key.
 Document getDocumentByUUID(String uuid)
          Gets a document given its ID.
 Document getNullDocument()
          Gets the null document, to be used as a fake parent to add placeless children.
 Collection<Document> getProxies(Document doc, Document folder)
          Finds the proxies for a document.
 Repository getRepository()
          Gets the repository that created this session.
 Document getRootDocument()
          Gets the root document in this repository.
 SecurityManager getSecurityManager()
          Gets the security manager used by the repository.
 Map<String,Serializable> getSessionContext()
          Gets the session context used to create this session.
 long getSessionId()
          Gets the session id.
 SchemaManager getTypeManager()
          Gets the type manager used by the repository.
 String getUserSessionId()
          The unique ID of the user session on this repository.
 Document getVersion(String versionableId, VersionModel versionModel)
          Gets a version of a document, given its versionable id and label.
 XAResource getXAResource()
          The XAResource corresponding to this session.
 Document importDocument(String uuid, Document parent, String name, String typeName, Map<String,Serializable> properties)
          Imports a document with a given id and parent.
 boolean isLive()
          Checks whether the session is alive.
 Document move(Document src, Document dst, String name)
          Moves the source document to the given folder.
 IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params)
           
 Document resolvePath(String path)
          Gets the document at the given path, if any.
 void save()
          Saves this session.
 void setProxyTarget(Document proxy, Document target)
          Sets a proxies' target.
 

Field Detail

USER_NAME

static final String USER_NAME
See Also:
Constant Field Values
Method Detail

getSessionId

long getSessionId()
Gets the session id.

This is an unique identifier of this session relative to the current JVM.

Returns:
the session id

getUserSessionId

String getUserSessionId()
The unique ID of the user session on this repository.

The ID is unique in the application (possible deployed on multiple machines).

This ID is normally passed by the session creator through the session context.

Returns:
the user session id

getRepository

Repository getRepository()
Gets the repository that created this session.

Returns:
the repository

getSessionContext

Map<String,Serializable> getSessionContext()
Gets the session context used to create this session.

Returns:
the session context

createQuery

Query createQuery(String query,
                  String queryType,
                  String... params)
                  throws QueryException
Creates a query object given a SQL like query string.

Parameters:
query - the SQL like query
Returns:
the query
Throws:
QueryException

createQuery

Query createQuery(String query,
                  Query.Type qType,
                  String... params)
                  throws QueryException
Creates a query object given a SQL like query string.

Parameters:
query - the SQL like query
Returns:
the query
Throws:
QueryException

queryAndFetch

IterableQueryResult queryAndFetch(String query,
                                  String queryType,
                                  QueryFilter queryFilter,
                                  Object... params)
                                  throws QueryException
Throws:
QueryException

getTypeManager

SchemaManager getTypeManager()
Gets the type manager used by the repository.

Returns:
the type manager

getSecurityManager

SecurityManager getSecurityManager()
Gets the security manager used by the repository.

Returns:
the security manager

getXAResource

XAResource getXAResource()
The XAResource corresponding to this session.

Returns:
the XAResource

save

void save()
          throws DocumentException
Saves this session.

Throws:
DocumentException - if any error occurs

cancel

void cancel()
            throws DocumentException
Cancels changes done in this session.

Throws:
DocumentException - if any error occurs

isLive

boolean isLive()
Checks whether the session is alive.

Returns:
true if the session is closed, false otherwise

close

void close()
           throws DocumentException
Closes this session and saves changes on the workspace, if any.

Throws:
DocumentException - if any error occurs

dispose

void dispose()
Closes the session and cancel changes on workspace, if any.


resolvePath

Document resolvePath(String path)
                     throws DocumentException
Gets the document at the given path, if any.

Parameters:
path -
Returns:
Throws:
DocumentException - if any error occurs

getDocumentByUUID

Document getDocumentByUUID(String uuid)
                           throws DocumentException
Gets a document given its ID.

Parameters:
uuid - the document id
Returns:
the document
Throws:
DocumentException - if any error occurs

getRootDocument

Document getRootDocument()
                         throws DocumentException
Gets the root document in this repository.

Returns:
the root document
Throws:
DocumentException - if any error occurs

getNullDocument

Document getNullDocument()
                         throws DocumentException
Gets the null document, to be used as a fake parent to add placeless children.

Returns:
the null document
Throws:
DocumentException

copy

Document copy(Document src,
              Document dst,
              String name)
              throws DocumentException
Copies the source document to the given folder.

If the destination document is not a folder, an exception is thrown.

Parameters:
src -
dst -
name -
Throws:
DocumentException - if any error occurs

move

Document move(Document src,
              Document dst,
              String name)
              throws DocumentException
Moves the source document to the given folder.

If the destination document is not a folder an exception is thrown.

Parameters:
src - the source document to move
dst - the destination folder
name - the new name of the document or null if the original name should be preserved
Throws:
DocumentException - if any error occurs

getDataStream

InputStream getDataStream(String key)
                          throws DocumentException
Gets a blob stream using the given key.

The implementation may use anything as the key. It may use the property path or a unique ID of the property.

This method can be used to lazily fetch blob content.

Parameters:
key - the key of the blob data
Returns:
the blob stream
Throws:
DocumentException - if any error occurs

createProxy

Document createProxy(Document doc,
                     Document folder)
                     throws DocumentException
Creates a generic proxy to the given document inside the given folder.

Parameters:
doc - the document
folder - the folder
Returns:
the proxy
Throws:
DocumentException - if any error occurs

createProxyForVersion

@Deprecated
Document createProxyForVersion(Document parent,
                                          Document doc,
                                          String versionLabel)
                               throws DocumentException
Deprecated. 

Creates a proxy to the given version of the given document inside the given parent.

Parameters:
parent - the parent
doc - the document
versionLabel - the version
Returns:
the proxy
Throws:
DocumentException - if any error occurs

getProxies

Collection<Document> getProxies(Document doc,
                                Document folder)
                                throws DocumentException
Finds the proxies for a document. If the folder is not null, the search will be limited to its children.

If the document is a version, then only proxies to that version will be looked up.

Parameters:
doc - the document or version
folder - the folder, or null
Returns:
the list of proxies if any is found otherwise an empty list
Throws:
DocumentException - if any error occurs
Since:
1.4.1 for the case where doc is a proxy

setProxyTarget

void setProxyTarget(Document proxy,
                    Document target)
                    throws DocumentException
Sets a proxies' target.

The target must have the same version series as the proxy.

Parameters:
proxy - the proxy
target - the new target
Throws:
DocumentException
Since:
5.4.3

importDocument

Document importDocument(String uuid,
                        Document parent,
                        String name,
                        String typeName,
                        Map<String,Serializable> properties)
                        throws DocumentException
Imports a document with a given id and parent.

The document can then be filled with the normal imported properties.

Parameters:
uuid - the document uuid
parent - the document parent, or null for a version
name - the document name in its parent
typeName - the document type, or ecm:proxy for a proxy
properties - system properties of the document, which will vary depending whether it's a live document, a version or a proxy (see the various IMPORT_* constants of CoreSession)
Returns:
a writable Document, even for proxies and versions
Throws:
DocumentException

getVersion

Document getVersion(String versionableId,
                    VersionModel versionModel)
                    throws DocumentException
Gets a version of a document, given its 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.

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

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.