org.apache.jackrabbit.core
Class SessionImpl

java.lang.Object
  extended by org.apache.jackrabbit.commons.AbstractSession
      extended by org.apache.jackrabbit.core.SessionImpl
All Implemented Interfaces:
Session, JackrabbitSession, Dumpable, NamePathResolver, NameResolver, PathResolver, NamespaceResolver
Direct Known Subclasses:
XASessionImpl

public class SessionImpl
extends AbstractSession
implements Session, JackrabbitSession, NamespaceResolver, NamePathResolver, Dumpable

A SessionImpl ...


Field Summary
protected  AccessManager accessMgr
          the AccessManager associated with this session
static String ADD_NODE_ACTION
          Deprecated. Use Session.ACTION_ADD_NODE instead.
protected  boolean alive
          flag indicating whether this session is alive
protected  HashMap attributes
          the attributes of this session
static String DISABLE_CLUSTER_SYNC_ON_REFRESH
          Name of the session attribute that controls whether the refresh(boolean) method will cause the repository to synchronize itself to changes in other cluster nodes.
protected  HierarchyManager hierMgr
          the HierarchyManager associated with this session
protected  ItemManager itemMgr
          the item mgr associated with this session
protected  SessionItemStateManager itemStateMgr
          the item state mgr associated with this session
protected  Map listeners
          Listeners (weak references)
protected  AuthContext loginContext
          the AuthContext of this session (can be null if this session was not instantiated through a login process)
protected  NamePathResolver namePathResolver
          Name and Path resolver
protected  NodeTypeManagerImpl ntMgr
          the node type manager
static String READ_ACTION
          Deprecated. Use Session.ACTION_READ instead.
static String REMOVE_ACTION
          Deprecated. Use Session.ACTION_REMOVE instead.
protected  RepositoryImpl rep
          the repository that issued this session
static String SET_PROPERTY_ACTION
          Deprecated. Use Session.ACTION_SET_PROPERTY instead.
protected  Subject subject
          the Subject of this session
protected  String userId
          the user ID that was used to acquire this session
protected  ValueFactory valueFactory
          value factory
protected  VersionManager versionMgr
          The version manager for this session
protected  WorkspaceImpl wsp
          the Workspace associated with this session
 
Fields inherited from interface org.apache.jackrabbit.api.jsr283.Session
ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY
 
Constructor Summary
protected SessionImpl(RepositoryImpl rep, AuthContext loginContext, WorkspaceConfig wspConfig)
          Protected constructor.
protected SessionImpl(RepositoryImpl rep, Subject subject, WorkspaceConfig wspConfig)
          Protected constructor.
 
Method Summary
 void addListener(SessionListener listener)
          Add a SessionListener
 void addLockToken(String lt)
          
 void checkPermission(String absPath, String actions)
          
protected  boolean clusterSyncOnRefresh()
          Checks whether the refresh(boolean) method should cause cluster synchronization.
protected  AccessManager createAccessManager(Subject subject, HierarchyManager hierarchyManager)
          Create the access manager.
 GarbageCollector createDataStoreGarbageCollector()
          Create a data store garbage collector for this repository.
protected  ItemManager createItemManager(SessionItemStateManager itemStateMgr, HierarchyManager hierMgr)
          Create the item manager.
 Session createSession(String workspaceName)
          Creates a new session with the same subject as this sessions but to a different workspace.
protected  SessionItemStateManager createSessionItemStateManager(LocalItemStateManager manager)
          Create the session item state manager.
protected  VersionManager createVersionManager(RepositoryImpl rep)
          Create the version manager.
protected  void createWorkspace(String workspaceName)
          Creates a workspace with the given name.
protected  void createWorkspace(String workspaceName, InputSource configTemplate)
          Creates a workspace with the given name and a workspace configuration template.
protected  WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig, SharedItemStateManager stateMgr, RepositoryImpl rep, SessionImpl session)
          Creates the workspace instance backing this session.
 void dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 void finalize()
          Finalize the session.
 AccessControlManager getAccessControlManager()
          Returns the access control manager for this Session.
 AccessManager getAccessManager()
          Returns the AccessManager associated with this session.
 Object getAttribute(String name)
          
 String[] getAttributeNames()
          
 HierarchyManager getHierarchyManager()
          Returns the HierarchyManager associated with this session.
 ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
          
 Item getItem(String absPath)
          Returns the node or property at the given path.
 ItemManager getItemManager()
          Returns the ItemManager of this session.
protected  SessionItemStateManager getItemStateManager()
          Returns the SessionItemStateManager associated with this session.
 String getJCRName(Name name)
          Returns the prefixed JCR name for the given qualified name.
 String getJCRPath(Path path)
          Returns the prefixed JCR path for the given qualified path.
 LockManager getLockManager()
          Return the lock manager for this session.
 Lock[] getLocks()
          Returns all locks owned by this session.
 String[] getLockTokens()
          
 Node getNode(String absPath)
          Returns the node at the specified absolute path in the workspace.
 NodeImpl getNodeById(NodeId id)
          Retrieves the Node with the given id.
 Node getNodeByIdentifier(String id)
          Returns the node specified by the given identifier.
 Node getNodeByUUID(String uuid)
          
 Node getNodeByUUID(UUID uuid)
          Retrieves the referenceable node with the given UUID.
 NodeTypeManagerImpl getNodeTypeManager()
          Returns the NodeTypeManager.
 String getPrefix(String uri)
          Returns the prefix which is mapped to the given URI.
 PrincipalManager getPrincipalManager()
          Returns the PrincipalManager for the current Session.
 Property getProperty(String absPath)
          Returns the property at the specified absolute path in the workspace.
 Name getQName(String name)
          Returns the qualified name for the given prefixed JCR name.
 Path getQPath(String path)
          Returns the qualified path for the given prefixed JCR path.
 Repository getRepository()
          
 RetentionManager getRetentionManager()
          Returns the retention and hold manager for this Session.
protected  RetentionRegistry getRetentionRegistry()
          Returns the internal retention manager used for evaluation of effective retention policies and holds.
 Node getRootNode()
          
 Subject getSubject()
          Returns the Subject associated with this session.
 String getURI(String prefix)
          Returns the URI to which the given prefix is mapped.
 String getUserID()
          
 UserManager getUserManager()
          Returns the UserManager for the current Session.
 ItemValidator getValidator()
           
 ValueFactory getValueFactory()
          
 VersionManager getVersionManager()
          Returns the VersionManager associated with this session.
 Workspace getWorkspace()
          
protected  String[] getWorkspaceNames()
          Returns the names of all workspaces of this repository with respect of the access rights of this session.
 boolean hasCapability(String methodType, Object target, Map arguments)
          Checks whether an operation can be performed given as much context as can be determined by the repository, including: Permissions granted to the current user, including access control privileges.
 boolean hasPendingChanges()
          
 boolean hasPermission(String absPath, String actions)
          Returns true if this Session has permission to perform the specified actions at the specified absPath and false otherwise.
 Session impersonate(Credentials otherCredentials)
          Logs in the same workspace with the given credentials.
 boolean isLive()
          
 boolean itemExists(String absPath)
          Calls AbstractSession.getItem(String) with the given path and returns true if the call succeeds.
 void logout()
          Clears the local namespace mappings.
 void move(String srcAbsPath, String destAbsPath)
          
 boolean nodeExists(String absPath)
          Returns true if a node exists at absPath and this Session has read access to it; otherwise returns false.
protected  void notifyLoggedOut()
          Notify the listeners that this session has been closed.
protected  void notifyLoggingOut()
          Notify the listeners that this session is about to be closed.
 boolean propertyExists(String absPath)
          Returns true if a property exists at absPath and this Session has read access to it; otherwise returns false.
 void refresh(boolean keepChanges)
          
 void removeItem(String absPath)
          Removes the specified item (and its subtree).
 void removeListener(SessionListener listener)
          Remove a SessionListener
 void removeLockToken(String lt)
          
protected  String retrieveUserId(Subject subject)
          Retrieve the userID from the specified subject.
protected  void sanityCheck()
          Performs a sanity check on this session.
 void save()
          
protected  void setAttribute(String name, Object value)
          Sets the named attribute.
 void setNamespacePrefix(String prefix, String uri)
          Modifies the session local namespace mappings to contain the given prefix to URI mapping.
 
Methods inherited from class org.apache.jackrabbit.commons.AbstractSession
exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, importXML
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jcr.Session
exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, importXML
 

Field Detail

DISABLE_CLUSTER_SYNC_ON_REFRESH

public static final String DISABLE_CLUSTER_SYNC_ON_REFRESH
Name of the session attribute that controls whether the refresh(boolean) method will cause the repository to synchronize itself to changes in other cluster nodes. This cluster synchronization is enabled by default, unless an attribute with this name is set (any non-null value) for this session.

