コード例 #1
0
  @Override
  protected void initFlow(HierarchicalConfiguration flowCfg) {
    // int node = flowCfg.getInt("[@node]");

    int inLink = flowCfg.getInt("[@inLink]", -1);
    int outLink = flowCfg.getInt("[@outLink]", -1);

    // int next = flowCfg.getInt("[@next]");
    int no = flowCfg.getInt("[@no]", 0);

    Node node;
    Node next;

    if (inLink != -1) {
      Link link = idToLinkMap.get(Id.create(inLink, Link.class));

      node = link.getFromNode();
      next = link.getToNode();
    } else {
      Link link = idToLinkMap.get(Id.create(outLink, Link.class));

      node = link.getToNode();
      next = link.getFromNode();
    }

    int nodeId = Integer.parseInt(node.getId().toString());
    int nextId = Integer.parseInt(next.getId().toString());

    flows[nodeId] = new MATSimFlow(nodeId, inLink, outLink, nextId, no);
  }
コード例 #2
0
ファイル: DictionaryTagger.java プロジェクト: oaqa/banner
  public void load(HierarchicalConfiguration config) throws IOException {
    HierarchicalConfiguration localConfig = config.configurationAt(this.getClass().getName());
    String dictionaryFilename = "/dict/single.txt";
    if (dictionaryFilename == null)
      throw new IllegalArgumentException("Must specify dictionary filename");
    String dictionaryTypeName = localConfig.getString("dictionaryType");
    if (dictionaryTypeName == null)
      throw new IllegalArgumentException("Must specify dictionary type");
    String delimiter = localConfig.getString("delimiter");
    int column = localConfig.getInt("column", -1);
    if (delimiter != null && column == -1)
      throw new IllegalArgumentException("Must specify column if delimiter specified");
    EntityType dictionaryType = EntityType.getType(dictionaryTypeName);

    // Load data
    java.util.Scanner s =
        new java.util.Scanner(getClass().getResourceAsStream(dictionaryFilename))
            .useDelimiter("\\A");

    while (s.hasNext()) {
      String line = s.nextLine();
      line = line.trim();
      if (line.length() > 0) {
        if (delimiter == null) {
          add(line, dictionaryType);
        } else {
          // TODO Performance - don't use split
          String[] split = line.split(delimiter);
          add(split[column], dictionaryType);
        }
      }
    }
    s.close();
  }
コード例 #3
0
  private boolean isDeprecated(String key) {
    final String pathToDeprecatedAttribute = key + "/deprecated";
    if (!keysConfig.containsKey(pathToDeprecatedAttribute)) {
      return false;
    }

    final List list = keysConfig.getList(pathToDeprecatedAttribute);
    if (list.size() != 1) {
      throw new IllegalArgumentException(
          "Configuration error; Key \"" + key + "\" has ambiguous definition.");
    }

    final Object value = list.iterator().next();
    try {
      return Boolean.parseBoolean((String) value);
    } catch (ClassCastException e) {
      throw new IllegalArgumentException(
          "Configuration error;"
              + " Key \""
              + key
              + "\" should be either 'true' or 'false'. Value '"
              + value
              + "' is not valid.");
    }
  }
