use of com.fasterxml.jackson.dataformat.yaml.YAMLMapper in project streamline by hortonworks.
the class ConfigFileWriter method writeConfigToYamlTypeFile.
private void writeConfigToYamlTypeFile(Map<String, String> configuration, File destPath) throws IOException {
ObjectMapper objectMapper = new YAMLMapper();
objectMapper.writeValue(destPath, configuration);
}
use of com.fasterxml.jackson.dataformat.yaml.YAMLMapper in project service-proxy by membrane.
the class ApiManagementConfiguration method parseAndConstructConfiguration.
private void parseAndConstructConfiguration(InputStream is) throws IOException {
String yamlSource = null;
try {
yamlSource = IOUtils.toString(is);
} catch (IOException e) {
log.warn("Could not read stream");
return;
}
YAMLMapper mapper = new YAMLMapper();
Map<String, Object> yaml = null;
try {
yaml = mapper.readValue(yamlSource, Map.class);
} catch (IOException e) {
log.warn("Could not parse yaml");
return;
}
setPolicies(parsePolicies(yaml));
setKeys(parsePoliciesForKeys(yaml));
is.close();
log.info("Configuration loaded. Notifying observers");
notifyConfigChangeObservers();
}
use of com.fasterxml.jackson.dataformat.yaml.YAMLMapper in project hub-detect by blackducksoftware.
the class CocoapodsPackager method extractDependencyGraph.
public DependencyGraph extractDependencyGraph(final String podLockText) throws IOException {
YAMLMapper mapper = new YAMLMapper();
PodfileLock podfileLock = mapper.readValue(podLockText, PodfileLock.class);
NameVersionNode root = new NameVersionNode();
root.setName(String.format("detectRootNode - %s", UUID.randomUUID()));
final SubcomponentNodeBuilder builder = new SubcomponentNodeBuilder(root);
for (Pod pod : podfileLock.getPods()) {
buildNameVersionNode(builder, pod);
}
;
for (Pod dependency : podfileLock.getDependencies()) {
NameVersionNode child = new NameVersionNode();
child.setName(cleanPodName(dependency.getName()));
builder.addChildNodeToParent(child, root);
}
;
if (null != podfileLock.getExternalSources() && !podfileLock.getExternalSources().getSources().isEmpty()) {
for (PodSource podSource : podfileLock.getExternalSources().getSources()) {
NodeMetadata nodeMetadata = createMetadata(builder, podSource.getName());
if (null != podSource.getGit() && podSource.getGit().contains("github")) {
// Change the forge to GitHub when there is better KB support
nodeMetadata.setForge(Forge.COCOAPODS);
} else if (null != podSource.getPath() && podSource.getPath().contains("node_modules")) {
nodeMetadata.setForge(Forge.NPM);
}
}
}
MutableDependencyGraph graph = new MutableMapDependencyGraph();
for (NameVersionNode nameVersionNode : builder.build().getChildren()) {
Dependency childDependency = nameVersionNodeTransformer.addNameVersionNodeToDependencyGraph(graph, Forge.COCOAPODS, nameVersionNode);
graph.addChildToRoot(childDependency);
}
return graph;
}
use of com.fasterxml.jackson.dataformat.yaml.YAMLMapper in project logging-log4j2 by apache.
the class StackTraceElementYamlMixInTest method testFromYamlWithSimpleModule.
@Test
public void testFromYamlWithSimpleModule() throws Exception {
final ObjectMapper mapper = new YAMLMapper();
final SimpleModule module = new SimpleModule();
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final StackTraceElement actual = mapper.readValue("---\nclass: package.SomeClass\nmethod: someMethod\nfile: SomeClass.java\nline: 123\n...", StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
use of com.fasterxml.jackson.dataformat.yaml.YAMLMapper in project fess by codelibs.
the class PluginHelper method loadArtifactsFromRepository.
protected List<Artifact> loadArtifactsFromRepository(final String url) {
final String content = getRepositoryContent(url);
final ObjectMapper objectMapper = new YAMLMapper();
try {
@SuppressWarnings("unchecked") final List<Map<?, ?>> result = objectMapper.readValue(content, List.class);
if (result != null) {
return result.stream().map(o -> new Artifact((String) o.get("name"), (String) o.get("version"), (String) o.get("url"))).collect(Collectors.toList());
}
return Collections.emptyList();
} catch (final Exception e) {
throw new PluginException("Failed to access " + url, e);
}
}
Aggregations