From 0d592b336289d8692314f170fddf0c8ba16406e3 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Tue, 17 Dec 2024 14:53:42 +0530 Subject: [PATCH] CIRCSTORE-540: fix NLP due to logging of null object --- .../processor/ItemUpdateProcessorForRequest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/folio/service/event/handler/processor/ItemUpdateProcessorForRequest.java b/src/main/java/org/folio/service/event/handler/processor/ItemUpdateProcessorForRequest.java index 1a1c2f3d..4600c4ac 100644 --- a/src/main/java/org/folio/service/event/handler/processor/ItemUpdateProcessorForRequest.java +++ b/src/main/java/org/folio/service/event/handler/processor/ItemUpdateProcessorForRequest.java @@ -71,13 +71,15 @@ protected Future>> collectRelevantChanges(JsonObject payloa changes.add(new Change<>(request -> request.getSearchIndex().setShelvingOrder(newShelvingOrder))); } - Future> fetchLocationAndServicePoint = updateItemAndServicePoint(newObject, changes); + Future> fetchLocationAndServicePoint = updateItemAndServicePoint(newObject); return fetchLocationAndServicePoint .compose(locationAndSpData -> addLocationAndServicePointChanges(locationAndSpData, changes)) - .compose(res -> Future.succeededFuture(changes)); + .compose(r -> Future.succeededFuture(changes)) + .recover(throwable -> Future.succeededFuture(changes)); } private static Future>> addLocationAndServicePointChanges(Map locationAndSpData, List> changes) { + log.info("ItemUpdateProcessorForRequest :: locationAndSpData: {}", locationAndSpData); changes.add(new Change<>(request -> { if (request.getItem() == null) { request.setItem(new Item()); @@ -90,7 +92,7 @@ private static Future>> addLocationAndServicePointChanges(M return Future.succeededFuture(changes); } - private Future> updateItemAndServicePoint(JsonObject newObject, List> changes) { + private Future> updateItemAndServicePoint(JsonObject newObject) { String effectiveLocationId = newObject.getString("effectiveLocationId"); Map locationAndSpData = new HashMap<>(); locationAndSpData.put(ITEM_EFFECTIVE_LOCATION_ID, effectiveLocationId); @@ -108,8 +110,6 @@ private static Future setEffectiveLocationData(Collection loca Location effectiveLocation = locations.stream() .filter(l -> l.getId().equals(effectiveLocationId)) .findFirst().orElse(null); - log.info("ItemUpdateProcessorForRequest :: setEffectiveLocationName(): locationsName: {}", - JsonObject.mapFrom(effectiveLocation).encode()); if (Objects.nonNull(effectiveLocation)) { locationAndSpData.put(ITEM_EFFECTIVE_LOCATION_NAME, effectiveLocation.getName()); return succeededFuture(effectiveLocation.getPrimaryServicePoint().toString()); @@ -125,8 +125,6 @@ private Future setRetrievalServicePointData(String primaryServicePoint, Servicepoint retrievalServicePoint = servicePoints.stream() .filter(sp -> sp.getId().equals(primaryServicePoint)) .findFirst().orElse(null); - log.info("ItemUpdateProcessorForRequest :: setServicePoint(): {}", - JsonObject.mapFrom(retrievalServicePoint).encode()); if (Objects.nonNull(retrievalServicePoint)) { locationAndSpData.put(RETRIEVAL_SERVICE_POINT_NAME, retrievalServicePoint.getName()); }