コード例 #4
0
 /**
  * Get's data from XML file in classpath in specified format.<br>
  * First search the
  *
  * @param className ClassName
  * @param context The context.
  */
 public HierarchicalConfiguration getData(
     final String className, HierarchicalConfiguration context) {
   HierarchicalConfiguration dataForTestCase = null;
   try {
     Class<?> clazz = Class.forName(className);
     String dataFilePath = null;
     URL dataFileURL = null;
     boolean packageFile = false;
     Map<String, HierarchicalConfiguration> dataMap = null;
     String dataFileName = context.getString("supplier.dataFile", null);
     log.debug("Checking the data file in argument...");
     if (dataFileName == null || dataFileName.equals("")) {
       log.debug("Data file not given in argument..Using DataFileFinder..");
       dataFilePath = DDUtils.findDataFile(className, ".xml", context);
     } else {
       log.debug("Got data file in argument");
       dataFilePath = dataFileName;
     }
     log.debug("Data file path: " + dataFilePath);
     if (dataFilePath == null) {
       return null; // No data found, hence it's a normal test case.
     }
     dataFileURL = clazz.getResource(dataFilePath);
     if (packageFile) {
       // The data file is from package file name so check the cache.
       log.debug("Cache: " + cache.size());
       synchronized (XMLDataSupplier.class) {
         if (loadedFiles.contains(dataFilePath)) { // get it from cache.
           log.info("File was loaded before !!!");
           dataForTestCase = cache.get(clazz.getName());
         } else { // not in cache, so load and put it to cache.
           log.info("File was not loaded before, loading now...");
           if (dataFileURL != null) {
             cache.putAll(XMLDataParser.load(dataFileURL, clazz));
           } else {
             cache.putAll(XMLDataParser.load(dataFilePath, clazz));
           }
           dataForTestCase = cache.get(clazz.getName());
           loadedFiles.add(dataFilePath);
         }
       }
       if ((dataForTestCase == null) || dataForTestCase.isEmpty()) {
         log.info("Data for '{}' is not available!", className);
         return null;
       }
     } else { // data file not from package file so go ahead and load.
       log.debug("Loading the xml file...");
       if (dataFileURL != null) {
         dataMap = XMLDataParser.load(dataFileURL, clazz);
       } else {
         dataMap = XMLDataParser.load(dataFilePath, clazz);
       }
       dataForTestCase = dataMap.get(clazz.getName());
     }
   } catch (Exception ex) {
     throw new DDException("Error in loading the data file", ex);
   }
   return dataForTestCase;
 }
コード例 #5
0
 protected void loadStringTransformerFromXML(XMLConfiguration xml) throws IOException {
   setCaseSensitive(xml.getBoolean("[@caseSensitive]", false));
   setInclusive(xml.getBoolean("[@inclusive]", false));
   List<HierarchicalConfiguration> nodes = xml.configurationsAt("stripBetween");
   for (HierarchicalConfiguration node : nodes) {
     addStripEndpoints(node.getString("start", null), node.getString("end", null));
   }
 }
コード例 #6
0
ファイル: GenreXmlTools.java プロジェクト: deblockt/yamj-v3
  @PostConstruct
  public void init() {
    String genreFileName = PropertyTools.getProperty("yamj3.genre.fileName");
    if (StringUtils.isBlank(genreFileName)) {
      LOG.trace("No valid genre file name configured");
      return;
    }
    if (!StringUtils.endsWithIgnoreCase(genreFileName, "xml")) {
      LOG.warn("Invalid genre file name specified: {}", genreFileName);
      return;
    }

    File xmlFile;
    if (StringUtils.isBlank(FilenameUtils.getPrefix(genreFileName))) {
      // relative path given
      String path = System.getProperty("yamj3.home");
      if (StringUtils.isEmpty(path)) {
        path = ".";
      }
      xmlFile = new File(FilenameUtils.concat(path, genreFileName));
    } else {
      // absolute path given
      xmlFile = new File(genreFileName);
    }

    if (!xmlFile.exists() || !xmlFile.isFile()) {
      LOG.warn("Genres file does not exist: {}", xmlFile.getPath());
      return;
    }
    if (!xmlFile.canRead()) {
      LOG.warn("Genres file not readble: {}", xmlFile.getPath());
      return;
    }

    LOG.debug("Initialize genres from file: {}", xmlFile.getPath());

    try {
      XMLConfiguration c = new XMLConfiguration(xmlFile);

      List<HierarchicalConfiguration> genres = c.configurationsAt("genre");
      for (HierarchicalConfiguration genre : genres) {
        String masterGenre = genre.getString("[@name]");
        List<Object> subGenres = genre.getList("subgenre");
        for (Object subGenre : subGenres) {
          LOG.debug("New genre added to map: {} -> {}", subGenre, masterGenre);
          GENRES_MAP.put(((String) subGenre).toLowerCase(), masterGenre);
        }
      }

      try {
        this.commonStorageService.updateGenresXml(GENRES_MAP);
      } catch (Exception ex) {
        LOG.warn("Failed update genres xml in database", ex);
      }
    } catch (Exception ex) {
      LOG.error("Failed parsing genre input file: " + xmlFile.getPath(), ex);
    }
  }
コード例 #7
0
 @Override
 protected String getTargetUrl() {
   HierarchicalConfiguration config = ConfigUtils.getCurrentConfig();
   if (config != null) {
     return config.getString(LOGIN_FAILURE_URL_KEY, targetUrl);
   } else {
     return targetUrl;
   }
 }
