aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java9
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java2
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java4
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java24
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java18
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml15
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/application.yaml2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java20
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java36
15 files changed, 122 insertions, 25 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
index 0541a8f51b..9ee8a09ea6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
@@ -40,6 +40,7 @@ import org.yaml.snakeyaml.Yaml;
public class MsoYamlEditorWithEnvt {
private static final Logger logger = LoggerFactory.getLogger(MsoYamlEditorWithEnvt.class);
+ public static final String EXCEPTION = "Exception:";
private Map<String, Object> yml;
private Yaml yaml = new Yaml();
@@ -68,7 +69,7 @@ public class MsoYamlEditorWithEnvt {
try {
resourceMap = (Map<String, Object>) yml.get("parameters");
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
return paramSet;
}
if (resourceMap == null) {
@@ -89,7 +90,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
value = "_BAD_JSON_MAPPING";
}
} else {
@@ -118,7 +119,7 @@ public class MsoYamlEditorWithEnvt {
}
return resourceList;
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
}
return null;
}
@@ -137,7 +138,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = resourceEntry.get("default");
} catch (ClassCastException cce) {
- logger.debug("Exception:", cce);
+ logger.debug(EXCEPTION, cce);
// This exception only - the value is an integer. For what we're doing
// here - we don't care - so set value to something - and it will
// get marked as not being required - which is correct.
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
index a4cdba22a1..16671bbe50 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"id", "links"})
public class MulticloudCreateHeatResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("id")
private String id;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
index e8a5b1480e..1f55aa92a2 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"href", "rel"})
public class MulticloudCreateLinkResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("href")
private String href;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
index bb15e58c88..fc08201bcb 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"template_type", "workload_id", "template_response"})
public class MulticloudCreateResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("template_type")
private String templateType;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
index 67cb73539d..67d1cbff4e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"stack"})
public class MulticloudCreateStackResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("stack")
private MulticloudCreateHeatResponse stack;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
index a22937aea3..ad37b39f30 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"template_type", "workload_id", "workload_status", "workload_status_reason"})
public class MulticloudQueryResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("template_type")
private String templateType;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
index b733552a2b..95dd48caa6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
"vf-module-model-customization-id", "oof_directives", "sdnc_directives", "user_directives", "template_type",
"template_data"})
public class MulticloudRequest implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("generic-vnf-id")
private String genericVnfId;
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
index 23bbbb3f43..7a2d4ec3e1 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
@@ -24,6 +24,8 @@ package org.onap.so.adapters.vnfrest;
import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -71,7 +73,7 @@ public abstract class VfResponseCommon {
public String toXmlString() {
try {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
- JAXBContext context = JAXBContext.newInstance(this.getClass());
+ JAXBContext context = JAXBContext.newInstance(this.getClass(), ArrayList.class, HashMap.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // pretty print XML
marshaller.marshal(this, bs);
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java
index d20d2b7758..0327fd67a3 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java
@@ -20,9 +20,16 @@
package org.onap.so.openstack.mappers;
+import java.util.List;
+import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class MapElements {
+ private static final Logger logger = LoggerFactory.getLogger(MapElements.class);
@XmlElement
public String key;
@XmlElement
@@ -32,6 +39,21 @@ public class MapElements {
public MapElements(String key, Object value) {
this.key = key;
- this.value = value;
+ // this is required to handle marshalling raw json
+ // always write values as strings for XML
+ if (value != null) {
+ if (value instanceof List || value instanceof Map) {
+ try {
+ this.value = new ObjectMapper().writeValueAsString(value);
+ } catch (JsonProcessingException e) {
+ logger.warn("could not marshal value to json, calling toString");
+ this.value = value.toString();
+ }
+ } else {
+ this.value = value;
+ }
+ } else {
+ this.value = value;
+ }
}
}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
index 8d27e54892..189d4cca3e 100644
--- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
@@ -24,17 +24,19 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Arrays;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.junit.Test;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class JAXBMarshallingTest {
@Test
- public void xmlMarshalTest() throws IOException, JAXBException {
+ public void xmlUnMarshalTest() throws IOException, JAXBException {
JAXBContext context = JAXBContext.newInstance(CreateVfModuleRequest.class);
CreateVfModuleRequest request = (CreateVfModuleRequest) context.createUnmarshaller().unmarshal(
@@ -43,6 +45,20 @@ public class JAXBMarshallingTest {
assertEquals("ubuntu-16-04-cloud-amd64", request.getVfModuleParams().get("vcpe_image_name"));
assertEquals("10.2.0.0/24", request.getVfModuleParams().get("cpe_public_net_cidr"));
assertEquals("", request.getVfModuleParams().get("workload_context"));
+ assertEquals("[\"a\",\"b\",\"c\"]", request.getVfModuleParams().get("raw-json-param"));
+ }
+
+ @Test
+ public void xmlMarshalTest() throws IOException, JAXBException {
+
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.getVfModuleParams().put("test-null", null);
+ request.getVfModuleParams().put("test array", Arrays.asList("a", "b", "c"));
+
+ assertEquals("documents are equal",
+ new String(Files
+ .readAllBytes(Paths.get("src/test/resources/VfRequest-marshalled-with-complex-object.xml"))),
+ request.toXmlString());
}
diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
new file mode 100644
index 0000000000..ce175127df
--- /dev/null
+++ b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<createVfModuleRequest>
+ <failIfExists>false</failIfExists>
+ <backout>true</backout>
+ <vfModuleParams>
+ <entry>
+ <key>test array</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">["a","b","c"]</value>
+ </entry>
+ <entry>
+ <key>test-null</key>
+ </entry>
+ </vfModuleParams>
+ <msoRequest/>
+</createVfModuleRequest>
diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml b/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
index 1ff24a50f6..2718f1df61 100644
--- a/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
+++ b/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
@@ -1,4 +1,4 @@
-<createVfModuleRequest>
+ <createVfModuleRequest>
<cloudSiteId>RegionOne</cloudSiteId>
<cloudOwner>CloudOwner</cloudOwner>
<tenantId>09d8566ea45e43aa974cf447ed591d77</tenantId>
@@ -196,7 +196,10 @@
<key>vf_module_index</key>
<value>0</value>
</entry>
-
+ <entry>
+ <key>raw-json-param</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">["a","b","c"]</value>
+ </entry>
</vfModuleParams>
<msoRequest>
<requestId>11c8ec20-a1f8-4aa2-926f-e55d67a30f8b</requestId>
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml
index aa9317c920..b1528a0897 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml
@@ -52,4 +52,4 @@ management:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
- \ No newline at end of file
+
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
index 38dd9089e1..b4cdcb45e2 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
@@ -20,7 +20,6 @@
package org.onap.so.adapters.inventory.create;
-import java.io.IOException;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
@@ -47,17 +46,16 @@ public class CreateInventoryTask {
public Environment env;
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ setupMDC(externalTask);
boolean success = true;
String auditInventoryString = externalTask.getVariable("auditInventoryResult");
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
AAIObjectAuditList auditInventory = null;
try {
+ GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
auditInventory = objectMapper.getMapper().readValue(auditInventoryString, AAIObjectAuditList.class);
- } catch (IOException e1) {
- success = false;
+ } catch (Exception e) {
+ logger.error("Error Parsing Audit Results", e);
}
- setupMDC(externalTask);
-
if (auditInventory != null) {
try {
logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", auditInventory,
@@ -96,9 +94,13 @@ public class CreateInventoryTask {
}
private void setupMDC(ExternalTask externalTask) {
- String msoRequestId = (String) externalTask.getVariable("mso-request-id");
- if (msoRequestId != null && !msoRequestId.isEmpty())
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ try {
+ String msoRequestId = (String) externalTask.getVariable("mso-request-id");
+ if (msoRequestId != null && !msoRequestId.isEmpty())
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ } catch (Exception e) {
+ logger.error("Error in setting up MDC", e);
+ }
}
protected long calculateRetryDelay(int currentRetries) {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java
new file mode 100644
index 0000000000..03622db655
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java
@@ -0,0 +1,36 @@
+package org.onap.so.adapters.inventory.create;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+public class CreateInventoryTaskTest {
+
+ @Mock
+ ExternalTask externalTask;
+
+ @Mock
+ ExternalTaskService externalTaskService;
+
+ @InjectMocks
+ CreateInventoryTask inventoryTask;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test_Runtime_Parse_Exception() {
+ doReturn(null).when(externalTask).getVariable("auditInventoryResult");
+ inventoryTask.executeExternalTask(externalTask, externalTaskService);
+ Mockito.verify(externalTaskService, times(1)).handleBpmnError(externalTask, "AAIInventoryFailure");
+ }
+}