|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.commons.AbstractSession
org.apache.jackrabbit.core.SessionImpl
public class SessionImpl
A SessionImpl ...
| Field Summary | |
|---|---|
protected AccessManager |
accessMgr
the AccessManager associated with this session |
protected boolean |
alive
flag indicating whether this session is alive |
protected Map<String,Object> |
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<SessionListener,SessionListener> |
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 NodeTypeInstanceHandler |
ntInstanceHandler
node type instance handler |
protected NodeTypeManagerImpl |
ntMgr
the node type manager |
protected RepositoryImpl |
rep
the repository that issued this session |
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 InternalVersionManager |
versionMgr
The version manager for this session |
protected WorkspaceImpl |
wsp
the Workspace associated with this session |
| Fields inherited from interface javax.jcr.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 |
checkFormat(String identifier)
|
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 InternalVersionManager |
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()
|
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)
|
InternalVersionManager |
getInternalVersionManager()
Returns the InternalVersionManager associated with this session. |
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 qualified JCR name String for the given Name object. |
String |
getJCRPath(Path path)
Returns the given JCR path string for the given path object. |
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 with the given absolute path. |
NodeImpl |
getNodeById(NodeId id)
Retrieves the Node with the given id. |
Node |
getNodeByIdentifier(String id)
|
Node |
getNodeByUUID(String uuid)
|
NodeTypeInstanceHandler |
getNodeTypeInstanceHandler()
Returns the node type instance handler for this session |
NodeTypeManagerImpl |
getNodeTypeManager()
Returns the NodeTypeManager. |
Path |
getPath(String identifier)
|
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 with the given absolute path. |
Name |
getQName(String name)
Returns the Name for the given JCR name String. |
Path |
getQPath(String path)
Returns the path object for the given JCR path string. |
Path |
getQPath(String path,
boolean normalizeIdentifier)
Returns the path object for the given JCR path string. |
Repository |
getRepository()
|
RetentionManager |
getRetentionManager()
|
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()
|
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 methodName,
Object target,
Object[] arguments)
|
boolean |
hasPendingChanges()
|
boolean |
hasPermission(String absPath,
String actions)
|
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)
Checks whether a node with the given absolute path exists. |
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)
Checks whether a property with the given absolute path exists. |
void |
refresh(boolean keepChanges)
|
void |
removeItem(String absPath)
Removes the identified item. |
void |
removeListener(SessionListener listener)
Remove a SessionListener |
void |
removeLockToken(String lt)
|
protected String |
retrieveUserId(Subject subject,
String workspaceName)
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 |
|---|
public static final String DISABLE_CLUSTER_SYNC_ON_REFRESH
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.
protected boolean alive
protected final RepositoryImpl rep
protected AuthContext loginContext
protected final Subject subject
protected final String userId
protected final Map<String,Object> attributes
protected final NodeTypeManagerImpl ntMgr
protected AccessManager accessMgr
protected final SessionItemStateManager itemStateMgr
protected final HierarchyManager hierMgr
protected final ItemManager itemMgr
protected final WorkspaceImpl wsp
protected NamePathResolver namePathResolver
protected final InternalVersionManager versionMgr
protected final NodeTypeInstanceHandler ntInstanceHandler
protected final Map<SessionListener,SessionListener> listeners
protected ValueFactory valueFactory
| Constructor Detail |
|---|
protected SessionImpl(RepositoryImpl rep,
AuthContext loginContext,
WorkspaceConfig wspConfig)
throws AccessDeniedException,
RepositoryException
rep - loginContext - wspConfig -
AccessDeniedException - if the subject of the given login context
is not granted access to the specified
workspace
RepositoryException - if another error occurs
protected SessionImpl(RepositoryImpl rep,
Subject subject,
WorkspaceConfig wspConfig)
throws AccessDeniedException,
RepositoryException
rep - subject - wspConfig -
AccessDeniedException - if the given subject is not granted access
to the specified workspace
RepositoryException - if another error occurs| Method Detail |
|---|
protected String retrieveUserId(Subject subject,
String workspaceName)
throws RepositoryException
RepositoryExceptionprotected SessionItemStateManager createSessionItemStateManager(LocalItemStateManager manager)
protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig,
SharedItemStateManager stateMgr,
RepositoryImpl rep,
SessionImpl session)
wspConfig - The workspace configurationstateMgr - The shared item state managerrep - The repositorysession - The session
WorkspaceImpl class or an extension
thereof.
protected ItemManager createItemManager(SessionItemStateManager itemStateMgr,
HierarchyManager hierMgr)
protected InternalVersionManager createVersionManager(RepositoryImpl rep)
throws RepositoryException
RepositoryException
protected AccessManager createAccessManager(Subject subject,
HierarchyManager hierarchyManager)
throws AccessDeniedException,
RepositoryException
subject - hierarchyManager -
AccessDeniedException - if the current subject is not granted access
to the current workspace
RepositoryException - if the access manager cannot be instantiated
protected void sanityCheck()
throws RepositoryException
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)
public ItemValidator getValidator()
throws RepositoryException
RepositoryException - If an error occurs.public Subject getSubject()
Subject associated with this session.
Subject associated with this session
public Session createSession(String workspaceName)
throws AccessDeniedException,
NoSuchWorkspaceException,
RepositoryException
workspaceName - name of the workspace to acquire a session for.
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 statepublic AccessManager getAccessManager()
AccessManager associated with this session.
AccessManager associated with this sessionpublic NodeTypeManagerImpl getNodeTypeManager()
NodeTypeManager.
NodeTypeManagerpublic ItemManager getItemManager()
ItemManager of this session.
ItemManagerprotected SessionItemStateManager getItemStateManager()
SessionItemStateManager associated with this session.
SessionItemStateManager associated with this sessionpublic HierarchyManager getHierarchyManager()
HierarchyManager associated with this session.
HierarchyManager associated with this sessionpublic InternalVersionManager getInternalVersionManager()
InternalVersionManager associated with this session.
InternalVersionManager associated with this session
protected RetentionRegistry getRetentionRegistry()
throws RepositoryException
RepositoryExceptionpublic NodeTypeInstanceHandler getNodeTypeInstanceHandler()
protected void setAttribute(String name,
Object value)
null, then
the named attribute is removed.
name - attribute namevalue - attribute value
public NodeImpl getNodeById(NodeId id)
throws ItemNotFoundException,
RepositoryException
Node with the given id.
id - id of node to be retrieved
NodeId.
ItemNotFoundException - if no such node exists or if this
Session does not have permission to access the node.
RepositoryException - if another error occurs.
protected String[] getWorkspaceNames()
throws RepositoryException
RepositoryException - if an error occurs
protected void createWorkspace(String workspaceName)
throws AccessDeniedException,
RepositoryException
workspaceName - name of the new workspace
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
protected void createWorkspace(String workspaceName,
InputSource configTemplate)
throws AccessDeniedException,
RepositoryException
workspaceName - name of the new workspaceconfigTemplate - the configuration template of the new workspace
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 occursprotected void notifyLoggingOut()
protected void notifyLoggedOut()
public void addListener(SessionListener listener)
SessionListener
listener - the new listener to be informed on modificationspublic void removeListener(SessionListener listener)
SessionListener
listener - an existing listener
public GarbageCollector createDataStoreGarbageCollector()
throws RepositoryException
RepositoryException
public String getPrefix(String uri)
throws NamespaceException
NamespaceResolver
getPrefix in interface NamespaceResolveruri - namespace URI
NamespaceException - if the URI is unknown.
public String getURI(String prefix)
throws NamespaceException
NamespaceResolver
getURI in interface NamespaceResolverprefix - namespace prefix
NamespaceException - if the prefix is unknown.
public String getJCRName(Name name)
throws NamespaceException
NameResolverName object.
getJCRName in interface NameResolvername - A Name object.
prefix:localName or
localName in case of the empty namespace.
NamespaceException - if the namespace URI can not be resolved
public Name getQName(String name)
throws IllegalNameException,
NamespaceException
NameResolverName for the given JCR name String.
getQName in interface NameResolvername - A JCR name String.
Name object.
IllegalNameException - if the JCR name format is invalid
NamespaceException - if the namespace prefix can not be resolved
public String getJCRPath(Path path)
throws NamespaceException
PathResolver
getJCRPath in interface PathResolverpath - a Path object.
NamespaceException - if a namespace URI can not be resolved
public Path getQPath(String path)
throws MalformedPathException,
IllegalNameException,
NamespaceException
PathResolver
getQPath in interface PathResolverpath - prefixed JCR path
Path object.
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.
public Path getQPath(String path,
boolean normalizeIdentifier)
throws MalformedPathException,
IllegalNameException,
NamespaceException
PathResolver
getQPath in interface PathResolverpath - prefixed JCR path
Path object.
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.
public Path getPath(String identifier)
throws MalformedPathException
getPath in interface IdentifierResolverMalformedPathExceptionIdentifierResolver.getPath(String)
public void checkFormat(String identifier)
throws MalformedPathException
checkFormat in interface IdentifierResolverMalformedPathExceptionIdentifierResolver.checkFormat(String)
public PrincipalManager getPrincipalManager()
throws RepositoryException,
AccessDeniedException
JackrabbitSessionPrincipalManager for the current Session.
getPrincipalManager in interface JackrabbitSessionPrincipalManager associated with this Session.
AccessDeniedException - If the session lacks privileges to access
the principal manager or principals in general.
UnsupportedRepositoryOperationException - If principal management
is not supported.
RepositoryException - If another error occors.JackrabbitSession.getPrincipalManager()
public UserManager getUserManager()
throws AccessDeniedException,
RepositoryException
JackrabbitSessionUserManager for the current Session.
getUserManager in interface JackrabbitSessionUserManager associated with this Session.
AccessDeniedException - If this session is not allowed to
to access user data.
UnsupportedRepositoryOperationException - If user management is
not supported.
RepositoryException - If another error occurs.JackrabbitSession.getUserManager()
public void checkPermission(String absPath,
String actions)
throws AccessControlException,
RepositoryException
checkPermission in interface SessionAccessControlException
RepositoryExceptionpublic Workspace getWorkspace()
getWorkspace in interface Session
public Session impersonate(Credentials otherCredentials)
throws LoginException,
RepositoryException
The default implementation:
Repository instance using
Session.getRepository()
Session.getWorkspace()
Workspace.getName()
Repository.login(Credentials, String) on the
retrieved repository with the given credentials and the retrieved
workspace name.
impersonate in interface Sessionimpersonate in class AbstractSessionotherCredentials - login credentials
RepositoryException - if an error occurs
LoginException
public Node getRootNode()
throws RepositoryException
getRootNode in interface SessionRepositoryException
public Node getNodeByUUID(String uuid)
throws ItemNotFoundException,
RepositoryException
getNodeByUUID in interface SessionItemNotFoundException
RepositoryException
public Item getItem(String absPath)
throws PathNotFoundException,
RepositoryException
The default implementation:
PathNotFoundException if the given path
does not start with a slash.
Node.getNode(String) on the root node with the
part of the given path after the first slash
Node.getProperty(String) similarly in case the
above call fails with a PathNotFoundException
getItem in interface SessiongetItem in class AbstractSessionabsPath - absolute path
PathNotFoundException - if the given path is invalid or not found
RepositoryException - if another error occursSession.getItem(String)
public boolean itemExists(String absPath)
throws RepositoryException
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.
itemExists in interface SessionitemExists in class AbstractSessionabsPath - absolute path
true if an item exists at the given path,
false otherwise
RepositoryException - if an error occursSession.itemExists(String)
public void save()
throws AccessDeniedException,
ItemExistsException,
ConstraintViolationException,
InvalidItemStateException,
VersionException,
LockException,
NoSuchNodeTypeException,
RepositoryException
save in interface SessionAccessDeniedException
ItemExistsException
ConstraintViolationException
InvalidItemStateException
VersionException
LockException
NoSuchNodeTypeException
RepositoryException
public void refresh(boolean keepChanges)
throws RepositoryException
refresh in interface SessionRepositoryExceptionprotected boolean clusterSyncOnRefresh()
refresh(boolean) method should cause
cluster synchronization.
Subclasses can override this method to implement alternative rules on when cluster synchronization should be done.
true if the DISABLE_CLUSTER_SYNC_ON_REFRESH
attribute is not set, false otherwise
public boolean hasPendingChanges()
throws RepositoryException
hasPendingChanges in interface SessionRepositoryException
public void move(String srcAbsPath,
String destAbsPath)
throws ItemExistsException,
PathNotFoundException,
VersionException,
ConstraintViolationException,
LockException,
RepositoryException
move in interface SessionItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
RepositoryException
public ContentHandler getImportContentHandler(String parentAbsPath,
int uuidBehavior)
throws PathNotFoundException,
ConstraintViolationException,
VersionException,
LockException,
RepositoryException
getImportContentHandler in interface SessionPathNotFoundException
ConstraintViolationException
VersionException
LockException
RepositoryExceptionpublic boolean isLive()
isLive in interface Sessionpublic void logout()
super.logout() when overriding this method to avoid
namespace mappings to be carried over to a new session.
logout in interface Sessionlogout in class AbstractSessionpublic Repository getRepository()
getRepository in interface Sessionpublic ValueFactory getValueFactory()
getValueFactory in interface Sessionpublic String getUserID()
getUserID in interface Sessionpublic Object getAttribute(String name)
getAttribute in interface Sessionpublic String[] getAttributeNames()
getAttributeNames in interface Session
public void setNamespacePrefix(String prefix,
String uri)
throws NamespaceException,
RepositoryException
This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.
setNamespacePrefix in interface SessionsetNamespacePrefix in class AbstractSessionprefix - namespace prefixuri - namespace URI
NamespaceException - if the mapping is illegal
RepositoryException - if a repository error occurspublic void addLockToken(String lt)
addLockToken in interface Sessionpublic String[] getLockTokens()
getLockTokens in interface Sessionpublic void removeLockToken(String lt)
removeLockToken in interface Session
public LockManager getLockManager()
throws RepositoryException
RepositoryExceptionpublic Lock[] getLocks()
Locks
public Node getNodeByIdentifier(String id)
throws ItemNotFoundException,
RepositoryException
getNodeByIdentifier in interface SessionItemNotFoundException
RepositoryExceptionSession.getNodeByIdentifier(String)
public Node getNode(String absPath)
throws PathNotFoundException,
RepositoryException
AbstractSession
getNode in interface SessiongetNode in class AbstractSessionabsPath - absolute path
RepositoryException - if the node can not be accessed
PathNotFoundExceptionSession.getNode(String)
public Property getProperty(String absPath)
throws PathNotFoundException,
RepositoryException
AbstractSession
getProperty in interface SessiongetProperty in class AbstractSessionabsPath - absolute path
RepositoryException - if the property can not be accessed
PathNotFoundExceptionSession.getProperty(String)
public boolean nodeExists(String absPath)
throws RepositoryException
AbstractSession
nodeExists in interface SessionnodeExists in class AbstractSessionabsPath - absolute path
true if a node with the given path exists,
false otherwise
RepositoryException - if the path is invalidSession.nodeExists(String)
public boolean propertyExists(String absPath)
throws RepositoryException
AbstractSession
propertyExists in interface SessionpropertyExists in class AbstractSessionabsPath - absolute path
true if a property with the given path exists,
false otherwise
RepositoryException - if the path is invalidSession.propertyExists(String)
public void removeItem(String absPath)
throws VersionException,
LockException,
ConstraintViolationException,
RepositoryException
AbstractSessionItem.remove() on the item removed by AbstractSession.getItem(String).
removeItem in interface SessionremoveItem in class AbstractSessionabsPath - An absolute path of the item to be removed
RepositoryException - if the item can not be removed
VersionException
LockException
ConstraintViolationExceptionSession.removeItem(String)
public boolean hasPermission(String absPath,
String actions)
throws RepositoryException
hasPermission in interface SessionRepositoryExceptionSession.hasPermission(String, String)
public boolean hasCapability(String methodName,
Object target,
Object[] arguments)
throws RepositoryException
hasCapability in interface SessionRepositoryExceptionSession.hasCapability(String, Object, Object[])
public AccessControlManager getAccessControlManager()
throws UnsupportedRepositoryOperationException,
RepositoryException
getAccessControlManager in interface SessionUnsupportedRepositoryOperationException
RepositoryExceptionSession.getAccessControlManager()
public RetentionManager getRetentionManager()
throws UnsupportedRepositoryOperationException,
RepositoryException
getRetentionManager in interface SessionUnsupportedRepositoryOperationException
RepositoryExceptionSession.getRetentionManager()public void dump(PrintStream ps)
dump in interface Dumpableps - stream to dump state topublic void finalize()
finalize in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||