Package org.apache.jackrabbit.api
Interface JackrabbitSession
- All Superinterfaces:
Session
- All Known Implementing Classes:
SessionImpl
Jackrabbit specific extension of the JCR
Session interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA constant representing theadd_propertyaction string, used to determine if thisSessionhas permission to add a new property.static final StringA constant representing thelockingaction string, used to determine if thisSessionhas permission to lock or unlock a node.static final StringA constant representing themodify_access_controlaction string, used to determine if thisSessionhas permission to modify access control content at the given path.static final StringA constant representing themodify_propertyaction string, used to determine if thisSessionhas permission to modify a property.static final StringA constant representing thenode_type_managementaction string, used to determine if thisSessionhas permission to write node type information of a node.static final StringA constant representing theread_access_controlaction string, used to determine if thisSessionhas permission to read access control content at the given path.static final StringA constant representing theremove_nodeaction string, used to determine if thisSessionhas permission to remove a node.static final StringA constant representing theremove_propertyaction string, used to determine if thisSessionhas permission to remove a property.static final StringA constant representing theuser_managementaction string, used to determine if thisSessionhas permission to perform user management operations at the given path.static final StringA constant representing theversioningaction string, used to determine if thisSessionhas permission to perform version operations on a node.Fields inherited from interface javax.jcr.Session
ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptionReturns the set of principals associated with this session.@NotNull StringgetExpandedName(@NotNull Item item) Returns the expanded name of the givenItem.@NotNull StringgetExpandedPath(@NotNull Item item) Returns the expanded path of the givenItem.getItemOrNull(String absPath) Returns the node at the specified absolute path in the workspace.getNodeOrNull(String absPath) Returns the node at the specified absolute path in the workspace ornullif no such node exists.default @Nullable NodegetParentOrNull(@NotNull Item item) Returns the parent of the givenItemornullif no parent exists (either because the givenItemrepresents the root node or the current session does not have sufficient access to retrieve the parent).Returns thePrincipalManagerfor the currentSession.getPropertyOrNull(String absPath) Returns the property at the specified absolute path in the workspace ornullif no such node exists.Returns theUserManagerfor the currentSession.booleanhasPermission(@NotNull String absPath, @NotNull String... actions) Returnstrueif thisSessionhas permission to perform the specified actions at the specifiedabsPathandfalseotherwise.Methods inherited from interface javax.jcr.Session
addLockToken, checkPermission, exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getAccessControlManager, getAttribute, getAttributeNames, getImportContentHandler, getItem, getLockTokens, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, getNode, getNodeByIdentifier, getNodeByUUID, getProperty, getRepository, getRetentionManager, getRootNode, getUserID, getValueFactory, getWorkspace, hasCapability, hasPendingChanges, hasPermission, impersonate, importXML, isLive, itemExists, logout, move, nodeExists, propertyExists, refresh, removeItem, removeLockToken, save, setNamespacePrefix
-
Field Details
-
ACTION_ADD_PROPERTY
A constant representing theadd_propertyaction string, used to determine if thisSessionhas permission to add a new property. -
ACTION_MODIFY_PROPERTY
A constant representing themodify_propertyaction string, used to determine if thisSessionhas permission to modify a property. -
ACTION_REMOVE_PROPERTY
A constant representing theremove_propertyaction string, used to determine if thisSessionhas permission to remove a property. -
ACTION_REMOVE_NODE
A constant representing theremove_nodeaction string, used to determine if thisSessionhas permission to remove a node. -
ACTION_NODE_TYPE_MANAGEMENT
A constant representing thenode_type_managementaction string, used to determine if thisSessionhas permission to write node type information of a node. -
ACTION_VERSIONING
A constant representing theversioningaction string, used to determine if thisSessionhas permission to perform version operations on a node. -
ACTION_LOCKING
A constant representing thelockingaction string, used to determine if thisSessionhas permission to lock or unlock a node. -
ACTION_READ_ACCESS_CONTROL
A constant representing theread_access_controlaction string, used to determine if thisSessionhas permission to read access control content at the given path. -
ACTION_MODIFY_ACCESS_CONTROL
A constant representing themodify_access_controlaction string, used to determine if thisSessionhas permission to modify access control content at the given path. -
ACTION_USER_MANAGEMENT
A constant representing theuser_managementaction string, used to determine if thisSessionhas permission to perform user management operations at the given path.
-
-
Method Details
-
hasPermission
boolean hasPermission(@NotNull @NotNull String absPath, @NotNull @NotNull String... actions) throws RepositoryException Returnstrueif thisSessionhas permission to perform the specified actions at the specifiedabsPathandfalseotherwise.The
actionsparameter is a list of action strings. Apart from the actions defined onSession, this variant also allows to specify the following additional actions to provide better permission discovery:-
: Ifadd_propertyhasPermission(path, "add_property")returnstrue, then thisSessionhas permission to add a new property atpath. -
: Ifmodify_propertyhasPermission(path, "modify_property")returnstrue, then thisSessionhas permission to change a property atpath. -
: Ifremove_propertyhasPermission(path, "remove_property")returnstrue, then thisSessionhas permission to remove a property atpath. -
: Ifremove_nodehasPermission(path, "remove_node")returnstrue, then thisSessionhas permission to remove a node atpath. -
: Ifnode_type_managementhasPermission(path, "node_type_management")returnstrue, then thisSessionhas permission to explicitly set or change the node type information associated with a node atpath. -
: IfversioninghasPermission(path, "versioning")returnstrue, then thisSessionhas permission to perform version related operations on a node atpath. -
: IflockinghasPermission(path, "locking")returnstrue, then thisSessionhas permission to lock and unlock a node atpath. -
: Ifread_access_controlhasPermission(path, "read_access_control")returnstrue, then thisSessionhas permission to read access control content stored at an item atpath. -
: Ifmodify_access_controlhasPermission(path, "modify_access_control")returnstrue, then thisSessionhas permission to modify access control content at an item atpath. -
: Ifuser_managementhasPermission(path, "user_management")returnstrue, then thisSessionhas permission to perform user management operations at an item atpath.
trueif thisSessionhas permission to perform all of the listed actions at the specified path.The information returned through this method will only reflect the permission status (both JCR defined and implementation-specific) and not other restrictions that may exist, such as node type or other implementation enforced constraints. For example, even though
hasPermissionmay indicate that a particularSessionmay add a property at/A/B/C, the node type of the node at/A/Bmay prevent the addition of a property calledC.- Parameters:
absPath- an absolute path.actions- one or several actions.- Returns:
trueif thisSessionhas permission to perform the specified actions at the specifiedabsPath.- Throws:
RepositoryException- if an error occurs.- See Also:
-
-
getPrincipalManager
PrincipalManager getPrincipalManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryExceptionReturns thePrincipalManagerfor the currentSession.- Returns:
- the
PrincipalManagerassociated with thisSession. - Throws:
AccessDeniedException- If the session lacks privileges to access the principal manager or principals in general.UnsupportedRepositoryOperationException- If principal management is not supported.RepositoryException- If another error occurs.- See Also:
-
getUserManager
UserManager getUserManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryExceptionReturns theUserManagerfor the currentSession.- Returns:
- the
UserManagerassociated with thisSession. - Throws:
AccessDeniedException- If this session is not allowed to to access user data.UnsupportedRepositoryOperationException- If user management is not supported.RepositoryException- If another error occurs.- See Also:
-
getItemOrNull
Returns the node at the specified absolute path in the workspace. If no such node exists, then it returns the property at the specified path. If no such property exists, then it returnnull.- Parameters:
absPath- An absolute path.- Returns:
- the specified
Itemornull. - Throws:
RepositoryException- if another error occurs.- Since:
- 2.11.1
-
getPropertyOrNull
Returns the property at the specified absolute path in the workspace ornullif no such node exists.- Parameters:
absPath- An absolute path.- Returns:
- the specified
Propertyornull. - Throws:
RepositoryException- if another error occurs.- Since:
- 2.11.1
-
getNodeOrNull
Returns the node at the specified absolute path in the workspace ornullif no such node exists.- Parameters:
absPath- An absolute path.- Returns:
- the specified
Nodeornull. - Throws:
RepositoryException- If another error occurs.- Since:
- 2.11.1
-
getParentOrNull
@Nullable default @Nullable Node getParentOrNull(@NotNull @NotNull Item item) throws RepositoryException Returns the parent of the givenItemornullif no parent exists (either because the givenItemrepresents the root node or the current session does not have sufficient access to retrieve the parent).- Parameters:
item- AnItemthat has been obtained by the current session.- Returns:
- The parent node of the given
Itemornull. - Throws:
RepositoryException- If another error occurs.- Since:
- 1.42
- See Also:
-
getExpandedName
Returns the expanded name of the givenItem.- Parameters:
item- the item for which to retrieve the name- Returns:
- the name of the item in expanded form.
- Throws:
NamespaceException- when no expanded name can be determined (for instance, if the registered namespace (name) is invalid)RepositoryException- if another error occurs- Since:
- 1.78.0
- See Also:
-
getExpandedPath
Returns the expanded path of the givenItem.- Parameters:
item- the item for which to retrieve the name- Returns:
- the path of the item in expanded form.
- Throws:
NamespaceException- when no expanded name can be determined (for instance, if the registered namespace (name) is invalid)RepositoryException- if another error occurs.- Since:
- 1.78.0
- See Also:
-
getBoundPrincipals
Returns the set of principals associated with this session.- Returns:
- the set of principals associated with this session. Usually this set is unmodifiable.
- Throws:
RepositoryException- in case principal information cannot be retrieved.IllegalStateException- if user information is not available or if the user is a system user.- Since:
- 1.84
-