diff options
Diffstat (limited to 'prh-commons/src/main')
6 files changed, 13 insertions, 82 deletions
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 f97c57be..122a6097 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 @@ -25,14 +25,14 @@ import static org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFacto 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.model.ConsumerDmaapModel; 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 reactor.core.publisher.Mono; -public final class AaiHttpGetClient implements AaiHttpClient<AaiModel, HttpResponse> { +public final class AaiHttpGetClient implements AaiHttpClient<ConsumerDmaapModel, HttpResponse> { private final RxHttpClient httpClient; private final AaiClientConfiguration configuration; @@ -44,7 +44,7 @@ public final class AaiHttpGetClient implements AaiHttpClient<AaiModel, HttpRespo } @Override - public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) { + public Mono<HttpResponse> getAaiResponse(ConsumerDmaapModel aaiModel) { return httpClient.call(ImmutableHttpRequest.builder() .method(HttpMethod.GET) .url(configuration.pnfUrl() + "/" + aaiModel.getCorrelationId()) 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 fdeb5e3c..efae2d54 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 @@ -26,8 +26,8 @@ import io.vavr.collection.HashMap; import io.vavr.collection.Map; 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.prh.model.AaiJsonBodyBuilderImpl; +import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; 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; @@ -35,28 +35,28 @@ 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; -public final class AaiHttpPatchClient implements AaiHttpClient<AaiModel, HttpResponse> { +public final class AaiHttpPatchClient implements AaiHttpClient<ConsumerDmaapModel, HttpResponse> { private final static Map<String, String> CONTENT_TYPE = HashMap.of("Content-Type", "application/merge-patch+json"); private RxHttpClient httpClient; private final AaiClientConfiguration configuration; - private final JsonBodyBuilder jsonBodyBuilder; + private final AaiJsonBodyBuilderImpl jsonBodyBuilder; - public AaiHttpPatchClient(final AaiClientConfiguration configuration, JsonBodyBuilder jsonBodyBuilder, + public AaiHttpPatchClient(final AaiClientConfiguration configuration, AaiJsonBodyBuilderImpl jsonBodyBuilder, RxHttpClient httpClient) { this.configuration = configuration; this.jsonBodyBuilder = jsonBodyBuilder; this.httpClient = httpClient; } - public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) { + public Mono<HttpResponse> getAaiResponse(ConsumerDmaapModel aaiModel) { final Map<String, String> headers = CONTENT_TYPE.merge(HashMap.ofAll(configuration.aaiHeaders())); String jsonBody = jsonBodyBuilder.createJsonBody(aaiModel); return httpClient.call(ImmutableHttpRequest.builder() - .url(configuration.pnfUrl() + "/" + aaiModel.getCorrelationId()) + .url(configuration.pnfUrl() + "/" + aaiModel.getCorrelationId()) .customHeaders(headers) .diagnosticContext(createRequestDiagnosticContext()) .body(RequestBody.fromString(jsonBody)) diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/AaiModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/AaiModel.java deleted file mode 100644 index f0353d74..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/AaiModel.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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. - * 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.model; - -@FunctionalInterface -public interface AaiModel { - - String getCorrelationId(); -} diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/JsonBodyBuilder.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/JsonBodyBuilder.java deleted file mode 100644 index db8839ea..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/adapter/aai/model/JsonBodyBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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. - * 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.model; - -@FunctionalInterface -public interface JsonBodyBuilder<T> { - - /** - * Method for serialization object by GSON. - * - * @param t - object which will be serialized - * @return string from serialization - */ - - String createJsonBody(T t); -}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java index c53da879..43e4ebbe 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ - * 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. @@ -23,19 +23,12 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapterFactory; import java.util.ServiceLoader; -import org.onap.dcaegen2.services.prh.adapter.aai.model.JsonBodyBuilder; import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel.Builder; import org.springframework.util.StringUtils; -public class AaiJsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> { +public class AaiJsonBodyBuilderImpl { - /** - * Method for serialization object by GSON. - * - * @param consumerDmaapModel - object which will be serialized - * @return string from serialization - */ public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java index d813116d..9ed36823 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java @@ -24,7 +24,6 @@ import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; import org.immutables.gson.Gson; import org.immutables.value.Value; -import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel; import org.springframework.lang.Nullable; /** @@ -33,7 +32,7 @@ import org.springframework.lang.Nullable; @Value.Immutable @Gson.TypeAdapters(fieldNamingStrategy = true) -public interface ConsumerDmaapModel extends AaiModel { +public interface ConsumerDmaapModel { @SerializedName(value = "correlationId", alternate = "correlationId") String getCorrelationId(); |