コード例 #8
0
  private Graph getGraphFromConfiguration(final HierarchicalConfiguration graphConfiguration)
      throws GraphConfigurationException {
    String graphConfigurationType = graphConfiguration.getString(Tokens.REXSTER_GRAPH_TYPE);
    final boolean isReadOnly = graphConfiguration.getBoolean(Tokens.REXSTER_GRAPH_READ_ONLY, false);

    if (graphConfigurationType.equals("neo4jgraph")) {
      graphConfigurationType = Neo4jGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("orientgraph")) {
      graphConfigurationType = OrientGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("tinkergraph")) {
      graphConfigurationType = TinkerGraphGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("rexstergraph")) {
      graphConfigurationType = RexsterGraphGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("memorystoresailgraph")) {
      graphConfigurationType = MemoryStoreSailGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("nativestoresailgraph")) {
      graphConfigurationType = NativeStoreSailGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("sparqlrepositorysailgraph")) {
      graphConfigurationType = SparqlRepositorySailGraphConfiguration.class.getName();
    } else if (graphConfigurationType.equals("dexgraph")) {
      graphConfigurationType = DexGraphConfiguration.class.getName();
    }

    final Graph graph;
    try {
      final Class clazz =
          Class.forName(
              graphConfigurationType, true, Thread.currentThread().getContextClassLoader());
      final GraphConfiguration graphConfigInstance = (GraphConfiguration) clazz.newInstance();
      Graph readWriteGraph = graphConfigInstance.configureGraphInstance(graphConfiguration);

      if (isReadOnly) {
        // the graph is configured to be readonly so wrap it up
        if (readWriteGraph instanceof IndexableGraph) {
          graph = new ReadOnlyIndexableGraph((IndexableGraph) readWriteGraph);
        } else {
          graph = new ReadOnlyGraph(readWriteGraph);
        }
      } else {
        graph = readWriteGraph;
      }

    } catch (NoClassDefFoundError err) {
      throw new GraphConfigurationException(
          String.format(
              "GraphConfiguration [%s] could not instantiate a class [%s].  Ensure that it is in Rexster's path.",
              graphConfigurationType, err.getMessage()));
    } catch (Exception ex) {
      throw new GraphConfigurationException(
          String.format(
              "GraphConfiguration could not be found or otherwise instantiated: [%s]. Ensure that it is in Rexster's path.",
              graphConfigurationType),
          ex);
    }

    return graph;
  }
コード例 #9
0
ファイル: VrpXMLReader.java プロジェクト: heerad/jsprit
 private static Coordinate getCoord(HierarchicalConfiguration serviceConfig, String prefix) {
   Coordinate pickupCoord = null;
   if (serviceConfig.getString(prefix + "coord[@x]") != null
       && serviceConfig.getString(prefix + "coord[@y]") != null) {
     double x = Double.parseDouble(serviceConfig.getString(prefix + "coord[@x]"));
     double y = Double.parseDouble(serviceConfig.getString(prefix + "coord[@y]"));
     pickupCoord = Coordinate.newInstance(x, y);
   }
   return pickupCoord;
 }
コード例 #10
0
  /**
   * @see org.apache.james.mailrepository.lib.AbstractMailRepository
   *     #doConfigure(org.apache.commons.configuration.HierarchicalConfiguration)
   */
  @Override
  public void doConfigure(HierarchicalConfiguration config) throws ConfigurationException {
    this.workspace = config.getString("workspace", null);
    String username = config.getString("username", null);
    String password = config.getString("password", null);

    if (username != null && password != null) {
      this.creds = new SimpleCredentials(username, password.toCharArray());
    }
  }
コード例 #11
0
  /** @return the configuration node used to create this object */
  public HierarchicalConfiguration getConfig() {
    final HierarchicalConfiguration config = new HierarchicalConfiguration();
    Node node = new Node("grSimNetwork");
    node.addAttribute(new Node("id", key));
    config.setRoot(node);
    config.addProperty("ip", ip);
    config.addProperty("port", port);
    config.addProperty("teamYellow", teamYellow);

    return config;
  }