Since:
Apache Jackrabbit 1.6
See Also:
JCR-1753, Constant Field Values

READ_ACTION

public static final String READ_ACTION
Deprecated. Use Session.ACTION_READ instead.
See Also:
Constant Field Values

REMOVE_ACTION

public static final String REMOVE_ACTION
Deprecated. Use Session.ACTION_REMOVE instead.
See Also:
Constant Field Values

ADD_NODE_ACTION

public static final String ADD_NODE_ACTION
Deprecated. Use Session.ACTION_ADD_NODE instead.
See Also:
Constant Field Values

SET_PROPERTY_ACTION

public static final String SET_PROPERTY_ACTION
Deprecated. Use Session.ACTION_SET_PROPERTY instead.
See Also:
Constant Field Values

alive

protected boolean alive
flag indicating whether this session is alive


rep

protected final RepositoryImpl rep
the repository that issued this session


loginContext

protected AuthContext loginContext
the AuthContext of this session (can be null if this session was not instantiated through a login process)


subject

protected final Subject subject
the Subject of this session


userId

protected final String userId
the user ID that was used to acquire this session


attributes

protected final HashMap attributes
the attributes of this session


ntMgr

protected final NodeTypeManagerImpl ntMgr
the node type manager


accessMgr

protected AccessManager accessMgr
the AccessManager associated with this session


itemStateMgr

protected final SessionItemStateManager itemStateMgr
the item state mgr associated with this session


hierMgr

protected final HierarchyManager hierMgr
the HierarchyManager associated with this session


itemMgr

protected final ItemManager itemMgr
the item mgr associated with this session


wsp

protected final WorkspaceImpl wsp
the Workspace associated with this session


namePathResolver

protected NamePathResolver namePathResolver
Name and Path resolver


versionMgr

protected final VersionManager versionMgr
The version manager for this session


listeners

protected final Map listeners
Listeners (weak references)


valueFactory

protected ValueFactory valueFactory
value factory

Constructor Detail

SessionImpl

protected SessionImpl(RepositoryImpl rep,
                      AuthContext loginContext,
                      WorkspaceConfig wspConfig)
               throws AccessDeniedException,
                      RepositoryException
Protected constructor.

Parameters:
rep -
loginContext -
wspConfig -
Throws:
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - if another error occurs

SessionImpl

protected SessionImpl(RepositoryImpl rep,
                      Subject subject,
                      WorkspaceConfig wspConfig)
               throws AccessDeniedException,
                      RepositoryException
Protected constructor.

Parameters:
rep -
subject -
wspConfig -
Throws:
AccessDeniedException - if the given subject is not granted access to the specified workspace
RepositoryException - if another error occurs
Method Detail

retrieveUserId

protected String retrieveUserId(Subject subject)
                         throws RepositoryException
Retrieve the userID from the specified subject.

Returns:
the userID.
Throws:
RepositoryException

createSessionItemStateManager

protected SessionItemStateManager createSessionItemStateManager(LocalItemStateManager manager)
Create the session item state manager.

Returns:
session item state manager

createWorkspaceInstance

protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig,
                                                SharedItemStateManager stateMgr,
                                                RepositoryImpl rep,
                                                SessionImpl session)
Creates the workspace instance backing this session.

Parameters:
wspConfig - The workspace configuration
stateMgr - The shared item state manager
rep - The repository
session - The session
Returns:
An instance of the WorkspaceImpl class or an extension thereof.

createItemManager

protected ItemManager createItemManager(SessionItemStateManager itemStateMgr,
                                        HierarchyManager hierMgr)
Create the item manager.

Returns:
item manager

createVersionManager

protected VersionManager createVersionManager(RepositoryImpl rep)
                                       throws RepositoryException
Create the version manager. If we are not using XA, we may safely use the repository version manager.

Returns:
version manager
Throws:
RepositoryException

createAccessManager

protected AccessManager createAccessManager(Subject subject,
                                            HierarchyManager hierarchyManager)
                                     throws AccessDeniedException,
                                            RepositoryException
Create the access manager.

Parameters:
subject -
hierarchyManager -
Returns:
access manager
Throws:
AccessDeniedException - if the current subject is not granted access to the current workspace
RepositoryException - if the access manager cannot be instantiated

sanityCheck

protected void sanityCheck()
                    throws RepositoryException
Performs a sanity check on this session.

