diff --git a/src/main/java/org/folio/helper/PurchaseOrderLineHelper.java b/src/main/java/org/folio/helper/PurchaseOrderLineHelper.java index 5ea8e94f5..ee2cb4824 100644 --- a/src/main/java/org/folio/helper/PurchaseOrderLineHelper.java +++ b/src/main/java/org/folio/helper/PurchaseOrderLineHelper.java @@ -70,6 +70,7 @@ import org.folio.rest.jaxrs.model.Error; import org.folio.rest.jaxrs.model.Errors; import org.folio.rest.jaxrs.model.FundDistribution; +import org.folio.rest.jaxrs.model.Location; import org.folio.rest.jaxrs.model.Physical; import org.folio.rest.jaxrs.model.PoLine; import org.folio.rest.jaxrs.model.PoLineCollection; @@ -736,13 +737,22 @@ private Future validateUserUnaffiliatedLocationUpdates(CompositePoLine upd return getUserTenantsIfNeeded(requestContext) .compose(userTenants -> { if (CollectionUtils.isEmpty(userTenants)) { + logger.info("validateUserUnaffiliatedLocationUpdates:: User tenants is empty"); return Future.succeededFuture(); } var storageUnaffiliatedLocations = extractUnaffiliatedLocations(storedPoLine.getLocations(), userTenants); var updatedUnaffiliatedLocations = extractUnaffiliatedLocations(updatedPoLine.getLocations(), userTenants); + logger.info("validateUserUnaffiliatedLocationUpdates:: Found unaffiliated POL location tenant ids, poLineId: '{}', stored: '{}', updated: '{}'", + updatedPoLine.getId(), + storageUnaffiliatedLocations.stream().map(Location::getTenantId).distinct().toList(), + updatedUnaffiliatedLocations.stream().map(Location::getTenantId).distinct().toList()); if (!SetUtils.isEqualSet(storageUnaffiliatedLocations, updatedUnaffiliatedLocations)) { + logger.info("validateUserUnaffiliatedLocationUpdates:: User is not affiliated with all locations on the POL, poLineId: '{}'", + updatedPoLine.getId()); return Future.failedFuture(new HttpException(422, ErrorCodes.LOCATION_UPDATE_WITHOUT_AFFILIATION)); } + logger.info("validateUserUnaffiliatedLocationUpdates:: User is affiliated with all locations on the POL, poLineId: '{}'", + updatedPoLine.getId()); return Future.succeededFuture(); }); } diff --git a/src/main/java/org/folio/service/ProtectionService.java b/src/main/java/org/folio/service/ProtectionService.java index 2984f531b..a8ede907e 100644 --- a/src/main/java/org/folio/service/ProtectionService.java +++ b/src/main/java/org/folio/service/ProtectionService.java @@ -69,6 +69,7 @@ public Future isOperationRestricted(List unitIds, ProtectedOperati */ public Future isOperationRestricted(List unitIds, Set operations, RequestContext requestContext) { if (userHasDesiredPermission(BYPASS_ACQ_UNITS, requestContext)) { + log.info("isOperationRestricted:: Bypassing checking acq units"); return Future.succeededFuture(); } if (CollectionUtils.isNotEmpty(unitIds)) { @@ -81,6 +82,7 @@ public Future isOperationRestricted(List unitIds, Set isOperationRestricted(List unitIds, Set> getConsortiumConfig .map(jsonObject -> jsonObject.getJsonArray(USER_TENANTS_ARRAY_IDENTIFIER)) .map(userTenants -> { if (userTenants.isEmpty()) { - logger.debug("Central tenant and consortium id not found"); + logger.debug("getConsortiumConfigurationFromRemote:: Central tenant and consortium id not found"); return Optional.empty(); } String consortiumId = userTenants.getJsonObject(0).getString(CONSORTIUM_ID_FIELD); String centralTenantId = userTenants.getJsonObject(0).getString(CENTRAL_TENANT_ID_FIELD); - logger.debug("Found centralTenantId: {} and consortiumId: {}", centralTenantId, consortiumId); + logger.info("getConsortiumConfigurationFromRemote:: Found centralTenantId: {} and consortiumId: {}", centralTenantId, consortiumId); return Optional.of(new ConsortiumConfiguration(centralTenantId, consortiumId)); }).toCompletionStage().toCompletableFuture(); }