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=5c6965a37769c611c3f0512f4edd2eefb60f5063;hb=83307e37a264972f4f9c60a114f40a375e32634b;hp=0f96181c6e3f56a143f799df18888c648682ceaf;hpb=6c9ff5b3edcb451bb61ff2180e30f79339434d1f;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 0f96181..5c6965a 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 @@ -15,8 +15,7 @@ */ package org.onap.holmes.common.dmaap; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.alibaba.fastjson.JSON; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; @@ -43,26 +42,19 @@ public class Publisher { public boolean publish(PolicyMsg msg) throws CorrelationException { Client client = ClientBuilder.newClient(new ClientConfig()); - ObjectMapper mapper = new ObjectMapper(); - String content = null; - try { - content = mapper.writeValueAsString(msg); - } catch (JsonProcessingException e) { - throw new CorrelationException("Failed to convert the message object to a json string.", - e); - } + String content = JSON.toJSONString(msg); WebTarget webTarget = client.target(url); Response response = null; try { response = webTarget.request(MediaType.APPLICATION_JSON) .post(Entity.entity(content, MediaType.APPLICATION_JSON)); } catch (Exception e) { - throw new CorrelationException("Failed to connect dcae.", e); + throw new CorrelationException("Failed to connect to DCAE.", e); } return checkStatus(response); } private boolean checkStatus(Response response) { - return (response.getStatus() == HttpStatus.SC_OK) ? true : false; + return response.getStatus() == HttpStatus.SC_OK; } }