Model Validation API
API to handle Model validation in XWiki |
Type | JAR |
Category | API |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Compatibility | Since XWiki 12.0RC1 |
Table of contents
Description
Provides APIs to allow performing checks and transformations on page.
- The primary intents of this module is to allow admin to have more capabilities to handle the type of pages names that are allowed in their wiki.
- This module also provides APIs to check if a page can be edited
Naming check and transformation
Existing Strategies
See the Existing validation strategies.
Create a Name Strategy Component
A new strategy component can be created by implementing the EntityNameValidation Java class.
A strategy is defined by transformation and validation methods, for both Strings and for EntityReferences.
Note that you can extend AbstractEntityNameValidation to only define the transformation and validation methods for Strings and reuse them for the EntityReferences, it's an easier way to define a strategy.
XWiki 15.9+
Pre-edit check
Edit Confirmation Checker
The EditConfirmationChecker role allow to define a pre-edit check.
* Provides the operation that a pre-edit checker must provide. The checks are called by the
* {@link EditConfirmationScriptService} and aggregated in a {@link EditConfirmationCheckerResults}. The components
* implementing this role are called in the order of their priorities. It is advised to define a priority to make the
* order of the resulting messages deterministic.
*
* @version $Id: 0c4f93899ab9a6406a88762e9f7b77277b93cb31 $
* @since 15.9RC1
*/
@Role
@Unstable
public interface EditConfirmationChecker
{
/**
* Checks if edit confirmation is required, or allowed, based on the provided boolean value.
*
* @return an {@link Optional} containing a {@link EditConfirmationCheckerResult} if the check identified a result
* to be displayed to the user, or {@link Optional#empty()} if no result was found
*/
Optional<EditConfirmationCheckerResult> check();
}
Script Service
The EditConfirmationScriptService check for the presence of warning or errors messages to be presented to the user when they click on edit on a page.
* This class provides the script services for handling document edit confirmation.
*
* @version $Id: 7e3a5ab3856372b9323d66b1a5e1cf455cee0885 $
* @since 15.9RC1
*/
@Component
@Singleton
@Named("modelvalidation.edit")
@Unstable
public class EditConfirmationScriptService implements ScriptService
{
/**
* Performs a check by invoking the check method of all available {@link EditConfirmationChecker} components and
* aggregating their results.
*
* @return a {@link EditConfirmationCheckerResults} object containing the results of the check
*/
public EditConfirmationCheckerResults check()
{
// ...
}
/**
* Force the last {@link EditConfirmationChecker} components checks. The results of the last call to
* {@link #check()} are persisted, and new checks are skipped as long as they match the persisted results.
*
* @since 15.10RC1
*/
@Unstable
public void force()
{
// ....
}
}
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Dependencies
Dependencies for this extension (org.xwiki.platform:xwiki-platform-model-validation-api 16.10.2):
- org.xwiki.platform:xwiki-platform-model-api 16.10.2
- org.xwiki.rendering:xwiki-rendering-api 16.10.2
- org.xwiki.platform:xwiki-platform-security-authorization-api 16.10.2