Пример #1
0
  private String getCommand(String configName) {
    String configValue = getConfigValue(configName);
    File exec = new File(configValue);

    if (!FileUtils.isExecutable(exec)) {
      throw new ResourceException(
          Status.SERVER_ERROR_INTERNAL,
          configValue + " command does not exist or is not executable");
    }

    return configValue;
  }
Пример #2
0
  private static Properties readConfigFile() {
    File cfgFile = locateConfigFile();

    Properties properties = new Properties();

    Reader reader = null;
    try {
      reader = new InputStreamReader(new FileInputStream(cfgFile), Charset.defaultCharset());
      properties.load(reader);
    } catch (IOException consumed) {
      throw new ResourceException(
          Status.SERVER_ERROR_INTERNAL, "An error occured while reading configuration file");
    } finally {
      FileUtils.closeRaisingError(reader, cfgFile.getAbsolutePath());
    }

    return properties;
  }