Package javax.portlet

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


            }
            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

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

      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

        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

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

      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

                }
            }
        }

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

      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

        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

Related Classes of javax.portlet.ValidatorException

Copyright © 2018 www.massapicom. 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.