ModeShape Distribution 3.2.0.Final

org.modeshape.jcr
Class JcrSession

java.lang.Object
  extended by org.modeshape.jcr.JcrSession
All Implemented Interfaces:
Session
Direct Known Subclasses:
JcrXaSession

public class JcrSession
extends Object
implements Session


Nested Class Summary
protected  class JcrSession.JcrPreSave
          Define the operations that are to be performed on all the nodes that were created or modified within this session.
protected  class JcrSession.SystemSessionCache
           
 
Field Summary
protected  JcrRepository repository
           
 
Fields inherited from interface javax.jcr.Session
ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY
 
Constructor Summary
protected JcrSession(JcrRepository repository, String workspaceName, ExecutionContext context, Map<String,Object> sessionAttributes, boolean readOnly)
           
protected JcrSession(JcrSession original, boolean readOnly)
           
 
Method Summary
 void addLockToken(String lockToken)
           
 void checkPermission(String path, String actions)
           
static NodeKey createNodeKeyFromIdentifier(String identifier, NodeKey rootKey)
          Determine if the supplied string represents just the node's identifier or whether it is a string representation of a NodeKey.
protected  SchematicEntry entryForNode(NodeKey nodeKey)
           
 void exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
           
 void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
           
 void exportSystemView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
           
 void exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
           
 AccessControlManager getAccessControlManager()
           
 Object getAttribute(String name)
           
 String[] getAttributeNames()
           
 ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
           
 org.modeshape.jcr.AbstractJcrItem getItem(String absPath)
           
 String[] getLockTokens()
           
 String getNamespacePrefix(String uri)
           
 String[] getNamespacePrefixes()
           
 String getNamespaceURI(String prefix)
           
 org.modeshape.jcr.AbstractJcrNode getNode(String absPath)
           
 org.modeshape.jcr.AbstractJcrNode getNodeByIdentifier(String id)
           
 org.modeshape.jcr.AbstractJcrNode getNodeByUUID(String uuid)
          Deprecated. 
 org.modeshape.jcr.AbstractJcrNode getNonSystemNodeByIdentifier(String id)
          A variant of the standard getNodeByIdentifier(String) method that does not find nodes within the system area.
 Property getProperty(String absPath)
           
 JcrRepository getRepository()
           
 RetentionManager getRetentionManager()
           
 org.modeshape.jcr.JcrRootNode getRootNode()
           
 String getUserID()
           
 JcrValueFactory getValueFactory()
           
 org.modeshape.jcr.JcrWorkspace getWorkspace()
           
 boolean hasCapability(String methodName, Object target, Object[] arguments)
          Makes a "best effort" determination of whether the given method can be successfully called on the given target with the given arguments.
 boolean hasPendingChanges()
           
 boolean hasPermission(String absPath, String actions)
           
 Session impersonate(Credentials credentials)
           
 void importXML(String parentAbsPath, InputStream in, int uuidBehavior)
           
protected  void initBaseVersionKeys()
           
protected  void initOriginalVersionKeys()
           
 boolean isAnonymous()
           
protected  boolean isForeignKey(NodeKey key)
          Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this session's root.
static boolean isForeignKey(NodeKey key, NodeKey rootKey)
          Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this session's root.
 boolean isLive()
           
 boolean itemExists(String absPath)
           
 void logout()
           
 void move(String srcAbsPath, String destAbsPath)
           
protected  boolean nodeExists(NodeKey key)
          Utility method to determine if the node with the specified key still exists within the transient & persisted state.
 boolean nodeExists(String absPath)
           
protected  String nodeIdentifier(NodeKey key)
          Returns a string representing a node's identifier, based on whether the node is foreign or not.
static String nodeIdentifier(NodeKey key, NodeKey rootKey)
          Returns a string representing a node's identifier, based on whether the node is foreign or not.
 boolean propertyExists(String absPath)
           
protected  String readable(Path path)
           
protected  String readableLocation(CachedNode node)
           
 void refresh(boolean keepChanges)
           
 void removeItem(String absPath)
           
 void removeLockToken(String lockToken)
           
 void save()
           
 void setNamespacePrefix(String newPrefix, String existingUri)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

repository

