Package org.apache.jackrabbit.jcr2spi
Class SessionImpl
- java.lang.Object
-
- org.apache.jackrabbit.commons.AbstractSession
-
- org.apache.jackrabbit.jcr2spi.SessionImpl
-
- All Implemented Interfaces:
Session
,ManagerProvider
,NamespaceResolver
- Direct Known Subclasses:
XASessionImpl
public class SessionImpl extends AbstractSession implements NamespaceResolver, ManagerProvider
SessionImpl
...
-
-
Field Summary
-
Fields inherited from interface javax.jcr.Session
ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(SessionListener listener)
Add aSessionListener
void
addLockToken(String lt)
void
checkPermission(String absPath, String actions)
protected ItemManager
createItemManager(HierarchyManager hierarchyManager)
protected SessionItemStateManager
createSessionItemStateManager(UpdatableItemStateManager workspaceStateManager, ItemStateFactory isf)
protected WorkspaceImpl
createWorkspaceInstance(RepositoryConfig config, SessionInfo sessionInfo)
AccessControlManager
getAccessControlManager()
AccessControlProvider
getAccessControlProvider()
AccessManager
getAccessManager()
Object
getAttribute(String name)
Always returnsnull
.String[]
getAttributeNames()
Always returns an empty String array.EffectiveNodeTypeProvider
getEffectiveNodeTypeProvider()
HierarchyManager
getHierarchyManager()
IdFactory
getIdFactory()
ContentHandler
getImportContentHandler(String parentAbsPath, int uuidBehavior)
Item
getItem(String absPath)
Returns the node or property at the given path.ItemDefinitionProvider
getItemDefinitionProvider()
ValueFactory
getJcrValueFactory()
Same asSession.getValueFactory()
but omits the check, if this repository is really level 2 compliant.LockStateManager
getLockStateManager()
Returns theLockStateManager
associated with thisManagerProvider
.String[]
getLockTokens()
NameFactory
getNameFactory()
NamePathResolver
getNamePathResolver()
NameResolver
getNameResolver()
NamespaceResolver
getNamespaceResolver()
Node
getNode(String absPath)
Returns the node with the given absolute path.Node
getNodeByIdentifier(String id)
Node
getNodeByUUID(String uuid)
NodeTypeDefinitionProvider
getNodeTypeDefinitionProvider()
PathResolver
getPathResolver()
String
getPrefix(String uri)
Returns the prefix which is mapped to the given URI.Property
getProperty(String absPath)
Returns the property with the given absolute path.QValueFactory
getQValueFactory()
Repository
getRepository()
RetentionManager
getRetentionManager()
Node
getRootNode()
String
getURI(String prefix)
Returns the URI to which the given prefix is mapped.String
getUserID()
ItemStateValidator
getValidator()
ValueFactory
getValueFactory()
VersionManager
getVersionStateManager()
Returns theVersionManager
associated with thisManagerProvider
.Workspace
getWorkspace()
boolean
hasCapability(String methodName, Object target, Object[] arguments)
boolean
hasPendingChanges()
boolean
hasPermission(String absPath, String actions)
Session
impersonate(Credentials credentials)
Logs in the same workspace with the given credentials.void
importXML(String parentAbsPath, InputStream in, int uuidBehavior)
Parses the given input stream as an XML document and processes the SAX events using theContentHandler
returned bySession.getImportContentHandler(String, int)
.boolean
isLive()
boolean
itemExists(String absPath)
CallsAbstractSession.getItem(String)
with the given path and returnstrue
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.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 aSessionListener
void
removeLockToken(String lt)
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
-
-
-
-
Method Detail
-
getRepository
public Repository getRepository()
- Specified by:
getRepository
in interfaceSession
- See Also:
Session.getRepository()
-
getUserID
public String getUserID()
- Specified by:
getUserID
in interfaceSession
- See Also:
Session.getUserID()
-
getAttribute
public Object getAttribute(String name)
Always returnsnull
.- Specified by:
getAttribute
in interfaceSession
- See Also:
Session.getAttribute(String)
-
getAttributeNames
public String[] getAttributeNames()
Always returns an empty String array.- Specified by:
getAttributeNames
in interfaceSession
- See Also:
Session.getAttributeNames()
-
getWorkspace
public Workspace getWorkspace()
- Specified by:
getWorkspace
in interfaceSession
- See Also:
Session.getWorkspace()
-
impersonate
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException
Description copied from class:AbstractSession
Logs in the same workspace with the given credentials.The default implementation:
- Retrieves the
Repository
instance usingSession.getRepository()
- Retrieves the current workspace using
Session.getWorkspace()
- Retrieves the name of the current workspace using
Workspace.getName()
- Calls
Repository.login(Credentials, String)
on the retrieved repository with the given credentials and the retrieved workspace name.
- Specified by:
impersonate
in interfaceSession
- Overrides:
impersonate
in classAbstractSession
- Parameters:
credentials
- login credentials- Returns:
- logged in session
- Throws:
RepositoryException
- if an error occursLoginException
- See Also:
Session.impersonate(Credentials)
- Retrieves the
-
getRootNode
public Node getRootNode() throws RepositoryException
- Specified by:
getRootNode
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.getRootNode()
-
getNodeByUUID
public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException
- Specified by:
getNodeByUUID
in interfaceSession
- Throws:
ItemNotFoundException
RepositoryException
- See Also:
Session.getNodeByUUID(String)
-
getItem
public Item getItem(String absPath) throws PathNotFoundException, RepositoryException
Description copied from class:AbstractSession
Returns the node or property at the given path.The default implementation:
- Returns the root node if the given path is "/"
- Delegates to
Session.getNodeByIdentifier(String)
for identifier paths - Throws a
PathNotFoundException
if the given path does not start with a slash. - Calls
Node.getNode(String)
on the root node with the part of the given path after the first slash - Calls
Node.getProperty(String)
similarly in case the above call fails with aPathNotFoundException
- Specified by:
getItem
in interfaceSession
- Overrides:
getItem
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
- the node or property with the given path
- Throws:
PathNotFoundException
- if the given path is invalid or not foundRepositoryException
- if another error occurs- See Also:
Session.getItem(String)
-
itemExists
public boolean itemExists(String absPath) throws RepositoryException
Description copied from class:AbstractSession
CallsAbstractSession.getItem(String)
with the given path and returnstrue
if the call succeeds. Returnsfalse
if aPathNotFoundException
was thrown. Other exceptions are passed through.- Specified by:
itemExists
in interfaceSession
- Overrides:
itemExists
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
true
if an item exists at the given path,false
otherwise- Throws:
RepositoryException
- if an error occurs- See Also:
Session.itemExists(String)
-
move
public void move(String srcAbsPath, String destAbsPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException
- Specified by:
move
in interfaceSession
- Throws:
ItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
RepositoryException
- See Also:
Session.move(String, String)
-
save
public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, RepositoryException
- Specified by:
save
in interfaceSession
- Throws:
AccessDeniedException
ConstraintViolationException
InvalidItemStateException
VersionException
LockException
RepositoryException
- See Also:
Session.save()
-
refresh
public void refresh(boolean keepChanges) throws RepositoryException
- Specified by:
refresh
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.refresh(boolean)
-
hasPendingChanges
public boolean hasPendingChanges() throws RepositoryException
- Specified by:
hasPendingChanges
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.hasPendingChanges()
-
getValueFactory
public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException, RepositoryException
- Specified by:
getValueFactory
in interfaceSession
- Throws:
UnsupportedRepositoryOperationException
RepositoryException
- See Also:
Session.getValueFactory()
-
checkPermission
public void checkPermission(String absPath, String actions) throws AccessControlException, RepositoryException
- Specified by:
checkPermission
in interfaceSession
- Throws:
AccessControlException
RepositoryException
- See Also:
Session.checkPermission(String, String)
-
getImportContentHandler
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException
- Specified by:
getImportContentHandler
in interfaceSession
- Throws:
PathNotFoundException
ConstraintViolationException
VersionException
LockException
RepositoryException
- See Also:
Session.getImportContentHandler(String, int)
-
importXML
public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, PathNotFoundException, ItemExistsException, ConstraintViolationException, VersionException, InvalidSerializedDataException, LockException, RepositoryException
Description copied from class:AbstractSession
Parses the given input stream as an XML document and processes the SAX events using theContentHandler
returned bySession.getImportContentHandler(String, int)
.- Specified by:
importXML
in interfaceSession
- Overrides:
importXML
in classAbstractSession
- Parameters:
parentAbsPath
- passed throughin
- input stream to be parsed as XML and importeduuidBehavior
- passed through- Throws:
IOException
- if an I/O error occursInvalidSerializedDataException
- if an XML parsing error occursRepositoryException
- if a repository error occursPathNotFoundException
ItemExistsException
ConstraintViolationException
VersionException
LockException
- See Also:
Session.importXML(String, java.io.InputStream, int)
-
setNamespacePrefix
public void setNamespacePrefix(String prefix, String uri) throws RepositoryException
Description copied from class:AbstractSession
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 interfaceSession
- Overrides:
setNamespacePrefix
in classAbstractSession
- Parameters:
prefix
- namespace prefixuri
- namespace URI- Throws:
NamespaceException
- if the mapping is illegalRepositoryException
- if a repository error occurs- See Also:
Session.setNamespacePrefix(String, String)
-
logout
public void logout()
Description copied from class:AbstractSession
Clears the local namespace mappings. Subclasses that for example want to participate in a session pools should remember to callsuper.logout()
when overriding this method to avoid namespace mappings to be carried over to a new session.- Specified by:
logout
in interfaceSession
- Overrides:
logout
in classAbstractSession
- See Also:
Session.logout()
-
isLive
public boolean isLive()
- Specified by:
isLive
in interfaceSession
- See Also:
Session.isLive()
-
addLockToken
public void addLockToken(String lt)
- Specified by:
addLockToken
in interfaceSession
- See Also:
Session.addLockToken(String)
-
getLockTokens
public String[] getLockTokens()
- Specified by:
getLockTokens
in interfaceSession
- See Also:
Session.getLockTokens()
-
removeLockToken
public void removeLockToken(String lt)
- Specified by:
removeLockToken
in interfaceSession
- See Also:
Session.removeLockToken(String)
-
getAccessControlManager
public AccessControlManager getAccessControlManager() throws RepositoryException
- Specified by:
getAccessControlManager
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.getAccessControlManager()
-
getNode
public Node getNode(String absPath) throws RepositoryException
Description copied from class:AbstractSession
Returns the node with the given absolute path.- Specified by:
getNode
in interfaceSession
- Overrides:
getNode
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
- node at the given path
- Throws:
RepositoryException
- if the node can not be accessed- See Also:
Session.getNode(String)
-
getNodeByIdentifier
public Node getNodeByIdentifier(String id) throws RepositoryException
- Specified by:
getNodeByIdentifier
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.getNodeByIdentifier(String)
-
getProperty
public Property getProperty(String absPath) throws RepositoryException
Description copied from class:AbstractSession
Returns the property with the given absolute path.- Specified by:
getProperty
in interfaceSession
- Overrides:
getProperty
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
- node at the given path
- Throws:
RepositoryException
- if the property can not be accessed- See Also:
Session.getProperty(String)
-
getRetentionManager
public RetentionManager getRetentionManager() throws UnsupportedRepositoryOperationException, RepositoryException
- Specified by:
getRetentionManager
in interfaceSession
- Throws:
UnsupportedRepositoryOperationException
RepositoryException
- See Also:
Session.getRetentionManager()
-
hasCapability
public boolean hasCapability(String methodName, Object target, Object[] arguments) throws RepositoryException
- Specified by:
hasCapability
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.hasCapability(String, Object, Object[])
-
hasPermission
public boolean hasPermission(String absPath, String actions) throws RepositoryException
- Specified by:
hasPermission
in interfaceSession
- Throws:
RepositoryException
- See Also:
Session.hasPermission(String, String)
-
nodeExists
public boolean nodeExists(String absPath) throws RepositoryException
Description copied from class:AbstractSession
Checks whether a node with the given absolute path exists.- Specified by:
nodeExists
in interfaceSession
- Overrides:
nodeExists
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
true
if a node with the given path exists,false
otherwise- Throws:
RepositoryException
- if the path is invalid- See Also:
Session.nodeExists(String)
-
propertyExists
public boolean propertyExists(String absPath) throws RepositoryException
Description copied from class:AbstractSession
Checks whether a property with the given absolute path exists.- Specified by:
propertyExists
in interfaceSession
- Overrides:
propertyExists
in classAbstractSession
- Parameters:
absPath
- absolute path- Returns:
true
if a property with the given path exists,false
otherwise- Throws:
RepositoryException
- if the path is invalid- See Also:
Session.propertyExists(String)
-
removeItem
public void removeItem(String absPath) throws RepositoryException
Description copied from class:AbstractSession
Removes the identified item. Implemented by callingItem.remove()
on the item removed byAbstractSession.getItem(String)
.- Specified by:
removeItem
in interfaceSession
- Overrides:
removeItem
in classAbstractSession
- Parameters:
absPath
- An absolute path of the item to be removed- Throws:
RepositoryException
- if the item can not be removed- See Also:
Session.removeItem(String)
-
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 interfaceNamespaceResolver
- Parameters:
uri
- namespace URI- Returns:
- the prefix mapped to the given URI.
- Throws:
NamespaceException
- if the URI is unknown.- See Also:
NamespaceResolver.getPrefix(String)
-
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 interfaceNamespaceResolver
- Parameters:
prefix
- namespace prefix- Returns:
- the namespace URI to which the given prefix is mapped.
- Throws:
NamespaceException
- if the prefix is unknown.- See Also:
NamespaceResolver.getURI(String)
-
addListener
public void addListener(SessionListener listener)
Add aSessionListener
- Parameters:
listener
- the new listener to be informed on modifications
-
removeListener
public void removeListener(SessionListener listener)
Remove aSessionListener
- Parameters:
listener
- an existing listener
-
createWorkspaceInstance
protected WorkspaceImpl createWorkspaceInstance(RepositoryConfig config, SessionInfo sessionInfo) throws RepositoryException
- Throws:
RepositoryException
-
createSessionItemStateManager
protected SessionItemStateManager createSessionItemStateManager(UpdatableItemStateManager workspaceStateManager, ItemStateFactory isf) throws RepositoryException
- Throws:
RepositoryException
-
createItemManager
protected ItemManager createItemManager(HierarchyManager hierarchyManager)
-
getNamePathResolver
public NamePathResolver getNamePathResolver()
- Specified by:
getNamePathResolver
in interfaceManagerProvider
- See Also:
ManagerProvider.getNamePathResolver()
-
getNameResolver
public NameResolver getNameResolver()
- Specified by:
getNameResolver
in interfaceManagerProvider
- See Also:
ManagerProvider.getNameResolver()
-
getPathResolver
public PathResolver getPathResolver()
- Specified by:
getPathResolver
in interfaceManagerProvider
- See Also:
ManagerProvider.getPathResolver()
-
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
- Specified by:
getNamespaceResolver
in interfaceManagerProvider
- See Also:
ManagerProvider.getNamespaceResolver()
-
getHierarchyManager
public HierarchyManager getHierarchyManager()
- Specified by:
getHierarchyManager
in interfaceManagerProvider
- See Also:
ManagerProvider.getHierarchyManager()
-
getLockStateManager
public LockStateManager getLockStateManager()
Description copied from interface:ManagerProvider
Returns theLockStateManager
associated with thisManagerProvider
.- Specified by:
getLockStateManager
in interfaceManagerProvider
- Returns:
- the
LockStateManager
associated with thisManagerProvider
- See Also:
ManagerProvider.getLockStateManager()
-
getAccessManager
public AccessManager getAccessManager()
- Specified by:
getAccessManager
in interfaceManagerProvider
- See Also:
ManagerProvider.getAccessManager()
-
getVersionStateManager
public VersionManager getVersionStateManager()
Description copied from interface:ManagerProvider
Returns theVersionManager
associated with thisManagerProvider
.- Specified by:
getVersionStateManager
in interfaceManagerProvider
- Returns:
- the
VersionManager
associated with thisManagerProvider
- See Also:
ManagerProvider.getVersionStateManager()
-
getItemDefinitionProvider
public ItemDefinitionProvider getItemDefinitionProvider()
- Specified by:
getItemDefinitionProvider
in interfaceManagerProvider
- See Also:
ManagerProvider.getItemDefinitionProvider()
-
getNodeTypeDefinitionProvider
public NodeTypeDefinitionProvider getNodeTypeDefinitionProvider()
- Specified by:
getNodeTypeDefinitionProvider
in interfaceManagerProvider
- See Also:
ManagerProvider.getNodeTypeDefinitionProvider()
-
getEffectiveNodeTypeProvider
public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider()
- Specified by:
getEffectiveNodeTypeProvider
in interfaceManagerProvider
- See Also:
ManagerProvider.getEffectiveNodeTypeProvider()
-
getQValueFactory
public QValueFactory getQValueFactory() throws RepositoryException
- Specified by:
getQValueFactory
in interfaceManagerProvider
- Throws:
RepositoryException
- See Also:
ManagerProvider.getQValueFactory()
-
getAccessControlProvider
public AccessControlProvider getAccessControlProvider() throws RepositoryException
- Specified by:
getAccessControlProvider
in interfaceManagerProvider
- Throws:
RepositoryException
- See Also:
ManagerProvider.getAccessControlProvider()
-
getJcrValueFactory
public ValueFactory getJcrValueFactory() throws RepositoryException
Description copied from interface:ManagerProvider
Same asSession.getValueFactory()
but omits the check, if this repository is really level 2 compliant. Therefore, this method may be used for internal functionality only, that require creation and conversion of JCR values.- Specified by:
getJcrValueFactory
in interfaceManagerProvider
- Returns:
- Throws:
RepositoryException
- See Also:
ManagerProvider.getJcrValueFactory()
-
getValidator
public ItemStateValidator getValidator()
-
getIdFactory
public IdFactory getIdFactory() throws RepositoryException
- Throws:
RepositoryException
-
getNameFactory
public NameFactory getNameFactory() throws RepositoryException
- Throws:
RepositoryException
-
-