Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql.coremodel
Class SQLSession

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession
All Implemented Interfaces:
Session

public class SQLSession
extends Object
implements Session

This class is the bridge between the Nuxeo SPI Session and the actual low-level implementation of the SQL storage session.

Author:
Florent Guillaume

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.core.model.Session
USER_NAME
 
Constructor Summary
SQLSession(Session session, Repository repository, Map<String,Serializable> context)
           
 
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 source, Document parent, 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 document, String label)
          Creates a proxy to the given version of the given document inside the given parent.
 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 getLastVersion(Serializable versionSeriesId)
           
 Document getNullDocument()
          Gets the null document, to be used as a fake parent to add placeless children.
 Collection<Document> getProxies(Document document, Document parent)
          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 source, Document parent, String name)
          Moves the source document to the given folder.
 IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params)
           
 void requireReadAclsUpdate()
          This method flag the current session, the read ACLs update will be done automatically at save time.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLSession

public SQLSession(Session session,
                  Repository repository,
                  Map<String,Serializable> context)
           throws DocumentException
Throws:
DocumentException
Method Detail

getRootDocument

public Document getRootDocument()
Description copied from interface: Session
Gets the root document in this repository.

Specified by:
getRootDocument in interface Session
Returns:
the root document

getNullDocument

public Document getNullDocument()
Description copied from interface: Session
Gets the null document, to be used as a fake parent to add placeless children.

Specified by:
getNullDocument in interface Session
Returns:
the null document

getXAResource

public XAResource getXAResource()
Description copied from interface: Session
The XAResource corresponding to this session.

Specified by:
getXAResource in interface Session
Returns:
the XAResource

close

public void close()
           throws DocumentException
Description copied from interface: Session
Closes this session and saves changes on the workspace, if any.

Specified by:
close in interface Session
Throws:
DocumentException - if any error occurs

save

public void save()
          throws DocumentException
Description copied from interface: Session
Saves this session.

Specified by:
save in interface Session
Throws:
DocumentException - if any error occurs

cancel

public void cancel()
            throws DocumentException
Description copied from interface: Session
Cancels changes done in this session.

Specified by:
cancel in interface Session
Throws:
DocumentException - if any error occurs

isLive

public boolean isLive()
Description copied from interface: Session
Checks whether the session is alive.

Specified by:
isLive in interface Session
Returns:
true if the session is closed, false otherwise

dispose

public void dispose()
Description copied from interface: Session
Closes the session and cancel changes on workspace, if any.

Specified by:
dispose in interface Session

getSessionId

public long getSessionId()
Description copied from interface: Session
Gets the session id.

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

Specified by:
getSessionId in interface Session
Returns:
the session id

getUserSessionId

public String getUserSessionId()
Description copied from interface: Session
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.

Specified by:
getUserSessionId in interface Session
Returns:
the user session id

getRepository

public Repository getRepository()
Description copied from interface: Session
Gets the repository that created this session.

Specified by:
getRepository in interface Session
Returns:
the repository

getSessionContext

public Map<String,Serializable> getSessionContext()
Description copied from interface: Session
Gets the session context used to create this session.

Specified by:
getSessionContext in interface Session
Returns:
the session context

getTypeManager

public SchemaManager getTypeManager()
Description copied from interface: Session
Gets the type manager used by the repository.

Specified by:
getTypeManager in interface Session
Returns:
the type manager

getSecurityManager

public SecurityManager getSecurityManager()
Description copied from interface: Session
Gets the security manager used by the repository.

Specified by:
getSecurityManager in interface Session
Returns:
the security manager

getDocumentByUUID

public Document getDocumentByUUID(String uuid)
                           throws DocumentException
Description copied from interface: Session
Gets a document given its ID.

Specified by:
getDocumentByUUID in interface Session
Parameters:
uuid - the document id
Returns:
the document
Throws:
DocumentException - if any error occurs

resolvePath