protected final JcrRepository repository
Constructor Detail

JcrSession

protected JcrSession(JcrRepository repository,
                     String workspaceName,
                     ExecutionContext context,
                     Map<String,Object> sessionAttributes,
                     boolean readOnly)

JcrSession

protected JcrSession(JcrSession original,
                     boolean readOnly)
Method Detail

entryForNode

protected SchematicEntry entryForNode(NodeKey nodeKey)
                               throws RepositoryException
Throws:
RepositoryException

readableLocation

protected final String readableLocation(CachedNode node)

readable

protected final String readable(Path path)

getRepository

public JcrRepository getRepository()
Specified by:
getRepository in interface Session

getUserID

public String getUserID()
Specified by:
getUserID in interface Session

isAnonymous

public boolean isAnonymous()

getAttributeNames

public String[] getAttributeNames()
Specified by:
getAttributeNames in interface Session

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface Session

getWorkspace

public org.modeshape.jcr.JcrWorkspace getWorkspace()
Specified by:
getWorkspace in interface Session

getRootNode

public org.modeshape.jcr.JcrRootNode getRootNode()
                                          throws RepositoryException
Specified by:
getRootNode in interface Session
Throws:
RepositoryException

impersonate

public Session impersonate(Credentials credentials)
                    throws LoginException,
                           RepositoryException
Specified by:
impersonate in interface Session
Throws:
LoginException
RepositoryException

getNodeByUUID

@Deprecated
public org.modeshape.jcr.AbstractJcrNode getNodeByUUID(String uuid)
                                                throws ItemNotFoundException,
                                                       RepositoryException
Deprecated. 

Specified by:
getNodeByUUID in interface Session
Throws:
ItemNotFoundException
RepositoryException

getNodeByIdentifier

public org.modeshape.jcr.AbstractJcrNode getNodeByIdentifier(String id)
                                                      throws ItemNotFoundException,
                                                             RepositoryException
Specified by:
getNodeByIdentifier in interface Session
Throws:
ItemNotFoundException
RepositoryException

getNonSystemNodeByIdentifier

public org.modeshape.jcr.AbstractJcrNode getNonSystemNodeByIdentifier(String id)
                                                               throws ItemNotFoundException,
                                                                      RepositoryException
A variant of the standard getNodeByIdentifier(String) method that does not find nodes within the system area. This is often needed by the JcrVersionManager functionality.

Parameters:
id - the string identifier
Returns:
the node; never null
Throws:
ItemNotFoundException - if a node cannot be found in the non-system content of the repository
RepositoryException - if there is another problem
See Also:
getNodeByIdentifier(String)

getNode

public org.modeshape.jcr.AbstractJcrNode getNode(String absPath)
                                          throws PathNotFoundException,
                                                 RepositoryException
Specified by:
getNode in interface Session
Throws:
PathNotFoundException
RepositoryException

getItem

public org.modeshape.jcr.AbstractJcrItem getItem(String absPath)
                                          throws PathNotFoundException,
                                                 RepositoryException
Specified by:
getItem in interface Session
Throws:
PathNotFoundException
RepositoryException

getProperty

public Property getProperty(String absPath)
                     throws PathNotFoundException,
                            RepositoryException
Specified by:
getProperty in interface Session
Throws:
PathNotFoundException
RepositoryException

itemExists

public boolean itemExists(String absPath)
                   throws RepositoryException
Specified by:
itemExists in interface Session
Throws:
RepositoryException

removeItem

public void removeItem(String absPath)
                throws VersionException,
                       LockException,
                       ConstraintViolationException,
                       AccessDeniedException,
                       RepositoryException
Specified by:
removeItem in interface Session
Throws:
VersionException
LockException
ConstraintViolationException
AccessDeniedException
RepositoryException

nodeExists

public boolean nodeExists(String absPath)
                   throws RepositoryException
Specified by:
nodeExists in interface Session
Throws:
RepositoryException

nodeExists

protected boolean nodeExists(NodeKey key)
Utility method to determine if the node with the specified key still exists within the transient & persisted state.

Parameters:
key - the key of the node; may not be null
Returns:
true if the node exists, or false if it does not

propertyExists

