From b9e909cd35c4a0704ad9d03ef3d16a34efa0fe18 Mon Sep 17 00:00:00 2001 From: Sooriyaa Date: Mon, 17 Sep 2018 13:12:26 +0530 Subject: Fixing sonar issue in HttpClientUtil.java Fixing sonar issue in HttpClientUtil.java Issue-ID: VFC-1133 Change-Id: I168d97231f05fed548e53e8f4f1b0f91eae49a04 Signed-off-by: Sooriyaa --- .../onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java index e4bcae9..393e257 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java @@ -35,6 +35,7 @@ import org.apache.http.util.EntityUtils; public class HttpClientUtil { private static final Logger log = LoggerFactory.getLogger(HttpClientUtil.class); + public static final String APPLICATION_JSON = "application/json"; public static String doPost(String url, String json, String charset) { String result = null; @@ -44,7 +45,7 @@ public class HttpClientUtil { if (null != json) { StringEntity s = new StringEntity(json); s.setContentEncoding("UTF-8"); - s.setContentType("application/json"); // set contentType + s.setContentType(APPLICATION_JSON); // set contentType httpPost.setEntity(s); } try(CloseableHttpResponse response = httpClient.execute(httpPost)){ @@ -90,8 +91,8 @@ public class HttpClientUtil { try ( CloseableHttpClient httpClient = HttpClients.createDefault()){ HttpGet httpGet = new HttpGet(url); - httpGet.setHeader("Content-Type", "application/json"); - httpGet.setHeader("Accept", "application/json"); + httpGet.setHeader("Content-Type", APPLICATION_JSON); + httpGet.setHeader("Accept", APPLICATION_JSON); httpGet.setHeader("X-TransactionId", "111"); httpGet.setHeader("X-FromAppId", "ems-driver"); Base64 token = new Base64(); -- cgit 1.2.3-korg