aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/so
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl/so')
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java23
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java4
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java81
-rw-r--r--controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java12
4 files changed, 104 insertions, 16 deletions
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
index c3828bb79..4ac98054f 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
@@ -135,7 +135,7 @@ public final class SOManager {
*
* This method makes an asynchronous Rest call to MSO and inserts the response into the Drools working memory
*/
- public void asyncSORestCall(WorkingMemory wm, String serviceInstanceId, String vnfInstanceId, SORequest request) {
+ public void asyncSORestCall(String requestID, WorkingMemory wm, String serviceInstanceId, String vnfInstanceId, SORequest request) {
executors.submit(new Runnable()
{
@Override
@@ -165,19 +165,26 @@ public final class SOManager {
netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), soJson);
Pair<Integer, String> httpResponse = RESTManager.post(url, "policy", "policy", headers, "application/json", soJson);
- if (httpResponse != null) {
- netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b);
+ if (httpResponse != null ) {
+ if (httpResponse.b != null && httpResponse.a != null) {
+ netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b);
+
+ Gson gson = new Gson();
+ so = gson.fromJson(httpResponse.b, SOResponse.class);
+ so.httpResponseCode = httpResponse.a;
+ } else {
+ logger.error("SO Response status/code is null.");
+ so.httpResponseCode = 999;
+ }
- Gson gson = new Gson();
- so = gson.fromJson(httpResponse.b, SOResponse.class);
- so.httpResponseCode = httpResponse.a;
} else {
logger.error("SO Response returned null.");
so.httpResponseCode = 999;
}
- wm.insert(so);
- logger.info("SOResponse inserted " + gsonPretty.toJson(so));
+ SOResponseWrapper SoWrapper = new SOResponseWrapper(so, requestID);
+ wm.insert(SoWrapper);
+ logger.info("SOResponse inserted " + gsonPretty.toJson(SoWrapper));
} catch (Exception e) {
logger.error("Error while performing asyncSORestCall: "+ e.getMessage(),e);
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java
index 94070ba9a..c6e138a2a 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java
@@ -38,8 +38,8 @@ public class SOModelInfo implements Serializable {
@SerializedName("modelInvariantId")
public String modelInvariantId;
- @SerializedName("modelNameVersionId")
- public String modelNameVersionId;
+ @SerializedName("modelVersionId")
+ public String modelVersionId;
@SerializedName("modelName")
public String modelName;
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java
new file mode 100644
index 000000000..6b2017eb2
--- /dev/null
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.so;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SOResponseWrapper implements Serializable {
+
+ private static final long serialVersionUID = 7673023687132889069L;
+
+ @SerializedName("SOResponse")
+ public SOResponse SOResponse;
+ public transient String requestID;
+
+
+ public SOResponseWrapper(SOResponse response, String reqID) {
+ this.SOResponse = response;
+ this.requestID = reqID;
+ }
+
+ @Override
+ public String toString() {
+ return "SOResponseWrapper [SOResponse=" + SOResponse + ", RequestID=" + requestID + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((SOResponse == null) ? 0 : SOResponse.hashCode());
+ result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SOResponseWrapper other = (SOResponseWrapper) obj;
+ if (SOResponse == null) {
+ if (other.SOResponse != null) {
+ return false;
+ }
+ } else if (!SOResponse.equals(other.SOResponse)) {
+ return false;
+ }
+ if (requestID == null) {
+ if (other.requestID != null) {
+ return false;
+ }
+ } else if (!requestID.equals(other.requestID)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java
index af8f4be0e..79f8d9392 100644
--- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java
+++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java
@@ -50,7 +50,7 @@ public class TestDemo {
request.requestDetails.modelInfo.modelType = "vfModule";
request.requestDetails.modelInfo.modelInvariantId = "ff5256d2-5a33-55df-13ab-12abad84e7ff";
- request.requestDetails.modelInfo.modelNameVersionId = "fe6478e5-ea33-3346-ac12-ab121484a3fe";
+ request.requestDetails.modelInfo.modelVersionId = "fe6478e5-ea33-3346-ac12-ab121484a3fe";
request.requestDetails.modelInfo.modelName = "vSAMP12..base..module-0";
request.requestDetails.modelInfo.modelVersion = "1";
@@ -77,7 +77,7 @@ public class TestDemo {
relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "service";
relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "fe6985cd-ea33-3346-ac12-ab121484a3fe";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = "fe6985cd-ea33-3346-ac12-ab121484a3fe";
relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "parent service model name";
relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1.0";
@@ -85,7 +85,7 @@ public class TestDemo {
relatedInstanceListElement3.relatedInstance.modelInfo = new SOModelInfo();
relatedInstanceListElement3.relatedInstance.modelInfo.modelType = "vnf";
relatedInstanceListElement3.relatedInstance.modelInfo.modelInvariantId = "ff5256d1-5a33-55df-13ab-12abad84e7ff";
- relatedInstanceListElement3.relatedInstance.modelInfo.modelNameVersionId = "fe6478e4-ea33-3346-ac12-ab121484a3fe";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelVersionId = "fe6478e4-ea33-3346-ac12-ab121484a3fe";
relatedInstanceListElement3.relatedInstance.modelInfo.modelName = "vSAMP12";
relatedInstanceListElement3.relatedInstance.modelInfo.modelVersion = "1.0";
relatedInstanceListElement3.relatedInstance.modelInfo.modelCustomizationName = "vSAMP12 1";
@@ -123,7 +123,7 @@ public class TestDemo {
request.requestDetails.modelInfo.modelType = "vfModule";
request.requestDetails.modelInfo.modelInvariantId = "a9c4a35a-de48-451a-9e4e-343f2ac52928";
- request.requestDetails.modelInfo.modelNameVersionId = "e0d98ad1-238d-4555-b439-023d3f9079f6";
+ request.requestDetails.modelInfo.modelVersionId = "e0d98ad1-238d-4555-b439-023d3f9079f6";
request.requestDetails.modelInfo.modelName = "0d9e0d9d352749f4B3cb..dnsscaling..module-0";
request.requestDetails.modelInfo.modelVersion = "2.0";
@@ -144,7 +144,7 @@ public class TestDemo {
relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "24329a0c-1d57-4210-b1af-a65df64e9d59";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "ac642881-8e7e-4217-bd64-16ad41c42e30";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersionId = "ac642881-8e7e-4217-bd64-16ad41c42e30";
relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "5116d67e-0b4f-46bf-a46f";
relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "2.0";
@@ -153,7 +153,7 @@ public class TestDemo {
relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "09fd971e-db5f-475d-997c-cf6704b6b8fe";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "152ed917-6dcc-46ee-bf8a-a775c5aa5a74";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = "152ed917-6dcc-46ee-bf8a-a775c5aa5a74";
relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "9e4c31d2-4b25-4d9e-9fb4";
relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "2.0";
relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "0d9e0d9d-3527-49f4-b3cb 2";