public boolean propertyExists(String absPath)
                       throws RepositoryException
Specified by:
propertyExists in interface Session
Throws:
RepositoryException

move

public void move(String srcAbsPath,
                 String destAbsPath)
          throws ItemExistsException,
                 PathNotFoundException,
                 VersionException,
                 ConstraintViolationException,
                 LockException,
                 RepositoryException
Specified by:
move in interface Session
Throws:
ItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
RepositoryException

save

public void save()
          throws AccessDeniedException,
                 ItemExistsException,
                 ReferentialIntegrityException,
                 ConstraintViolationException,
                 InvalidItemStateException,
                 VersionException,
                 LockException,
                 NoSuchNodeTypeException,
                 RepositoryException
Specified by:
save in interface Session
Throws:
AccessDeniedException
ItemExistsException
ReferentialIntegrityException
ConstraintViolationException
InvalidItemStateException
VersionException
LockException
NoSuchNodeTypeException
RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws RepositoryException
Specified by:
refresh in interface Session
Throws:
RepositoryException

hasPendingChanges

public boolean hasPendingChanges()
                          throws RepositoryException
Specified by:
hasPendingChanges in interface Session
Throws:
RepositoryException

getValueFactory

public JcrValueFactory getValueFactory()
                                throws UnsupportedRepositoryOperationException,
                                       RepositoryException
Specified by:
getValueFactory in interface Session
Throws:
UnsupportedRepositoryOperationException
RepositoryException

checkPermission

public void checkPermission(String path,
                            String actions)
Specified by:
checkPermission in interface Session

hasPermission

public boolean hasPermission(String absPath,
                             String actions)
                      throws RepositoryException
Specified by:
hasPermission in interface Session
Throws:
RepositoryException

hasCapability

public boolean hasCapability(String methodName,
                             Object target,
                             Object[] arguments)
                      throws RepositoryException
Makes a "best effort" determination of whether the given method can be successfully called on the given target with the given arguments. A return value of false indicates that the method would not succeed. A return value of true indicates that the method might succeed.

Specified by:
hasCapability in interface Session
Parameters:
methodName - the method to invoke; may not be null
target - the object on which to invoke it; may not be null
arguments - the arguments to pass to the method; varies depending on the method
Returns:
true if the given method can be determined to be supported, or false otherwise
Throws:
IllegalArgumentException
RepositoryException

getImportContentHandler

public ContentHandler getImportContentHandler(String parentAbsPath,
                                              int uuidBehavior)
                                       throws PathNotFoundException,
                                              ConstraintViolationException,
                                              VersionException,
                                              LockException,
                                              RepositoryException
Specified by:
getImportContentHandler in interface Session
Throws:
PathNotFoundException
ConstraintViolationException
VersionException
LockException
RepositoryException

initBaseVersionKeys

protected void initBaseVersionKeys()

initOriginalVersionKeys

protected void initOriginalVersionKeys()

importXML

public void importXML(String parentAbsPath,
                      InputStream in,
                      int uuidBehavior)
               throws IOException,
                      PathNotFoundException,
                      ItemExistsException,
                      ConstraintViolationException,
                      VersionException,
                      InvalidSerializedDataException,
                      LockException,
                      RepositoryException
Specified by:
importXML in interface Session
Throws:
IOException
PathNotFoundException
ItemExistsException
ConstraintViolationException
VersionException
InvalidSerializedDataException
LockException
RepositoryException

exportSystemView

public void exportSystemView(String absPath,
                             ContentHandler contentHandler,
                             boolean skipBinary,
                             boolean noRecurse)
                      throws PathNotFoundException,
                             SAXException,
                             RepositoryException
Specified by:
exportSystemView in interface Session
Throws:
PathNotFoundException
SAXException
RepositoryException

exportSystemView

public void exportSystemView(String absPath,
                             OutputStream out,
                             boolean skipBinary,
                             boolean noRecurse)
                      throws IOException,
                             PathNotFoundException,
                             RepositoryException
Specified by:
exportSystemView in interface Session
Throws:
IOException
PathNotFoundException
RepositoryException

exportDocumentView