コード例 #12
0
ファイル: g.java プロジェクト: jiaozhujun/c3f
 public static boolean loadConfig(String configFilePath) {
   String tmp = System.getProperty("os.name").toLowerCase();
   if (tmp.startsWith("windows")) {
     g.os = g.OS_WINDOWS;
   } else if (tmp.startsWith("linux")) {
     g.os = g.OS_LINUX;
   } else {
     g.os = g.OS_OTHER;
   }
   tmp = System.getProperty("sun.arch.data.model");
   if (tmp.equals("64")) {
     g.arch = g.ARCH_64;
   } else {
     g.arch = g.ARCH_32;
   }
   try {
     if (configFilePath == null) {
       config = new XMLConfiguration(configPath + "config.xml");
     } else {
       config = new XMLConfiguration(configFilePath);
     }
     dbConfig = config.getString("db", "").toLowerCase();
     siteUrl = config.getString("serverInfo.siteUrl");
     siteName = config.getString("serverInfo.siteName");
     uploadTemp = rootPath + config.getString("serverInfo.uploadTemp");
     uploadSizeMax = config.getLong("serverInfo.uploadSizeMax", 0);
     sessionExpiredTime = config.getInt("serverInfo.sessionExpiredTime", 0);
     sessionIdName = config.getString("serverInfo.sessionIdName", "ycsid");
     String _s = g.getConfig().getString("startup");
     if ("".equals(_s)) {
       startup = null;
     } else {
       _s = _s.replaceAll("\\s", "");
       startup = _s.split(";");
     }
     _s = null;
     // 加载全局参数
     List<HierarchicalConfiguration> fields = config.configurationsAt("globalVars.var");
     if (fields != null && fields.size() > 0) {
       vars = new String[fields.size()][2];
       HierarchicalConfiguration sub;
       for (int i = 0; i < fields.size(); i++) {
         sub = fields.get(i);
         vars[i][0] = sub.getString("[@name]");
         vars[i][1] = sub.getString("[@value]");
       }
       sub = null;
     }
     return true;
   } catch (ConfigurationException e) {
     return false;
   }
 }
コード例 #13
0
  @SuppressWarnings("unchecked")
  public static Map<String, String> getFilters() {

    Map<String, String> filters = new HashMap<String, String>();

    List<HierarchicalConfiguration> packNodes = getConfiguration().configurationsAt("filter");
    for (HierarchicalConfiguration packNode : packNodes) {
      String field = packNode.configurationAt("field").getProperty("[@value]").toString();
      String regexp = packNode.configurationAt("regexp").getProperty("[@value]").toString();

      filters.put(field, regexp);
    }

    return filters;
  }
コード例 #14
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  /** @return the availableThemes */
  public SortedMap<String, String> getAvailableThemes() {
    synchronized (this) {
      if (availableThemes == null) {
        this.availableThemes = new TreeMap<String, String>();

        List<HierarchicalConfiguration> configurations =
            configuration.configurationsAt("appearances.ui-theme.available-themes.theme");
        for (HierarchicalConfiguration config : configurations) {
          String name = config.getString("[@name]");
          availableThemes.put(StringUtils.capitalize(name), name);
        }
      }
    }

    return availableThemes;
  }
コード例 #15
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  public String getResourcePrefix() {
    if (resourcePrefix == null) {
      this.resourcePrefix = StringUtils.trimToEmpty(configuration.getString("web.resource-prefix"));
    }

    return resourcePrefix;
  }
コード例 #16
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  public String getLocaleAttributeName() {
    if (localeAttributeName == null) {
      this.localeAttributeName = configuration.getString("web.locale-attribute", "locale").trim();
    }

    return localeAttributeName;
  }
コード例 #17
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  public String getTheme() {
    if (theme == null) {
      this.theme = configuration.getString("appearances.ui-theme.default", "redmond").trim();
    }

    return theme;
  }
コード例 #18
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  public String getEditorTheme() {
    if (editorTheme == null) {
      this.editorTheme =
          StringUtils.trimToNull(configuration.getString("appearances.editor-theme"));
    }

    return editorTheme;
  }
