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 voidaddListener(SessionListener listener)Add aSessionListenervoidaddLockToken(String lt)voidcheckPermission(String absPath, String actions)protected ItemManagercreateItemManager(HierarchyManager hierarchyManager)protected SessionItemStateManagercreateSessionItemStateManager(UpdatableItemStateManager workspaceStateManager, ItemStateFactory isf)protected WorkspaceImplcreateWorkspaceInstance(RepositoryConfig config, SessionInfo sessionInfo)AccessControlManagergetAccessControlManager()AccessControlProvidergetAccessControlProvider()AccessManagergetAccessManager()ObjectgetAttribute(String name)Always returnsnull.String[]getAttributeNames()Always returns an empty String array.EffectiveNodeTypeProvidergetEffectiveNodeTypeProvider()HierarchyManagergetHierarchyManager()IdFactorygetIdFactory()ContentHandlergetImportContentHandler(String parentAbsPath, int uuidBehavior)ItemgetItem(String absPath)Returns the node or property at the given path.ItemDefinitionProvidergetItemDefinitionProvider()ValueFactorygetJcrValueFactory()Same asSession.getValueFactory()but omits the check, if this repository is really level 2 compliant.LockStateManagergetLockStateManager()Returns theLockStateManagerassociated with thisManagerProvider.String[]getLockTokens()NameFactorygetNameFactory()NamePathResolvergetNamePathResolver()NameResolvergetNameResolver()NamespaceResolvergetNamespaceResolver()NodegetNode(String absPath)Returns the node with the given absolute path.NodegetNodeByIdentifier(String id)NodegetNodeByUUID(String uuid)NodeTypeDefinitionProvidergetNodeTypeDefinitionProvider()PathResolvergetPathResolver()StringgetPrefix(String uri)Returns the prefix which is mapped to the given URI.PropertygetProperty(String absPath)Returns the property with the given absolute path.QValueFactorygetQValueFactory()RepositorygetRepository()RetentionManagergetRetentionManager()NodegetRootNode()StringgetURI(String prefix)Returns the URI to which the given prefix is mapped.StringgetUserID()ItemStateValidatorgetValidator()ValueFactorygetValueFactory()VersionManagergetVersionStateManager()Returns theVersionManagerassociated with thisManagerProvider.WorkspacegetWorkspace()booleanhasCapability(String methodName, Object target, Object[] arguments)booleanhasPendingChanges()booleanhasPermission(String absPath, String actions)Sessionimpersonate(Credentials credentials)Logs in the same workspace with the given credentials.voidimportXML(String parentAbsPath, InputStream in, int uuidBehavior)Parses the given input stream as an XML document and processes the SAX events using theContentHandlerreturned bySession.getImportContentHandler(String, int).booleanisLive()booleanitemExists(String absPath)CallsAbstractSession.getItem(String)with the given path and returnstrueif the call succeeds.voidlogout()Clears the local namespace mappings.voidmove(String srcAbsPath, String destAbsPath)booleannodeExists(String absPath)Checks whether a node with the given absolute path exists.booleanpropertyExists(String absPath)Checks whether a property with the given absolute path exists.voidrefresh(boolean keepChanges)voidremoveItem(String absPath)Removes the identified item.voidremoveListener(SessionListener listener)Remove aSessionListenervoidremoveLockToken(String lt)voidsave()voidsetNamespacePrefix(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:
getRepositoryin interfaceSession- See Also:
Session.getRepository()
-
getUserID
public String getUserID()
- Specified by:
getUserIDin interfaceSession- See Also:
Session.getUserID()
-
getAttribute
public Object getAttribute(String name)
Always returnsnull.- Specified by:
getAttributein interfaceSession- See Also:
Session.getAttribute(String)
-
getAttributeNames
public String[] getAttributeNames()
Always returns an empty String array.- Specified by:
getAttributeNamesin interfaceSession- See Also:
Session.getAttributeNames()
-
getWorkspace
public Workspace getWorkspace()
- Specified by:
getWorkspacein interfaceSession- See Also:
Session.getWorkspace()
-
impersonate
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException
Description copied from class:AbstractSessionLogs in the same workspace with the given credentials.The default implementation:
- Retrieves the
Repositoryinstance 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:
impersonatein interfaceSession- Overrides:
impersonatein 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:
getRootNodein interfaceSession- Throws:
RepositoryException- See Also:
Session.getRootNode()
-
getNodeByUUID
public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException
- Specified by:
getNodeByUUIDin interfaceSession- Throws:
ItemNotFoundExceptionRepositoryException- See Also:
Session.getNodeByUUID(String)
-
getItem
public Item getItem(String absPath) throws PathNotFoundException, RepositoryException
Description copied from class:AbstractSessionReturns 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
PathNotFoundExceptionif 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:
getItemin interfaceSession- Overrides:
getItemin 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:AbstractSessionCallsAbstractSession.getItem(String)with the given path and returnstrueif the call succeeds. Returnsfalseif aPathNotFoundExceptionwas thrown. Other exceptions are passed through.- Specified by:
itemExistsin interfaceSession- Overrides:
itemExistsin classAbstractSession- Parameters:
absPath- absolute path- Returns:
trueif an item exists at the given path,falseotherwise- 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:
movein interfaceSession- Throws:
ItemExistsExceptionPathNotFoundExceptionVersionExceptionConstraintViolationExceptionLockExceptionRepositoryException- See Also:
Session.move(String, String)
-
save
public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, RepositoryException- Specified by:
savein interfaceSession- Throws:
AccessDeniedExceptionConstraintViolationExceptionInvalidItemStateExceptionVersionExceptionLockExceptionRepositoryException- See Also:
Session.save()
-
refresh
public void refresh(boolean keepChanges) throws RepositoryException- Specified by:
refreshin interfaceSession- Throws:
RepositoryException- See Also:
Session.refresh(boolean)
-
hasPendingChanges
public boolean hasPendingChanges() throws RepositoryException- Specified by:
hasPendingChangesin interfaceSession- Throws:
RepositoryException- See Also:
Session.hasPendingChanges()
-
getValueFactory
public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException, RepositoryException
- Specified by:
getValueFactoryin interfaceSession- Throws:
UnsupportedRepositoryOperationExceptionRepositoryException- See Also:
Session.getValueFactory()
-
checkPermission
public void checkPermission(String absPath, String actions) throws AccessControlException, RepositoryException
- Specified by:
checkPermissionin interfaceSession- Throws:
AccessControlExceptionRepositoryException- See Also:
Session.checkPermission(String, String)
-
getImportContentHandler
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException
- Specified by:
getImportContentHandlerin interfaceSession- Throws:
PathNotFoundExceptionConstraintViolationExceptionVersionExceptionLockExceptionRepositoryException- 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:AbstractSessionParses the given input stream as an XML document and processes the SAX events using theContentHandlerreturned bySession.getImportContentHandler(String, int).- Specified by:
importXMLin interfaceSession- Overrides:
importXMLin 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 occursPathNotFoundExceptionItemExistsExceptionConstraintViolationExceptionVersionExceptionLockException- See Also:
Session.importXML(String, java.io.InputStream, int)
-
setNamespacePrefix
public void setNamespacePrefix(String prefix, String uri) throws RepositoryException
Description copied from class:AbstractSessionModifies 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:
setNamespacePrefixin interfaceSession- Overrides:
setNamespacePrefixin 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:AbstractSessionClears 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:
logoutin interfaceSession- Overrides:
logoutin classAbstractSession- See Also:
Session.logout()
-
isLive
public boolean isLive()
- Specified by:
isLivein interfaceSession- See Also:
Session.isLive()
-
addLockToken
public void addLockToken(String lt)
- Specified by:
addLockTokenin interfaceSession- See Also:
Session.addLockToken(String)
-
getLockTokens
public String[] getLockTokens()
- Specified by:
getLockTokensin interfaceSession- See Also:
Session.getLockTokens()
-
removeLockToken
public void removeLockToken(String lt)
- Specified by:
removeLockTokenin interfaceSession- See Also:
Session.removeLockToken(String)
-
getAccessControlManager
public AccessControlManager getAccessControlManager() throws RepositoryException
- Specified by:
getAccessControlManagerin interfaceSession- Throws:
RepositoryException- See Also:
Session.getAccessControlManager()
-
getNode
public Node getNode(String absPath) throws RepositoryException
Description copied from class:AbstractSessionReturns the node with the given absolute path.- Specified by:
getNodein interfaceSession- Overrides:
getNodein 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:
getNodeByIdentifierin interfaceSession- Throws:
RepositoryException- See Also:
Session.getNodeByIdentifier(String)
-
getProperty
public Property getProperty(String absPath) throws RepositoryException
Description copied from class:AbstractSessionReturns the property with the given absolute path.- Specified by:
getPropertyin interfaceSession- Overrides:
getPropertyin 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:
getRetentionManagerin interfaceSession- Throws:
UnsupportedRepositoryOperationExceptionRepositoryException- See Also:
Session.getRetentionManager()
-
hasCapability
public boolean hasCapability(String methodName, Object target, Object[] arguments) throws RepositoryException
- Specified by:
hasCapabilityin interfaceSession- Throws:
RepositoryException- See Also:
Session.hasCapability(String, Object, Object[])
-
hasPermission
public boolean hasPermission(String absPath, String actions) throws RepositoryException
- Specified by:
hasPermissionin interfaceSession- Throws:
RepositoryException- See Also:
Session.hasPermission(String, String)
-
nodeExists
public boolean nodeExists(String absPath) throws RepositoryException
Description copied from class:AbstractSessionChecks whether a node with the given absolute path exists.- Specified by:
nodeExistsin interfaceSession- Overrides:
nodeExistsin classAbstractSession- Parameters:
absPath- absolute path- Returns:
trueif a node with the given path exists,falseotherwise- Throws:
RepositoryException- if the path is invalid- See Also:
Session.nodeExists(String)
-
propertyExists
public boolean propertyExists(String absPath) throws RepositoryException
Description copied from class:AbstractSessionChecks whether a property with the given absolute path exists.- Specified by:
propertyExistsin interfaceSession- Overrides:
propertyExistsin classAbstractSession- Parameters:
absPath- absolute path- Returns:
trueif a property with the given path exists,falseotherwise- Throws:
RepositoryException- if the path is invalid- See Also:
Session.propertyExists(String)
-
removeItem
public void removeItem(String absPath) throws RepositoryException
Description copied from class:AbstractSessionRemoves the identified item. Implemented by callingItem.remove()on the item removed byAbstractSession.getItem(String).- Specified by:
removeItemin interfaceSession- Overrides:
removeItemin 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:NamespaceResolverReturns the prefix which is mapped to the given URI.- Specified by:
getPrefixin 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:NamespaceResolverReturns the URI to which the given prefix is mapped.- Specified by:
getURIin 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:
getNamePathResolverin interfaceManagerProvider- See Also:
ManagerProvider.getNamePathResolver()
-
getNameResolver
public NameResolver getNameResolver()
- Specified by:
getNameResolverin interfaceManagerProvider- See Also:
ManagerProvider.getNameResolver()
-
getPathResolver
public PathResolver getPathResolver()
- Specified by:
getPathResolverin interfaceManagerProvider- See Also:
ManagerProvider.getPathResolver()
-
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
- Specified by:
getNamespaceResolverin interfaceManagerProvider- See Also:
ManagerProvider.getNamespaceResolver()
-
getHierarchyManager
public HierarchyManager getHierarchyManager()
- Specified by:
getHierarchyManagerin interfaceManagerProvider- See Also:
ManagerProvider.getHierarchyManager()
-
getLockStateManager
public LockStateManager getLockStateManager()
Description copied from interface:ManagerProviderReturns theLockStateManagerassociated with thisManagerProvider.- Specified by:
getLockStateManagerin interfaceManagerProvider- Returns:
- the
LockStateManagerassociated with thisManagerProvider - See Also:
ManagerProvider.getLockStateManager()
-
getAccessManager
public AccessManager getAccessManager()
- Specified by:
getAccessManagerin interfaceManagerProvider- See Also:
ManagerProvider.getAccessManager()
-
getVersionStateManager
public VersionManager getVersionStateManager()
Description copied from interface:ManagerProviderReturns theVersionManagerassociated with thisManagerProvider.- Specified by:
getVersionStateManagerin interfaceManagerProvider- Returns:
- the
VersionManagerassociated with thisManagerProvider - See Also:
ManagerProvider.getVersionStateManager()
-
getItemDefinitionProvider
public ItemDefinitionProvider getItemDefinitionProvider()
- Specified by:
getItemDefinitionProviderin interfaceManagerProvider- See Also:
ManagerProvider.getItemDefinitionProvider()
-
getNodeTypeDefinitionProvider
public NodeTypeDefinitionProvider getNodeTypeDefinitionProvider()
- Specified by:
getNodeTypeDefinitionProviderin interfaceManagerProvider- See Also:
ManagerProvider.getNodeTypeDefinitionProvider()
-
getEffectiveNodeTypeProvider
public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider()
- Specified by:
getEffectiveNodeTypeProviderin interfaceManagerProvider- See Also:
ManagerProvider.getEffectiveNodeTypeProvider()
-
getQValueFactory
public QValueFactory getQValueFactory() throws RepositoryException
- Specified by:
getQValueFactoryin interfaceManagerProvider- Throws:
RepositoryException- See Also:
ManagerProvider.getQValueFactory()
-
getAccessControlProvider
public AccessControlProvider getAccessControlProvider() throws RepositoryException
- Specified by:
getAccessControlProviderin interfaceManagerProvider- Throws:
RepositoryException- See Also:
ManagerProvider.getAccessControlProvider()
-
getJcrValueFactory
public ValueFactory getJcrValueFactory() throws RepositoryException
Description copied from interface:ManagerProviderSame 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:
getJcrValueFactoryin 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
-
-