Package de.odysseus.calyxo.base.conf

Examples of de.odysseus.calyxo.base.conf.ConfigException


   * Add forms element
   */
  public void add(FormsConfigImpl value) throws ConfigException {
    String key = getFormsKey(value);
    if (formsConfigs.containsKey(key)) {
      throw new ConfigException("Duplicate forms for key '" + key + "' in " + toInlineString());
    }
    formsConfigs.put(key, value);
  }
View Full Code Here


      s.append(relax);
      s.append("}");
      try {
        relaxExpression = evaluator.parseExpression(s.toString(), Boolean.class, this);
      } catch (Exception e) {
        throw new ConfigException("Parse error in '" + relax + "'", e);
      }
    }
    if (ignore != null) {
      StringBuffer s = new StringBuffer();
      s.append("${");
      s.append(ignore);
      s.append("}");
      try {
        ignoreExpression = evaluator.parseExpression(s.toString(), Boolean.class, this);
      } catch (Exception e) {
        throw new ConfigException("Parse error in '" + ignore + "'", e);
      }
    }
  }
View Full Code Here

  /**
   * Add field element
   */
  public void add(FieldConfigImpl value) throws ConfigException {
    if (fieldConfigs.containsKey(value.getProperty())) {
      throw new ConfigException("Duplicate field '" + value.getProperty() + "' in " + toInlineString());
    }
    fieldConfigs.put(value.getProperty(), value);
  }
View Full Code Here

   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.PropertyConfig#set(java.lang.Object)
   */
  public void set(Object object, ExpressionEvaluator evaluator) throws ConfigException {
    if (!defined) {
      throw new ConfigException("Cannot set undefined property " + toInlineString());
    }
    if (object instanceof Map) {
      ((Map)object).put(name, value);
    } else {
      try {
        if (value instanceof String) {
          Class type = PropertyUtils.getPropertyDescriptor(object.getClass(), name).getPropertyType();
          if (type == Expression.class) {
            String s = "${" + value + "}";
            Expression e = evaluator.parseExpression(s, Object.class, this);
            PropertyUtils.setProperty(object, name, new PrintableExpression(e, (String) value));
          } else {           
            PropertyUtils.setPropertyFromString(object, name, (String)value);
          }
        } else {
          PropertyUtils.setProperty(object, name, value);
        }
      } catch (Exception e) {
        throw new ConfigException(
          "Could not set property " + name + " in " + toInlineString(), e);
      }
    }
  }
View Full Code Here

   * Add panels element
   */
  public void add(PanelsConfigImpl value) throws ConfigException {
    String key = getPanelsKey(value);
    if (panelsConfigs.containsKey(key)) {
      throw new ConfigException("Duplicate panels for key '" + key + "' in " + toInlineString());
    }
    panelsConfigs.put(key, value);
  }
View Full Code Here

    I18nSupport i18n = I18nSupport.getInstance(request);
    Locale locale = i18n.getLocale(request);     
    FormsSupport support = FormsSupport.getInstance(request);
    Form form = support.getForm(request, locale, mapping.getPath());
    if (form == null) {
      throw new ConfigException("No form for action '" + mapping.getPath() + "'");
    }
    ActionErrors errors = null;
    // execute validation
    FormResult result = form.validate(request, inputs);
    if (!result.isValid()) { // collect error messages
View Full Code Here

  private boolean commit;

  public void init(FilterConfig config, ModuleContext context) throws ConfigException {
    formsSupport = (FormsSupport)FormsSupport.getInstance(context);
    if (formsSupport == null) {
      throw new ConfigException("No forms support! Forms plugin loaded?");
    }
    dispatch = config.getDispatchConfig(null);
    ParamConfig param = config.getParamConfig("dispatch");
    if ((param == null) == (dispatch == null)) {
      throw new ConfigException("One of 'dispatch' parameter or anonymous <dispatch> child must be given for filter '" + config.toInlineString() + "'");
    }
    if (dispatch == null) {
      dispatch = config.getActionConfig().findDispatchConfig(param.getValue());
      if (dispatch == null) {
        throw new ConfigException("Cannot find dispatch '" + param.getValue() + "' for filter '" + config.toInlineString() + "'");
      }
    }
    messageSupport = MessageSupport.getInstance(context);
    param = config.getParamConfig("commit");
    if (param == null) {
        commit = false;
    } else {
        try {
            commit = ((Boolean)ParseUtils.parse(Boolean.class, param.getValue())).booleanValue();
        } catch (Exception e) {
        throw new ConfigException("Bad commit value '" + param.getValue() + "' in " + config.toInlineString());
        }
    }
    formsSupport.add(config);
    this.config = config;
  }
View Full Code Here

    Class dataClass = null;
    if (param != null) {
      try {
        dataClass = module.getClassLoader().loadClass(param.getValue());
      } catch (Exception e) {
        throw new ConfigException("Could not load data class in " + config.toInlineString(), e);
      }
    }
    String factoryClass = DEFAULT_FACTORY;
    param = config.getParamConfig("factory-class");
    if (param != null) {
      factoryClass = param.getValue();
    }
    FormFactory factory = null;
    try {
      factory = (FormFactory)module.getClassLoader().loadClass(factoryClass).newInstance();
    } catch (Exception e) {
      throw new ConfigException("Could not create form factory in " + config.toInlineString(), e);
    }
    factory.init(module);
    param = config.getParamConfig("config");
    if (param == null) {
      throw new ConfigException("Missing parameter 'config' in " + config.toInlineString());
    }
    FormsSupport support = new FormsSupport(module.getClassLoader(), dataClass);
    service.init(module, support, factory, param.getValue());

    context.setFilterClass("forms", FormsFilter.class);
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.base.conf.ConfigException

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.