modify http request bug 85/18985/1
authorShiwei Tian <tian.shiwei@zte.com.cn>
Mon, 16 Oct 2017 02:51:51 +0000 (10:51 +0800)
committerShiwei Tian <tian.shiwei@zte.com.cn>
Mon, 16 Oct 2017 02:51:51 +0000 (10:51 +0800)
Issue-ID: HOLMES-71

Change-Id: I733adbe08e2c237dddb9362c90c368142ec17627
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java

index 1576215..8dd3690 100644 (file)
@@ -30,7 +30,12 @@ public class DcaeConfigurationQuery {
     public static DcaeConfigurations getDcaeConfigurations(String hostname)
             throws CorrelationException {
         String serviceAddrInfo = MicroServiceConfig.getServiceAddrInfoFromCBS(hostname);
-        String response = getDcaeResponse(serviceAddrInfo);
+        String response;
+        try {
+            response = getDcaeResponse(serviceAddrInfo);
+        } catch (Exception e) {
+            throw new CorrelationException("Failed to connect to dcae", e);
+        }
         DcaeConfigurations dcaeConfigurations = null;
         dcaeConfigurations = DcaeConfigurationParser.parse(response);
         return dcaeConfigurations;
index 285c3d6..0f96181 100644 (file)
@@ -52,8 +52,13 @@ public class Publisher {
                     e);\r
         }\r
         WebTarget webTarget = client.target(url);\r
-        Response response = webTarget.request(MediaType.APPLICATION_JSON)\r
-                .post(Entity.entity(content, MediaType.APPLICATION_JSON));\r
+        Response response = null;\r
+        try {\r
+            response = webTarget.request(MediaType.APPLICATION_JSON)\r
+                    .post(Entity.entity(content, MediaType.APPLICATION_JSON));\r
+        } catch (Exception e) {\r
+            throw new CorrelationException("Failed to connect dcae.", e);\r
+        }\r
         return checkStatus(response);\r
     }\r
 \r