use of org.yaml.snakeyaml.Yaml in project fabric8-maven-plugin by fabric8io.
the class ImageStreamServiceTest method readImageStreamDescriptor.
private Map readImageStreamDescriptor(File target) throws FileNotFoundException {
Yaml yaml = new Yaml();
InputStream ios = new FileInputStream(target);
// Parse the YAML file and return the output as a series of Maps and Lists
return (Map<String, Object>) yaml.load(ios);
}
use of org.yaml.snakeyaml.Yaml in project halyard by spinnaker.
the class GlobalApplicationOptions method getInstance.
public static GlobalApplicationOptions getInstance() {
if (GlobalApplicationOptions.options == null) {
Yaml yamlParser = new Yaml();
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;
}
use of org.yaml.snakeyaml.Yaml in project CommandHelper by EngineHub.
the class VirtualFileSystemSettings method serialize.
public static String serialize(Map<VirtualGlob, SettingGroup> settings) {
DumperOptions options = new DumperOptions();
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
Map<String, Map<String, Object>> serializable = new HashMap<String, Map<String, Object>>();
for (VirtualGlob glob : settings.keySet()) {
Map<String, Object> inner = new HashMap<String, Object>();
for (VirtualFileSystemSetting setting : settings.get(glob).settingGroup.keySet()) {
inner.put(setting.getName(), settings.get(glob).get(setting));
}
serializable.put(glob.toString(), inner);
}
return yaml.dump(serializable);
}
use of org.yaml.snakeyaml.Yaml in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationServiceImpl method create.
@Override
public void create(Hook hook, List<String> users, Object params) {
try {
// get notification template
String tpl = RELATIVE_TPL_PATH + hook.getScope().name() + "." + hook.name() + ".yml";
final Template template = freemarkerConfiguration.getTemplate(tpl);
final String yamlContent = processTemplateIntoString(template, params);
Yaml yaml = new Yaml();
Map<String, String> load = yaml.loadAs(yamlContent, HashMap.class);
List<NewPortalNotificationEntity> notifications = new ArrayList<>(users.size());
users.forEach(user -> {
NewPortalNotificationEntity notification = new NewPortalNotificationEntity();
notification.setUser(user);
notification.setTitle(load.get("title"));
notification.setMessage(load.get("message"));
notifications.add(notification);
});
create(notifications);
} catch (final Exception ex) {
LOGGER.error("Error while sending notification", ex);
throw new TechnicalManagementException("Error while sending notification", ex);
}
}
use of org.yaml.snakeyaml.Yaml in project pai by Microsoft.
the class YamlUtils method toObject.
// Bytes <-> Yaml
public static <T> T toObject(byte[] bytes, Class<T> classRef) {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(classRef), representer);
return yaml.loadAs(new String(bytes), classRef);
}
Aggregations