aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/rest/src
diff options
context:
space:
mode:
authorHockla, Ali (ah999m) <ah999m@att.com>2017-11-08 17:27:16 -0600
committerHockla, Ali (ah999m) <ah999m@att.com>2017-11-08 17:33:31 -0600
commit48c62738bf4c5653e36c6ea1e8e33e649b8526fc (patch)
treeb80c35c608012e842861ef14cb9034a86406ac40 /controlloop/common/model-impl/rest/src
parent9cbbe8c6abd790ab84ff47214db1f63bb5c2e1d7 (diff)
Fix SO Request body
- Renamed modelNameVersionId to modelVersionId in SOModelInfo - Removed requestID from SO Request body - As a result of this, an SOResponseWrapper was needed in order to attach the control loop event requestId to use in the SOResponse rule in drl (the requestID that is returned in the SO response is a newly generated requestId with no relation to the Policy control loop event requestId as per Arthur) - Updated drl to reflect the above mentioned change - Updated simulator and junits to reflect changes - Added an additional null httpResponse check/logger statement in SOManager and RestManager Issue-ID: POLICY-438 Change-Id: I5f414ba69b60b5565cca9073b47f4c4835e5abbf Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
Diffstat (limited to 'controlloop/common/model-impl/rest/src')
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index 9ea480981..e2d140c03 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -79,19 +79,21 @@ public final class RESTManager {
post.setEntity(input);
HttpResponse response = client.execute(post);
-
- String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
- logger.debug("HTTP POST Response Body:");
- logger.debug(returnBody);
-
- return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
- } catch (IOException e) {
+ if (response != null) {
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+ logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
+
+ return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
+ } else {
+ logger.error("Response from {} is null", url);
+ return null;
+ }
+ } catch (Exception e) {
logger.error("Failed to POST to {}",url,e);
-
return null;
- }
-
+ }
}
public static Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {