Search in sources :

Example 1 with ValidatorException

use of org.apache.commons.validator.ValidatorException in project sonarqube by SonarSource.

the class ValidatorForm method validate.

/**
     * Validate the properties that have been set from this HTTP request, and
     * return an <code>ActionErrors</code> object that encapsulates any
     * validation errors that have been found.  If no errors are found, return
     * <code>null</code> or an <code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     * @return <code>ActionErrors</code> object that encapsulates any
     *         validation errors
     */
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ServletContext application = getServlet().getServletContext();
    ActionErrors errors = new ActionErrors();
    String validationKey = getValidationKey(mapping, request);
    Validator validator = Resources.initValidator(validationKey, this, application, request, errors, page);
    try {
        validatorResults = validator.validate();
    } catch (ValidatorException e) {
        log.error(e.getMessage(), e);
    }
    return errors;
}
Also used : ValidatorException(org.apache.commons.validator.ValidatorException) ServletContext(javax.servlet.ServletContext) ActionErrors(org.apache.struts.action.ActionErrors) Validator(org.apache.commons.validator.Validator)

Example 2 with ValidatorException

use of org.apache.commons.validator.ValidatorException in project sonarqube by SonarSource.

the class DynaValidatorForm method validate.

/**
     * Validate the properties that have been set from this HTTP request, and
     * return an <code>ActionErrors</code> object that encapsulates any
     * validation errors that have been found.  If no errors are found, return
     * <code>null</code> or an <code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * @param mapping The mapping used to select this instance.
     * @param request The servlet request we are processing.
     * @return <code>ActionErrors</code> object that encapsulates any
     *         validation errors.
     */
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    this.setPageFromDynaProperty();
    ServletContext application = getServlet().getServletContext();
    ActionErrors errors = new ActionErrors();
    String validationKey = getValidationKey(mapping, request);
    Validator validator = Resources.initValidator(validationKey, this, application, request, errors, page);
    try {
        validatorResults = validator.validate();
    } catch (ValidatorException e) {
        log.error(e.getMessage(), e);
    }
    return errors;
}
Also used : ValidatorException(org.apache.commons.validator.ValidatorException) ServletContext(javax.servlet.ServletContext) ActionErrors(org.apache.struts.action.ActionErrors) Validator(org.apache.commons.validator.Validator)

Aggregations

ServletContext (javax.servlet.ServletContext)2 Validator (org.apache.commons.validator.Validator)2 ValidatorException (org.apache.commons.validator.ValidatorException)2 ActionErrors (org.apache.struts.action.ActionErrors)2