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 int
CHECK_ACCESS
static int
CHECK_ALL
static int
CHECK_COLLISION
option for
method:checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int)
static int
CHECK_CONSTRAINTS
static int
CHECK_LOCK
static int
CHECK_NONE
static int
CHECK_VERSIONING
-
Constructor Summary
Constructors Constructor Description ItemStateValidator(ManagerProvider mgrProvider, PathFactory pathFactory)
Creates a newItemStateValidator
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkAddNode(NodeState parentState, Name nodeName, Name nodeTypeName, int options)
Checks if adding a child node callednodeName
of node typenodeTypeName
to the given parent node is allowed in the current context.void
checkAddProperty(NodeState parentState, Name propertyName, QPropertyDefinition definition, int options)
void
checkIsWritable(NodeState parentState, int options)
void
checkRemoveItem(ItemState targetState, int options)
Checks if removing the given target state is allowed in the current context.void
checkSetProperty(PropertyState propState, int options)
void
validate(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 for
andcheckAddNode(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 for
andcheckAddNode(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 for
andcheckAddNode(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 for
andcheckAddNode(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 for
method: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 newItemStateValidator
instance.- 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:
VersionException
LockException
ItemNotFoundException
ItemExistsException
PathNotFoundException
RepositoryException
-
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:
ConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ItemExistsException
PathNotFoundException
RepositoryException
-
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:
ConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ItemExistsException
PathNotFoundException
RepositoryException
-
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 callednodeName
of node typenodeTypeName
to 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:
ConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ItemExistsException
RepositoryException
-
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:
ConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ReferentialIntegrityException
RepositoryException
-
-