Skip to content

Commit

Permalink
[EUREKA-561-2]. (ECS) Can open/unopen order with PO line locations fr…
Browse files Browse the repository at this point in the history
…om tenant in which user does not have affiliation
  • Loading branch information
BKadirkhodjaev committed Dec 2, 2024
1 parent 892b1db commit 018316f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/folio/helper/PurchaseOrderLineHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,16 @@ private Future<Void> 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);
if (!SetUtils.isEqualSet(storageUnaffiliatedLocations, updatedUnaffiliatedLocations)) {
logger.info("validateUserUnaffiliatedLocationUpdates:: User is not affiliated with all locations on the POL");
return Future.failedFuture(new HttpException(422, ErrorCodes.LOCATION_UPDATE_WITHOUT_AFFILIATION));
}
logger.info("validateUserUnaffiliatedLocationUpdates:: User is affiliated with all locations on the POL");
return Future.succeededFuture();
});
}
Expand Down Expand Up @@ -829,6 +832,7 @@ private Future<Void> verifyDeleteAllowed(PoLine line, RequestContext requestCont
}

private Future<Void> createShadowInstanceIfNeeded(CompositePoLine compositePoLine, RequestContext requestContext) {
logger.info("createShadowInstanceIfNeeded:: Creating shadow instance if needed");
String instanceId = compositePoLine.getInstanceId();
if (Boolean.TRUE.equals(compositePoLine.getIsPackage()) || Objects.isNull(instanceId)) {
return Future.succeededFuture();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/folio/service/ProtectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public Future<Void> isOperationRestricted(List<String> unitIds, ProtectedOperati
*/
public Future<Void> isOperationRestricted(List<String> unitIds, Set<ProtectedOperationType> operations, RequestContext requestContext) {
if (userHasDesiredPermission(BYPASS_ACQ_UNITS, requestContext)) {
log.info("isOperationRestricted:: No desired permissions found");
return Future.succeededFuture();
}
if (CollectionUtils.isNotEmpty(unitIds)) {
Expand All @@ -81,6 +82,7 @@ public Future<Void> isOperationRestricted(List<String> unitIds, Set<ProtectedOpe
.collect(Collectors.toList());

if (!activeUnits.isEmpty() && applyMergingStrategy(activeUnits, operations)) {
log.info("isOperationRestricted:: Unit ids are merged");
return verifyUserIsMemberOfOrdersUnits(extractUnitIds(activeUnits), requestContext);
}
return Future.succeededFuture();
Expand All @@ -90,6 +92,7 @@ public Future<Void> isOperationRestricted(List<String> unitIds, Set<ProtectedOpe
}
});
} else {
log.info("isOperationRestricted:: Unit ids are empty");
return Future.succeededFuture();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ private CompletableFuture<Optional<ConsortiumConfiguration>> getConsortiumConfig
.map(jsonObject -> jsonObject.getJsonArray(USER_TENANTS_ARRAY_IDENTIFIER))
.map(userTenants -> {
if (userTenants.isEmpty()) {
logger.debug("Central tenant and consortium id not found");
logger.info("getConsortiumConfigurationFromRemote:: Central tenant and consortium id not found");
return Optional.<ConsortiumConfiguration>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();
}
Expand Down

0 comments on commit 018316f

Please sign in to comment.