X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Faai%2FAaiQueryMdons.java;h=892638b92d94f6e7718ef41e79158f5127a4c830;hb=6af8af01fb0cdceb384cf47cf241736620510465;hp=e2bc3579695fce3e43ebd496774139999640a663;hpb=459e4faa15c47f39c7400000cb15ca2d2123e70f;p=holmes%2Fcommon.git diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java index e2bc357..892638b 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java @@ -1,5 +1,5 @@ /** - * Copyright 2020 Fujitsu Limited. + * Copyright 2020 - 2021 Fujitsu Limited. *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -17,30 +17,22 @@ package org.onap.holmes.common.aai;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.config.AaiConfig;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.HttpsUtils;
-
-import static org.onap.holmes.common.aai.AaiJsonParserUtil.getInfo;
-import static org.onap.holmes.common.aai.AaiJsonParserUtil.getPath;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import org.onap.holmes.common.utils.JerseyClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+import java.util.HashMap;
+import java.util.Map;
-import org.jvnet.hk2.annotations.Service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.onap.holmes.common.aai.AaiJsonParserUtil.getInfo;
+import static org.onap.holmes.common.aai.AaiJsonParserUtil.getPath;
@Service
public class AaiQueryMdons {
@@ -71,32 +63,17 @@ public class AaiQueryMdons {
}
return url;
}
-
+
private String getResponse(String url) throws CorrelationException {
- String response;
- CloseableHttpClient httpClient = null;
- HttpGet httpGet = new HttpGet(url);
try {
- httpClient = HttpsUtils.getHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
- HttpResponse httpResponse = HttpsUtils.get(httpGet, getHeaders(), httpClient);
- response = HttpsUtils.extractResponseEntity(httpResponse);
+ return new JerseyClient().headers(getHeaders()).get(url);
} catch (Exception e) {
throw new CorrelationException("Failed to get data from aai", e);
- } finally {
- httpGet.releaseConnection();
- if (httpClient != null) {
- try {
- httpClient.close();
- } catch (IOException e) {
- log.warn("Failed to close http client!");
- }
- }
}
- return response;
}
- private Map