diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index c87bad9224..3cdebd5a9d 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -1898,7 +1898,10 @@ "mod-settings.entries.collection.get", "mod-settings.entries.item.get", "mod-settings.global.read.mod-circulation", - "mod-settings.global.read.circulation" + "mod-settings.global.read.circulation", + "manualblocks.item.get", + "manualblocks.collection.get", + "patron-blocks.automated-patron-blocks.collection.get" ], "visible": false }, @@ -1920,6 +1923,7 @@ "circulation-storage.fixed-due-date-schedules.item.get", "circulation-storage.fixed-due-date-schedules.collection.get", "circulation-storage.patron-notice-policies.item.get", + "circulation-storage.request-batch.item.post", "circulation.rules.notice-policy.get", "circulation.rules.loan-policy.get", "circulation.rules.request-policy.get", diff --git a/src/main/java/org/folio/circulation/domain/CreateRequestService.java b/src/main/java/org/folio/circulation/domain/CreateRequestService.java index 66ec8fff43..9dc5e349cf 100644 --- a/src/main/java/org/folio/circulation/domain/CreateRequestService.java +++ b/src/main/java/org/folio/circulation/domain/CreateRequestService.java @@ -1,6 +1,8 @@ package org.folio.circulation.domain; import static java.util.concurrent.CompletableFuture.completedFuture; +import static org.folio.circulation.domain.EcsRequestPhase.INTERMEDIATE; +import static org.folio.circulation.domain.EcsRequestPhase.PRIMARY; import static org.folio.circulation.domain.RequestLevel.TITLE; import static org.folio.circulation.domain.representations.RequestProperties.INSTANCE_ID; import static org.folio.circulation.domain.representations.RequestProperties.ITEM_ID; @@ -227,8 +229,9 @@ private CompletableFuture> checkPolicy( boolean tlrFeatureEnabled = request.getTlrSettingsConfiguration().isTitleLevelRequestsFeatureEnabled(); if (tlrFeatureEnabled && request.isTitleLevel() && request.isHold()) { - if (request.getEcsRequestPhase() == EcsRequestPhase.PRIMARY) { - log.warn("checkPolicy:: ECS TLR primary Hold detected, skipping policy check"); + EcsRequestPhase ecsRequestPhase = request.getEcsRequestPhase(); + if (ecsRequestPhase == PRIMARY || ecsRequestPhase == INTERMEDIATE) { + log.warn("checkPolicy:: ECS TLR Hold with phase {} detected, skipping policy check", ecsRequestPhase); return ofAsync(() -> records); } diff --git a/src/main/java/org/folio/circulation/domain/EcsRequestPhase.java b/src/main/java/org/folio/circulation/domain/EcsRequestPhase.java index 8272931b2e..69099d63c0 100644 --- a/src/main/java/org/folio/circulation/domain/EcsRequestPhase.java +++ b/src/main/java/org/folio/circulation/domain/EcsRequestPhase.java @@ -7,7 +7,8 @@ public enum EcsRequestPhase { NONE(""), PRIMARY("Primary"), - SECONDARY("Secondary"); + SECONDARY("Secondary"), + INTERMEDIATE("Intermediate"); public final String value; diff --git a/src/main/java/org/folio/circulation/resources/RequestFromRepresentationService.java b/src/main/java/org/folio/circulation/resources/RequestFromRepresentationService.java index 9860f9b454..5b6ba0d90d 100644 --- a/src/main/java/org/folio/circulation/resources/RequestFromRepresentationService.java +++ b/src/main/java/org/folio/circulation/resources/RequestFromRepresentationService.java @@ -5,6 +5,8 @@ import static java.util.stream.Collectors.toList; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.folio.circulation.domain.EcsRequestPhase.INTERMEDIATE; +import static org.folio.circulation.domain.EcsRequestPhase.PRIMARY; import static org.folio.circulation.domain.RequestLevel.ITEM; import static org.folio.circulation.domain.RequestLevel.TITLE; import static org.folio.circulation.domain.RequestType.RECALL; @@ -253,9 +255,11 @@ private CompletableFuture> fetchItemAndLoan( Request request = records.getRequest(); Function>> itemAndLoanFetchingFunction; - log.info("fetchItemAndLoan:: Request phase is {}", request.getEcsRequestPhase().value); - if (request.getEcsRequestPhase() == EcsRequestPhase.PRIMARY) { - log.info("fetchItemAndLoan:: Primary ECS request detected, using default item fetcher"); + EcsRequestPhase ecsRequestPhase = request.getEcsRequestPhase(); + log.info("fetchItemAndLoan:: ECS request phase is {}", ecsRequestPhase); + if (ecsRequestPhase == PRIMARY || ecsRequestPhase == INTERMEDIATE) { + log.info("fetchItemAndLoan:: ECS request phase {} detected, using default item fetcher", + ecsRequestPhase); itemAndLoanFetchingFunction = this::fetchItemAndLoanDefault; } else if (request.isTitleLevel() && request.isPage()) { @@ -543,8 +547,9 @@ private Result refuseToCreateTlrLinkedToAnItem(Result request) } private Result validateAbsenceOfItemLinkInTlr(Request request) { - if (request.getEcsRequestPhase() == EcsRequestPhase.PRIMARY) { - log.info("validateAbsenceOfItemLinkInTlr:: Primary ECS request detected, skipping"); + EcsRequestPhase ecsRequestPhase = request.getEcsRequestPhase(); + if (ecsRequestPhase == PRIMARY || ecsRequestPhase == INTERMEDIATE) { + log.info("validateAbsenceOfItemLinkInTlr:: ECS request phase {} detected, skipping", ecsRequestPhase); return of(() -> request); } diff --git a/src/test/java/api/requests/RequestsAPICreationTests.java b/src/test/java/api/requests/RequestsAPICreationTests.java index 0d302544b6..5232edb027 100644 --- a/src/test/java/api/requests/RequestsAPICreationTests.java +++ b/src/test/java/api/requests/RequestsAPICreationTests.java @@ -3960,8 +3960,11 @@ void titleLevelPageRequestIsCreatedForItemClosestToPickupServicePoint(int testCa assertThat(request.getJson().getString("itemId"), is(expectedItemId)); } - @Test - void primaryTlrCreationSkipsClosestServicePointLogicAndPoliciesIgnoredForHoldTlr() { + @ParameterizedTest + @ValueSource(strings = {"Primary", "Intermediate"}) + void tlrCreationSkipsClosestServicePointLogicAndPoliciesIgnoredForHoldTlr( + String ecsRequestPhase) { + settingsFixture.configureTlrFeature(true, true, null, null, null); policiesActivation.use(new RequestPolicyBuilder( @@ -4032,9 +4035,9 @@ void primaryTlrCreationSkipsClosestServicePointLogicAndPoliciesIgnoredForHoldTlr // Request without ECS phase should fail requestsFixture.attemptPlace(requestBuilder); - // The same request with Primary ECS phase should succeed because validation is skipped + // The same request with Primary/Intermediate ECS phase should succeed because validation is skipped IndividualResource request = requestsFixture.place( - requestBuilder.withEcsRequestPhase("Primary")); + requestBuilder.withEcsRequestPhase(ecsRequestPhase)); assertThat(request.getJson().getString("itemId"), is(expectedItemId)); @@ -4043,7 +4046,7 @@ void primaryTlrCreationSkipsClosestServicePointLogicAndPoliciesIgnoredForHoldTlr requestBuilder .withRequesterId(usersFixture.jessica().getId()) .withItemId(closestItemId) - .withEcsRequestPhase("Primary")); + .withEcsRequestPhase(ecsRequestPhase)); // Placing TLR Hold request var requestBuilderTlrHold = new RequestBuilder() @@ -4060,8 +4063,8 @@ void primaryTlrCreationSkipsClosestServicePointLogicAndPoliciesIgnoredForHoldTlr // Request without ECS phase should fail requestsFixture.attemptPlace(requestBuilderTlrHold); - // The same request with Primary ECS phase should succeed because policy check is skipped - requestsFixture.place(requestBuilderTlrHold.withEcsRequestPhase("Primary")); + // The same request with Primary/Intermediate ECS phase should succeed because policy check is skipped + requestsFixture.place(requestBuilderTlrHold.withEcsRequestPhase(ecsRequestPhase)); } @Test