Throws:
RepositoryException - if this session has been rendered invalid for some reason (e.g. if this session has been closed explicitly or if it has expired)

getValidator

public ItemValidator getValidator()
                           throws RepositoryException
Returns:
ItemValidator instance for this session.
Throws:
RepositoryException - If an error occurs.

getSubject

public Subject getSubject()
Returns the Subject associated with this session.

Returns:
the Subject associated with this session

createSession

public Session createSession(String workspaceName)
                      throws AccessDeniedException,
                             NoSuchWorkspaceException,
                             RepositoryException
Creates a new session with the same subject as this sessions but to a different workspace. The returned session is a newly logged in session, with the same subject but a different workspace. Even if the given workspace is the same as this sessions one, the implementation must return a new session object.

Parameters:
workspaceName - name of the workspace to acquire a session for.
Returns:
A session to the requested workspace for the same authenticated subject.
Throws:
AccessDeniedException - in case the current Subject is not allowed to access the requested Workspace
NoSuchWorkspaceException - If the named workspace does not exist.
RepositoryException - in any other exceptional state

getAccessManager

public AccessManager getAccessManager()
Returns the AccessManager associated with this session.

Returns:
the AccessManager associated with this session

getNodeTypeManager

public NodeTypeManagerImpl getNodeTypeManager()
Returns the NodeTypeManager.

Returns:
the NodeTypeManager

getItemManager

public ItemManager getItemManager()
Returns the ItemManager of this session.

Returns:
the ItemManager

getItemStateManager

protected SessionItemStateManager getItemStateManager()
Returns the SessionItemStateManager associated with this session.

Returns:
the SessionItemStateManager associated with this session

getHierarchyManager

public HierarchyManager getHierarchyManager()
Returns the HierarchyManager associated with this session.

Returns:
the HierarchyManager associated with this session

getVersionManager

public VersionManager getVersionManager()
Returns the VersionManager associated with this session.

Returns:
the VersionManager associated with this session

getRetentionRegistry

protected RetentionRegistry getRetentionRegistry()
                                          throws RepositoryException
Returns the internal retention manager used for evaluation of effective retention policies and holds.

Returns:
internal retention manager
Throws:
RepositoryException

setAttribute

protected void setAttribute(String name,
                            Object value)
Sets the named attribute. If the value is null, then the named attribute is removed.

Parameters:
name - attribute name
value - attribute value
Since:
Apache Jackrabbit 1.6
See Also:
JCR-1932

getNodeByUUID

public Node getNodeByUUID(UUID uuid)
                   throws ItemNotFoundException,
                          RepositoryException
Retrieves the referenceable node with the given UUID.

Parameters:
uuid - uuid of the node to be retrieved
Returns:
referenceable node with the given uuid
Throws:
ItemNotFoundException - if no node exists with the given uuid or if the existing node is not referenceable.
RepositoryException - if another error occurs.
See Also:
getNodeByUUID(String), getNodeById(NodeId)

getNodeById

public NodeImpl getNodeById(NodeId id)
                     throws ItemNotFoundException,
                            RepositoryException
Retrieves the Node with the given id.

Parameters:
id - id of node to be retrieved
Returns:
node with the given NodeId.
Throws:
ItemNotFoundException - if no such node exists or if this Session does not have permission to access the node.
RepositoryException - if another error occurs.

getWorkspaceNames

protected String[] getWorkspaceNames()
                              throws RepositoryException
Returns the names of all workspaces of this repository with respect of the access rights of this session.

Returns:
the names of all accessible workspaces
Throws:
RepositoryException - if an error occurs

createWorkspace

protected void createWorkspace(String workspaceName)
                        throws AccessDeniedException,
                               RepositoryException
Creates a workspace with the given name.

Parameters:
workspaceName - name of the new workspace
Throws:
AccessDeniedException - if the current session is not allowed to create the workspace
RepositoryException - if a workspace with the given name already exists or if another error occurs

createWorkspace

protected void createWorkspace(String workspaceName,
                               InputSource configTemplate)
                        throws AccessDeniedException,
                               RepositoryException
Creates a workspace with the given name and a workspace configuration template.

Parameters:
workspaceName - name of the new workspace
configTemplate - the configuration template of the new workspace
Throws:
AccessDeniedException - if the current session is not allowed to create the workspace
RepositoryException - if a workspace with the given name already exists or if another error occurs

notifyLoggingOut

protected void notifyLoggingOut()
Notify the listeners that this session is about to be closed.


