summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiGetServiceInstanceClient.java23
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiHttpGetClient.java21
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/patch/AaiHttpPatchClient.java29
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/put/AaiHttpPutClient.java18
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/impl/AaiRequests.java85
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/AbstractHttpClientTest.java3
6 files changed, 45 insertions, 134 deletions
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiGetServiceInstanceClient.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiGetServiceInstanceClient.java
index e6490c62..89f35154 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiGetServiceInstanceClient.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiGetServiceInstanceClient.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.dcaegen2.services.prh.adapter.aai.api.get;
-import static org.onap.dcaegen2.services.prh.adapter.aai.impl.AaiRequests.createAaiGetRequest;
import static org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFactory.createRequestDiagnosticContext;
import io.vavr.collection.HashMap;
@@ -29,10 +28,10 @@ import org.apache.commons.text.StringSubstitutor;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiHttpClient;
import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiServiceInstanceQueryModel;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.ImmutableHttpRequest;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
-import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
import reactor.core.publisher.Mono;
public class AaiGetServiceInstanceClient implements
@@ -59,15 +58,13 @@ public class AaiGetServiceInstanceClient implements
SERVICE_INSTANCE_ID, aaiModel.serviceInstanceId());
final StringSubstitutor substitutor = new StringSubstitutor(mapping.toJavaMap());
- final String replaced = substitutor.replace(configuration.aaiServiceInstancePath());
+ final String endpoint = substitutor.replace(configuration.aaiServiceInstancePath());
- final HttpRequest getRequest = createAaiGetRequest(getUri(replaced),
- createRequestDiagnosticContext(), configuration.aaiHeaders());
-
- return httpClient.call(getRequest);
- }
-
- private String getUri(final String endpoint) {
- return new URI.URIBuilder().path(configuration.baseUrl() + endpoint).build().toString();
+ return httpClient.call(ImmutableHttpRequest.builder()
+ .method(HttpMethod.GET)
+ .url(configuration.baseUrl() + endpoint)
+ .customHeaders(HashMap.ofAll(configuration.aaiHeaders()))
+ .diagnosticContext(createRequestDiagnosticContext())
+ .build());
}
}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiHttpGetClient.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiHttpGetClient.java
index 62c2ef50..f97c57be 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiHttpGetClient.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/get/AaiHttpGetClient.java
@@ -20,16 +20,16 @@
package org.onap.dcaegen2.services.prh.adapter.aai.api.get;
-import static org.onap.dcaegen2.services.prh.adapter.aai.impl.AaiRequests.createAaiGetRequest;
import static org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFactory.createRequestDiagnosticContext;
+import io.vavr.collection.HashMap;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiHttpClient;
import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.ImmutableHttpRequest;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
-import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
import reactor.core.publisher.Mono;
public final class AaiHttpGetClient implements AaiHttpClient<AaiModel, HttpResponse> {
@@ -45,14 +45,11 @@ public final class AaiHttpGetClient implements AaiHttpClient<AaiModel, HttpRespo
@Override
public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
- final HttpRequest getRequest = createAaiGetRequest(getUri(aaiModel.getCorrelationId()),
- createRequestDiagnosticContext(), configuration.aaiHeaders());
-
- return httpClient.call(getRequest);
- }
-
-
- private String getUri(String pnfName) {
- return new URI.URIBuilder().path(configuration.pnfUrl() + "/" + pnfName).build().toString();
+ return httpClient.call(ImmutableHttpRequest.builder()
+ .method(HttpMethod.GET)
+ .url(configuration.pnfUrl() + "/" + aaiModel.getCorrelationId())
+ .customHeaders(HashMap.ofAll(configuration.aaiHeaders()))
+ .diagnosticContext(createRequestDiagnosticContext())
+ .build());
}
}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/patch/AaiHttpPatchClient.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/patch/AaiHttpPatchClient.java
index cf65547f..fdeb5e3c 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/patch/AaiHttpPatchClient.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/patch/AaiHttpPatchClient.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.dcaegen2.services.prh.adapter.aai.api.patch;
-import static org.onap.dcaegen2.services.prh.adapter.aai.impl.AaiRequests.createAaiPatchRequest;
import static org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFactory.createRequestDiagnosticContext;
import io.vavr.collection.HashMap;
@@ -29,10 +28,11 @@ import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiHttpClient;
import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel;
import org.onap.dcaegen2.services.prh.adapter.aai.model.JsonBodyBuilder;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.ImmutableHttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RequestBody;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
-import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
import reactor.core.publisher.Mono;
public final class AaiHttpPatchClient implements AaiHttpClient<AaiModel, HttpResponse> {
@@ -53,19 +53,14 @@ public final class AaiHttpPatchClient implements AaiHttpClient<AaiModel, HttpRes
public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
final Map<String, String> headers = CONTENT_TYPE.merge(HashMap.ofAll(configuration.aaiHeaders()));
+ String jsonBody = jsonBodyBuilder.createJsonBody(aaiModel);
- final HttpRequest aaiPatchRequest = createAaiPatchRequest(
- getUri(aaiModel.getCorrelationId()),
- createRequestDiagnosticContext(),
- headers.toJavaMap(),
- jsonBodyBuilder,
- aaiModel);
-
- return httpClient.call(aaiPatchRequest);
- }
-
- private String getUri(String pnfName) {
- return new URI.URIBuilder()
- .path(configuration.pnfUrl() + "/" + pnfName).build().toString();
+ return httpClient.call(ImmutableHttpRequest.builder()
+ .url(configuration.pnfUrl() + "/" + aaiModel.getCorrelationId())
+ .customHeaders(headers)
+ .diagnosticContext(createRequestDiagnosticContext())
+ .body(RequestBody.fromString(jsonBody))
+ .method(HttpMethod.PATCH)
+ .build());
}
}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/put/AaiHttpPutClient.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/put/AaiHttpPutClient.java
index 590c7c0d..eb51d5f7 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/put/AaiHttpPutClient.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/api/put/AaiHttpPutClient.java
@@ -21,15 +21,17 @@
package org.onap.dcaegen2.services.prh.adapter.aai.api.put;
-import static org.onap.dcaegen2.services.prh.adapter.aai.impl.AaiRequests.createAaiPutRequest;
import static org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFactory.createRequestDiagnosticContext;
+import io.vavr.collection.HashMap;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.adapter.aai.api.AaiHttpClient;
import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel;
import org.onap.dcaegen2.services.prh.adapter.aai.model.JsonBodyBuilder;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.ImmutableHttpRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RequestBody;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
import reactor.core.publisher.Mono;
@@ -50,8 +52,14 @@ public class AaiHttpPutClient implements AaiHttpClient<AaiModel, HttpResponse> {
@Override
public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
- final HttpRequest aaiPutRequest = createAaiPutRequest(uri, createRequestDiagnosticContext(),
- configuration.aaiHeaders(), jsonBodyBuilder, aaiModel);
- return httpClient.call(aaiPutRequest);
+ String jsonBody = jsonBodyBuilder.createJsonBody(aaiModel);
+
+ return httpClient.call(ImmutableHttpRequest.builder()
+ .url(uri)
+ .customHeaders(HashMap.ofAll(configuration.aaiHeaders()))
+ .diagnosticContext(createRequestDiagnosticContext())
+ .body(RequestBody.fromString(jsonBody))
+ .method(HttpMethod.PUT)
+ .build());
}
}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/impl/AaiRequests.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/impl/AaiRequests.java
deleted file mode 100644
index 01e13da7..00000000
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/impl/AaiRequests.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcaegen2.services.prh.adapter.aai.impl;
-
-import io.vavr.collection.HashMap;
-import java.util.Map;
-import org.onap.dcaegen2.services.prh.adapter.aai.model.ClientModel;
-import org.onap.dcaegen2.services.prh.adapter.aai.model.JsonBodyBuilder;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.ImmutableHttpRequest;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RequestBody;
-import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
-
-
-public final class AaiRequests {
-
- private AaiRequests(){}
-
- public static HttpRequest createAaiPatchRequest(String url,
- RequestDiagnosticContext context,
- Map<String, String> customHeaders,
- JsonBodyBuilder jsonBodyBuilder,
- ClientModel clientModel) {
-
- return buildAaiRequestWithBody(url, context, customHeaders,
- jsonBodyBuilder, clientModel, HttpMethod.PATCH);
- }
-
- public static HttpRequest createAaiPutRequest(String url,
- RequestDiagnosticContext context,
- Map<String, String> customHeaders,
- JsonBodyBuilder jsonBodyBuilder,
- ClientModel clientModel) {
-
- return buildAaiRequestWithBody(url, context, customHeaders,
- jsonBodyBuilder, clientModel, HttpMethod.PUT);
- }
-
- private static HttpRequest buildAaiRequestWithBody(String url,
- RequestDiagnosticContext context,
- Map<String, String> customHeaders,
- JsonBodyBuilder jsonBodyBuilder,
- ClientModel clientModel,
- HttpMethod method) {
-
- String jsonBody = jsonBodyBuilder.createJsonBody(clientModel);
-
- return ImmutableHttpRequest.builder()
- .url(url)
- .customHeaders(HashMap.ofAll(customHeaders))
- .diagnosticContext(context)
- .body(RequestBody.fromString(jsonBody))
- .method(method)
- .build();
- }
-
- public static HttpRequest createAaiGetRequest(String url,
- RequestDiagnosticContext context,
- Map<String, String> customHeaders) {
- return ImmutableHttpRequest.builder()
- .method(HttpMethod.GET)
- .url(url)
- .customHeaders(HashMap.ofAll(customHeaders))
- .diagnosticContext(context)
- .build();
- }
-}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/AbstractHttpClientTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/AbstractHttpClientTest.java
index 81f51ef9..d717e245 100644
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/AbstractHttpClientTest.java
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/AbstractHttpClientTest.java
@@ -26,7 +26,6 @@ import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel;
import org.onap.dcaegen2.services.prh.adapter.aai.model.JsonBodyBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
-import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
public class AbstractHttpClientTest {
@@ -37,6 +36,6 @@ public class AbstractHttpClientTest {
protected String constructAaiUri(AaiClientConfiguration configuration, String pnfName) {
- return new URI.URIBuilder().path(configuration.pnfUrl() + "/" + pnfName).build().toString();
+ return configuration.pnfUrl() + "/" + pnfName;
}
}