handle 404 from aai 31/89631/1
authorgrabinsk <maciej.grabinski@nokia.com>
Fri, 7 Jun 2019 10:21:44 +0000 (12:21 +0200)
committergrabinsk <maciej.grabinski@nokia.com>
Mon, 10 Jun 2019 09:15:06 +0000 (11:15 +0200)
(parsing response body from aai should not be attempted if there is no 2xx response)

Change-Id: Iedc9daa65895600d826ac808784b3c6803a6dab4
Issue-ID: DCAEGEN2-1601
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java

index 8548ffe..e09322d 100644 (file)
@@ -55,16 +55,22 @@ public class AaiHttpClientConfig {
     public AaiHttpClient<AaiServiceInstanceQueryModel, AaiServiceInstanceResultModel> getServiceInstanceClient() {
         return createLazyConfigClient(
                 (config, client) -> new AaiGetServiceInstanceClient(config, client)
-                        .map(httpResponse -> httpResponse.bodyAsJson(StandardCharsets.UTF_8,
-                                PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class)));
+                        .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.bodyAsJson(StandardCharsets.UTF_8,
-                                PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class)));
+                        .map(httpResponse -> {
+                            httpResponse.throwIfUnsuccessful();
+                            return httpResponse.bodyAsJson(StandardCharsets.UTF_8,
+                                    PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class);
+                        }));
     }
 
     private <T, U> AaiHttpClient<T, U> createLazyConfigClient(