コード例 #19
0
  public ConfigKey generateByPropertiesKey(String key) {
    SubnodeConfiguration configurationAt = null;
    try {
      if (Character.isLetter(key.charAt(0))) {
        configurationAt = keysConfig.configurationAt(key);
      }
    } catch (IllegalArgumentException e) {
      // Can't find a key. maybe its an alternate key.
    }
    if (configurationAt == null || configurationAt.isEmpty()) {
      key = alternateKeysMap.get(key);
      configurationAt = keysConfig.configurationAt(key);
    }

    String type = configurationAt.getString("type");
    if (StringUtils.isBlank(type)) {
      type = "String";
    }
    String[] validValues = configurationAt.getStringArray("validValues");

    // Description containing the list delimiter *will* be broken into an array, so rejoin it using
    // that delimiter.
    // We pad the separator because the strings in the array are trimmed automatically.
    String description =
        StringUtils.join(
            configurationAt.getStringArray("description"),
            configurationAt.getListDelimiter() + " ");
    String alternateKey = keysConfig.getString("/" + key + "/" + "alternateKey");

    // If the isReloadable attribute isn't specified - assume it is false
    boolean reloadable = configurationAt.getBoolean("isReloadable", false);
    ConfigKey configKey =
        new ConfigKey(
            type,
            description,
            alternateKey,
            key,
            "",
            validValues,
            "",
            getHelperByType(type),
            reloadable,
            isDeprecated(key));
    configKey.setParser(parser);
    return configKey;
  }
コード例 #20
0
  @Override
  @SuppressWarnings("unchecked")
  public List<UserAlert> getAvailableAlerts() {
    List<UserAlert> alerts = new ArrayList<UserAlert>();

    final SortedMap<Integer, Pair> categoryNames = new ConcurrentSkipListMap<Integer, Pair>();

    HierarchicalConfiguration hc = (HierarchicalConfiguration) configuration;
    List<HierarchicalConfiguration> categories = hc.configurationsAt(ALERTS_CATEGORIES_CATEGORY);

    for (HierarchicalConfiguration c : categories) {
      String key = c.getString("[@key]");
      int order = c.getInt("[@displayOrder]", categoryNames.size());
      String value = c.getString("");

      categoryNames.put(order, new Pair<String, String>(key, value));
    }

    final String[] weeklyCategories = hc.getStringArray(ALERTS_WEEKLY);
    final String[] monthlyCategories = hc.getStringArray(ALERTS_MONTHLY);
    final String[] subjectFilters = hc.getStringArray(SUBJECT_FILTER);

    final Set<Map.Entry<Integer, Pair>> categoryNamesSet = categoryNames.entrySet();

    for (final Map.Entry<Integer, Pair> category : categoryNamesSet) {
      final String key = (String) category.getValue().getFirst();
      boolean weeklyCategoryKey = false;
      boolean monthlyCategoryKey = false;
      boolean subjectFilter = false;

      if (ArrayUtils.contains(weeklyCategories, key)) {
        weeklyCategoryKey = true;
      }
      if (ArrayUtils.contains(monthlyCategories, key)) {
        monthlyCategoryKey = true;
      }
      if (ArrayUtils.contains(subjectFilters, key)) {
        subjectFilter = true;
      }

      alerts.add(
          new UserAlert(
              (String) category.getValue().getFirst(),
              (String) category.getValue().getSecond(),
              weeklyCategoryKey,
              monthlyCategoryKey,
              subjectFilter));
    }
    return alerts;
  }
コード例 #21
0
ファイル: ScriptParam.java プロジェクト: roxberry/zaproxy
  @Override
  protected void parse() {
    defaultScript = getConfig().getString(PARAM_DEFAULT_SCRIPT, "");
    defaultDir = getConfig().getString(PARAM_DEFAULT_DIR, "");

    try {
      List<HierarchicalConfiguration> fields =
          ((HierarchicalConfiguration) getConfig()).configurationsAt(ALL_SCRIPTS_KEY);
      this.scripts = new HashSet<>(fields.size());
      List<String> tempListNames = new ArrayList<>(fields.size());
      for (HierarchicalConfiguration sub : fields) {
        String name = sub.getString(SCRIPT_NAME_KEY, "");
        try {
          if (!"".equals(name) && !tempListNames.contains(name)) {
            tempListNames.add(name);

            File file = new File(sub.getString(SCRIPT_FILE_KEY));
            if (!file.exists()) {
              logger.error("Script '" + file.getAbsolutePath() + "' does not exist");
              continue;
            }

            ScriptWrapper script =
                new ScriptWrapper(
                    sub.getString(SCRIPT_NAME_KEY),
                    sub.getString(SCRIPT_DESC_KEY),
                    sub.getString(SCRIPT_ENGINE_KEY),
                    sub.getString(SCRIPT_TYPE_KEY),
                    sub.getBoolean(SCRIPT_ENABLED_KEY),
                    file);

            script.setLoadOnStart(true); // Because it was saved ;)

            scripts.add(script);
          }
        } catch (Exception e) {
          logger.error("Error while loading the script: " + name, e);
        }
      }
    } catch (Exception e) {
      logger.error("Error while loading the scripts: " + e.getMessage(), e);
    }

    try {
      this.scriptDirs = new ArrayList<File>();
      for (Object dirName : getConfig().getList(SCRIPT_DIRS)) {
        File f = new File((String) dirName);
        if (!f.exists() || !f.isDirectory()) {
          logger.error("Not a valid script directory: " + dirName);
        } else {
          scriptDirs.add(f);
        }
      }

    } catch (Exception e) {
      logger.error("Error while loading the script dirs: " + e.getMessage(), e);
    }
    confirmRemoveDir = getConfig().getBoolean(SCRIPT_CONFIRM_REMOVE_DIR, true);
  }
