|
||||||||||
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 |
static String |
ADD_NODE_ACTION
TODO deprecate as soon as present with Session interface (JSR 283) |
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 NamePathResolver |
namePathResolver
Name and Path resolver |
protected NodeTypeManagerImpl |
ntMgr
the node type manager |
static String |
READ_ACTION
TODO deprecate as soon as present with Session interface (JSR 283) |
static String |
REMOVE_ACTION
TODO deprecate as soon as present with Session interface (JSR 283) |
protected RepositoryImpl |
rep
the repository that issued this session |
static String |
SET_PROPERTY_ACTION
TODO deprecate as soon as present with Session interface (JSR 283) |
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 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. |
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)
|
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()
|
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 . |
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()
|
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)
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 |
removeListener(SessionListener listener)
Remove a SessionListener |
void |
removeLockToken(String lt)
|
void |
removeLockToken(String lt,
boolean notify)
Internal implementation of removeLockToken(String) . |
protected String |
retrieveUserId(Subject subject)
Retrieve the userID from the specified subject. |
protected void |
sanityCheck()
Performs a sanity check on this session. |
void |
save()
|
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, finalize, 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 READ_ACTION
public static final String REMOVE_ACTION
public static final String ADD_NODE_ACTION
public static final String SET_PROPERTY_ACTION
protected boolean alive
protected final RepositoryImpl rep
protected AuthContext loginContext
protected final Subject subject
protected final String userId
protected final HashMap 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 VersionManager versionMgr
protected final Map listeners
protected final Set lockTokens
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 occursprotected 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 occursMethod Detail |
---|
protected String retrieveUserId(Subject subject) throws RepositoryException
RepositoryException
protected 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 VersionManager 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 instantiatedprotected 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 Subject getSubject()
Subject
associated with this session.
Subject
associated with this sessionpublic 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
.
NodeTypeManager
public ItemManager getItemManager()
ItemManager
of this session.
ItemManager
protected SessionItemStateManager getItemStateManager()
SessionItemStateManager
associated with this session.
SessionItemStateManager
associated with this sessionpublic HierarchyManager getHierarchyManager()
HierarchyManager
associated with this session.
HierarchyManager
associated with this sessionpublic VersionManager getVersionManager()
VersionManager
associated with this session.
VersionManager
associated with this sessionpublic Node getNodeByUUID(UUID uuid) throws ItemNotFoundException, RepositoryException
UUID
.
uuid
- uuid of the node to be retrieved
ItemNotFoundException
- if no node exists with the given uuid or
if the existing node is not referenceable.
RepositoryException
- if another error occurs.getNodeByUUID(String)
,
getNodeById(NodeId)
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 occursprotected 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 occursprotected 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 listenerpublic GarbageCollector createDataStoreGarbageCollector() throws RepositoryException, ItemStateException
ItemStateException
RepositoryException
public String getPrefix(String uri) throws NamespaceException
NamespaceResolver
getPrefix
in interface NamespaceResolver
uri
- namespace URI
NamespaceException
- if the URI is unknown.public String getURI(String prefix) throws NamespaceException
NamespaceResolver
getURI
in interface NamespaceResolver
prefix
- namespace prefix
NamespaceException
- if the prefix is unknown.public String getJCRName(Name name) throws NamespaceException
NameResolver
getJCRName
in interface NameResolver
name
- qualified name
NamespaceException
- if the namespace URI can not be resolvedpublic Name getQName(String name) throws IllegalNameException, NamespaceException
NameResolver
getQName
in interface NameResolver
name
- prefixed JCR name
IllegalNameException
- if the JCR name format is invalid
NamespaceException
- if the namespace prefix can not be resolvedpublic String getJCRPath(Path path) throws NamespaceException
PathResolver
getJCRPath
in interface PathResolver
path
- qualified path
NamespaceException
- if a namespace URI can not be resolvedpublic Path getQPath(String path) throws MalformedPathException, IllegalNameException, NamespaceException
PathResolver
getQPath
in interface PathResolver
path
- prefixed JCR path
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 PrincipalManager getPrincipalManager() throws RepositoryException, AccessDeniedException
JackrabbitSession
PrincipalManager
for the current Session
.
getPrincipalManager
in interface JackrabbitSession
AccessDeniedException
UnsupportedRepositoryOperationException
- If principal management
is not supported.
RepositoryException
JackrabbitSession.getPrincipalManager()
public UserManager getUserManager() throws AccessDeniedException, RepositoryException
JackrabbitSession
UserManager
for the current Session
.
getUserManager
in interface JackrabbitSession
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 Session
AccessControlException
RepositoryException
public 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 Session
impersonate
in class AbstractSession
otherCredentials
- login credentials
RepositoryException
- if an error occurs
LoginException
public Node getRootNode() throws RepositoryException
getRootNode
in interface Session
RepositoryException
public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException
getNodeByUUID
in interface Session
ItemNotFoundException
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 Session
getItem
in class AbstractSession
absPath
- absolute path
PathNotFoundException
- if the given path is invalid or not found
RepositoryException
- if another error occurspublic 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 Session
itemExists
in class AbstractSession
absPath
- absolute path
true
if an item exists at the given path,
false
otherwise
RepositoryException
- if an error occurspublic void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException
save
in interface Session
AccessDeniedException
ItemExistsException
ConstraintViolationException
InvalidItemStateException
VersionException
LockException
NoSuchNodeTypeException
RepositoryException
public void refresh(boolean keepChanges) throws RepositoryException
refresh
in interface Session
RepositoryException
public boolean hasPendingChanges() throws RepositoryException
hasPendingChanges
in interface Session
RepositoryException
public void move(String srcAbsPath, String destAbsPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException
move
in interface Session
ItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
RepositoryException
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException
getImportContentHandler
in interface Session
PathNotFoundException
ConstraintViolationException
VersionException
LockException
RepositoryException
public boolean isLive()
isLive
in interface Session
public void logout()
super.logout()
when overriding this method to avoid
namespace mappings to be carried over to a new session.
logout
in interface Session
logout
in class AbstractSession
public Repository getRepository()
getRepository
in interface Session
public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException, RepositoryException
getValueFactory
in interface Session
UnsupportedRepositoryOperationException
RepositoryException
public String getUserID()
getUserID
in interface Session
public Object getAttribute(String name)
getAttribute
in interface Session
public 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 Session
setNamespacePrefix
in class AbstractSession
prefix
- namespace prefixuri
- namespace URI
NamespaceException
- if the mapping is illegal
RepositoryException
- if a repository error occurspublic void addLockToken(String lt)
addLockToken
in interface Session
public void addLockToken(String lt, boolean notify)
addLockToken(String)
. Additionally
takes a parameter indicating whether the lock manager needs to be
informed.
public String[] getLockTokens()
getLockTokens
in interface Session
public void removeLockToken(String lt)
removeLockToken
in interface Session
public void removeLockToken(String lt, boolean notify)
removeLockToken(String)
. Additionally
takes a parameter indicating whether the lock manager needs to be
informed.
public LockManager getLockManager() throws RepositoryException
RepositoryException
public Lock[] getLocks()
Lock
spublic Node getNodeByIdentifier(String id) throws ItemNotFoundException, RepositoryException
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
public Node getNode(String absPath) throws PathNotFoundException, RepositoryException
PathNotFoundException
is thrown.
absPath
- An absolute path.
Node
.
PathNotFoundException
- If no node exists.
RepositoryException
- If another error occurs.public Property getProperty(String absPath) throws PathNotFoundException, RepositoryException
PathNotFoundException
is thrown.
absPath
- An absolute path.
Property
.
PathNotFoundException
- If no property exists.
RepositoryException
- if another error occurs.public boolean nodeExists(String absPath) throws RepositoryException
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.
absPath
- An absolute path.
boolean
RepositoryException
- if absPath
is not a well-formed
absolute path.public boolean propertyExists(String absPath) throws RepositoryException
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.
absPath
- An absolute path.
boolean
RepositoryException
- if absPath
is not a well-formed
absolute path.public boolean hasPermission(String absPath, String actions) throws RepositoryException
RepositoryException
Session#hasPermission(String, String)
public AccessControlManager getAccessControlManager() throws UnsupportedRepositoryOperationException, RepositoryException
UnsupportedRepositoryOperationException
RepositoryException
Session#getAccessControlManager()
public RetentionManager getRetentionManager() throws UnsupportedRepositoryOperationException, RepositoryException
UnsupportedRepositoryOperationException
RepositoryException
Session#getRetentionManager()
public void dump(PrintStream ps)
dump
in interface Dumpable
ps
- stream to dump state to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |