Class ItemStateValidator
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.state.ItemStateValidator
-
public class ItemStateValidator extends Object
Utility class for validating an item state against constraints specified by its definition.
-
-
Field Summary
Fields Modifier and Type Field Description static intCHECK_ACCESSstatic intCHECK_ALLstatic intCHECK_COLLISIONoption formethod:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)static intCHECK_CONSTRAINTSstatic intCHECK_LOCKstatic intCHECK_NONEstatic intCHECK_VERSIONING
-
Constructor Summary
Constructors Constructor Description ItemStateValidator(ManagerProvider mgrProvider, PathFactory pathFactory)Creates a newItemStateValidatorinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckAddNode(NodeState parentState, Name nodeName, Name nodeTypeName, int options)Checks if adding a child node callednodeNameof node typenodeTypeNameto the given parent node is allowed in the current context.voidcheckAddProperty(NodeState parentState, Name propertyName, QPropertyDefinition definition, int options)voidcheckIsWritable(NodeState parentState, int options)voidcheckRemoveItem(ItemState targetState, int options)Checks if removing the given target state is allowed in the current context.voidcheckSetProperty(PropertyState propState, int options)voidvalidate(NodeState nodeState)Checks whether the given node state satisfies the constraints specified by its primary and mixin node types.
-
-
-
Field Detail
-
CHECK_ACCESS
public static final int CHECK_ACCESS
option forandcheckAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int)methods:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)check access rights
- See Also:
- Constant Field Values
-
CHECK_LOCK
public static final int CHECK_LOCK
option forandcheckAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int)methods:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)check lock status
- See Also:
- Constant Field Values
-
CHECK_VERSIONING
public static final int CHECK_VERSIONING
option forandcheckAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int)methods:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)check checked-out status
- See Also:
- Constant Field Values
-
CHECK_CONSTRAINTS
public static final int CHECK_CONSTRAINTS
option forandcheckAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int)methods:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)check constraints defined in node type
- See Also:
- Constant Field Values
-
CHECK_COLLISION
public static final int CHECK_COLLISION
option formethod:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)check that target node is not being referenced
- See Also:
- Constant Field Values
-
CHECK_NONE
public static final int CHECK_NONE
- See Also:
- Constant Field Values
-
CHECK_ALL
public static final int CHECK_ALL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ItemStateValidator
public ItemStateValidator(ManagerProvider mgrProvider, PathFactory pathFactory)
Creates a newItemStateValidatorinstance.- Parameters:
mgrProvider- manager provider
-
-
Method Detail
-
validate
public void validate(NodeState nodeState) throws ConstraintViolationException, RepositoryException
Checks whether the given node state satisfies the constraints specified by its primary and mixin node types. The following validations/checks are performed:- check if its node type satisfies the 'required node types' constraint specified in its definition
- check if all 'mandatory' child items exist
- for every property: check if the property value satisfies the value constraints specified in the property's definition
- Parameters:
nodeState- state of node to be validated- Throws:
ConstraintViolationException- if any of the validations failRepositoryException- if another error occurs
-
checkIsWritable
public void checkIsWritable(NodeState parentState, int options) throws VersionException, LockException, ItemNotFoundException, ItemExistsException, PathNotFoundException, RepositoryException
- Parameters:
parentState-options-- Throws:
VersionExceptionLockExceptionItemNotFoundExceptionItemExistsExceptionPathNotFoundExceptionRepositoryException
-
checkSetProperty
public void checkSetProperty(PropertyState propState, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ItemExistsException, PathNotFoundException, RepositoryException
- Parameters:
propState-options- bit-wise OR'ed flags specifying the checks that should be performed; any combination of the following constants:: make sure current session is granted read access on parent node and can add a child node with the given name.CHECK_ACCESS: make sure there's no foreign lock on parent nodeCHECK_LOCK: make sure parent node is checked-outCHECK_VERSIONING: make sure no node type constraints would be violatedCHECK_CONSTRAINTS: check for collision with existing properties or nodesCHECK_COLLISION
- Throws:
ConstraintViolationExceptionAccessDeniedExceptionVersionExceptionLockExceptionItemNotFoundExceptionItemExistsExceptionPathNotFoundExceptionRepositoryException
-
checkAddProperty
public void checkAddProperty(NodeState parentState, Name propertyName, QPropertyDefinition definition, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ItemExistsException, PathNotFoundException, RepositoryException
- Parameters:
parentState-propertyName-options- bit-wise OR'ed flags specifying the checks that should be performed; any combination of the following constants:: make sure current session is granted read access on parent node and can add a child node with the given name.CHECK_ACCESS: make sure there's no foreign lock on parent nodeCHECK_LOCK: make sure parent node is checked-outCHECK_VERSIONING: make sure no node type constraints would be violatedCHECK_CONSTRAINTS: check for collision with existing properties or nodesCHECK_COLLISION
- Throws:
ConstraintViolationExceptionAccessDeniedExceptionVersionExceptionLockExceptionItemNotFoundExceptionItemExistsExceptionPathNotFoundExceptionRepositoryException
-
checkAddNode
public void checkAddNode(NodeState parentState, Name nodeName, Name nodeTypeName, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ItemExistsException, RepositoryException
Checks if adding a child node callednodeNameof node typenodeTypeNameto the given parent node is allowed in the current context.- Parameters:
parentState-nodeName-nodeTypeName-options- bit-wise OR'ed flags specifying the checks that should be performed; any combination of the following constants:: make sure current session is granted read access on parent node and can add a child node with the given name.CHECK_ACCESS: make sure there's no foreign lock on parent nodeCHECK_LOCK: make sure parent node is checked-outCHECK_VERSIONING: make sure no node type constraints would be violatedCHECK_CONSTRAINTS: check for collision with existing properties or nodesCHECK_COLLISION
- Throws:
ConstraintViolationExceptionAccessDeniedExceptionVersionExceptionLockExceptionItemNotFoundExceptionItemExistsExceptionRepositoryException
-
checkRemoveItem
public void checkRemoveItem(ItemState targetState, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ReferentialIntegrityException, RepositoryException
Checks if removing the given target state is allowed in the current context.- Parameters:
targetState-options- bit-wise OR'ed flags specifying the checks that should be performed; any combination of the following constants:: make sure current session is granted read access on parent and remove privilege on target nodeCHECK_ACCESS: make sure there's no foreign lock on parent nodeCHECK_LOCK: make sure parent node is checked-outCHECK_VERSIONING: make sure no node type constraints would be violatedCHECK_CONSTRAINTS
- Throws:
ConstraintViolationExceptionAccessDeniedExceptionVersionExceptionLockExceptionItemNotFoundExceptionReferentialIntegrityExceptionRepositoryException
-
-