Class BasicNodeValidator<I>

java.lang.Object
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
Last modified
$Date: 2011-10-21 13:15:41 +0200 (fr, 21 okt 2011) $
  • Field Details

  • Constructor Details

    • 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 Details

    • 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(DbControl dc, 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(DbControl dc, 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.