From 48c62738bf4c5653e36c6ea1e8e33e649b8526fc Mon Sep 17 00:00:00 2001 From: "Hockla, Ali (ah999m)" Date: Wed, 8 Nov 2017 17:27:16 -0600 Subject: 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) --- .../java/org/onap/policy/rest/RESTManager.java | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'controlloop/common/model-impl/rest/src/main/java/org') 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(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(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 get(String url, String username, String password, Map headers) { -- cgit 1.2.3-korg