- URL inventoryUrl = new URL(fullUrl);\r
-\r
- HttpURLConnection conn = (HttpURLConnection) inventoryUrl.openConnection();\r
- conn.setRequestMethod("GET");\r
- String reqid = LoggingUtils.getRequestId();\r
- logger.info("reqid set to " + reqid);\r
- conn.setRequestProperty("X-ECOMP-RequestID", reqid);\r
-\r
- boolean requestFailed = true;\r
- int responseCode = conn.getResponseCode();\r
- if (responseCode == 200) {\r
- requestFailed = false;\r
- }\r
-\r
- StringBuilder response = new StringBuilder();\r
-\r
- try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {\r
- String inputLine = null;\r
-\r
- while ((inputLine = in.readLine()) != null) {\r
- response.append(inputLine);\r
- }\r
- }\r
- String responseStr = response.toString();\r
- if (responseStr != null) {\r
- if (requestFailed) {\r
- logger.error("requestFailed - responseStr=" + response);\r
- throw new BadRequestException(responseStr);\r
- }\r
- }\r
- String jsonResponseString = response.toString();\r