コード例 #22
0
ファイル: XsltTransformMap.java プロジェクト: opf-attic/ref
  public static Hashtable getMap(String config) throws FitsConfigurationException {
    Hashtable mappings = new Hashtable();
    XMLConfiguration conf = null;
    try {
      conf = new XMLConfiguration(config);
    } catch (ConfigurationException e) {
      throw new FitsConfigurationException("Error reading " + config + "fits.xml", e);
    }

    List fields = conf.configurationsAt("map");
    for (Iterator it = fields.iterator(); it.hasNext(); ) {
      HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
      // sub contains now all data about a single field
      String format = sub.getString("[@format]");
      String transform = sub.getString("[@transform]");
      mappings.put(format, transform);
    }
    return mappings;
  }
コード例 #23
0
ファイル: DictionaryTagger.java プロジェクト: oaqa/banner
 // TODO Determine how to combine this with loading
 public void configure(HierarchicalConfiguration config, Tokenizer tokenizer) {
   HierarchicalConfiguration localConfig = config.configurationAt(this.getClass().getName());
   filterContainedMentions = localConfig.getBoolean("filterContainedMentions", false);
   normalizeMixedCase = localConfig.getBoolean("normalizeMixedCase", false);
   normalizeDigits = localConfig.getBoolean("normalizeDigits", false);
   generate2PartVariations = localConfig.getBoolean("generate2PartVariations", false);
   dropEndParentheticals = localConfig.getBoolean("dropEndParentheticals", false);
   this.tokenizer = tokenizer;
 }
コード例 #24
0
 @Override
 public void loadFromXML(Reader in) throws IOException {
   try {
     XMLConfiguration xml = ConfigurationUtil.newXMLConfiguration(in);
     defaultDelay = xml.getLong("[@default]", defaultDelay);
     ignoreRobotsCrawlDelay = xml.getBoolean("[@ignoreRobotsCrawlDelay]", ignoreRobotsCrawlDelay);
     scope = xml.getString("[@scope]", SCOPE_CRAWLER);
     List<HierarchicalConfiguration> nodes = xml.configurationsAt("schedule");
     for (HierarchicalConfiguration node : nodes) {
       schedules.add(
           new DelaySchedule(
               node.getString("[@dayOfWeek]", null),
               node.getString("[@dayOfMonth]", null),
               node.getString("[@time]", null),
               node.getLong("", DEFAULT_DELAY)));
     }
   } catch (ConfigurationException e) {
     throw new IOException("Cannot load XML.", e);
   }
 }
コード例 #25
0
ファイル: Settings.java プロジェクト: kabassociates/pivot4j
  public String getViewParameterName() {
    if (viewParameterName == null) {
      this.viewParameterName = configuration.getString("web.view-parameter", "viewId").trim();

      if (viewParameterName == null) {
        this.viewParameterName = "viewId";
      }
    }

    return viewParameterName;
  }
コード例 #26
0
  public static DefaultEngineConfig create() {
    DefaultEngineConfig conf = new DefaultEngineConfig();
    String path = Utils.getConfigDir() + Constants.HDATA_XML;

    try {
      XMLConfiguration config = new XMLConfiguration(path);
      config.setValidating(true);

      List<HierarchicalConfiguration> properties = config.configurationsAt(".property");
      for (HierarchicalConfiguration hc : properties) {
        String name = hc.getString("name");
        String value = hc.getString("value");
        conf.setProperty(name, value);
      }
    } catch (ConfigurationException e) {
      Throwables.propagate(e);
    }

    return conf;
  }
