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
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 Summary
-
Constructor Summary
ConstructorDescriptionBasicNodeValidator
(Validator ruleMissing, Validator ruleDenied) Creates a new validator. -
Method Summary
Modifier and TypeMethodDescriptionprotected Fix
getDeniedItemFix
(DbControl dc, Node node, Node parentNode) Subclasses should override this method if they have a suggessted fix for an access denied problem.protected abstract Fix
getMissingItemFix
(DbControl dc, 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 theruleDenied
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 theruleMissing
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.
-
Field Details
-
ruleMissing
-
ruleDenied
-
-
Constructor Details
-
BasicNodeValidator
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 failureruleDenied
- 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
Submits theruleMissing
validator to the context as a failure unless it is null.- Specified by:
preMissingItem
in interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextparentNode
- The parent node that is missing the item- Returns:
- Always false
-
preDeniedItem
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 interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextparentNode
- The parent node that is linked with the item- Returns:
- Always true
-
preValidate
Subclasses should override this method if the need more validation for an existing and accessible item.- Specified by:
preValidate
in interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextitem
- The item to validateparentNode
- The parent node that is linked with the item- Returns:
- Always true
-
postMissingItem
Do nothing.- Specified by:
postMissingItem
in interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextnode
- The node object that represents the missing itemparentNode
- The parent node that is missing the item
-
postDeniedItem
Submits theruleDenied
validator to the context as a failure unless it is null.- Specified by:
postDeniedItem
in interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextnode
- The node object that represents the unaccessible itemparentNode
- The parent node that is linked with the item
-
postValidate
Do nothing. Subclasses should override this method if they need more validation for an existing and accessible item.- Specified by:
postValidate
in interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextnode
- The node object that represents itemparentNode
- 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 interfaceNodeValidator<I>
- Parameters:
dc
- A DbControl to use for database accesscontext
- The current overview contextfolderNode
- The folder node, or null if no folder has been createdparentNode
- The parent node (never null)
-
getMissingItemFix
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
Subclasses should override this method if they have a suggessted fix for an access denied problem. The default implementation does nothing.
-