org.apache.jackrabbit.core
Class ItemValidator

java.lang.Object
  extended by org.apache.jackrabbit.core.ItemValidator
Direct Known Subclasses:
BatchedItemOperations

public class ItemValidator
extends Object

Utility class for validating an item against constraints specified by its definition.


Field Summary
protected  AccessManager accessMgr
           
static int CHECK_ACCESS
          check access permissions
static int CHECK_CONSTRAINTS
          option to check if the item is protected by it's nt definition
static int CHECK_HOLD
          option to check for effective holds
static int CHECK_LOCK
          option to check lock status
static int CHECK_PENDING_CHANGES
          option to check for pending changes on the session
static int CHECK_PENDING_CHANGES_ON_NODE
          option to check for pending changes on the specified node
static int CHECK_REFERENCES
          check for referential integrity upon removal
static int CHECK_RETENTION
          option to check for effective retention policies
static int CHECK_VERSIONING
          option to check checked-out status
protected  HierarchyManager hierMgr
          hierarchy manager used for generating error msg's that contain human readable paths
protected  LockManager lockMgr
           
protected  NodeTypeRegistry ntReg
          node type registry
protected  PathResolver resolver
          Path resolver for outputting user-friendly error messages.
protected  RetentionRegistry retentionReg
           
 
Constructor Summary
ItemValidator(NodeTypeRegistry ntReg, HierarchyManager hierMgr, PathResolver resolver, LockManager lockMgr, AccessManager accessMgr, RetentionRegistry retentionReg)
          Creates a new ItemValidator instance.
ItemValidator(NodeTypeRegistry ntReg, HierarchyManager hierMgr, SessionImpl session)
          Creates a new ItemValidator instance.
 
Method Summary
 boolean canModify(ItemImpl item, int options, int permissions)
           
 void checkModify(ItemImpl item, int options, int permissions)
           
 void checkRemove(ItemImpl item, int options, int permissions)
           
 NodeDef findApplicableNodeDefinition(Name name, Name nodeTypeName, NodeState parentState)
          Helper method that finds the applicable definition for a child node with the given name and node type in the parent node's node type and mixin types.
 PropDef findApplicablePropertyDefinition(Name name, int type, boolean multiValued, NodeState parentState)
          Helper method that finds the applicable definition for a property with the given name, type and multiValued characteristic in the parent node's node type and mixin types.
 PropDef findApplicablePropertyDefinition(Name name, int type, NodeState parentState)
          Helper method that finds the applicable definition for a property with the given name, type in the parent node's node type and mixin types.
 EffectiveNodeType getEffectiveNodeType(NodeState state)
          Helper method that builds the effective (i.e. merged and resolved) node type representation of the specified node's primary and mixin node types.
 String safeGetJCRPath(ItemId id)
          Failsafe translation of internal ItemId to JCR path for use in error messages etc.
 String safeGetJCRPath(Path path)
          Failsafe conversion of internal Path to JCR path for use in error messages etc.
 void validate(NodeState nodeState)
          Checks whether the given node state satisfies the constraints specified by its primary and mixin node types.
 void validate(PropertyState propState)
          Checks whether the given property state satisfies the constraints specified by its definition.
 
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
check access permissions

See Also:
Constant Field Values

CHECK_LOCK

public static final int CHECK_LOCK
option to check lock status

See Also:
Constant Field Values

CHECK_VERSIONING

public static final int CHECK_VERSIONING
option to check checked-out status

See Also:
Constant Field Values

CHECK_REFERENCES

public static final int CHECK_REFERENCES
check for referential integrity upon removal

See Also:
Constant Field Values

CHECK_CONSTRAINTS

public static final int CHECK_CONSTRAINTS
option to check if the item is protected by it's nt definition

See Also:
Constant Field Values

CHECK_PENDING_CHANGES

public static final int CHECK_PENDING_CHANGES
option to check for pending changes on the session

See Also:
Constant Field Values

CHECK_PENDING_CHANGES_ON_NODE

public static final int CHECK_PENDING_CHANGES_ON_NODE
option to check for pending changes on the specified node

See Also:
Constant Field Values

CHECK_HOLD

public static final int CHECK_HOLD
option to check for effective holds

See Also:
Constant Field Values

CHECK_RETENTION

public static final int CHECK_RETENTION
option to check for effective retention policies

See Also:
Constant Field Values

ntReg

protected final NodeTypeRegistry ntReg
node type registry


