can be used to check for proper configuration and the existence of certain objects to ensure an application will run properly, such as:
- Required schema objects, such as tables and columns
- The existence of required fields in tables
- The configuration of expected permissions, such as checking whether guests have permission to read the "home" project.
A validator can either be site
level, or scoped to run at a specific container level, i.e. folder
scoped. Folder scoped validators can be enabled only in folders where they are needed.
To access and run site validators:
- Select (Admin) > Site > Admin Console.
- Under Diagnostics, click Site Validation.
Any validator should implement SiteValidationProvider, or more likely, the subclass SiteValidationProviderImpl. The methods getName() and getDescription() implement the name and description for the validator.
The boolean flag isSiteScope() controls whether the validator is site-scoped. The boolean flag shouldRun() controls whether the validator is applicable to a given container.
The method runValidation() returns a SiteValidationResultList of validation messages that will be displayed on the validation page in the admin console.
The messages can be set at different levels of severity: info, warn, or error. Errors will appear in red on the validation page. There are helper methods on SiteValidationResultList to aid in building the list. To build compound messages, SiteValidationResult behaves much like a StringBuilder, with an append() that returns itself.
- Implement SiteValidationProvider
- Implement runValidation():
- Instantiate a SiteValidationResultList
- For each of your validation steps, call SiteValidationResultList.addInfo(), addWarn() or addError()
- In your module's doStartup(), call SiteValidationService.registerProvider() to register your validator
An example validator that checks whether any Guest users have read or edit permissions: PermissionsValidator.java