org.apache.jackrabbit.api.jsr283
Interface Session

All Superinterfaces:
Session

public interface Session
extends Session

This interface holds extensions made in JCR 2.0 while work is in progress implementing JCR 2.0.

Since:
JCR 2.0

Field Summary
static String ACTION_ADD_NODE
          A constant representing the add_node action string, used to determine if this Session has permission to add a new node.
static String ACTION_READ
          A constant representing the read action string, used to determine if this Session has permission to retrieve an item (and read the value, in the case of a property).
static String ACTION_REMOVE
          A constant representing the remove action string, used to determine if this Session has permission to remove an item.
static String ACTION_SET_PROPERTY
          A constant representing the set_property action string, used to determine if this Session has permission to set (add or modify) a property.
 
Method Summary
 AccessControlManager getAccessControlManager()
          Returns the access control manager for this Session.
 Node getNode(String absPath)
          Returns the node at the specified absolute path in the workspace.
 Node getNodeByIdentifier(String id)
          Returns the node specified by the given identifier.
 Property getProperty(String absPath)
          Returns the property at the specified absolute path in the workspace.
 RetentionManager getRetentionManager()
          Returns the retention and hold manager for this Session.
 boolean hasCapability(String methodName, Object target, Map arguments)
          Checks whether an operation can be performed given as much context as can be determined by the repository, including: Permissions granted to the current user, including access control privileges.
 boolean hasPermission(String absPath, String actions)
          Returns true if this Session has permission to perform the specified actions at the specified absPath and false otherwise.
 boolean nodeExists(String absPath)
          Returns true if a node exists at absPath and this Session has read access to it; otherwise returns false.
 boolean propertyExists(String absPath)
          Returns true if a property exists at absPath and this Session has read access to it; otherwise returns false.
 void removeItem(String absPath)
          Removes the specified item (and its subtree).
 
Methods inherited from interface javax.jcr.Session
addLockToken, checkPermission, exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getAttribute, getAttributeNames, getImportContentHandler, getItem, getLockTokens, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, getNodeByUUID, getRepository, getRootNode, getUserID, getValueFactory, getWorkspace, hasPendingChanges, impersonate, importXML, isLive, itemExists, logout, move, refresh, removeLockToken, save, setNamespacePrefix
 

Field Detail

ACTION_READ

static final String ACTION_READ
A constant representing the read action string, used to determine if this Session has permission to retrieve an item (and read the value, in the case of a property).

Since:
JCR 2.0
See Also:
hasPermission(String, String), Session.checkPermission(String, String), Constant Field Values

ACTION_ADD_NODE

static final String ACTION_ADD_NODE
A constant representing the add_node action string, used to determine if this Session has permission to add a new node.

Since:
JCR 2.0
See Also:
hasPermission(String, String), Session.checkPermission(String, String), Constant Field Values

ACTION_SET_PROPERTY

static final String ACTION_SET_PROPERTY
A constant representing the set_property action string, used to determine if this Session has permission to set (add or modify) a property.

Since:
JCR 2.0
See Also:
hasPermission(String, String), Session.checkPermission(String, String), Constant Field Values

ACTION_REMOVE

static final String ACTION_REMOVE
A constant representing the remove action string, used to determine if this Session has permission to remove an item.

Since:
JCR 2.0
See Also:
hasPermission(String, String), Session.checkPermission(String, String), Constant Field Values
Method Detail

getNodeByIdentifier

Node getNodeByIdentifier(String id)
                         throws ItemNotFoundException,
                                RepositoryException
Returns the node specified by the given identifier. Applies to both referenceable and non-referenceable nodes.

An 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

getNode

Node getNode(String absPath)
             throws PathNotFoundException,
                    RepositoryException
Returns the node at the specified absolute path in the workspace. If no node exists, then a PathNotFoundException is thrown.

Parameters:
absPath - An absolute path.
Returns:
the specified Node.
Throws:
PathNotFoundException - If no node exists.
RepositoryException - If another error occurs.
Since:
JCR 2.0

getProperty

Property getProperty(String absPath)
                     throws PathNotFoundException,
                            RepositoryException
Returns the property at the specified absolute path in the workspace. If no property exists, then a PathNotFoundException is thrown.

Parameters:
absPath - An absolute path.
Returns:
the specified Property.
Throws:
PathNotFoundException - If no property exists.
RepositoryException - if another error occurs.
Since:
JCR 2.0

nodeExists

boolean nodeExists(String absPath)
                   throws RepositoryException
Returns 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.

Parameters:
absPath - An absolute path.
Returns:
a boolean
Throws:
RepositoryException - if absPath is not a well-formed absolute path.
Since:
JCR 2.0

propertyExists

boolean propertyExists(String absPath)
                       throws RepositoryException
Returns 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.

Parameters:
absPath - An absolute path.
Returns:
a boolean
Throws:
RepositoryException - if absPath is not a well-formed absolute path.
Since:
JCR 2.0

removeItem

void removeItem(String absPath)
                throws VersionException,
                       LockException,
                       ConstraintViolationException,
                       RepositoryException