コード例 #27
0
 @Override
 protected void doConfigure(HierarchicalConfiguration arg0) throws ConfigurationException {
   String[] mapConf = arg0.getStringArray("mapping");
   mappings = Maps.newHashMap();
   if (mapConf != null && mapConf.length > 0) {
     for (String aMapConf : mapConf) {
       mappings.putAll(RecipientRewriteTableUtil.getXMLMappings(aMapConf));
     }
   } else {
     throw new ConfigurationException("No mapping configured");
   }
 }
コード例 #28
0
 /**
  * filters test based on given filterKey/filterValue. If the any of the filter key/value pairs
  * found from data object, then returns true.
  *
  * @param data test data
  * @return true if test is selected after applying filter, false otherwise
  */
 private boolean checkAgainstFilterProperties(
     HierarchicalConfiguration data, HierarchicalConfiguration context) {
   boolean included = true;
   String filterKeys[] = null;
   String filterValues[] = null;
   if (context.containsKey(ARG_FILTER_KEY)
       && !context.getString(ARG_FILTER_KEY).trim().equals("")) {
     filterKeys = context.getStringArray(ARG_FILTER_KEY);
     filterValues = context.getStringArray(ARG_FILTER_VALUE);
   } else if (DDConfig.getSingleton().getData().containsKey(ARG_FILTER_KEY)
       && !DDConfig.getSingleton().getData().getString(ARG_FILTER_KEY).trim().equals("")) {
     filterKeys = DDConfig.getSingleton().getData().getStringArray(ARG_FILTER_KEY);
     filterValues = DDConfig.getSingleton().getData().getStringArray(ARG_FILTER_VALUE);
   }
   if (filterKeys != null && filterValues != null) {
     included = false;
     for (int index = 0; index < filterKeys.length; index++) {
       String filterKey = filterKeys[index];
       String filterValue = null;
       if (index >= filterValues.length) {
         filterValue = "";
       } else {
         filterValue = filterValues[index];
       }
       if (data.containsKey(filterKey) && data.getString(filterKey, "").equals(filterValue)) {
         included = true;
         break;
       }
     }
   }
   return included;
 }
コード例 #29
0
ファイル: GetTests.java プロジェクト: dulvac/jerry
  @BeforeClass(groups = {"functional", "real_server"})
  public void startServer() {
    // set up a document root
    documentRoot = Files.createTempDir();

    // create listeners configuration
    config = new HierarchicalConfiguration();
    config.addProperty("listeners.listener.port", Integer.toString(port));
    config.addProperty("listeners.listener.filesRoot", documentRoot.getAbsolutePath());
    // the values below could, in fact, be missing; there are defaults in
    // RequestListenerConfiguration
    config.addProperty("jerry.listeners.listener.http.connection_timeout", "3000");
    config.addProperty("jerry.listeners.listener.http.socket_timeout", "3000");
    config.addProperty("jerry.listeners.listener.http.socket_buffer_size", "16384");
    config.addProperty("jerry.listeners.listener.workers.core_pool_size", "30");
    config.addProperty("jerry.listeners.listener.workers.max_pool_size", "500");
    config.addProperty("jerry.listeners.listener.workers.keep_alive_time", "5");
    config.addProperty("jerry.listeners.listener.workers.queue_size", "80");

    // create webserver
    server = new JerryServer();

    // Now try to bind the listener on an open port
    for (int i = 0; i < 10; i++) {
      try {
        // increment port number
        server.loadConfiguration(config);
        server.start();
        break;
      } catch (BindException e) {
        System.out.println("Couldn't start server on " + port + ". Trying " + port + 1);
        // increment port number
        config.setProperty("listeners.listener.port", Integer.toString(++port));
        continue;
      } catch (IOException e) {
        Assert.fail("Error loading configuration: ", e);
      }
    }
  }
コード例 #30
0
  public RoutingConfiguration parseConfiguration(HierarchicalConfiguration config)
      throws ConfigurationException {
    RoutingConfigurationImpl result = new RoutingConfigurationImpl();
    Set<AddressFamilyKey> keys = new HashSet<AddressFamilyKey>();

    for (HierarchicalConfiguration afConfig : config.configurationsAt("AddressFamily")) {
      AddressFamilyRoutingConfiguration afRouting = afParser.parseConfiguration(afConfig);

      if (keys.contains(afRouting.getKey()))
        throw new ConfigurationException("Duplicate address family: " + afRouting.getKey());

      result.getRoutingConfigurations().add(afRouting);
      keys.add(afRouting.getKey());
    }

    return result;
  }