public void exportDocumentView(String absPath,
                               ContentHandler contentHandler,
                               boolean skipBinary,
                               boolean noRecurse)
                        throws PathNotFoundException,
                               SAXException,
                               RepositoryException
Specified by:
exportDocumentView in interface Session
Throws:
PathNotFoundException
SAXException
RepositoryException

exportDocumentView

public void exportDocumentView(String absPath,
                               OutputStream out,
                               boolean skipBinary,
                               boolean noRecurse)
                        throws IOException,
                               PathNotFoundException,
                               RepositoryException
Specified by:
exportDocumentView in interface Session
Throws:
IOException
PathNotFoundException
RepositoryException

getNamespacePrefix

public String getNamespacePrefix(String uri)
                          throws RepositoryException
Specified by:
getNamespacePrefix in interface Session
Throws:
RepositoryException

getNamespacePrefixes

public String[] getNamespacePrefixes()
                              throws RepositoryException
Specified by:
getNamespacePrefixes in interface Session
Throws:
RepositoryException

getNamespaceURI

public String getNamespaceURI(String prefix)
                       throws RepositoryException
Specified by:
getNamespaceURI in interface Session
Throws:
RepositoryException

setNamespacePrefix

public void setNamespacePrefix(String newPrefix,
                               String existingUri)
                        throws NamespaceException,
                               RepositoryException
Specified by:
setNamespacePrefix in interface Session
Throws:
NamespaceException
RepositoryException

logout

public void logout()
Specified by:
logout in interface Session

isLive

public boolean isLive()
Specified by:
isLive in interface Session

addLockToken

public void addLockToken(String lockToken)
Specified by:
addLockToken in interface Session

getLockTokens

public String[] getLockTokens()
Specified by:
getLockTokens in interface Session

removeLockToken

public void removeLockToken(String lockToken)
Specified by:
removeLockToken in interface Session

getAccessControlManager

public AccessControlManager getAccessControlManager()
                                             throws UnsupportedRepositoryOperationException,
                                                    RepositoryException
Specified by:
getAccessControlManager in interface Session
Throws:
UnsupportedRepositoryOperationException
RepositoryException

getRetentionManager

public RetentionManager getRetentionManager()
                                     throws UnsupportedRepositoryOperationException,
                                            RepositoryException
Specified by:
getRetentionManager in interface Session
Throws:
UnsupportedRepositoryOperationException
RepositoryException

createNodeKeyFromIdentifier

public static NodeKey createNodeKeyFromIdentifier(String identifier,
                                                  NodeKey rootKey)
Determine if the supplied string represents just the node's identifier or whether it is a string representation of a NodeKey. If it is just the node's identifier, then the NodeKey is created by using the same source key and workspace key from the supplied root node.

Parameters:
identifier - the identifier string; may not be null
rootKey - the node of the root in the workspace; may not be null
Returns:
the node key re-created from the supplied identifier; never null

isForeignKey

public static boolean isForeignKey(NodeKey key,
                                   NodeKey rootKey)
Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this session's root. This method is used for reference resolving.

Parameters:
key - the node key; may be null
rootKey - the key of the root node in the workspace; may not be null
Returns:
true if the node key is considered foreign, false otherwise.

nodeIdentifier

public static String nodeIdentifier(NodeKey key,
                                    NodeKey rootKey)
Returns a string representing a node's identifier, based on whether the node is foreign or not.

Parameters:
key - the node key; may be null
rootKey - the key of the root node in the workspace; may not be null
Returns:
the identifier for the node; never null
See Also:
Node.getIdentifier()

isForeignKey

protected final boolean isForeignKey(NodeKey key)
Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this session's root. This method is used for reference resolving.

Parameters:
key - the node key; may be null
Returns:
true if the node key is considered foreign, false otherwise.

nodeIdentifier

protected final String nodeIdentifier(NodeKey key)
Returns a string representing a node's identifier, based on whether the node is foreign or not.

Parameters:
key - the node key; may be null
Returns:
the identifier for the node; never null
See Also:
Node.getIdentifier()

toString

public String toString()
Overrides:
toString in class Object

ModeShape Distribution 3.2.0.Final

Copyright © 2008-2013 JBoss, a division of Red Hat. All Rights Reserved.