diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2018-11-28 20:06:29 +0800 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2018-11-28 20:08:21 +0800 |
commit | e5aae68146ed7311698358a50da39d8aa2198c7b (patch) | |
tree | fe55a8327e9bc912c768ec8224bcf018ba734aff /bpmn | |
parent | 52536a87de7addf8994f44692e84b918f62e2e14 (diff) |
Correct the http client auth issue
Issue-ID: SO-1257
Change-Id: Iac3cf2cf594b9b3224b5741d8589c7d3b9c5e205
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'bpmn')
-rw-r--r-- | bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index b4851ee7a4..5e05637bca 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -47,6 +47,9 @@ import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.client.HttpClient; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient; +import org.onap.so.rest.RESTConfig; import org.onap.so.utils.TargetEntity; import com.fasterxml.jackson.core.JsonProcessingException; @@ -261,10 +264,20 @@ public class ResourceRequestBuilder { private static String getCsarFromUuid(String uuid) throws Exception { String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint"); - HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB); - - Response response = client.get(); - String value = response.readEntity(String.class); + + RESTClient restClient = new RESTClient(new RESTConfig( + UriBuilder.fromUri(catalogEndPoint) + .path(SERVICE_URL_TOSCA_CSAR) + .queryParam("serviceModelUuid", uuid) + .build().toURL().toString() + )); + + restClient.addHeader("Accept", "application/json"); + restClient.addAuthorizationHeader(UrnPropertiesReader.getVariable("mso.db.auth")); + + APIResponse apiResponse = restClient.httpGet(); + + String value = apiResponse.getResponseBodyAsString(); HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType()); |