org.apache.jackrabbit.core
Class SessionImpl

java.lang.Object
  extended byorg.apache.jackrabbit.core.SessionImpl
All Implemented Interfaces:
Dumpable, Session
Direct Known Subclasses:
XASessionImpl

public class SessionImpl
extends Object
implements Session, Dumpable

A SessionImpl ...


Field Summary
protected  AccessManager accessMgr
          the AccessManager associated with this session
static String ADD_NODE_ACTION
           
protected  boolean alive
          flag indicating whether this session is alive
protected  HashMap attributes
          the attributes of this session
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  Set lockTokens
          Lock tokens
protected  AuthContext loginContext
          the AuthContext of this session (can be null if this session was not instantiated through a login process)
protected  org.apache.jackrabbit.core.LocalNamespaceMappings nsMappings
          the transient prefix/namespace mappings with session scope
protected  NodeTypeManagerImpl ntMgr
          the node type manager
static String READ_ACTION
          prededfined action constants in checkPermission
static String REMOVE_ACTION
           
protected  RepositoryImpl rep
          the repository that issued this session
static String SET_PROPERTY_ACTION
           
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
 
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 addLockToken(String lt, boolean notify)
          Internal implementation of addLockToken(String).
 void checkPermission(String absPath, String actions)
          
protected  AccessManager createAccessManager(Subject subject, HierarchyManager hierMgr)
          Create the access manager.
protected  ItemManager createItemManager(SessionItemStateManager itemStateMgr, HierarchyManager hierMgr)
          Create the item manager.
protected  SessionItemStateManager createSessionItemStateManager(UpdatableItemStateManager 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 exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
          
 void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
          
 void exportSystemView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
          
 void exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
          
 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)
          
 ItemManager getItemManager()
          Returns the ItemManager of this session.
protected  SessionItemStateManager getItemStateManager()
          Returns the SessionItemStateManager associated with this session.
 LockManager getLockManager()
          Return the lock manager for this session.
 String[] getLockTokens()
          
 String getNamespacePrefix(String uri)
          
 String[] getNamespacePrefixes()
          
 NamespaceResolver getNamespaceResolver()
          Returns the NamespaceResolver of this session.
 String getNamespaceURI(String prefix)
          
 NodeImpl getNodeById(NodeId id)
          Retrieves the Node with the given id.
 Node getNodeByUUID(String uuid)
          
 Node getNodeByUUID(UUID uuid)
          Retrieves the referenceable node with the given UUID.
 NodeTypeManagerImpl getNodeTypeManager()
          Returns the NodeTypeManager.
 Repository getRepository()
          
 Node getRootNode()
          
protected  Subject getSubject()
          Returns the Subject associated with this session.
 String getUserID()
          
 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 hasPendingChanges()
          
 Session impersonate(Credentials otherCredentials)
          
 void importXML(String parentAbsPath, InputStream in, int uuidBehavior)
          
 boolean isLive()
          
 boolean itemExists(String absPath)
          
 void logout()
          
 void move(String srcAbsPath, String destAbsPath)
          
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.
 void refresh(boolean keepChanges)
          
 void removeListener(SessionListener listener)
          Remove a SessionListener
 void removeLockToken(String lt)
          
 void removeLockToken(String lt, boolean notify)
          Internal implementation of removeLockToken(String).
protected  void sanityCheck()
          Performs a sanity check on this session.
 void save()
          
 void setNamespacePrefix(String prefix, String uri)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_ACTION

public static final String READ_ACTION
prededfined action constants in checkPermission

See Also:
Constant Field Values

REMOVE_ACTION

public static final String REMOVE_ACTION
See Also:
Constant Field Values

ADD_NODE_ACTION

public static final String ADD_NODE_ACTION
See Also:
Constant Field Values

SET_PROPERTY_ACTION

public static final String SET_PROPERTY_ACTION
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


nsMappings

protected final org.apache.jackrabbit.core.LocalNamespaceMappings nsMappings
the transient prefix/namespace mappings with session scope


versionMgr

protected final VersionManager versionMgr
The version manager for this session


listeners

protected final Map listeners
Listeners (weak references)


lockTokens

protected final Set lockTokens
Lock tokens


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

createSessionItemStateManager