Removes the specified item (and its subtree).

To persist a removal, a save must be performed.

If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.

A ReferentialIntegrityException will be thrown on save if the specified item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside the specified item's subtree and the current Session has read access to that REFERENCE property.

An AccessDeniedException will be thrown on save if the specified item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside the specified item's subtree and the current Session does not have read access to that REFERENCE property.

A ConstraintViolationException will be thrown either immediately or on save, if removing the specified item would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.

A VersionException will be thrown either immediately or on save, if the parent node of the specified item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in. Implementations may differ on when this validation is performed.

A LockException will be thrown either immediately or on save if a lock prevents the removal of the specified item. Implementations may differ on when this validation is performed.

Parameters:
absPath - the absolute path of the item to be removed.
Throws:
VersionException - if the parent node of the item at absPath is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save.
LockException - if a lock prevents the removal of the specified item and this implementation performs this validation immediately instead of waiting until save.
ConstraintViolationException - if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save.
RepositoryException - if another error occurs.
Since:
JCR 2.0
See Also:
Item.remove()

hasPermission

boolean hasPermission(String absPath,
                      String actions)
                      throws RepositoryException
Returns true if this Session has permission to perform the specified actions at the specified absPath and false otherwise.

The actions parameter is a comma separated list of action strings. The following action strings are defined:

  • add_node: If hasPermission(path, "add_node") returns true, then this Session has permission to add a node at path.
  • set_property: If hasPermission(path, "set_property") returns true, then this Session has permission to set (add or change) a property at path.
  • remove: If hasPermission(path, "remove") returns true, then this Session has permission to remove an item at path.
  • read: If hasPermission(path, "read") returns true, then this Session has permission to retrieve (and read the value of, in the case of a property) an item at path.
When more than one action is specified in the actions parameter, this method will only return true if this Session has permission to perform all of the listed actions at the specified path.

The information returned through this method will only reflect the access control status (both JCR defined and implementation-specific) and not other restrictions that may exist, such as node type constraints. For example, even though hasPermission may indicate that a particular Session may add a property at /A/B/C, the node type of the node at /A/B may prevent the addition of a property called C.

Parameters:
absPath - an absolute path.
actions - a comma separated list of action strings.
Returns:
boolean true if this Session has permission to perform the specified actions at the specified absPath.
Throws:
RepositoryException - if an error occurs.
Since:
JCR 2.0

hasCapability

boolean hasCapability(String methodName,
                      Object target,
                      Map arguments)
                      throws RepositoryException
Checks whether an operation can be performed given as much context as can be determined by the repository, including:
  • Permissions granted to the current user, including access control privileges.
  • Current state of the target object (reflecting locks, checkin/checkout status, retention and hold status etc.).
  • Repository capabilities.
  • Node type-enforced restrictions.
  • Repository configuration-specific restrictions.
The implementation of this method is best effort: returning false guarantees that the operation cannot be performed, but returning true does not guarantee the opposite. The repository implementation should use this to give priority to performance over completeness. An exception should be thrown only for important failures such as loss of connectivity to the back-end.

The implementation of this method is best effort: returning false guarantees that the operation cannot be performed, but returning true does not guarantee the opposite.

The methodName parameter identifies the method in question by its name as defined in the Javadoc.

The target parameter identifies the object on which the specified method is called.

The arguments parameter contains a Map object consisting of name/value pairs where the name is a String holding the parameter name of the method as defined in the Javadoc and the value is an Object holding the value to be passed. In cases where the value is a Java primitive type it must be converted to its corresponding Java object form before being passed.

For example, given a Session S and Node N then

Map p = new HashMap(); p.put("relPath", "foo"); boolean b = S.hasCapability("addNode", N, p);

will result in b == false if a child node called foo cannot be added to the node N within the session S.

Parameters:
methodName - the nakme of the method.
target - the target object of the operation.
arguments - the arguments of the operation.
Returns:
boolean false if the operation cannot be performed, true if the operation can be performed or if the repository cannot determine whether the operation can be performed.
Throws:
RepositoryException - if an error occurs
Since:
JCR 2.0

getAccessControlManager

AccessControlManager getAccessControlManager()
                                             throws UnsupportedRepositoryOperationException,
                                                    RepositoryException
Returns the access control manager for this Session.

An UnsupportedRepositoryOperationException is thrown if access control is not supported.

A RepositoryException is thrown if another error occurs.

Returns:
the access control manager for this Session
Throws:
UnsupportedRepositoryOperationException - if access control is not supported.
RepositoryException - if another error occurs.
Since:
JCR 2.0

getRetentionManager

RetentionManager getRetentionManager()
                                     throws UnsupportedRepositoryOperationException,
                                            RepositoryException
Returns the retention and hold manager for this Session.

An UnsupportedRepositoryOperationException is thrown if retention and hold are not supported.

A RepositoryException is thrown if another error occurs.

Returns:
the retention manager for this Session.
Throws:
UnsupportedRepositoryOperationException - if retention and hold are not supported.
RepositoryException - if another error occurs.
Since:
JCR 2.0


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.