2.17.2: 2011-06-17

net.sf.basedb.util.overview.validator
Class BasicNodeValidator<I>

java.lang.Object
  extended by net.sf.basedb.util.overview.validator.BasicNodeValidator<I>
All Implemented Interfaces:
NodeValidator<I>
Direct Known Subclasses:
AnnotationValidator, AnyToAnyValidator, DataFileValidator, NameableNodeValidator

public abstract class BasicNodeValidator<I>
extends Object
implements NodeValidator<I>

A simple node validation implementation that takes care of missing and denied access to items. This implementation will create child nodes for items that we are denied access to but not to missing items. Missing items are reported as failures to the parent node. Denied access are reported as failures to the node representing the item.

Version:
2.10
Author:
Nicklas
This class/package is not part of the Public API
This class is still being developed. It may change without notice in future versions of BASE.
Last modified
$Date: 2009-02-18 14:26:21 +0100 (Wed, 18 Feb 2009) $

Field Summary
private  Validator ruleDenied
           
private  Validator ruleMissing
           
 
Constructor Summary
BasicNodeValidator(Validator ruleMissing, Validator ruleDenied)
          Creates a new validator.
 
Method Summary
protected  Fix getDeniedItemFix(Node node, Node parentNode)
          Subclasses should override this method if they have a suggessted fix for an access denied problem.
protected abstract  Fix getMissingItemFix(Node parentNode)
          Subclasses should override this method if they have a suggessted fix for a missing item problem.
 void postDeniedItem(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Submits the ruleDenied validator to the context as a failure unless it is null.
 void postMissingItem(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Do nothing.
 void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Do nothing.
 void postValidateFolder(DbControl dc, OverviewContext context, Node folderNode, Node parentNode)
          Do nothing.
 boolean preDeniedItem(DbControl dc, OverviewContext context, Node parentNode)
          Validate an item that the current user doen't have access to before creating a node for it.
 boolean preMissingItem(DbControl dc, OverviewContext context, Node parentNode)
          Submits the ruleMissing validator to the context as a failure unless it is null.
 boolean preValidate(DbControl dc, OverviewContext context, I item, Node parentNode)
          Subclasses should override this method if the need more validation for an existing and accessible item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ruleMissing

private Validator ruleMissing

ruleDenied

private Validator ruleDenied
Constructor Detail

BasicNodeValidator

public BasicNodeValidator(Validator ruleMissing,
                          Validator ruleDenied)
Creates a new validator.

Parameters:
ruleMissing - The validation rule that is broken if an item is missing, or null to not report missing items as a failure
ruleDenied - The validation rule that is broken if we are denied access to an item, or null to not report this as a failure
Method Detail

preMissingItem

public boolean preMissingItem(DbControl dc,
                              OverviewContext context,
                              Node parentNode)
Submits the ruleMissing validator to the context as a failure unless it is null.

Specified by:
preMissingItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
parentNode - The parent node that is missing the item
Returns:
Always false

preDeniedItem

public boolean preDeniedItem(DbControl dc,
                             OverviewContext context,
                             Node parentNode)
Description copied from interface: NodeValidator
Validate an item that the current user doen't have access to before creating a node for it.

Specified by:
preDeniedItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
parentNode - The parent node that is linked with the item
Returns:
Always true

preValidate

public boolean preValidate(DbControl dc,
                           OverviewContext context,
                           I item,
                           Node parentNode)
Subclasses should override this method if the need more validation for an existing and accessible item.

Specified by:
preValidate in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
item - The item to validate
parentNode - The parent node that is linked with the item
Returns:
Always true

postMissingItem

public void postMissingItem(DbControl dc,
                            OverviewContext context,
                            Node node,
                            Node parentNode)
Do nothing.

Specified by:
postMissingItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents the missing item
parentNode - The parent node that is missing the item

postDeniedItem

public void postDeniedItem(DbControl dc,
                           OverviewContext context,
                           Node node,
                           Node parentNode)
Submits the ruleDenied validator to the context as a failure unless it is null.

Specified by:
postDeniedItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents the unaccessible item
parentNode - The parent node that is linked with the item

postValidate

public void postValidate(DbControl dc,
                         OverviewContext context,
                         Node node,
                         Node parentNode)
Do nothing. Subclasses should override this method if they need more validation for an existing and accessible item.

Specified by:
postValidate in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents item
parentNode - The parent node that is linked with the item

postValidateFolder

public void postValidateFolder(DbControl dc,
                               OverviewContext context,
                               Node folderNode,
                               Node parentNode)
Do nothing. Subclasses should override this method if they need to validate all items inside a folder-type node.

Specified by:
postValidateFolder in interface NodeValidator<I>
Parameters:
dc - A DbControl to use for database access
context - The current overview context
folderNode - The folder node, or null if no folder has been created
parentNode - The parent node (never null)

getMissingItemFix

protected abstract Fix getMissingItemFix(Node parentNode)
Subclasses should override this method if they have a suggessted fix for a missing item problem. The default implementation does nothing, but the following template may be usable by most subclasses:
                new Fix("Add item to parent", parentNode.getItem())
                


getDeniedItemFix

protected Fix getDeniedItemFix(Node node,
                               Node parentNode)
Subclasses should override this method if they have a suggessted fix for an access denied problem. The default implementation does nothing.


2.17.2: 2011-06-17