/** * Parse Halyard's config. * * @param is is the input stream to read from. * @return the fully parsed halconfig. * @see Halconfig */ Halconfig parseHalconfig(InputStream is) throws IllegalArgumentException { try { Object obj = yamlParser.load(is); return objectMapper.convertValue(obj, Halconfig.class); } catch (IllegalArgumentException e) { throw e; } }
/** * Parse Halyard's config. * * @param is is the input stream to read from. * @return the fully parsed halconfig. * @see Halconfig */ Halconfig parseHalconfig(InputStream is) throws IllegalArgumentException { try { Object obj = yamlParser.load(is); return objectMapper.convertValue(obj, Halconfig.class); } catch (IllegalArgumentException e) { throw e; } }
private void saveConfigTo(Path path) { Halconfig local = (Halconfig) DaemonTaskHandler.getContext(); if (local == null) { throw new HalException( new ConfigProblemBuilder(Severity.WARNING, "No halconfig changes have been made, nothing to write") .build() ); } AtomicFileWriter writer = null; try { writer = new AtomicFileWriter(path); writer.write(yamlParser.dump(objectMapper.convertValue(local, Map.class))); writer.commit(); } catch (IOException e) { throw new HalException(Severity.FATAL, "Failure writing your halconfig to path \"" + halconfigPath + "\": " + e.getMessage(), e); } finally { DaemonTaskHandler.setContext(null); if (writer != null) { writer.close(); } } } }
private void saveConfigTo(Path path) { Halconfig local = (Halconfig) DaemonTaskHandler.getContext(); if (local == null) { throw new HalException( new ConfigProblemBuilder(Severity.WARNING, "No halconfig changes have been made, nothing to write") .build() ); } AtomicFileWriter writer = null; try { writer = new AtomicFileWriter(path); writer.write(yamlParser.dump(objectMapper.convertValue(local, Map.class))); writer.commit(); } catch (IOException e) { throw new HalException(Severity.FATAL, "Failure writing your halconfig to path \"" + halconfigPath + "\": " + e.getMessage(), e); } finally { DaemonTaskHandler.setContext(null); if (writer != null) { writer.close(); } } } }