use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project streamline by hortonworks.
the class ConfigFileReader method readConfigFromHadoopXmlType.
private Map<String, String> readConfigFromHadoopXmlType(InputStream configFileStream) throws IOException {
ObjectReader reader = new XmlMapper().reader();
HadoopXml hadoopXml = reader.forType(HadoopXml.class).readValue(configFileStream);
Map<String, String> configMap = new HashMap<>();
for (HadoopXml.HadoopXmlProperty property : hadoopXml.getProperties()) {
configMap.put(property.getName(), property.getValue());
}
return configMap;
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project jocean-http by isdom.
the class MessageUtil method unserializeAsXml.
public static <T> T unserializeAsXml(final InputStream is, final Class<T> type) {
final XmlMapper mapper = new XmlMapper();
mapper.addHandler(new DeserializationProblemHandler() {
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser p, final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName) throws IOException {
LOG.warn("UnknownProperty [{}], just skip", propertyName);
p.skipChildren();
return true;
}
});
try {
return mapper.readValue(is, type);
} catch (Exception e) {
LOG.warn("exception when parse as xml, detail: {}", ExceptionUtils.exception2detail(e));
return null;
}
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project cypher-for-gremlin by opencypher.
the class TckResultsComparator method getFeatures.
private static Features getFeatures(String reportPath) throws IOException {
File reportFile = new File(reportPath);
checkState(reportFile.exists(), format("File %s doesn't exist, but is required for TCK reports comparison.", reportPath));
ObjectMapper xmlMapper = new XmlMapper();
xmlMapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE);
xmlMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
Feature value = xmlMapper.readValue(reportFile, Feature.class);
return new Features(new Feature[] { value });
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project metron by apache.
the class PcapServiceImpl method getPdml.
@Override
public Pdml getPdml(String username, String jobId, Integer page) throws RestException {
Pdml pdml = null;
Path path = getPath(username, jobId, page);
try {
FileSystem fileSystem = getFileSystem();
if (path != null && fileSystem.exists(path)) {
String scriptPath = environment.getProperty(MetronRestConstants.PCAP_PDML_SCRIPT_PATH_SPRING_PROPERTY);
InputStream processInputStream = pcapToPdmlScriptWrapper.execute(scriptPath, fileSystem, path);
pdml = new XmlMapper().readValue(processInputStream, Pdml.class);
processInputStream.close();
}
} catch (IOException e) {
throw new RestException(e);
}
return pdml;
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method hasParentModule.
/**
* If module has parent defined.
*
* @param moduleName
* @return true = is submodule.
*/
protected boolean hasParentModule(String moduleName) {
File modulePackage = new File(String.format("%s/pom.xml", getBackendModuleBasePath(moduleName)));
Assert.isTrue(modulePackage.exists(), String.format("Backend module [%s] not found on filesystem.", moduleName));
//
try {
XmlMapper xmlMapper = new XmlMapper();
JsonNode json = xmlMapper.readTree(modulePackage);
//
return json.get("parent") != null;
} catch (Exception ex) {
throw new ReleaseException(ex);
}
}
Aggregations