diff --git a/src/main/java/org/folio/inventory/resources/Items.java b/src/main/java/org/folio/inventory/resources/Items.java index bd4d92f0c..17c1ac4a4 100644 --- a/src/main/java/org/folio/inventory/resources/Items.java +++ b/src/main/java/org/folio/inventory/resources/Items.java @@ -312,7 +312,6 @@ protected void respondWithManyItems( CollectionResourceClient locationsClient; try { - log.info("respondWithManyItems:: creating http clients"); OkapiHttpClient okapiClient = createHttpClient(routingContext, context); holdingsClient = createHoldingsClient(okapiClient, context); instancesClient = createInstancesClient(okapiClient, context); @@ -322,7 +321,7 @@ protected void respondWithManyItems( } catch (MalformedURLException e) { invalidOkapiUrlResponse(routingContext, context); - log.info("respondWithManyItems:: error while creating http clients", e); + return; } @@ -356,8 +355,6 @@ protected void respondWithManyItems( final List holdings = JsonArrayHelper.toList( holdingsResponse.getJson().getJsonArray("holdingsRecords")); - log.info("respondWithManyItems:: collecting instanceIds"); - List instanceIds = holdings.stream() .map(holding -> holding.getString(INSTANCE_ID_PROPERTY)) .filter(Objects::nonNull) @@ -380,21 +377,15 @@ protected void respondWithManyItems( instancesResponse.getBody())); } - log.info("respondWithManyItems:: instanceIds size: {}", instanceIds.size()); - final List instances = JsonArrayHelper.toList( instancesResponse.getJson().getJsonArray("instances")); - log.info("respondWithManyItems:: collecting materialTypeIds"); - List materialTypeIds = wrappedItems.records.stream() .map(Item::getMaterialTypeId) .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); - log.info("respondWithManyItems:: materialTypeIds size: {}", materialTypeIds.size()); - materialTypeIds.forEach(id -> { CompletableFuture newFuture = new CompletableFuture<>(); @@ -404,17 +395,12 @@ protected void respondWithManyItems( materialTypesClient.get(id, newFuture::complete); }); - log.info("respondWithManyItems:: collecting permanentLoanTypeIds"); - List permanentLoanTypeIds = wrappedItems.records.stream() .map(Item::getPermanentLoanTypeId) .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); - log.info("respondWithManyItems:: permanentLoanTypeIds size: {}", permanentLoanTypeIds.size()); - - log.info("respondWithManyItems:: collecting temporaryLoanTypeIds"); List temporaryLoanTypeIds = wrappedItems.records.stream() .map(Item::getTemporaryLoanTypeId) .filter(Objects::nonNull) @@ -433,28 +419,18 @@ protected void respondWithManyItems( loanTypesClient.get(id, newFuture::complete); }); - log.info("respondWithManyItems:: collecting effectiveLocationIds"); - List effectiveLocationIds = wrappedItems.records.stream() .map(Item::getEffectiveLocationId) .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); - log.info("respondWithManyItems:: effectiveLocationIds size: {}", effectiveLocationIds.size()); - - log.info("respondWithManyItems:: collecting permanentLocationIds"); - List permanentLocationIds = wrappedItems.records.stream() .map(Item::getPermanentLocationId) .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); - log.info("respondWithManyItems:: permanentLocationIds size: {}", permanentLocationIds.size()); - - log.info("respondWithManyItems: collecting temporaryLocationIds"); - List temporaryLocationIds = wrappedItems.records.stream() .map(Item::getTemporaryLocationId) .filter(Objects::nonNull) @@ -473,8 +449,6 @@ protected void respondWithManyItems( locationsClient.get(id, newFuture::complete); }); - log.info("respondWithManyItems:: temporaryLocationIds size: {}", temporaryLocationIds.size()); - CompletableFuture boundWithPartsFuture = getBoundWithPartsForMultipleItemsFuture(wrappedItems, routingContext); @@ -487,45 +461,27 @@ protected void respondWithManyItems( try { - log.info("respondWithManyItems:: trying to fetch materialTypes"); - Map foundMaterialTypes = allMaterialTypeFutures.stream() .map(CompletableFuture::join) - .peek(r -> log.info("Fetch material type -> response code '{}'", r.getStatusCode())) .filter(response -> response.getStatusCode() == 200) .map(Response::getJson) - .peek(r -> log.info("Successfully fetch material type with id '{}'", r.getString("id"))) .collect(Collectors.toMap(r -> r.getString("id"), r -> r)); - log.info("respondWithManyItems:: foundMaterialTypes size: {}", foundMaterialTypes.size()); - - log.info("respondWithManyItems:: trying to fetch loanTypes"); - Map foundLoanTypes = allLoanTypeFutures.stream() .map(CompletableFuture::join) - .peek(r -> log.info("Fetch loan type -> response code '{}'", r.getStatusCode())) .filter(response -> response.getStatusCode() == 200) .map(Response::getJson) - .peek(r -> log.info("Successfully fetch loan type with id '{}'", r.getString("id"))) .collect(Collectors.toMap(r -> r.getString("id"), r -> r)); - log.info("respondWithManyItems:: foundLoanTypes size: {}", foundLoanTypes.size()); - - log.info("respondWithManyItems:: trying to fetch locations"); - Map foundLocations = allLocationsFutures.stream() .map(CompletableFuture::join) - .peek(r -> log.info("Fetch location -> response code '{}'", r.getStatusCode())) .filter(response -> response.getStatusCode() == 200) .map(Response::getJson) - .peek(r -> log.info("Successfully fetch locations with id '{}'", r.getString("id"))) .collect(Collectors.toMap(r -> r.getString("id"), r -> r)); - log.info("respondWithManyItems:: foundLocations size: {}", foundLocations.size()); - setBoundWithFlagsOnItems(wrappedItems, boundWithPartsFuture); JsonResponse.success(routingContext.response(), @@ -1104,7 +1060,7 @@ private CompletableFuture getBoundWithPartsForItemFuture( private void setBoundWithFlagsOnItems(MultipleRecords wrappedItems, CompletableFuture boundWithPartsFuture) { - log.info("setBoundWithFlagsOnItems:: trying to set withIsBoundWith"); + Response response = boundWithPartsFuture.join(); if (response != null && response.hasBody() && response.getStatusCode()==200) { JsonArray boundWithParts = response.getJson().getJsonArray(BOUND_WITH_PARTS_COLLECTION);