notifyLoggedOut

protected void notifyLoggedOut()
Notify the listeners that this session has been closed.


addListener

public void addListener(SessionListener listener)
Add a SessionListener

Parameters:
listener - the new listener to be informed on modifications

removeListener

public void removeListener(SessionListener listener)
Remove a SessionListener

Parameters:
listener - an existing listener

createDataStoreGarbageCollector

public GarbageCollector createDataStoreGarbageCollector()
                                                 throws RepositoryException
Create a data store garbage collector for this repository.

Throws:
RepositoryException

getPrefix

public String getPrefix(String uri)
                 throws NamespaceException
Description copied from interface: NamespaceResolver
Returns the prefix which is mapped to the given URI.

Specified by:
getPrefix in interface NamespaceResolver
Parameters:
uri - namespace URI
Returns:
the prefix mapped to the given URI.
Throws:
NamespaceException - if the URI is unknown.

getURI

public String getURI(String prefix)
              throws NamespaceException
Description copied from interface: NamespaceResolver
Returns the URI to which the given prefix is mapped.

Specified by:
getURI in interface NamespaceResolver
Parameters:
prefix - namespace prefix
Returns:
the namespace URI to which the given prefix is mapped.
Throws:
NamespaceException - if the prefix is unknown.

getJCRName

public String getJCRName(Name name)
                  throws NamespaceException
Description copied from interface: NameResolver
Returns the prefixed JCR name for the given qualified name.

Specified by:
getJCRName in interface NameResolver
Parameters:
name - qualified name
Returns:
prefixed JCR name
Throws:
NamespaceException - if the namespace URI can not be resolved

getQName

public Name getQName(String name)
              throws IllegalNameException,
                     NamespaceException
Description copied from interface: NameResolver
Returns the qualified name for the given prefixed JCR name.

Specified by:
getQName in interface NameResolver
Parameters:
name - prefixed JCR name
Returns:
qualified name
Throws:
IllegalNameException - if the JCR name format is invalid
NamespaceException - if the namespace prefix can not be resolved

getJCRPath

public String getJCRPath(Path path)
                  throws NamespaceException
Description copied from interface: PathResolver
Returns the prefixed JCR path for the given qualified path.

Specified by:
getJCRPath in interface PathResolver
Parameters:
path - qualified path
Returns:
prefixed JCR path
Throws:
NamespaceException - if a namespace URI can not be resolved

getQPath

public Path getQPath(String path)
              throws MalformedPathException,
                     IllegalNameException,
                     NamespaceException
Description copied from interface: PathResolver
Returns the qualified path for the given prefixed JCR path.

Specified by:
getQPath in interface PathResolver
Parameters:
path - prefixed JCR path
Returns:
qualified path
Throws:
MalformedPathException - if the JCR path format is invalid.
IllegalNameException - if any of the JCR names contained in the path are invalid.
NamespaceException - if a namespace prefix can not be resolved.

getPrincipalManager

public PrincipalManager getPrincipalManager()
                                     throws RepositoryException,
                                            AccessDeniedException
Description copied from interface: JackrabbitSession
Returns the PrincipalManager for the current Session.

Specified by:
getPrincipalManager in interface JackrabbitSession
Returns:
this sessions principal manager.
Throws:
AccessDeniedException
UnsupportedRepositoryOperationException - If principal management is not supported.
RepositoryException
See Also:
JackrabbitSession.getPrincipalManager()

getUserManager

public UserManager getUserManager()
                           throws AccessDeniedException,
                                  RepositoryException
Description copied from interface: JackrabbitSession
Returns the UserManager for the current Session.

Specified by:
getUserManager in interface JackrabbitSession
Throws:
AccessDeniedException - If this session is not allowed to to access user data.
UnsupportedRepositoryOperationException - If user management is not supported.
RepositoryException - If another error occurs.
See Also:
JackrabbitSession.getUserManager()

checkPermission

public void checkPermission(String absPath,
                            String actions)
                     throws AccessControlException,
                            RepositoryException

Specified by:
checkPermission in interface Session
Throws:
AccessControlException
RepositoryException

getWorkspace

public Workspace getWorkspace()

Specified by:
getWorkspace in interface Session

impersonate

public Session impersonate(Credentials otherCredentials)
                    throws LoginException,
                           RepositoryException
Logs in the same workspace with the given credentials.

The default implementation:

Specified by:
impersonate in interface Session
Overrides:
impersonate in class AbstractSession
Parameters:
otherCredentials - login credentials
Returns:
logged in session
Throws:
RepositoryException - if an error occurs
LoginException

getRootNode

public Node getRootNode()
                 throws RepositoryException

Specified by:
getRootNode in interface Session
Throws:
RepositoryException

getNodeByUUID

public Node getNodeByUUID(String uuid)
                   throws ItemNotFoundException,
                          RepositoryException

Specified by:
getNodeByUUID in interface Session
Throws:
ItemNotFoundException
RepositoryException

getItem

public Item getItem(String absPath)
             throws PathNotFoundException,
                    RepositoryException
Returns the node or property at the given path.

The default implementation:

Specified by:
getItem in interface Session
Overrides:
getItem in class AbstractSession
Parameters:
absPath - absolute path
Returns:
the node or property with the given path
Throws:
PathNotFoundException - if the given path is invalid or not found
RepositoryException - if another error occurs

itemExists

public boolean itemExists(String absPath)
                   throws RepositoryException
Calls AbstractSession.getItem(String) with the given path and returns true if the call succeeds. Returns false if a PathNotFoundException was thrown. Other exceptions are passed through.

Specified by:
itemExists in interface Session
Overrides:
itemExists in class AbstractSession
Parameters:
absPath - absolute path
Returns:
true if an item exists at the given path, false otherwise
Throws:
RepositoryException - if an error occurs

save

public void save()
          throws AccessDeniedException,
                 ItemExistsException,
                 ConstraintViolationException,
                 InvalidItemStateException,
                 VersionException,
                 LockException,
                 NoSuchNodeTypeException,
                 RepositoryException

Specified by:
save in interface Session
Throws:
AccessDeniedException
ItemExistsException
ConstraintViolationException
InvalidItemStateException
VersionException
LockException
NoSuchNodeTypeException
RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws RepositoryException

Specified by:
refresh in interface Session
Throws:
RepositoryException

clusterSyncOnRefresh

protected boolean clusterSyncOnRefresh()
Checks whether the refresh(boolean) method should cause cluster synchronization.

Subclasses can override this method to implement alternative rules on when cluster synchronization should be done.

Returns:
true if the DISABLE_CLUSTER_SYNC_ON_REFRESH attribute is not set, false otherwise
Since:
Apache Jackrabbit 1.6
See Also:
JCR-1753

hasPendingChanges

public boolean hasPendingChanges()
                          throws RepositoryException

Specified by:
hasPendingChanges in interface Session
Throws:
RepositoryException

move

public void move(String srcAbsPath,
                 String destAbsPath)
          throws ItemExistsException,
                 PathNotFoundException,
                 VersionException,
                 ConstraintViolationException,
                 LockException,
                 RepositoryException

Specified by:
move in interface Session
Throws:
ItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
RepositoryException

getImportContentHandler

public ContentHandler getImportContentHandler(String parentAbsPath,
                                              int uuidBehavior)
                                       throws PathNotFoundException,
                                              ConstraintViolationException,
                                              VersionException,
                                              LockException,
                                              RepositoryException

Specified by:
getImportContentHandler in interface Session
Throws:
PathNotFoundException
ConstraintViolationException
VersionException
LockException
RepositoryException

isLive

public boolean isLive()

Specified by:
isLive in interface Session

logout

public void logout()
Clears the local namespace mappings. Subclasses that for example want to participate in a session pools should remember to call super.logout() when overriding this method to avoid namespace mappings to be carried over to a new session.

Specified by:
logout in interface Session
Overrides:
logout in class AbstractSession

getRepository

public Repository getRepository()

Specified by:
getRepository in interface Session

getValueFactory

public ValueFactory getValueFactory()
                             throws UnsupportedRepositoryOperationException,
                                    RepositoryException

Specified by:
getValueFactory in interface Session
Throws:
UnsupportedRepositoryOperationException
RepositoryException

getUserID

public String getUserID()

Specified by:
getUserID in interface Session

getAttribute

public Object getAttribute(String name)

Specified by:
getAttribute in interface Session

getAttributeNames

public String[] getAttributeNames()

Specified by:
getAttributeNames in interface Session

setNamespacePrefix

public void setNamespacePrefix(String prefix,
                               String uri)
                        throws NamespaceException,
                               RepositoryException
Modifies the session local namespace mappings to contain the given prefix to URI mapping.

This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.