protected SessionItemStateManager createSessionItemStateManager(UpdatableItemStateManager 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 hierMgr)
                                     throws AccessDeniedException,
                                            RepositoryException
Create the access manager.

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)

getSubject

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

Returns:
the Subject associated with this session

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

getNamespaceResolver

public NamespaceResolver getNamespaceResolver()
Returns the NamespaceResolver of this session.

Returns:
the NamespaceResolver of this session

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

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

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

Specified by:
impersonate in interface Session
Throws:
LoginException
RepositoryException

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

Specified by:
getItem in interface Session
Throws:
PathNotFoundException
RepositoryException

itemExists

public boolean itemExists(String absPath)
                   throws RepositoryException

Specified by:
itemExists in interface Session
Throws:
RepositoryException

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

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

importXML

public void importXML(String parentAbsPath,
                      InputStream in,
                      int uuidBehavior)
               throws IOException,
                      PathNotFoundException,
                      ItemExistsException,
                      ConstraintViolationException,
                      VersionException,
                      InvalidSerializedDataException,
                      LockException,
                      RepositoryException

Specified by:
importXML in interface Session
Throws:
IOException
PathNotFoundException
ItemExistsException
ConstraintViolationException
VersionException
InvalidSerializedDataException
LockException
RepositoryException

exportDocumentView

public void exportDocumentView(String absPath,
                               ContentHandler contentHandler,
                               boolean skipBinary,
                               boolean noRecurse)
                        throws PathNotFoundException,
                               SAXException,
                               RepositoryException

Specified by:
exportDocumentView in interface Session
Throws:
PathNotFoundException
SAXException
RepositoryException

exportDocumentView

public void exportDocumentView(String absPath,
                               OutputStream out,
                               boolean skipBinary,
                               boolean noRecurse)
                        throws IOException,
                               PathNotFoundException,
                               RepositoryException

Specified by:
exportDocumentView in interface Session
Throws:
IOException
PathNotFoundException
RepositoryException

exportSystemView

public void exportSystemView(String absPath,
                             ContentHandler contentHandler,
                             boolean skipBinary,
                             boolean noRecurse)
                      throws PathNotFoundException,
                             SAXException,
                             RepositoryException

Specified by:
exportSystemView in interface Session
Throws:
PathNotFoundException
SAXException
RepositoryException

exportSystemView

public void exportSystemView(String absPath,
                             OutputStream out,
                             boolean skipBinary,
                             boolean noRecurse)
                      throws IOException,
                             PathNotFoundException,
                             RepositoryException

Specified by:
exportSystemView in interface Session
Throws:
IOException
PathNotFoundException
RepositoryException

isLive

public boolean isLive()

Specified by:
isLive in interface Session

logout

public void logout()

Specified by:
logout in interface Session

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

Specified by:
setNamespacePrefix in interface Session
Throws:
NamespaceException
RepositoryException

getNamespacePrefixes

public String[] getNamespacePrefixes()
                              throws NamespaceException,
                                     RepositoryException

Specified by:
getNamespacePrefixes in interface Session
Throws:
NamespaceException
RepositoryException

getNamespaceURI

public String getNamespaceURI(String prefix)
                       throws NamespaceException,
                              RepositoryException

Specified by:
getNamespaceURI in interface Session
Throws:
NamespaceException
RepositoryException

getNamespacePrefix

public String getNamespacePrefix(String uri)
                          throws NamespaceException,
                                 RepositoryException

Specified by:
getNamespacePrefix in interface Session
Throws:
NamespaceException
RepositoryException

addLockToken

public void addLockToken(String lt)

Specified by:
addLockToken in interface Session

addLockToken

public void addLockToken(String lt,
                         boolean notify)
Internal implementation of addLockToken(String). Additionally takes a parameter indicating whether the lock manager needs to be informed.


getLockTokens

public String[] getLockTokens()

Specified by:
getLockTokens in interface Session

removeLockToken

public void removeLockToken(String lt)

Specified by:
removeLockToken in interface Session

removeLockToken

public void removeLockToken(String lt,
                            boolean notify)
Internal implementation of removeLockToken(String). Additionally takes a parameter indicating whether the lock manager needs to be informed.


getLockManager

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

Returns:
lock manager for this session
Throws:
RepositoryException

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


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