public Document resolvePath(String path)
                     throws DocumentException
Description copied from interface: Session
Gets the document at the given path, if any.

Specified by:
resolvePath in interface Session
Returns:
Throws:
DocumentException - if any error occurs

move

public Document move(Document source,
                     Document parent,
                     String name)
              throws DocumentException
Description copied from interface: Session
Moves the source document to the given folder.

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

Specified by:
move in interface Session
Parameters:
source - the source document to move
parent - 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

copy

public Document copy(Document source,
                     Document parent,
                     String name)
              throws DocumentException
Description copied from interface: Session
Copies the source document to the given folder.

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

Specified by:
copy in interface Session
Throws:
DocumentException - if any error occurs

getVersion

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

Specified by:
getVersion in interface Session
Parameters:
versionableId - the versionable id
versionModel - the version model
Returns:
the version, or null if not found
Throws:
DocumentException

createProxy

public Document createProxy(Document doc,
                            Document folder)
                     throws DocumentException
Description copied from interface: Session
Creates a generic proxy to the given document inside the given folder.

Specified by:
createProxy in interface Session
Parameters:
doc - the document
folder - the folder
Returns:
the proxy
Throws:
DocumentException - if any error occurs

createProxyForVersion

public Document createProxyForVersion(Document parent,
                                      Document document,
                                      String label)
                               throws DocumentException
Description copied from interface: Session
Creates a proxy to the given version of the given document inside the given parent.

Specified by:
createProxyForVersion in interface Session
Parameters:
parent - the parent
document - the document
label - the version
Returns:
the proxy
Throws:
DocumentException - if any error occurs

getProxies

public Collection<Document> getProxies(Document document,
                                       Document parent)
                                throws DocumentException
Description copied from interface: Session
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.

Specified by:
getProxies in interface Session
Parameters:
document - the document or version
parent - the folder, or null
Returns:
the list of proxies if any is found otherwise an empty list
Throws:
DocumentException - if any error occurs

setProxyTarget

public void setProxyTarget(Document proxy,
                           Document target)
                    throws DocumentException
Description copied from interface: Session
Sets a proxies' target.

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

Specified by:
setProxyTarget in interface Session
Parameters:
proxy - the proxy
target - the new target
Throws:
DocumentException

getDataStream

public InputStream getDataStream(String key)
                          throws DocumentException
Description copied from interface: Session
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.

Specified by:
getDataStream in interface Session
Parameters:
key - the key of the blob data
Returns:
the blob stream
Throws:
DocumentException - if any error occurs

importDocument

public Document importDocument(String uuid,
                               Document parent,
                               String name,
                               String typeName,
                               Map<String,Serializable> properties)
                        throws DocumentException
Description copied from interface: Session
Imports a document with a given id and parent.

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

Specified by:
importDocument in interface Session
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

createQuery

public Query createQuery(String query,
                         String queryType,
                         String... params)
                  throws QueryException
Description copied from interface: Session
Creates a query object given a SQL like query string.

Specified by:
createQuery in interface Session
Parameters:
query - the SQL like query
Returns:
the query
Throws:
QueryException

createQuery

public Query createQuery(String query,
                         Query.Type qType,
                         String... params)
                  throws QueryException
Description copied from interface: Session
Creates a query object given a SQL like query string.

Specified by:
createQuery in interface Session
Parameters:
query - the SQL like query
Returns:
the query
Throws:
QueryException

queryAndFetch

public IterableQueryResult queryAndFetch(String query,
                                         String queryType,
                                         QueryFilter queryFilter,
                                         Object... params)
                                  throws QueryException
Specified by:
queryAndFetch in interface Session
Throws:
QueryException

getLastVersion

public Document getLastVersion(Serializable versionSeriesId)
                        throws DocumentException
Throws:
DocumentException

requireReadAclsUpdate

public void requireReadAclsUpdate()
This method flag the current session, the read ACLs update will be done automatically at save time.


Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.