X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Fdmaap%2FPublisher.java;h=d95853d2f8f3897c435586dbb41e41bbb7f9614a;hb=58401075a66f7c5963848a7349067f995fe4f947;hp=b3a92145050e7c589814c32abef8ffd80d51c3df;hpb=3356fb82b20ebe7209522e4e009dd6aea5ed1802;p=holmes%2Fcommon.git diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java index b3a9214..d95853d 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java @@ -17,12 +17,11 @@ package org.onap.holmes.common.dmaap; import java.io.IOException; import lombok.extern.slf4j.Slf4j; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.onap.holmes.common.dmaap.entity.PolicyMsg; import org.onap.holmes.common.exception.CorrelationException; -import com.alibaba.fastjson.JSON; +import com.google.gson.Gson; import java.util.HashMap; import javax.ws.rs.core.MediaType; import lombok.Getter; @@ -47,7 +46,8 @@ public class Publisher { public boolean publish(PolicyMsg msg) throws CorrelationException { String content; try { - content = JSON.toJSONString(msg); + //content = JSON.toJSONString(msg); + content = new Gson().toJson(msg); } catch (Exception e) { throw new CorrelationException("Failed to convert the message object to a json string.", e); @@ -59,7 +59,7 @@ public class Publisher { CloseableHttpClient httpClient = null; HttpPost httpPost = new HttpPost(url); try { - httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); + httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT); httpResponse = HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient); } catch (Exception e) { throw new CorrelationException("Failed to connect to DCAE.", e);