org.apache.jackrabbit.jcr2spi.state
Class ItemStateValidator

java.lang.Object
  extended by 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
static int CHECK_ACCESS
          option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check access rights

static int CHECK_ALL
           
static int CHECK_COLLISION
          option for checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) method:

check that target node is not being referenced

static int CHECK_CONSTRAINTS
          option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check constraints defined in node type

static int CHECK_LOCK
          option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check lock status

static int CHECK_NONE
           
static int CHECK_VERSIONING
          option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check checked-out status

 
Constructor Summary
ItemStateValidator(ManagerProvider mgrProvider, PathFactory pathFactory)
          Creates a new ItemStateValidator instance.
 
Method Summary
 void checkAddNode(NodeState parentState, Name nodeName, Name nodeTypeName, int options)
          Checks if adding a child node called nodeName of node type nodeTypeName 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_ACCESS

public static final int CHECK_ACCESS
option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check access rights

See Also:
Constant Field Values

CHECK_LOCK

public static final int CHECK_LOCK
option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check lock status

See Also:
Constant Field Values

CHECK_VERSIONING

public static final int CHECK_VERSIONING
option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check checked-out status

See Also:
Constant Field Values

CHECK_CONSTRAINTS

public static final int CHECK_CONSTRAINTS
option for checkAddNode(org.apache.jackrabbit.jcr2spi.state.NodeState, org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.spi.Name, int) and checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) methods:

check constraints defined in node type

See Also:
Constant Field Values

CHECK_COLLISION

public static final int CHECK_COLLISION
option for checkRemoveItem(org.apache.jackrabbit.jcr2spi.state.ItemState, int) method:

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 new ItemStateValidator 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:

Parameters:
nodeState - state of node to be validated
Throws:
ConstraintViolationException - if any of the validations fail
RepositoryException - 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:
  • CHECK_ACCESS: make sure current session is granted read access on parent node and can add a child node with the given name.
  • CHECK_LOCK: make sure there's no foreign lock on parent node
  • CHECK_VERSIONING: make sure parent node is checked-out
  • CHECK_CONSTRAINTS: make sure no node type constraints would be violated
  • CHECK_COLLISION: check for collision with existing properties or nodes
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:
  • CHECK_ACCESS: make sure current session is granted read access on parent node and can add a child node with the given name.
  • CHECK_LOCK: make sure there's no foreign lock on parent node
  • CHECK_VERSIONING: make sure parent node is checked-out
  • CHECK_CONSTRAINTS: make sure no node type constraints would be violated
  • CHECK_COLLISION: check for collision with existing properties or nodes
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 called nodeName of node type nodeTypeName 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:
  • CHECK_ACCESS: make sure current session is granted read access on parent node and can add a child node with the given name.
  • CHECK_LOCK: make sure there's no foreign lock on parent node
  • CHECK_VERSIONING: make sure parent node is checked-out
  • CHECK_CONSTRAINTS: make sure no node type constraints would be violated
  • CHECK_COLLISION: check for collision with existing properties or nodes
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:
  • CHECK_ACCESS: make sure current session is granted read access on parent and remove privilege on target node
  • CHECK_LOCK: make sure there's no foreign lock on parent node
  • CHECK_VERSIONING: make sure parent node is checked-out
  • CHECK_CONSTRAINTS: make sure no node type constraints would be violated
Throws:
ConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ReferentialIntegrityException
RepositoryException


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