- private String authInfo;\r
- private String authExpDate;\r
-\r
- public boolean publish(PolicyMsg msg) throws CorrelationException {\r
- String content;\r
- try {\r
- //content = JSON.toJSONString(msg);\r
- content = new Gson().toJson(msg);\r
- } catch (Exception e) {\r
- throw new CorrelationException("Failed to convert the message object to a json string.",\r
- e);\r
- }\r
- HttpResponse httpResponse;\r
- HashMap<String, String> headers = new HashMap<>();\r
- headers.put("Accept", MediaType.APPLICATION_JSON);\r
- headers.put("Content-Type", MediaType.APPLICATION_JSON);\r
- CloseableHttpClient httpClient = null;\r
- HttpPost httpPost = new HttpPost(url);\r
- try {\r
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
- httpResponse = HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient);\r
- } catch (Exception e) {\r
- throw new CorrelationException("Failed to connect to DCAE.", e);\r
- } finally {\r
- httpPost.releaseConnection();\r
- if (httpClient != null) {\r
- try {\r
- httpClient.close();\r
- } catch (IOException e) {\r
- log.warn("Failed to close http client!");\r
- }\r
- }\r
- }\r
- return checkStatus(httpResponse);\r
- }\r