Class FileValidator
java.lang.Object
net.sf.basedb.util.overview.validator.BasicNodeValidator<I>
net.sf.basedb.util.overview.validator.NameableNodeValidator<File>
net.sf.basedb.util.overview.validator.FileValidator
- All Implemented Interfaces:
NodeValidator<File>
Validator implementation for files. Validation rules:
- Missing item:
Validator.MISSING_FILE
- Access denied:
Validator.DENIED_FILE
- Incorrect file type:
Validator.INCORRECT_FILETYPE
- Since:
- 3.17
- Author:
- Nicklas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ItemSubtype
getExpectedFileSubtype
(DbControl dc, BasicItem parentItem) Get the subtype of the associated file that we expect for the given parent item.protected Fix
getMissingItemFix
(DbControl dc, Node parentNode) Subclasses should override this method if they have a suggessted fix for a missing item problem.void
postValidate
(DbControl dc, OverviewContext context, Node node, Node parentNode) Checks if the file is of the correct file type.boolean
preMissingItem
(DbControl dc, OverviewContext context, Node parentNode) If the parent item has a subtype that is related to a FILE subtype, report the missing item as aValidator.MISSING_FILE
failure.Methods inherited from class net.sf.basedb.util.overview.validator.BasicNodeValidator
getDeniedItemFix, postDeniedItem, postMissingItem, postValidateFolder, preDeniedItem, preValidate
-
Constructor Details
-
FileValidator
public FileValidator()
-
-
Method Details
-
preMissingItem
If the parent item has a subtype that is related to a FILE subtype, report the missing item as aValidator.MISSING_FILE
failure. Otherwise, ignore the missing file.- Specified by:
preMissingItem
in interfaceNodeValidator<File>
- Overrides:
preMissingItem
in classBasicNodeValidator<File>
- 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
-
postValidate
Checks if the file is of the correct file type.- Specified by:
postValidate
in interfaceNodeValidator<File>
- Overrides:
postValidate
in classNameableNodeValidator<File>
- 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
-
getMissingItemFix
Description copied from class:BasicNodeValidator
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())
- Specified by:
getMissingItemFix
in classBasicNodeValidator<File>
- Returns:
- Suggested fix is to add a file to the parent item
-
getExpectedFileSubtype
Get the subtype of the associated file that we expect for the given parent item.
-