Make HTTP/s Optional
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / dmaap / Publisher.java
index b3a9214..d95853d 100644 (file)
@@ -17,12 +17,11 @@ package org.onap.holmes.common.dmaap;
 \r
 import java.io.IOException;\r
 import lombok.extern.slf4j.Slf4j;\r
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;\r
 import org.apache.http.client.methods.HttpPost;\r
 import org.apache.http.impl.client.CloseableHttpClient;\r
 import org.onap.holmes.common.dmaap.entity.PolicyMsg;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
-import com.alibaba.fastjson.JSON;\r
+import com.google.gson.Gson;\r
 import java.util.HashMap;\r
 import javax.ws.rs.core.MediaType;\r
 import lombok.Getter;\r
@@ -47,7 +46,8 @@ public class Publisher {
     public boolean publish(PolicyMsg msg) throws CorrelationException {\r
         String content;\r
         try {\r
-            content = JSON.toJSONString(msg);\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
@@ -59,7 +59,7 @@ public class Publisher {
         CloseableHttpClient httpClient = null;\r
         HttpPost httpPost = new HttpPost(url);\r
         try {\r
-            httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+            httpClient = HttpsUtils.getConditionalHttpsClient(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