diff options
author | Michal Kabaj <michal.kabaj@nokia.com> | 2019-11-28 12:21:19 +0100 |
---|---|---|
committer | Michal Kabaj <michal.kabaj@nokia.com> | 2019-11-28 12:21:19 +0100 |
commit | e3595ee528b4ddb9d6ff6e26d812c0e293b34a19 (patch) | |
tree | e779b5bdf704b00a5ec301aa011ecc3433f8a8b9 /prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java | |
parent | 880dba137afdf2ddf0693d2290314bf683d7f5d7 (diff) |
aaiclient api refactor
- Moved aaiclient code from SDK to PRH
improvement of logic fragmentation
Issue-ID: DCAEGEN2-1955
Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Change-Id: I11d5b92014cdeb036699099113f64fc320cb4dd1
Diffstat (limited to 'prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java')
-rw-r--r-- | prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java index 71dedba1..9156732d 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java @@ -22,55 +22,56 @@ package org.onap.dcaegen2.services.prh.configuration; import java.nio.charset.StandardCharsets; import java.util.function.BiFunction; +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.api.get.AaiGetServiceInstanceClient; +import org.onap.dcaegen2.services.prh.adapter.aai.api.get.AaiHttpGetClient; +import org.onap.dcaegen2.services.prh.adapter.aai.api.patch.AaiHttpPatchClient; +import org.onap.dcaegen2.services.prh.adapter.aai.main.AaiHttpClientFactory; +import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiModel; +import org.onap.dcaegen2.services.prh.adapter.aai.model.AaiServiceInstanceQueryModel; import org.onap.dcaegen2.services.prh.model.AaiJsonBodyBuilderImpl; import org.onap.dcaegen2.services.prh.model.AaiPnfResultModel; import org.onap.dcaegen2.services.prh.model.AaiServiceInstanceResultModel; import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.AaiClientConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.main.AaiHttpClientFactory; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.AaiHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.get.AaiGetServiceInstanceClient; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.get.AaiHttpGetClient; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.patch.AaiHttpPatchClient; 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.aai.client.model.AaiModel; -import org.onap.dcaegen2.services.sdk.rest.services.aai.client.model.AaiServiceInstanceQueryModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class AaiHttpClientConfig { + @Autowired private CbsConfiguration cbsConfiguration; @Bean public AaiHttpClient<AaiModel, HttpResponse> getPatchClientFactory() { return createLazyConfigClient( - (config, client) -> new AaiHttpPatchClient(config, new AaiJsonBodyBuilderImpl(), client)); + (config, client) -> new AaiHttpPatchClient(config, new AaiJsonBodyBuilderImpl(), client)); } @Bean public AaiHttpClient<AaiServiceInstanceQueryModel, AaiServiceInstanceResultModel> getServiceInstanceClient() { return createLazyConfigClient( - (config, client) -> new AaiGetServiceInstanceClient(config, client) - .map(httpResponse -> { - httpResponse.throwIfUnsuccessful(); - return httpResponse.bodyAsJson(StandardCharsets.UTF_8, - PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class); - })); + (config, client) -> new AaiGetServiceInstanceClient(config, client) + .map(httpResponse -> { + httpResponse.throwIfUnsuccessful(); + return httpResponse.bodyAsJson(StandardCharsets.UTF_8, + PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class); + })); } @Bean public AaiHttpClient<AaiModel, AaiPnfResultModel> getGetClient() { return createLazyConfigClient( - (config, client) -> new AaiHttpGetClient(config, client) - .map(httpResponse -> { - httpResponse.throwIfUnsuccessful(); - return httpResponse.bodyAsJson(StandardCharsets.UTF_8, - PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class); - })); + (config, client) -> new AaiHttpGetClient(config, client) + .map(httpResponse -> { + httpResponse.throwIfUnsuccessful(); + return httpResponse.bodyAsJson(StandardCharsets.UTF_8, + PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class); + })); } private <T, U> AaiHttpClient<T, U> createLazyConfigClient( @@ -78,7 +79,7 @@ public class AaiHttpClientConfig { return x -> factoryMethod.apply( cbsConfiguration.getAaiClientConfiguration(), - new AaiHttpClientFactory(cbsConfiguration.getAaiClientConfiguration()).build() + new AaiHttpClientFactory(cbsConfiguration.getAaiClientConfiguration()).build() ).getAaiResponse(x); } } |