hierMgr

protected final HierarchyManager hierMgr
hierarchy manager used for generating error msg's that contain human readable paths

See Also:
safeGetJCRPath(ItemId)

resolver

protected final PathResolver resolver
Path resolver for outputting user-friendly error messages.


lockMgr

protected final LockManager lockMgr

accessMgr

protected final AccessManager accessMgr

retentionReg

protected final RetentionRegistry retentionReg
Constructor Detail

ItemValidator

public ItemValidator(NodeTypeRegistry ntReg,
                     HierarchyManager hierMgr,
                     SessionImpl session)
              throws RepositoryException
Creates a new ItemValidator instance.

Parameters:
ntReg - node type registry
hierMgr - hierarchy manager
session - session
Throws:
RepositoryException

ItemValidator

public ItemValidator(NodeTypeRegistry ntReg,
                     HierarchyManager hierMgr,
                     PathResolver resolver,
                     LockManager lockMgr,
                     AccessManager accessMgr,
                     RetentionRegistry retentionReg)
Creates a new ItemValidator instance.

Parameters:
ntReg - node type registry
hierMgr - hierarchy manager
resolver - resolver
lockMgr - lockMgr
accessMgr - accessMgr
retentionReg -
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

validate

public void validate(PropertyState propState)
              throws ConstraintViolationException,
                     RepositoryException
Checks whether the given property state satisfies the constraints specified by its definition. The following validations/checks are performed:

Parameters:
propState - state of property to be validated
Throws:
ConstraintViolationException - if any of the validations fail
RepositoryException - if another error occurs

checkModify

public void checkModify(ItemImpl item,
                        int options,
                        int permissions)
                 throws RepositoryException
Throws:
RepositoryException

checkRemove

public void checkRemove(ItemImpl item,
                        int options,
                        int permissions)
                 throws RepositoryException
Throws:
RepositoryException

canModify

public boolean canModify(ItemImpl item,
                         int options,
                         int permissions)
                  throws RepositoryException
Throws:
RepositoryException

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType(NodeState state)
                                       throws RepositoryException
Helper method that builds the effective (i.e. merged and resolved) node type representation of the specified node's primary and mixin node types.

Parameters:
state -
Returns:
the effective node type
Throws:
RepositoryException

findApplicableNodeDefinition

public NodeDef findApplicableNodeDefinition(Name name,
                                            Name nodeTypeName,
                                            NodeState parentState)
                                     throws RepositoryException,
                                            ConstraintViolationException
Helper method that finds the applicable definition for a child node with the given name and node type in the parent node's node type and mixin types.

Parameters:
name -
nodeTypeName -
parentState -
Returns:
a NodeDef
Throws:
ConstraintViolationException - if no applicable child node definition could be found
RepositoryException - if another error occurs

findApplicablePropertyDefinition

public PropDef findApplicablePropertyDefinition(Name name,
                                                int type,
                                                boolean multiValued,
                                                NodeState parentState)
                                         throws RepositoryException,
                                                ConstraintViolationException
Helper method that finds the applicable definition for a property with the given name, type and multiValued characteristic in the parent node's node type and mixin types. If there more than one applicable definitions then the following rules are applied:

Parameters:
name -
type -
multiValued -
parentState -
Returns:
a PropDef
Throws:
ConstraintViolationException - if no applicable property definition could be found
RepositoryException - if another error occurs

findApplicablePropertyDefinition

public PropDef findApplicablePropertyDefinition(Name name,
                                                int type,
                                                NodeState parentState)
                                         throws RepositoryException,
                                                ConstraintViolationException
Helper method that finds the applicable definition for a property with the given name, type in the parent node's node type and mixin types. Other than findApplicablePropertyDefinition(Name, int, boolean, NodeState) this method does not take the multiValued flag into account in the selection algorithm. If there more than one applicable definitions then the following rules are applied:

Parameters:
name -
type -
parentState -
Returns:
a PropDef
Throws:
ConstraintViolationException - if no applicable property definition could be found
RepositoryException - if another error occurs

safeGetJCRPath

public String safeGetJCRPath(Path path)
Failsafe conversion of internal Path to JCR path for use in error messages etc.

Parameters:
path - path to convert
Returns:
JCR path

safeGetJCRPath

public String safeGetJCRPath(ItemId id)
Failsafe translation of internal ItemId to JCR path for use in error messages etc.

Parameters:
id - id to translate
Returns:
JCR path


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