X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=engine-d%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fdsa%2Fdmaappolling%2FSubscriber.java;h=8c3d4f56d87a17ac19b7398a080d42a4d48c51c6;hb=a2d41239cd468bd2894336353b31007dfe99bf81;hp=245647df1f4fed6b39b3823f69c7643beffdb29d;hpb=3f438510b3aae2372b33d4d976cd10482a07492a;p=holmes%2Fengine-management.git diff --git a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java index 245647d..8c3d4f5 100644 --- a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java +++ b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java @@ -19,18 +19,13 @@ package org.onap.holmes.dsa.dmaappolling; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.onap.holmes.common.api.stat.VesAlarm; import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder; import org.onap.holmes.common.exception.CorrelationException; -import org.onap.holmes.common.utils.GsonUtil; -import org.onap.holmes.common.utils.HttpsUtils; +import org.onap.holmes.common.utils.JerseyClient; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -82,31 +77,15 @@ public class Subscriber { } } - private List getDMaaPData() throws Exception { - String response; - CloseableHttpClient closeableHttpClient = null; - HttpGet httpGet = new HttpGet(url + "/" + consumerGroup + "/" + consumer + "?timeout=" + period); - try { - closeableHttpClient = HttpsUtils.getConditionalHttpsClient(timeout); - HttpResponse httpResponse = HttpsUtils - .get(httpGet, new HashMap<>(), closeableHttpClient); - response = HttpsUtils.extractResponseEntity(httpResponse); - } catch (Exception e) { - throw e; - } finally { - httpGet.releaseConnection(); - if (closeableHttpClient != null) { - try { - closeableHttpClient.close(); - } catch (IOException e) { - log.warn("Failed to close http client!"); - } - } - } - return GsonUtil.jsonToBean(response, List.class); + private List getDMaaPData() { + return JerseyClient.newInstance() + .path(consumerGroup) + .path(consumer) + .queryParam("timeout", period) + .get(url, List.class); } - private List extractVesAlarm(List responseEntity) throws IOException { + private List extractVesAlarm(List responseEntity) { List vesAlarmList = new ArrayList<>(); for (String entity : responseEntity) { vesAlarmList.add(dMaaPResponseUtil.convertJsonToVesAlarm(entity));