aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/so/src/main
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-11-09 04:03:10 +0000
committerGerrit Code Review <gerrit@onap.org>2017-11-09 04:03:10 +0000
commit40d761966d4c867007015c894b5dd783edf96cfd (patch)
tree70365857e1de82b7bfd5efadce34677db0267df4 /controlloop/common/model-impl/so/src/main
parentb444334ec9d80aabb6dc7cefae1f2dfd3dd62577 (diff)
parent48c62738bf4c5653e36c6ea1e8e33e649b8526fc (diff)
Merge "Fix SO Request body"
Diffstat (limited to 'controlloop/common/model-impl/so/src/main')
-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
3 files changed, 98 insertions, 10 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;
+ }
+
+}