예제 #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;
  }