Code improvement
[clamp.git] / src / main / java / org / onap / clamp / clds / client / DcaeDispatcherServices.java
index 343391e..e5144bf 100644 (file)
@@ -129,25 +129,26 @@ public class DcaeDispatcherServices {
      */\r
     public String getOperationStatus(String statusUrl) throws Exception {\r
 \r
-        String opStatus = null;\r
+        //Assigning processing status to monitor operation status further\r
+        String opStatus = "processing";\r
         InputStream in = null;\r
         try {\r
             URL obj = new URL(statusUrl);\r
             HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
             conn.setRequestMethod("GET");\r
             int responseCode = conn.getResponseCode();\r
-            logger.debug("response code " + responseCode);\r
-            in = conn.getInputStream();\r
-            String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
-            JSONParser parser = new JSONParser();\r
-            Object obj0 = parser.parse(res);\r
-            JSONObject jsonObj = (JSONObject) obj0;\r
-            String operationType = (String) jsonObj.get("operationType");\r
-            String status = (String) jsonObj.get("status");\r
-            logger.debug("Operation Type " + operationType);\r
-            logger.debug("Status " + status);\r
-            opStatus = status;\r
-\r
+            logger.debug("Deployment operation status response code - " + responseCode);\r
+            if(responseCode == 200){\r
+                in = conn.getInputStream();\r
+                String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
+                JSONParser parser = new JSONParser();\r
+                Object obj0 = parser.parse(res);\r
+                JSONObject jsonObj = (JSONObject) obj0;\r
+                String operationType = (String) jsonObj.get("operationType");\r
+                String status = (String) jsonObj.get("status");\r
+                logger.debug("Operation Type - " + operationType + ", Status " + status);\r
+                opStatus = status;\r
+            }\r
         } catch (Exception e) {\r
             logger.debug(e.getClass().getName() + " " + e.getMessage());\r
             logger.debug(e.getMessage()\r