Specified by:
setNamespacePrefix in interface Session
Overrides:
setNamespacePrefix in class AbstractSession
Parameters:
prefix - namespace prefix
uri - namespace URI
Throws:
NamespaceException - if the mapping is illegal
RepositoryException - if a repository error occurs

addLockToken

public void addLockToken(String lt)

Specified by:
addLockToken in interface Session

getLockTokens

public String[] getLockTokens()

Specified by:
getLockTokens in interface Session

removeLockToken

public void removeLockToken(String lt)

Specified by:
removeLockToken in interface Session

getLockManager

public LockManager getLockManager()
                           throws RepositoryException
Return the lock manager for this session.

Returns:
lock manager for this session
Throws:
RepositoryException

getLocks

public Lock[] getLocks()
Returns all locks owned by this session.

Returns:
an array of Locks

getNodeByIdentifier

public Node getNodeByIdentifier(String id)
                         throws ItemNotFoundException,
                                RepositoryException
Description copied from interface: Session
Returns the node specified by the given identifier. Applies to both referenceable and non-referenceable nodes.

An ItemNotFoundException is thrown if no node with the specified identifier exists. This exception is also thrown if this Session does not have read access to the node with the specified identifier.

A RepositoryException is thrown if another error occurs.

Parameters:
id - An identifier.
Returns:
A Node.
Throws:
ItemNotFoundException - if the specified identifier is not found.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Session.getNodeByIdentifier(String)

getNode

public Node getNode(String absPath)
             throws PathNotFoundException,
                    RepositoryException
Description copied from interface: Session
Returns the node at the specified absolute path in the workspace. If no node exists, then a PathNotFoundException is thrown.

Parameters:
absPath - An absolute path.
Returns:
the specified Node.
Throws:
PathNotFoundException - If no node exists.
RepositoryException - If another error occurs.
Since:
JCR 2.0
See Also:
Session.getNode(String)

getProperty

public Property getProperty(String absPath)
                     throws PathNotFoundException,
                            RepositoryException
Description copied from interface: Session
Returns the property at the specified absolute path in the workspace. If no property exists, then a PathNotFoundException is thrown.

Parameters:
absPath - An absolute path.
Returns:
the specified Property.
Throws:
PathNotFoundException - If no property exists.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Session.getProperty(String)

nodeExists

public boolean nodeExists(String absPath)
                   throws RepositoryException
Description copied from interface: Session
Returns true if a node exists at absPath and this Session has read access to it; otherwise returns false.

Throws a RepositoryException if absPath is not a well-formed absolute path.

Parameters:
absPath - An absolute path.
Returns:
a boolean
Throws:
RepositoryException - if absPath is not a well-formed absolute path.
Since:
JCR 2.0
See Also:
Session.nodeExists(String)

propertyExists

public boolean propertyExists(String absPath)
                       throws RepositoryException
Description copied from interface: Session
Returns true if a property exists at absPath and this Session has read access to it; otherwise returns false.

Throws a RepositoryException if absPath is not a well-formed absolute path.

Parameters:
absPath - An absolute path.
Returns:
a boolean
Throws:
RepositoryException - if absPath is not a well-formed absolute path.
Since:
JCR 2.0
See Also:
Session.propertyExists(String)

removeItem

public void removeItem(String absPath)
                throws VersionException,
                       LockException,
                       ConstraintViolationException,
                       RepositoryException
Description copied from interface: Session
Removes the specified item (and its subtree).

To persist a removal, a save must be performed.

If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.

A ReferentialIntegrityException will be thrown on save if the specified item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside the specified item's subtree and the current Session has read access to that REFERENCE property.

An AccessDeniedException will be thrown on save if the specified item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside the specified item's subtree and the current Session does not have read access to that REFERENCE property.

A ConstraintViolationException will be thrown either immediately or on save, if removing the specified item would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.

A VersionException will be thrown either immediately or on save, if the parent node of the specified item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in. Implementations may differ on when this validation is performed.

A LockException will be thrown either immediately or on save if a lock prevents the removal of the specified item. Implementations may differ on when this validation is performed.

Parameters:
absPath - the absolute path of the item to be removed.
Throws:
VersionException - if the parent node of the item at absPath is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save.
LockException - if a lock prevents the removal of the specified item and this implementation performs this validation immediately instead of waiting until save.
ConstraintViolationException - if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Session.removeItem(String)

hasPermission

public boolean hasPermission(String absPath,
                             String actions)
                      throws RepositoryException
