use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project cloudstack by apache.
the class VeeamClient method parseRestoreSessionResponse.
private RestoreSession parseRestoreSessionResponse(HttpResponse response) throws IOException {
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
return objectMapper.readValue(response.getEntity().getContent(), RestoreSession.class);
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project cloudstack by apache.
the class VeeamClient method findDCHierarchy.
// /////////////////////////////////////////////////////////////////
// ////////////// Private Veeam Helper Methods /////////////////////
// /////////////////////////////////////////////////////////////////
private String findDCHierarchy(final String vmwareDcName) {
LOG.debug("Trying to find hierarchy ID for vmware datacenter: " + vmwareDcName);
try {
final HttpResponse response = get("/hierarchyRoots");
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
for (final Ref ref : references.getRefs()) {
if (ref.getName().equals(vmwareDcName) && ref.getType().equals("HierarchyRootReference")) {
return ref.getUid();
}
}
} catch (final IOException e) {
LOG.error("Failed to list Veeam jobs due to:", e);
checkResponseTimeOut(e);
}
throw new CloudRuntimeException("Failed to find hierarchy reference for VMware datacenter " + vmwareDcName + " in Veeam, please ask administrator to check Veeam B&R manager configuration");
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project dhis2-core by dhis2.
the class StAXNodeSerializer method startSerialize.
@Override
protected void startSerialize(RootNode rootNode, OutputStream outputStream) throws Exception {
writer = xmlFactory.createXMLStreamWriter(outputStream);
generator = (new XmlFactory()).createGenerator(writer);
generator.setCodec(new XmlMapper());
writer.setDefaultNamespace(rootNode.getDefaultNamespace());
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project dhis2-core by dhis2.
the class AbstractJobParametersDeserializer method deserialize.
@Override
public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
final ObjectCodec oc = p.getCodec();
final JsonNode jsonNode;
if (oc instanceof XmlMapper) {
jsonNode = createJsonNode(p, ctxt);
return objectMapper.treeToValue(jsonNode, overrideClass);
} else {
jsonNode = oc.readTree(p);
// serialization settings
return oc.treeToValue(jsonNode, overrideClass);
}
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project dhis2-core by dhis2.
the class JobConfigurationSerializationTest method xmlWithJson.
@Test
void xmlWithJson() throws IOException {
final XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
xmlMapper.configure(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY, false);
JobConfiguration jc = xmlMapper.readValue("<jobConfiguration lastUpdated=\"2019-03-26T22:57:44.649\" id=\"uB9oC4R2nTn\" created=\"2019-03-26T22:57:44.649\" name=\"Test Analytic\">\n" + " <jobStatus>SCHEDULED</jobStatus>\n" + " <displayName>Test Analytic</displayName>\n" + " <enabled>true</enabled>\n" + " <leaderOnlyJob>true</leaderOnlyJob>\n" + " <externalAccess>false</externalAccess>\n" + " <jobType>ANALYTICS_TABLE</jobType>\n" + " <nextExecutionTime>2019-03-27T12:00:00.000</nextExecutionTime>\n" + " <favorite>false</favorite>\n" + " <configurable>true</configurable>\n" + " <access>\n" + " <read>true</read>\n" + " <update>true</update>\n" + " <externalize>false</externalize>\n" + " <delete>true</delete>\n" + " <write>true</write>\n" + " <manage>true</manage>\n" + " </access>\n" + " <lastUpdatedBy id=\"xE7jOejl9FI\"/>\n" + " <jobParameters>\n" + " <lastYears>2</lastYears>\n" + " <skipResourceTables>true</skipResourceTables>\n" + " <skipTableTypes>\n" + " <skipTableType>ENROLLMENT</skipTableType>\n" + " <skipTableType>ORG_UNIT_TARGET</skipTableType>\n" + " <skipTableType>VALIDATION_RESULT</skipTableType>\n" + " </skipTableTypes>" + " <skipPrograms>\n" + " <String>" + UID1 + "</String>\n" + " <String>" + UID2 + "</String>\n" + " </skipPrograms>" + " </jobParameters>\n" + " <cronExpression>0 0 12 ? * MON-FRI</cronExpression>\n" + " </jobConfiguration>", JobConfiguration.class);
assertEquals(JobStatus.SCHEDULED, jc.getJobStatus());
assertEquals("Test Analytic", jc.getName());
assertEquals("Test Analytic", jc.getDisplayName());
assertTrue(jc.isEnabled());
assertTrue(jc.isLeaderOnlyJob());
assertEquals(JobType.ANALYTICS_TABLE, jc.getJobType());
assertNull(jc.getNextExecutionTime());
assertEquals("0 0 12 ? * MON-FRI", jc.getCronExpression());
assertNotNull(jc.getJobParameters());
assertEquals((Integer) 2, ((AnalyticsJobParameters) jc.getJobParameters()).getLastYears());
assertTrue(((AnalyticsJobParameters) jc.getJobParameters()).isSkipResourceTables());
assertNotNull(((AnalyticsJobParameters) jc.getJobParameters()).getSkipTableTypes());
assertEquals(3, ((AnalyticsJobParameters) jc.getJobParameters()).getSkipTableTypes().size());
assertThat(((AnalyticsJobParameters) jc.getJobParameters()).getSkipTableTypes(), Matchers.hasItems(AnalyticsTableType.ENROLLMENT, AnalyticsTableType.ORG_UNIT_TARGET, AnalyticsTableType.VALIDATION_RESULT));
assertThat(((AnalyticsJobParameters) jc.getJobParameters()).getSkipPrograms(), Matchers.hasItems(UID1, UID2));
}
Aggregations