private Digester createDigester() {
    Digester d = new Digester();

    d.addObjectCreate("configuration/accounts", ArrayList.class);
    d.addObjectCreate("configuration/accounts/account", Account.class);
    d.addSetProperties("configuration/accounts/account");

    d.addObjectCreate("configuration/accounts/account/folders", ArrayList.class);
    d.addObjectCreate("configuration/accounts/account/folders/folder", FolderDefinition.class);
    d.addSetProperties("configuration/accounts/account/folders/folder");

    d.addObjectCreate("configuration/accounts/account/folders/folder/rules", ArrayList.class);

    d.addFactoryCreate(
        "configuration/accounts/account/folders/folder/rules/groovy",
        new GroovyRuleObjectCreationFactory());
    // d.addObjectCreate(
    // "configuration/accounts/account/folders/folder/rules/groovy",
    // GroovyRuleDefinition.class);
    //
    // d
    // .addSetProperties("configuration/accounts/account/folders/folder/rules/groovy");

    d.addSetNext("configuration/accounts/account/folders/folder/rules/groovy", "add");

    d.addFactoryCreate(
        "configuration/accounts/account/folders/folder/rules/rule",
        new BuiltinRuleObjectCreationFactory());
    d.addSetNext("configuration/accounts/account/folders/folder/rules/rule", "add");

    d.addSetNext("configuration/accounts/account/folders/folder/rules", "setRules");

    d.addSetNext("configuration/accounts/account/folders/folder", "add");

    d.addSetNext("configuration/accounts/account/folders", "setFolders");

    d.addSetNext("configuration/accounts/account", "add");

    return d;
  }
  /**
   * Add the set of Rule instances defined in this RuleSet to the specified <code>Digester</code>
   * instance, associating them with our namespace URI (if any). This method should only be called
   * by a Digester instance. These rules assume that an instance of <code>
   * org.apache.struts.config.ModuleConfig</code> is pushed onto the evaluation stack before parsing
   * begins.
   *
   * @param digester Digester instance to which the new Rule instances should be added.
   */
  public void addRuleInstances(Digester digester) {

    digester.addObjectCreate(
        "struts-config/data-sources/data-source",
        "org.apache.struts.config.DataSourceConfig",
        "className");
    digester.addSetProperties("struts-config/data-sources/data-source");
    digester.addSetNext(
        "struts-config/data-sources/data-source",
        "addDataSourceConfig",
        "org.apache.struts.config.DataSourceConfig");

    digester.addRule(
        "struts-config/data-sources/data-source/set-property", new AddDataSourcePropertyRule());

    digester.addRule("struts-config/action-mappings", new SetActionMappingClassRule());

    digester.addFactoryCreate("struts-config/action-mappings/action", new ActionMappingFactory());
    digester.addSetProperties("struts-config/action-mappings/action");
    digester.addSetNext(
        "struts-config/action-mappings/action",
        "addActionConfig",
        "org.apache.struts.config.ActionConfig");

    digester.addSetProperty(
        "struts-config/action-mappings/action/set-property", "property", "value");

    digester.addObjectCreate(
        "struts-config/action-mappings/action/exception",
        "org.apache.struts.config.ExceptionConfig",
        "className");
    digester.addSetProperties("struts-config/action-mappings/action/exception");
    digester.addSetNext(
        "struts-config/action-mappings/action/exception",
        "addExceptionConfig",
        "org.apache.struts.config.ExceptionConfig");

    digester.addSetProperty(
        "struts-config/action-mappings/action/exception/set-property", "property", "value");

    digester.addFactoryCreate(
        "struts-config/action-mappings/action/forward", new ActionForwardFactory());
    digester.addSetProperties("struts-config/action-mappings/action/forward");
    digester.addSetNext(
        "struts-config/action-mappings/action/forward",
        "addForwardConfig",
        "org.apache.struts.config.ForwardConfig");

    digester.addSetProperty(
        "struts-config/action-mappings/action/forward/set-property", "property", "value");

    digester.addObjectCreate(
        "struts-config/controller", "org.apache.struts.config.ControllerConfig", "className");
    digester.addSetProperties("struts-config/controller");
    digester.addSetNext(
        "struts-config/controller",
        "setControllerConfig",
        "org.apache.struts.config.ControllerConfig");

    digester.addSetProperty("struts-config/controller/set-property", "property", "value");

    digester.addRule("struts-config/form-beans", new SetActionFormBeanClassRule());

    digester.addFactoryCreate("struts-config/form-beans/form-bean", new ActionFormBeanFactory());
    digester.addSetProperties("struts-config/form-beans/form-bean");
    digester.addSetNext(
        "struts-config/form-beans/form-bean",
        "addFormBeanConfig",
        "org.apache.struts.config.FormBeanConfig");

    digester.addObjectCreate(
        "struts-config/form-beans/form-bean/form-property",
        "org.apache.struts.config.FormPropertyConfig",
        "className");
    digester.addSetProperties("struts-config/form-beans/form-bean/form-property");
    digester.addSetNext(
        "struts-config/form-beans/form-bean/form-property",
        "addFormPropertyConfig",
        "org.apache.struts.config.FormPropertyConfig");

    digester.addSetProperty(
        "struts-config/form-beans/form-bean/form-property/set-property", "property", "value");

    digester.addSetProperty("struts-config/form-beans/form-bean/set-property", "property", "value");

    digester.addObjectCreate(
        "struts-config/global-exceptions/exception",
        "org.apache.struts.config.ExceptionConfig",
        "className");
    digester.addSetProperties("struts-config/global-exceptions/exception");
    digester.addSetNext(
        "struts-config/global-exceptions/exception",
        "addExceptionConfig",
        "org.apache.struts.config.ExceptionConfig");

    digester.addSetProperty(
        "struts-config/global-exceptions/exception/set-property", "property", "value");

    digester.addRule("struts-config/global-forwards", new SetActionForwardClassRule());

    digester.addFactoryCreate("struts-config/global-forwards/forward", new GlobalForwardFactory());
    digester.addSetProperties("struts-config/global-forwards/forward");
    digester.addSetNext(
        "struts-config/global-forwards/forward",
        "addForwardConfig",
        "org.apache.struts.config.ForwardConfig");

    digester.addSetProperty(
        "struts-config/global-forwards/forward/set-property", "property", "value");

    digester.addObjectCreate(
        "struts-config/message-resources",
        "org.apache.struts.config.MessageResourcesConfig",
        "className");
    digester.addSetProperties("struts-config/message-resources");
    digester.addSetNext(
        "struts-config/message-resources",
        "addMessageResourcesConfig",
        "org.apache.struts.config.MessageResourcesConfig");

    digester.addSetProperty("struts-config/message-resources/set-property", "property", "value");

    digester.addObjectCreate("struts-config/plug-in", "org.apache.struts.config.PlugInConfig");
    digester.addSetProperties("struts-config/plug-in");
    digester.addSetNext(
        "struts-config/plug-in", "addPlugInConfig", "org.apache.struts.config.PlugInConfig");

    digester.addRule("struts-config/plug-in/set-property", new PlugInSetPropertyRule());
  }
  /**
   * Method that uses the {@link org.apache.commons.digester.Digester} to read the objects from the
   * given xml-File an build the java-Objects in a parent-child Hirachy.
   *
   * @param _xml URL to the XML-File
   */
  public void readXMLFile(final URL _xml) {
    Digester digester = new Digester();

    digester.setValidating(false);

    digester.addObjectCreate("import", RootObject.class);

    // Read the Definitions
    digester.addCallMethod("import/definition/date", "setDateFormat", 1);
    digester.addCallParam("import/definition/date", 0, "format");

    // Read OrderObject
    digester.addFactoryCreate("import/definition/order", new OrderObjectFactory(), false);
    digester.addCallMethod(
        "import/definition/order/attribute",
        "addAttribute",
        3,
        new Class[] {Integer.class, String.class, String.class});
    digester.addCallParam("import/definition/order/attribute", 0, "index");
    digester.addCallParam("import/definition/order/attribute", 1, "name");
    digester.addCallParam("import/definition/order/attribute", 2, "criteria");
    digester.addSetNext("import/definition/order", "addOrder", "org.efaps.importer.OrderObject");

    // Read DefaultObject
    digester.addObjectCreate("import/definition/default", DefaultObject.class);
    digester.addCallMethod("import/definition/default", "addDefault", 3);
    digester.addCallParam("import/definition/default", 0, "type");
    digester.addCallParam("import/definition/default", 1, "name");
    digester.addCallParam("import/definition/default", 2);

    digester.addObjectCreate("import/definition/default/linkattribute", ForeignObject.class);
    digester.addCallMethod("import/definition/default/linkattribute", "setLinkAttribute", 2);
    digester.addCallParam("import/definition/default/linkattribute", 0, "name");
    digester.addCallParam("import/definition/default/linkattribute", 1, "type");

    digester.addCallMethod(
        "import/definition/default/linkattribute/queryattribute", "addAttribute", 2);
    digester.addCallParam("import/definition/default/linkattribute/queryattribute", 0, "name");
    digester.addCallParam("import/definition/default/linkattribute/queryattribute", 1);

    digester.addSetNext(
        "import/definition/default/linkattribute", "addLink", "org.efaps.importer.ForeignObject");

    // Create the Objects
    digester.addFactoryCreate("*/object", new InsertObjectFactory(), false);

    digester.addCallMethod("*/object/attribute", "addAttribute", 3);
    digester.addCallParam("*/object/attribute", 0, "name");
    digester.addCallParam("*/object/attribute", 1);
    digester.addCallParam("*/object/attribute", 2, "unique");

    digester.addCallMethod("*/object/file", "setCheckinObject", 2);
    digester.addCallParam("*/object/file", 0, "name");
    digester.addCallParam("*/object/file", 1, "url");

    digester.addCallMethod("*/object/parentattribute", "setParentAttribute", 2);
    digester.addCallParam("*/object/parentattribute", 0, "name");
    digester.addCallParam("*/object/parentattribute", 1, "unique");

    digester.addCallMethod("*/object/linkattribute", "addUniqueAttribute", 2);
    digester.addCallParam("*/object/linkattribute", 0, "unique");
    digester.addCallParam("*/object/linkattribute", 1, "name");

    digester.addSetNext("*/object", "addChild", "org.efaps.importer.InsertObject");

    digester.addObjectCreate("*/object/linkattribute", ForeignObject.class);
    digester.addCallMethod("*/object/linkattribute", "setLinkAttribute", 2);
    digester.addCallParam("*/object/linkattribute", 0, "name");
    digester.addCallParam("*/object/linkattribute", 1, "type");

    digester.addCallMethod("*/object/linkattribute/queryattribute", "addAttribute", 2);
    digester.addCallParam("*/object/linkattribute/queryattribute", 0, "name");
    digester.addCallParam("*/object/linkattribute/queryattribute", 1);

    digester.addSetNext("*/object/linkattribute", "addLink", "org.efaps.importer.ForeignObject");

    try {
      this.root = (RootObject) digester.parse(_xml);
    } catch (IOException e) {
      e.printStackTrace(System.err);
    } catch (SAXException e) {
      e.printStackTrace(System.err);
    }
  }
  /**
   * Create Digester rules for manufacturers and models
   *
   * @return
   */
  protected Digester createManufacturerDigester() {
    // Initialize the digester
    Digester digester = new Digester();
    digester.setValidating(false);
    // Manufacturer stage
    digester.addObjectCreate("*/Manufacturer", ManufacturerItem.class);
    digester.addBeanPropertySetter("*/Manufacturer/ExternalID", "externalID");
    digester.addBeanPropertySetter("*/Manufacturer/Name", "name");
    digester.addBeanPropertySetter("*/Manufacturer/Description", "description");
    digester.addSetNext("*/Manufacturer", "add");

    digester.addCallMethod("*/Models", "addIncludeFile4Model", 1);
    digester.addCallParam("*/Models", 0, "filename");

    // Model stage
    digester.addFactoryCreate("*/Models/Model", ModelItemObjectCreationFactory.class);
    // digester.addObjectCreate("*/Models/Model", ModelItem.class);
    digester.addSetNext("*/Models/Model", "addModel");

    // Basic information
    // digester.addCallMethod("*/Models/Model", "setFamilyID", 1);
    // digester.addCallParam("*/Models/Model", 0, "family");
    digester.addBeanPropertySetter("*/Models/Model/ExternalID", "externalID");
    digester.addBeanPropertySetter("*/Models/Model/Name", "name");
    digester.addBeanPropertySetter("*/Models/Model/Description", "description");
    // digester.addBeanPropertySetter("*/Models/Model/FamilyID", "familyID");
    digester.addBeanPropertySetter("*/Models/Model/IconFile", "iconFile");
    digester.addBeanPropertySetter("*/Models/Model/IsOmaDmEnabled", "isOmaDmEnabled");
    digester.addBeanPropertySetter("*/Models/Model/OmaDmVersion", "omaDmVersion");
    digester.addBeanPropertySetter("*/Models/Model/IsOmaCpEnabled", "isOmaCpEnabled");
    digester.addBeanPropertySetter("*/Models/Model/OmaCpVersion", "omaCpVersion");
    digester.addBeanPropertySetter("*/Models/Model/IsNokiaOtaEnabled", "isNokiaOtaEnabled");
    digester.addBeanPropertySetter("*/Models/Model/NokiaOtaVersion", "nokiaOtaVersion");
    digester.addBeanPropertySetter(
        "*/Models/Model/SupportedDownloadMethods", "supportedDownloadMethods");
    digester.addBeanPropertySetter("*/Models/Model/FirmwareVersionNode", "firmwareVersionNode");
    digester.addBeanPropertySetter("*/Models/Model/FirmwareUpdateNode", "firmwareUpdateNode");
    digester.addBeanPropertySetter("*/Models/Model/FirmwareDownloadNode", "firmwareDownloadNode");
    digester.addBeanPropertySetter(
        "*/Models/Model/FirmwareDownloadAndUpdateNode", "firmwareDownloadAndUpdateNode");
    digester.addBeanPropertySetter("*/Models/Model/FirmwareStatusNode", "firmwareStatusNode");
    // DDF Information
    digester.addCallMethod("*/Models/Model/DDFs/DDF", "addDdfFile", 1);
    digester.addCallParam("*/Models/Model/DDFs/DDF", 0, "filename");
    // DM Profile Mappings
    digester.addCallMethod(
        "*/Models/Model/ProfileMappings/ProfileMapping", "addProfileMappingFile", 1);
    digester.addCallParam("*/Models/Model/ProfileMappings/ProfileMapping", 0, "filename");
    // CP Templates
    digester.addCallMethod("*/Models/Model/CPTemplates", "addCpTemplatesFiles", 1);
    digester.addCallParam("*/Models/Model/CPTemplates", 0, "filename");
    // TAC Informations
    digester.addCallMethod("*/Models/Model/TACs/TAC", "addTac", 1);
    digester.addCallParam("*/Models/Model/TACs/TAC", 0);
    // Firmwares
    digester.addObjectCreate("*/Models/Model/Firmwares/Firmware", FirmwareItem.class);
    digester.addBeanPropertySetter("*/Models/Model/Firmwares/Firmware/FromVersion", "fromVersion");
    digester.addBeanPropertySetter("*/Models/Model/Firmwares/Firmware/ToVersion", "toVersion");
    digester.addBeanPropertySetter("*/Models/Model/Firmwares/Firmware/Status", "status");
    digester.addBeanPropertySetter("*/Models/Model/Firmwares/Firmware/Filename", "filename");
    digester.addSetNext("*/Models/Model/Firmwares/Firmware", "addFirmware");
    // Specifications
    digester.addCallMethod("*/Models/Model/Specifications/Specification", "setSpecification", 3);
    digester.addCallParam("*/Models/Model/Specifications/Specification", 0, "category");
    digester.addCallParam("*/Models/Model/Specifications/Specification", 1, "name");
    digester.addCallParam("*/Models/Model/Specifications/Specification", 2, "value");

    // Model Family stage
    digester.addFactoryCreate("*/Models/Family", ModelFamilyItemObjectCreationFactory.class);
    // digester.addObjectCreate("*/Models/Family", ModelFamilyItem.class);
    digester.addSetNext("*/Models/Family", "addModelFamily");
    // Basic information
    // digester.addCallMethod("*/Models/Family", "setParentID", 1);
    // digester.addCallParam("*/Models/Family", 0, "parent");
    // digester.addSetNestedProperties("*/Models/Family", "parent", "parentID");
    digester.addBeanPropertySetter("*/Models/Family/ExternalID", "externalID");
    digester.addBeanPropertySetter("*/Models/Family/Name", "name");
    digester.addBeanPropertySetter("*/Models/Family/Description", "description");
    // digester.addBeanPropertySetter("*/Models/Family/ParentID", "parentID");
    digester.addBeanPropertySetter("*/Models/Family/IconFile", "iconFile");
    digester.addBeanPropertySetter("*/Models/Family/IsOmaDmEnabled", "isOmaDmEnabled");
    digester.addBeanPropertySetter("*/Models/Family/OmaDmVersion", "omaDmVersion");
    digester.addBeanPropertySetter("*/Models/Family/IsOmaCpEnabled", "isOmaCpEnabled");
    digester.addBeanPropertySetter("*/Models/Family/OmaCpVersion", "omaCpVersion");
    digester.addBeanPropertySetter("*/Models/Family/IsNokiaOtaEnabled", "isNokiaOtaEnabled");
    digester.addBeanPropertySetter("*/Models/Family/NokiaOtaVersion", "nokiaOtaVersion");
    digester.addBeanPropertySetter(
        "*/Models/Family/SupportedDownloadMethods", "supportedDownloadMethods");
    digester.addBeanPropertySetter("*/Models/Family/FirmwareVersionNode", "firmwareVersionNode");
    digester.addBeanPropertySetter("*/Models/Family/FirmwareUpdateNode", "firmwareUpdateNode");
    digester.addBeanPropertySetter("*/Models/Family/FirmwareDownloadNode", "firmwareDownloadNode");
    digester.addBeanPropertySetter(
        "*/Models/Family/FirmwareDownloadAndUpdateNode", "firmwareDownloadAndUpdateNode");
    digester.addBeanPropertySetter("*/Models/Family/FirmwareStatusNode", "firmwareStatusNode");
    // DDF Information
    digester.addCallMethod("*/Models/Family/DDFs/DDF", "addDdfFile", 1);
    digester.addCallParam("*/Models/Family/DDFs/DDF", 0, "filename");
    // DM Profile Mappings
    digester.addCallMethod(
        "*/Models/Family/ProfileMappings/ProfileMapping", "addProfileMappingFile", 1);
    digester.addCallParam("*/Models/Family/ProfileMappings/ProfileMapping", 0, "filename");
    // CP Templates
    digester.addCallMethod("*/Models/Family/CPTemplates", "addCpTemplatesFiles", 1);
    digester.addCallParam("*/Models/Family/CPTemplates", 0, "filename");
    // Firmwares
    digester.addObjectCreate("*/Models/Family/Firmwares/Firmware", FirmwareItem.class);
    digester.addBeanPropertySetter("*/Models/Family/Firmwares/Firmware/FromVersion", "fromVersion");
    digester.addBeanPropertySetter("*/Models/Family/Firmwares/Firmware/ToVersion", "toVersion");
    digester.addBeanPropertySetter("*/Models/Family/Firmwares/Firmware/Status", "status");
    digester.addBeanPropertySetter("*/Models/Family/Firmwares/Firmware/Filename", "filename");
    digester.addSetNext("*/Models/Family/Firmwares/Firmware", "addFirmware");
    // Specifications
    digester.addCallMethod("*/Models/Family/Specifications/Specification", "setSpecification", 3);
    digester.addCallParam("*/Models/Family/Specifications/Specification", 0, "category");
    digester.addCallParam("*/Models/Family/Specifications/Specification", 1, "name");
    digester.addCallParam("*/Models/Family/Specifications/Specification", 2, "value");

    return (digester);
  }