Description copied from interface: Session
Returns true if this Session has permission to perform the specified actions at the specified absPath and false otherwise.

The actions parameter is a comma separated list of action strings. The following action strings are defined:

  • add_node: If hasPermission(path, "add_node") returns true, then this Session has permission to add a node at path.
  • set_property: If hasPermission(path, "set_property") returns true, then this Session has permission to set (add or change) a property at path.
  • remove: If hasPermission(path, "remove") returns true, then this Session has permission to remove an item at path.
  • read: If hasPermission(path, "read") returns true, then this Session has permission to retrieve (and read the value of, in the case of a property) an item at path.
When more than one action is specified in the actions parameter, this method will only return true if this Session has permission to perform all of the listed actions at the specified path.

The information returned through this method will only reflect the access control status (both JCR defined and implementation-specific) and not other restrictions that may exist, such as node type constraints. For example, even though hasPermission may indicate that a particular Session may add a property at /A/B/C, the node type of the node at /A/B may prevent the addition of a property called C.

Parameters:
absPath - an absolute path.
actions - a comma separated list of action strings.
Returns:
boolean true if this Session has permission to perform the specified actions at the specified absPath.
Throws:
RepositoryException - if an error occurs.
Since:
2.0
See Also:
Session.hasPermission(String, String)

hasCapability

public boolean hasCapability(String methodType,
                             Object target,
                             Map arguments)
                      throws RepositoryException
Description copied from interface: Session
Checks whether an operation can be performed given as much context as can be determined by the repository, including:
  • Permissions granted to the current user, including access control privileges.
  • Current state of the target object (reflecting locks, checkin/checkout status, retention and hold status etc.).
  • Repository capabilities.
  • Node type-enforced restrictions.
  • Repository configuration-specific restrictions.
The implementation of this method is best effort: returning false guarantees that the operation cannot be performed, but returning true does not guarantee the opposite. The repository implementation should use this to give priority to performance over completeness. An exception should be thrown only for important failures such as loss of connectivity to the back-end.

The implementation of this method is best effort: returning false guarantees that the operation cannot be performed, but returning true does not guarantee the opposite.

The methodName parameter identifies the method in question by its name as defined in the Javadoc.

The target parameter identifies the object on which the specified method is called.

The arguments parameter contains a Map object consisting of name/value pairs where the name is a String holding the parameter name of the method as defined in the Javadoc and the value is an Object holding the value to be passed. In cases where the value is a Java primitive type it must be converted to its corresponding Java object form before being passed.

For example, given a Session S and Node N then

Map p = new HashMap(); p.put("relPath", "foo"); boolean b = S.hasCapability("addNode", N, p);

will result in b == false if a child node called foo cannot be added to the node N within the session S.

Parameters:
methodType - the nakme of the method.
target - the target object of the operation.
arguments - the arguments of the operation.
Returns:
boolean false if the operation cannot be performed, true if the operation can be performed or if the repository cannot determine whether the operation can be performed.
Throws:
RepositoryException - if an error occurs
Since:
JCR 2.0
See Also:
Session.hasCapability(String, Object, Map)

getAccessControlManager

public AccessControlManager getAccessControlManager()
                                             throws UnsupportedRepositoryOperationException,
                                                    RepositoryException
Description copied from interface: Session
Returns the access control manager for this Session.

An UnsupportedRepositoryOperationException is thrown if access control is not supported.

A RepositoryException is thrown if another error occurs.

Returns:
the access control manager for this Session
Throws:
UnsupportedRepositoryOperationException - if access control is not supported.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Session.getAccessControlManager()

getRetentionManager

public RetentionManager getRetentionManager()
                                     throws UnsupportedRepositoryOperationException,
                                            RepositoryException
Description copied from interface: Session
Returns the retention and hold manager for this Session.

An UnsupportedRepositoryOperationException is thrown if retention and hold are not supported.

A RepositoryException is thrown if another error occurs.

Returns:
the retention manager for this Session.
Throws:
UnsupportedRepositoryOperationException - if retention and hold are not supported.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Session.getRetentionManager()

dump

public void dump(PrintStream ps)
Dumps the state of this instance in a human readable format for diagnostic purposes.

Specified by:
dump in interface Dumpable
Parameters:
ps - stream to dump state to

finalize

public void finalize()
Finalize the session. If the application doesn't close Session.logout(), the session is closed automatically; however a warning is written to the log file, together with the stack trace of where the session was opened.

Overrides:
finalize in class Object


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.