Examples of ValidatorException


Examples of javax.faces.validator.ValidatorException

            suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
        FacesMessage facesMsg = null;
        // value must be a String
        if (!(value instanceof String)) {
            Object[] args = { value };
            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_NOT_STRING_MESSAGE_ID, args));
        }
        Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
        if (getSeparator() == null)
            setSeparator(DEFAULT_SEPARATOR);
        String[] values = null;
        try {
            values = ((String)value).split(getSeparator());
        }
        catch (PatternSyntaxException e) {
            Object[] args = { getSeparator() };
            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_INVALID_SEPARATOR_MESSAGE_ID, args));
        }
       
        // loop through the separated values and validate each one
        for (int i = 0; i < values.length; i++) {
            if (values[i].trim().length() == 0) {
                continue;
            }
            else try {
                validator.validate(facesContext, uiComponent, values[i]);
            }
            catch (ValidatorException e) {
                facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
            }
        }
        if (facesMsg != null)
            throw new ValidatorException(facesMsg);
    }
View Full Code Here

Examples of javax.faces.validator.ValidatorException

                return;
            }
        initValidator();
        if (!this.creditCardValidator.isValid(value.toString())){
            Object[] args = {value.toString()};
            throw new ValidatorException(getFacesMessage(CREDITCARD_MESSAGE_ID, args));
        }
    }
View Full Code Here

Examples of javax.faces.validator.ValidatorException

            {
                return;
            }
            if (!GenericValidator.isEmail(value.toString().trim())) {
                Object[] args = {value.toString()};
                throw new ValidatorException(getFacesMessage(EMAIL_MESSAGE_ID, args));
            }

    }
View Full Code Here

Examples of javax.faces.validator.ValidatorException

           
            org.apache.commons.validator.UrlValidator urlValidator = initValidator();
           
            if (!urlValidator.isValid(value.toString())) {
                Object[] args = {value.toString()};
                throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
            }

    }
View Full Code Here

Examples of javax.faces.validator.ValidatorException

        {
            if (convertedObject == null
                    || !java.util.regex.Pattern.compile(expression).matcher(
                            convertedObject.toString()).matches())
            {
                throw new ValidatorException(new FacesMessage(
                        FacesMessage.SEVERITY_ERROR,
                        getErrorMessageSummary(annotation),
                        getErrorMessageDetail(annotation).replace("{0}", expression)));
            }
        }
View Full Code Here

Examples of javax.portlet.ValidatorException

        if (this.scriptSourceUri == null)
        {
            Collection failedKeys = new ArrayList();
            failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
            throw new ValidatorException("Configuration failed: " + SCRIPT_SOURCE_PREF_KEY + " should be set properly!", failedKeys);
        }
        else
        {
            try
            {
                if (this.scriptSourceUri.startsWith("file:"))
                {
                    String decodedScriptSourceUri = this.scriptSourceUri;

                    try
                    {
                        decodedScriptSourceUri = URLDecoder.decode(this.scriptSourceUri, this.scriptSourceUriEncoding);
                    }
                    catch (UnsupportedEncodingException encodingEx)
                    {
                        Collection failedKeys = new ArrayList();
                        failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
                        throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
                    }

                    this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
                }
                else if (this.scriptSourceUri.startsWith("classpath:"))
                {
                    String resourceURL = this.groovyClassLoader.getResource(this.scriptSourceUri.substring(10))
                            .toString();

                    if (resourceURL.startsWith("file:"))
                    {
                        String decodedScriptSourceUri = resourceURL;

                        try
                        {
                            decodedScriptSourceUri = URLDecoder.decode(resourceURL, this.scriptSourceUriEncoding);
                        }
                        catch (UnsupportedEncodingException encodingEx)
                        {
                            Collection failedKeys = new ArrayList();
                            failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
                            throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
                        }

                        this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
                    }
                    else
                    {
                        Collection failedKeys = new ArrayList();
                        failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
                        throw new ValidatorException(SCRIPT_SOURCE_PREF_KEY
                                + " with 'classpath:' prefix should indicate to a local resource", failedKeys);
                    }
                }
                else
                {
                    Collection failedKeys = new ArrayList();
                    failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
                    throw new ValidatorException("Configuration failed: " + SCRIPT_SOURCE_PREF_KEY + " should be prefixed by 'file:' or 'classpath'.", failedKeys);
                }
            }
            catch (FileNotFoundException e)
            {
                Collection failedKeys = new ArrayList();
                failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
                throw new ValidatorException("File not found: " + this.scriptSourceUri, failedKeys);
            }

            this.groovyCodeSource.setCachable(!this.autoRefresh);
        }
    }
View Full Code Here

Examples of javax.portlet.ValidatorException

            }
            catch (Exception ex)
            {
                Collection failedKeys = new ArrayList();
                failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
                throw new ValidatorException("Could not compile script: " + this.scriptSourceUri, failedKeys);
            }
        }
        else if (this.autoRefresh && isScriptFileModified())
        {
            synchronized (this.scriptPreferencesValidatorInstance)
            {
                try
                {
                    createScriptPreferencesValidatorInstance();
                }
                catch (Exception ex)
                {
                    Collection failedKeys = new ArrayList();
                    failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
                    throw new ValidatorException("Could not compile script: " + this.scriptSourceUri, failedKeys);
                }
            }
        }
    }
View Full Code Here

Examples of javax.portlet.ValidatorException

                }
            }
        }
       
        if (!failedNames.isEmpty()) {
            throw new ValidatorException(
                "One or more preferences do not pass the validation.",
                failedNames);
        }
    }
View Full Code Here

Examples of javax.portlet.ValidatorException

      if (LOG.isDebugEnabled()) {
        LOG.debug("Method validate() invoked " + validateInvoked + " times.");
        LOG.debug("Validator created " + instanceCreated.intValue() + " times.");
      }
      if (instanceCreated.intValue() != 1) {
        throw new ValidatorException(instanceCreated.toString()
            + " validator instances were created, "
            + "expected 1 validator instance per portlet definition.",
            null);
      }
    }
View Full Code Here

Examples of javax.portlet.ValidatorException

        Class clazz = loader.loadClass(className);
          validator = (PreferencesValidator) clazz.newInstance();
          cache.put(portletDD, validator);
      } catch (InstantiationException ex) {
        LOG.error("Error instantiating validator.", ex);
          throw new ValidatorException(ex, null);
      } catch (IllegalAccessException ex) {
        LOG.error("Error instantiating validator.", ex);
          throw new ValidatorException(ex, null);
      } catch (ClassNotFoundException ex) {
        LOG.error("Error instantiating validator.", ex);
          throw new ValidatorException(ex, null);
      } catch (ClassCastException ex) {
        LOG.error("Error casting instance to PreferencesValidator.", ex);
        throw new ValidatorException(ex, null);
      }
    }
    return validator;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.