@Override public String convert(String value) { if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { try { return FileUtil.readAsString(new File(value)); } catch (IOException e) { throw new HalException(Problem.Severity.FATAL, "Was passed parameter " + value + " to unreadable file: " + e.getMessage()); } } return new File(value).getAbsolutePath(); } }
public static GlobalApplicationOptions getInstance() { if (GlobalApplicationOptions.options == null) { Yaml yamlParser = new Yaml(new SafeConstructor()); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { GlobalApplicationOptions.options = objectMapper.convertValue( yamlParser.load(FileUtils.openInputStream(new File(CONFIG_PATH))), GlobalApplicationOptions.class ); } catch (IOException e) { GlobalApplicationOptions.options = new GlobalApplicationOptions(); } } return GlobalApplicationOptions.options; }
@Override public String convert(String value) { if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { try { return FileUtil.readAsString(new File(value)); } catch (IOException e) { throw new HalException(Problem.Severity.FATAL, "Was passed parameter " + value + " to unreadable file: " + e.getMessage()); } } return new File(value).getAbsolutePath(); } }
public void stageLocalFiles(Path outputPath) { if (!GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { return; } localFiles().forEach(f -> { try { f.setAccessible(true); String fContent = (String) f.get(this); if (fContent != null) { CRC32 crc = new CRC32(); crc.update(fContent.getBytes()); String fPath = Paths .get(outputPath.toAbsolutePath().toString(), Long.toHexString(crc.getValue())) .toString(); FileUtils.writeStringToFile(new File(fPath), fContent); f.set(this, fPath); } } catch (IllegalAccessException | IOException e) { throw new RuntimeException("Failed to get local files for node " + this.getNodeName(), e); } finally { f.setAccessible(false); } }); }
public void stageLocalFiles(Path outputPath) { if (!GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { return; } localFiles().forEach(f -> { try { f.setAccessible(true); String fContent = (String) f.get(this); if (fContent != null) { CRC32 crc = new CRC32(); crc.update(fContent.getBytes()); String fPath = Paths .get(outputPath.toAbsolutePath().toString(), Long.toHexString(crc.getValue())) .toString(); FileUtils.writeStringToFile(new File(fPath), fContent); f.set(this, fPath); } } catch (IllegalAccessException | IOException e) { throw new RuntimeException("Failed to get local files for node " + this.getNodeName(), e); } finally { f.setAccessible(false); } }); }
if (!GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { return;
if (!GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { return;