diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderComponentFactory.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderComponentFactory.java index 016a7f59..c22602e0 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderComponentFactory.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderComponentFactory.java @@ -99,16 +99,15 @@ public Set getReportRoleNames( public JsonSchemaValidator getMessageSchemaValidator(String apiProviderRole, boolean forRequest) { String schemaFilePath = - "/standards/eblsurrender/schemas/eblsurrender-v%s.json" - .formatted( - standardVersion); + "/standards/eblsurrender/schemas/eblsurrender-v%s.json".formatted(standardVersion); String schemaName = - EblSurrenderRole.isCarrier(apiProviderRole) - ? (forRequest ? "SurrenderRequestDetails" : null) - : (forRequest ? "SurrenderRequestAnswer" : null); + EblSurrenderRole.isCarrier(apiProviderRole) + ? (forRequest ? "SurrenderRequestDetails" : null) + : (forRequest ? "SurrenderRequestAnswer" : null); if (schemaName == null) { - throw new IllegalArgumentException("No schema for " + apiProviderRole + " (forRequest=" + forRequest + ")"); + throw new IllegalArgumentException( + "No schema for " + apiProviderRole + " (forRequest=" + forRequest + ")"); } return JsonSchemaValidator.getInstance(schemaFilePath, schemaName); } diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderScenarioListBuilder.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderScenarioListBuilder.java index d27dad4d..9b1bd4d1 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderScenarioListBuilder.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderScenarioListBuilder.java @@ -1,31 +1,29 @@ package org.dcsa.conformance.standards.eblsurrender; -import lombok.extern.slf4j.Slf4j; -import org.dcsa.conformance.core.scenario.ConformanceAction; -import org.dcsa.conformance.core.scenario.ScenarioListBuilder; -import org.dcsa.conformance.standards.eblsurrender.action.SupplyScenarioParametersAction; -import org.dcsa.conformance.standards.eblsurrender.action.SurrenderRequestAction; -import org.dcsa.conformance.standards.eblsurrender.action.SurrenderResponseAction; -import org.dcsa.conformance.standards.eblsurrender.action.VoidAndReissueAction; -import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; -import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderState; - import java.util.LinkedHashMap; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderState.*; +import lombok.extern.slf4j.Slf4j; +import org.dcsa.conformance.core.scenario.ConformanceAction; +import org.dcsa.conformance.core.scenario.ScenarioListBuilder; +import org.dcsa.conformance.standards.eblsurrender.action.SupplyScenarioParametersAction; +import org.dcsa.conformance.standards.eblsurrender.action.SurrenderRequestResponseAction; +import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; @Slf4j -class EblSurrenderScenarioListBuilder - extends ScenarioListBuilder { +class EblSurrenderScenarioListBuilder extends ScenarioListBuilder { private static final ThreadLocal threadLocalComponentFactory = new ThreadLocal<>(); private static final ThreadLocal threadLocalCarrierPartyName = new ThreadLocal<>(); private static final ThreadLocal threadLocalPlatformPartyName = new ThreadLocal<>(); + private EblSurrenderScenarioListBuilder( + Function actionBuilder) { + super(actionBuilder); + } + public static LinkedHashMap createModuleScenarioListBuilders( EblSurrenderComponentFactory componentFactory, @@ -35,144 +33,86 @@ class EblSurrenderScenarioListBuilder threadLocalCarrierPartyName.set(carrierPartyName); threadLocalPlatformPartyName.set(platformPartyName); return Stream.of( - Map.entry("", supplyAvailableTdrAction().thenAllPathsFrom(AVAILABLE_FOR_SURRENDER))) + Map.entry( + "Surrender Accepted", + noAction() + .thenEither( + supplyAvailableTdrAction("SURR", "Straight eBL") + .thenEither( + requestSurrenderForDeliveryAnd(true), + requestSurrenderForAmendmentAnd(true, false), + requestSurrenderForAmendmentAnd(true, true)), + supplyAvailableTdrAction("SURR", "Negotiable eBL") + .thenEither( + requestSurrenderForDeliveryAnd(true), + requestSurrenderForAmendmentAnd(true, false), + requestSurrenderForAmendmentAnd(true, true)))), + Map.entry( + "Surrender Rejected", + noAction() + .thenEither( + supplyAvailableTdrAction("SREJ", "Straight eBL") + .thenEither( + requestSurrenderForDeliveryAnd(false), + requestSurrenderForAmendmentAnd(false, false), + requestSurrenderForAmendmentAnd(false, true)), + supplyAvailableTdrAction("SREJ", "Negotiable eBL") + .thenEither( + requestSurrenderForDeliveryAnd(false), + requestSurrenderForAmendmentAnd(false, false), + requestSurrenderForAmendmentAnd(false, true))))) .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); } - private EblSurrenderScenarioListBuilder thenAllPathsFrom( - EblSurrenderState surrenderState) { - return switch (surrenderState) { - case AVAILABLE_FOR_SURRENDER -> thenEither( - requestSurrenderForDelivery(204).thenAllPathsFrom(DELIVERY_SURRENDER_REQUESTED), - requestSurrenderForAmendment(204).thenAllPathsFrom(AMENDMENT_SURRENDER_REQUESTED) - ); - case DELIVERY_SURRENDER_REQUESTED -> thenEither( - acceptSurrenderRequest(204).thenAllPathsFrom(SURRENDERED_FOR_DELIVERY), - rejectSurrenderRequest(204).thenAllHappyPathsFrom(AVAILABLE_FOR_SURRENDER), - requestSurrenderForAmendment(409).thenAllHappyPathsFrom(DELIVERY_SURRENDER_REQUESTED), - requestSurrenderForDelivery(409).thenAllHappyPathsFrom(DELIVERY_SURRENDER_REQUESTED) - ); - case SURRENDERED_FOR_DELIVERY -> thenAnyRequest(409); - case AMENDMENT_SURRENDER_REQUESTED -> thenEither( - acceptSurrenderRequest(204).thenAllPathsFrom(SURRENDERED_FOR_AMENDMENT), - rejectSurrenderRequest(204).thenAllHappyPathsFrom(AVAILABLE_FOR_SURRENDER), - requestSurrenderForAmendment(409).thenAllHappyPathsFrom(AMENDMENT_SURRENDER_REQUESTED), - requestSurrenderForDelivery(409).thenAllHappyPathsFrom(AMENDMENT_SURRENDER_REQUESTED) - ); - case SURRENDERED_FOR_AMENDMENT -> thenEither( - acceptSurrenderRequest(409).thenAllHappyPathsFrom(SURRENDERED_FOR_AMENDMENT), - rejectSurrenderRequest(409).thenAllHappyPathsFrom(SURRENDERED_FOR_AMENDMENT), - requestSurrenderForAmendment(409).thenAllHappyPathsFrom(SURRENDERED_FOR_AMENDMENT), - requestSurrenderForDelivery(409).thenAllHappyPathsFrom(SURRENDERED_FOR_AMENDMENT), - voidAndReissue().thenAllHappyPathsFrom(AVAILABLE_FOR_SURRENDER) - ); - }; - } - - private EblSurrenderScenarioListBuilder thenAllHappyPathsFrom( - EblSurrenderState surrenderState) { - var cases = switch (surrenderState) { - case AVAILABLE_FOR_SURRENDER -> requestSurrenderForDelivery(204).thenAllHappyPathsFrom(DELIVERY_SURRENDER_REQUESTED); - case DELIVERY_SURRENDER_REQUESTED -> acceptSurrenderRequest(204); - case SURRENDERED_FOR_DELIVERY -> noAction(); - case AMENDMENT_SURRENDER_REQUESTED -> acceptSurrenderRequest(204) - .thenAllHappyPathsFrom(SURRENDERED_FOR_AMENDMENT); - case SURRENDERED_FOR_AMENDMENT -> voidAndReissue().thenAllHappyPathsFrom(AVAILABLE_FOR_SURRENDER); - }; - return thenEither(cases); - } - - private EblSurrenderScenarioListBuilder noAction() { + private static EblSurrenderScenarioListBuilder noAction() { return new EblSurrenderScenarioListBuilder(null); } - private EblSurrenderScenarioListBuilder thenAnyRequest(int status) { - return thenEither( - noAction(), - requestSurrenderForAmendment(status), - requestSurrenderForDelivery(status), - rejectSurrenderRequest(status), - acceptSurrenderRequest(status) - ); - } - - private static EblSurrenderScenarioListBuilder supplyAvailableTdrAction() { + private static EblSurrenderScenarioListBuilder supplyAvailableTdrAction( + String response, String eblType) { log.debug("EblSurrenderScenarioListBuilder.supplyAvailableTdrAction()"); String carrierPartyName = threadLocalCarrierPartyName.get(); return new EblSurrenderScenarioListBuilder( - noPreviousAction -> new SupplyScenarioParametersAction(carrierPartyName, null)); + noPreviousAction -> + new SupplyScenarioParametersAction(carrierPartyName, null, response, eblType)); } - private EblSurrenderScenarioListBuilder( - Function actionBuilder) { - super(actionBuilder); - } + private static EblSurrenderScenarioListBuilder requestSurrenderForAmendmentAnd( + boolean accept, boolean isSWTP) { + log.debug("EblSurrenderScenarioListBuilder.requestSurrenderForAmendment"); - private static EblSurrenderScenarioListBuilder requestSurrenderForAmendment(int status) { - log.debug( - "EblSurrenderScenarioListBuilder.requestSurrenderForAmendment(%d)".formatted(status)); - return _surrenderRequestBuilder(true, status); + String titleSuffix = isSWTP ? "AndSwitchToPaper" : ""; + titleSuffix = accept ? titleSuffix + "Accepted" : titleSuffix + "Rejected"; + return _surrenderRequestBuilder(true, accept, "SurrenderForAmendment" + titleSuffix, isSWTP); } - private static EblSurrenderScenarioListBuilder requestSurrenderForDelivery(int status) { - log.debug( - "EblSurrenderScenarioListBuilder.requestSurrenderForDelivery(%d)".formatted(status)); - return _surrenderRequestBuilder(false, status); + private static EblSurrenderScenarioListBuilder requestSurrenderForDeliveryAnd(boolean accept) { + log.debug("EblSurrenderScenarioListBuilder.requestSurrenderForDelivery"); + String titleSuffix = accept ? "Accepted" : "Rejected"; + return _surrenderRequestBuilder(false, accept, "SurrenderForDelivery" + titleSuffix, false); } private static EblSurrenderScenarioListBuilder _surrenderRequestBuilder( - boolean forAmendment, int expectedStatus) { + boolean forAmendment, boolean accept, String title, boolean isSWTP) { EblSurrenderComponentFactory componentFactory = threadLocalComponentFactory.get(); String carrierPartyName = threadLocalCarrierPartyName.get(); String platformPartyName = threadLocalPlatformPartyName.get(); return new EblSurrenderScenarioListBuilder( previousAction -> - new SurrenderRequestAction( + new SurrenderRequestResponseAction( forAmendment, platformPartyName, carrierPartyName, - expectedStatus, + 204, previousAction, componentFactory.getMessageSchemaValidator( - EblSurrenderRole.CARRIER.getConfigName(), true)) - ); - } - - private static EblSurrenderScenarioListBuilder acceptSurrenderRequest(int status) { - log.debug("EblSurrenderScenarioListBuilder.acceptSurrenderRequest(%d)".formatted(status)); - return _surrenderResponseBuilder(true, status); - } - - private static EblSurrenderScenarioListBuilder rejectSurrenderRequest(int status) { - log.debug("EblSurrenderScenarioListBuilder.rejectSurrenderRequest(%d)".formatted(status)); - return _surrenderResponseBuilder(false, status); - } - - private static EblSurrenderScenarioListBuilder _surrenderResponseBuilder( - boolean accept, int expectedStatus) { - EblSurrenderComponentFactory componentFactory = threadLocalComponentFactory.get(); - String carrierPartyName = threadLocalCarrierPartyName.get(); - String platformPartyName = threadLocalPlatformPartyName.get(); - return new EblSurrenderScenarioListBuilder( - previousAction -> - new SurrenderResponseAction( - accept, - carrierPartyName, - platformPartyName, - expectedStatus, - previousAction, + EblSurrenderRole.CARRIER.getConfigName(), true), componentFactory.getMessageSchemaValidator( - EblSurrenderRole.PLATFORM.getConfigName(), true))); - } - - private static EblSurrenderScenarioListBuilder voidAndReissue() { - log.debug("EblSurrenderScenarioListBuilder.voidAndReissue()"); - String carrierPartyName = threadLocalCarrierPartyName.get(); - String platformPartyName = threadLocalPlatformPartyName.get(); - return new EblSurrenderScenarioListBuilder( - previousAction -> - new VoidAndReissueAction(carrierPartyName, platformPartyName, previousAction)); + EblSurrenderRole.PLATFORM.getConfigName(), true), + accept, + title, + isSWTP)); } } diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderStandard.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderStandard.java index eb66d255..0b4cdd7a 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderStandard.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/EblSurrenderStandard.java @@ -13,9 +13,7 @@ private EblSurrenderStandard() { @Override public SortedMap> getScenarioSuitesByStandardVersion() { - return new TreeMap<>( - Map.ofEntries( - Map.entry("3.0.0", new TreeSet<>(Set.of("Conformance"))))); + return new TreeMap<>(Map.ofEntries(Map.entry("3.0.0", new TreeSet<>(Set.of("Conformance"))))); } @Override diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/SurrenderChecks.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/SurrenderChecks.java index 10018124..4b79de50 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/SurrenderChecks.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/SurrenderChecks.java @@ -1,5 +1,8 @@ package org.dcsa.conformance.standards.eblsurrender; +import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES; + +import java.util.UUID; import org.dcsa.conformance.core.check.ActionCheck; import org.dcsa.conformance.core.check.JsonAttribute; import org.dcsa.conformance.core.check.JsonContentCheck; @@ -8,10 +11,6 @@ import org.dcsa.conformance.core.traffic.HttpMessageType; import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; -import java.util.UUID; - -import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES; - public class SurrenderChecks { private static final KeywordDataset SURRENDER_ACTIONS_DATA_SET = KeywordDataset.staticDataset( "ISSUE", @@ -46,4 +45,5 @@ public static ActionCheck surrenderRequestChecks(UUID matched, String standardVe SURRENDER_PARTY_CODE_LIST_PROVIDER ); } + } diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SupplyScenarioParametersAction.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SupplyScenarioParametersAction.java index 03731c00..d7a6a16d 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SupplyScenarioParametersAction.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SupplyScenarioParametersAction.java @@ -1,5 +1,7 @@ package org.dcsa.conformance.standards.eblsurrender.action; +import static org.dcsa.conformance.core.toolkit.JsonToolkit.OBJECT_MAPPER; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.UUID; @@ -7,14 +9,16 @@ import org.dcsa.conformance.core.scenario.ConformanceAction; import org.dcsa.conformance.standards.eblsurrender.party.SuppliedScenarioParameters; -import static org.dcsa.conformance.core.toolkit.JsonToolkit.OBJECT_MAPPER; - @Getter public class SupplyScenarioParametersAction extends ConformanceAction { private SuppliedScenarioParameters suppliedScenarioParameters = null; + private String response; + private String eblType; - public SupplyScenarioParametersAction(String carrierPartyName, ConformanceAction previousAction) { - super(carrierPartyName, null, previousAction, "SupplyTDR"); + public SupplyScenarioParametersAction(String carrierPartyName, ConformanceAction previousAction, String response, String eblType) { + super(carrierPartyName, null, previousAction, "SupplyTDR[%s]".formatted(eblType)); + this.response = response; + this.eblType = eblType; } @Override @@ -29,6 +33,8 @@ public ObjectNode exportJsonState() { if (suppliedScenarioParameters != null) { jsonState.set("suppliedScenarioParameters", suppliedScenarioParameters.toJson()); } + jsonState.put("response",response); + jsonState.put("eblType",eblType); return jsonState; } @@ -39,19 +45,23 @@ public void importJsonState(JsonNode jsonState) { if (sspNode != null) { suppliedScenarioParameters = SuppliedScenarioParameters.fromJson(sspNode); } + response = jsonState.get("response").asText(); + eblType = jsonState.get("eblType").asText(); } @Override public String getHumanReadablePrompt() { + String responseAction = response.equals("SURR")?"accept":"reject"; return "Use the following format to provide the transport document reference and additional info " - + "of a straight eBL for which your party can accept a surrender request:"; + + "of a "+ eblType +" for which your party can "+responseAction+ " a surrender request:"; } @Override public JsonNode getJsonForHumanReadablePrompt() { + String eblPlatform = response.equals("SURR")?"WAVE":"WAVER"; var issueToParty = OBJECT_MAPPER.createObjectNode(); issueToParty.put("partyName", "Issue To name") - .put("eblPlatform", "WAVE"); + .put("eblPlatform", eblPlatform); var carrierParty = OBJECT_MAPPER.createObjectNode(); carrierParty.put("partyName", "Carrier name") .put("eblPlatform", "WAVE"); @@ -78,4 +88,11 @@ public void handlePartyInput(JsonNode partyInput) { super.handlePartyInput(partyInput); suppliedScenarioParameters = SuppliedScenarioParameters.fromJson(partyInput.get("input")); } + + @Override + public ObjectNode asJsonNode() { + return super.asJsonNode() + .put("eblType", eblType) + .put("response", response); + } } diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestAction.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestAction.java deleted file mode 100644 index f3a3e1f6..00000000 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestAction.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.dcsa.conformance.standards.eblsurrender.action; - -import com.fasterxml.jackson.core.JsonPointer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; -import java.util.stream.Stream; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.dcsa.conformance.core.check.*; -import org.dcsa.conformance.core.scenario.ConformanceAction; -import org.dcsa.conformance.core.traffic.ConformanceExchange; -import org.dcsa.conformance.core.traffic.HttpMessageType; -import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; - -import static org.dcsa.conformance.standards.eblsurrender.SurrenderChecks.surrenderRequestChecks; - -@Getter -@Slf4j -public class SurrenderRequestAction extends EblSurrenderAction { - private final JsonSchemaValidator requestSchemaValidator; - private final boolean forAmendment; - - private final AtomicReference surrenderRequestReference = new AtomicReference<>(); - - private final Supplier srrSupplier = surrenderRequestReference::get; - - public SurrenderRequestAction( - boolean forAmendment, - String platformPartyName, - String carrierPartyName, - int expectedStatus, - ConformanceAction previousAction, - JsonSchemaValidator requestSchemaValidator) { - super( - platformPartyName, - carrierPartyName, - expectedStatus, - previousAction, - "%s %d".formatted(forAmendment ? "AREQ" : "SREQ", expectedStatus)); - this.forAmendment = forAmendment; - this.requestSchemaValidator = requestSchemaValidator; - } - - @Override - public ObjectNode exportJsonState() { - ObjectNode jsonState = super.exportJsonState(); - String srr = surrenderRequestReference.get(); - if (srr != null) { - jsonState.put("surrenderRequestReference", srr); - } - return jsonState; - } - - @Override - public void importJsonState(JsonNode jsonState) { - super.importJsonState(jsonState); - JsonNode srrNode = jsonState.get("surrenderRequestReference"); - if (srrNode != null) { - surrenderRequestReference.set(srrNode.asText()); - } - } - - @Override - public String getHumanReadablePrompt() { - return ("Send a surrender request for %s " - + "for the eBL with the transport document reference '%s'") - .formatted(forAmendment ? "amendment" : "delivery", sspSupplier.get()); - } - - @Override - public synchronized Supplier getSrrSupplier() { - return srrSupplier; - } - - @Override - public ObjectNode asJsonNode() { - // don't include srr because it's not known when this is sent out - return super.asJsonNode().put("forAmendment", forAmendment); - } - - @Override - protected void doHandleExchange(ConformanceExchange exchange) { - JsonNode requestJsonNode = exchange.getRequest().message().body().getJsonBody(); - String srr = requestJsonNode.get("surrenderRequestReference").asText(); - log.info("Updating SurrenderRequestAction '%s' with SRR '%s'".formatted(getActionTitle(), srr)); - this.surrenderRequestReference.set(srr); - } - - @Override - public ConformanceCheck createCheck(String expectedApiVersion) { - return new ConformanceCheck(getActionTitle()) { - @Override - protected Stream createSubChecks() { - return Stream.of( - new UrlPathCheck( - EblSurrenderRole::isPlatform, getMatchedExchangeUuid(), "/ebl-surrender-requests"), - new ResponseStatusCheck( - EblSurrenderRole::isCarrier, getMatchedExchangeUuid(), getExpectedStatus()), - new ApiHeaderCheck( - EblSurrenderRole::isPlatform, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - expectedApiVersion), - new ApiHeaderCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - HttpMessageType.RESPONSE, - expectedApiVersion), - new JsonSchemaCheck( - EblSurrenderRole::isPlatform, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - requestSchemaValidator), - new JsonAttributeCheck( - EblSurrenderRole::isPlatform, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - JsonPointer.compile("/surrenderRequestCode"), - forAmendment ? "AREQ" : "SREQ"), - surrenderRequestChecks(getMatchedExchangeUuid(), expectedApiVersion), - new JsonAttributeCheck( - EblSurrenderRole::isPlatform, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - JsonPointer.compile("/transportDocumentReference"), - sspSupplier.get() == null ? null : sspSupplier.get().transportDocumentReference())); - } - }; - } -} diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestResponseAction.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestResponseAction.java new file mode 100644 index 00000000..bec77edc --- /dev/null +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderRequestResponseAction.java @@ -0,0 +1,186 @@ +package org.dcsa.conformance.standards.eblsurrender.action; + +import static org.dcsa.conformance.standards.eblsurrender.SurrenderChecks.surrenderRequestChecks; + +import com.fasterxml.jackson.core.JsonPointer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; +import java.util.stream.Stream; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.dcsa.conformance.core.check.*; +import org.dcsa.conformance.core.scenario.ConformanceAction; +import org.dcsa.conformance.core.traffic.ConformanceExchange; +import org.dcsa.conformance.core.traffic.HttpMessageType; +import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; + +@Getter +@Slf4j +public class SurrenderRequestResponseAction extends EblSurrenderAction { + private final JsonSchemaValidator requestSchemaValidator; + private final JsonSchemaValidator responseSchemaValidator; + private final boolean forAmendment; + private final boolean accept; + private final boolean isSwitchToPaper; + + private final AtomicReference surrenderRequestReference = new AtomicReference<>(); + + private final Supplier srrSupplier = surrenderRequestReference::get; + + public SurrenderRequestResponseAction( + boolean forAmendment, + String platformPartyName, + String carrierPartyName, + int expectedStatus, + ConformanceAction previousAction, + JsonSchemaValidator requestSchemaValidator, + JsonSchemaValidator responseSchemaValidator, + boolean accept, + String title, + boolean isSWTP) { + super(platformPartyName, carrierPartyName, expectedStatus, previousAction, title); + this.forAmendment = forAmendment; + this.requestSchemaValidator = requestSchemaValidator; + this.responseSchemaValidator = responseSchemaValidator; + this.accept = accept; + this.isSwitchToPaper = isSWTP; + } + + @Override + public ObjectNode exportJsonState() { + ObjectNode jsonState = super.exportJsonState(); + String srr = surrenderRequestReference.get(); + if (srr != null) { + jsonState.put("surrenderRequestReference", srr); + } + return jsonState; + } + + @Override + public void importJsonState(JsonNode jsonState) { + super.importJsonState(jsonState); + JsonNode srrNode = jsonState.get("surrenderRequestReference"); + if (srrNode != null) { + surrenderRequestReference.set(srrNode.asText()); + } + } + + @Override + public String getHumanReadablePrompt() { + return ("Send a surrender request for %s " + + "for the eBL with the transport document reference '%s'") + .formatted( + forAmendment ? "amendment" : "delivery", + sspSupplier.get().transportDocumentReference()); + } + + @Override + protected boolean expectsNotificationExchange() { + return true; + } + + @Override + public synchronized Supplier getSrrSupplier() { + return srrSupplier; + } + + @Override + public ObjectNode asJsonNode() { + // don't include srr because it's not known when this is sent out + return super.asJsonNode() + .put("forAmendment", forAmendment) + .put("isSwitchToPaper", isSwitchToPaper); + } + + @Override + protected void doHandleExchange(ConformanceExchange exchange) { + JsonNode requestJsonNode = exchange.getRequest().message().body().getJsonBody(); + String srr = requestJsonNode.get("surrenderRequestReference").asText(); + log.info("Updating SurrenderRequestAction '%s' with SRR '%s'".formatted(getActionTitle(), srr)); + this.surrenderRequestReference.set(srr); + } + + @Override + public ConformanceCheck createCheck(String expectedApiVersion) { + return new ConformanceCheck(getActionTitle()) { + @Override + protected Stream createSubChecks() { + return Stream.concat( + Stream.of( + new UrlPathCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + "/ebl-surrender-requests"), + new ResponseStatusCheck( + EblSurrenderRole::isCarrier, getMatchedExchangeUuid(), getExpectedStatus()), + new ApiHeaderCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + expectedApiVersion), + new ApiHeaderCheck( + EblSurrenderRole::isCarrier, + getMatchedExchangeUuid(), + HttpMessageType.RESPONSE, + expectedApiVersion), + new JsonSchemaCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + requestSchemaValidator), + new JsonAttributeCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + JsonPointer.compile("/surrenderRequestCode"), + forAmendment ? "AREQ" : "SREQ"), + new JsonAttributeCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + JsonPointer.compile("/reasonCode"), + forAmendment && isSwitchToPaper ? "SWTP" : ""), + surrenderRequestChecks(getMatchedExchangeUuid(), expectedApiVersion), + new JsonAttributeCheck( + EblSurrenderRole::isPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + JsonPointer.compile("/transportDocumentReference"), + sspSupplier.get() == null + ? null + : sspSupplier.get().transportDocumentReference())), + Stream.of( + new UrlPathCheck( + "[Response]", + EblSurrenderRole::isCarrier, + getMatchedNotificationExchangeUuid(), + "/ebl-surrender-responses"), + new ResponseStatusCheck( + "[Response]", + EblSurrenderRole::isPlatform, + getMatchedNotificationExchangeUuid(), + getExpectedStatus()), + new ApiHeaderCheck( + EblSurrenderRole::isPlatform, + getMatchedNotificationExchangeUuid(), + HttpMessageType.RESPONSE, + expectedApiVersion), + new JsonSchemaCheck( + "[Response]", + EblSurrenderRole::isCarrier, + getMatchedNotificationExchangeUuid(), + HttpMessageType.REQUEST, + responseSchemaValidator), + new JsonAttributeCheck( + "[Response]", + EblSurrenderRole::isCarrier, + getMatchedNotificationExchangeUuid(), + HttpMessageType.REQUEST, + JsonPointer.compile("/action"), + accept ? "SURR" : "SREJ"))); + } + }; + } +} diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderResponseAction.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderResponseAction.java deleted file mode 100644 index d03de71d..00000000 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/SurrenderResponseAction.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.dcsa.conformance.standards.eblsurrender.action; - -import com.fasterxml.jackson.core.JsonPointer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.util.Objects; -import java.util.function.Supplier; -import java.util.stream.Stream; -import lombok.Getter; -import org.dcsa.conformance.core.check.*; -import org.dcsa.conformance.core.scenario.ConformanceAction; -import org.dcsa.conformance.core.traffic.HttpMessageType; -import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole; - -@Getter -public class SurrenderResponseAction extends EblSurrenderAction { - private final JsonSchemaValidator requestSchemaValidator; - private final boolean accept; - private Supplier srrSupplier; - - public SurrenderResponseAction( - boolean accept, - String carrierPartyName, - String platformPartyName, - int expectedStatus, - ConformanceAction previousAction, - JsonSchemaValidator requestSchemaValidator) { - super( - carrierPartyName, - platformPartyName, - expectedStatus, - previousAction, - "%s %d".formatted(accept ? "SURR" : "SREJ", expectedStatus)); - this.accept = accept; - this.requestSchemaValidator = requestSchemaValidator; - } - - @Override - public ObjectNode exportJsonState() { - return super.exportJsonState(); - } - - @Override - public void importJsonState(JsonNode jsonState) { - super.importJsonState(jsonState); - } - - @Override - public String getHumanReadablePrompt() { - return ("%s the surrender request with surrender request reference '%s'") - .formatted(accept ? "Accept" : "Reject", getSrrSupplier().get()); - } - - @Override - public synchronized Supplier getSrrSupplier() { - if (srrSupplier != null) return srrSupplier; - for (ConformanceAction action = this.previousAction; - action != null; - action = action.getPreviousAction()) { - if (action instanceof EblSurrenderAction tdrAction) { - if ((srrSupplier = tdrAction.getSrrSupplier()) != null) { - return srrSupplier; - } - } - } - return () -> "*"; - } - - @Override - public ObjectNode asJsonNode() { - return super.asJsonNode().put("srr", getSrrSupplier().get()).put("accept", accept); - } - - @Override - public ConformanceCheck createCheck(String expectedApiVersion) { - return new ConformanceCheck(getActionTitle()) { - @Override - protected Stream createSubChecks() { - String expectedSrr = getSrrSupplier().get(); - return Stream.of( - new UrlPathCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - "/ebl-surrender-responses"), - new ResponseStatusCheck( - EblSurrenderRole::isPlatform, getMatchedExchangeUuid(), getExpectedStatus()), - new ApiHeaderCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - expectedApiVersion), - new ApiHeaderCheck( - EblSurrenderRole::isPlatform, - getMatchedExchangeUuid(), - HttpMessageType.RESPONSE, - expectedApiVersion), - new JsonSchemaCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - requestSchemaValidator), - new JsonAttributeCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - JsonPointer.compile("/action"), - accept ? "SURR" : "SREJ"), - expectedSrr == null || expectedSrr.equals("*") - ? null - : new JsonAttributeCheck( - EblSurrenderRole::isCarrier, - getMatchedExchangeUuid(), - HttpMessageType.REQUEST, - JsonPointer.compile("/surrenderRequestReference"), - expectedSrr)) - .filter(Objects::nonNull); - } - }; - } -} diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/VoidAndReissueAction.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/VoidAndReissueAction.java deleted file mode 100644 index 0795c9f6..00000000 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/action/VoidAndReissueAction.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.dcsa.conformance.standards.eblsurrender.action; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.function.Supplier; -import lombok.Getter; -import org.dcsa.conformance.core.scenario.ConformanceAction; - -@Getter -public class VoidAndReissueAction extends EblSurrenderAction { - - private final Consumer tdrConsumer = - tdr -> { - if (!Objects.equals(tdr, sspSupplier.get().transportDocumentReference())) { - throw new UnsupportedOperationException( - "Changing the transportDocumentReference during void/reissue is currently not supported"); - } - }; - - public VoidAndReissueAction( - String carrierPartyName, String platformPartyName, ConformanceAction previousAction) { - super(carrierPartyName, platformPartyName, -1, previousAction, "Void&Reissue"); - } - - @Override - public ObjectNode exportJsonState() { - return super.exportJsonState(); - } - - @Override - public void importJsonState(JsonNode jsonState) { - super.importJsonState(jsonState); - } - - @Override - public String getHumanReadablePrompt() { - return "Void and reissue the eBL with transport document reference '%s'".formatted(sspSupplier.get()); - } - - @Override - public boolean isConfirmationRequired() { - return true; - } - - @Override - public boolean isMissingMatchedExchange() { - return false; - } - - @Override - public Supplier getSrrSupplier() { - return null; - } -} diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderCarrier.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderCarrier.java index c7a1c461..508d1717 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderCarrier.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderCarrier.java @@ -19,8 +19,6 @@ import org.dcsa.conformance.core.traffic.ConformanceRequest; import org.dcsa.conformance.core.traffic.ConformanceResponse; import org.dcsa.conformance.standards.eblsurrender.action.SupplyScenarioParametersAction; -import org.dcsa.conformance.standards.eblsurrender.action.SurrenderResponseAction; -import org.dcsa.conformance.standards.eblsurrender.action.VoidAndReissueAction; @Slf4j public class EblSurrenderCarrier extends ConformanceParty { @@ -73,9 +71,7 @@ protected void doReset() { @Override protected Map, Consumer> getActionPromptHandlers() { return Map.ofEntries( - Map.entry(SupplyScenarioParametersAction.class, this::supplyScenarioParameters), - Map.entry(SurrenderResponseAction.class, this::sendSurrenderResponse), - Map.entry(VoidAndReissueAction.class, this::voidAndReissue)); + Map.entry(SupplyScenarioParametersAction.class, this::supplyScenarioParameters)); } private void supplyScenarioParameters(JsonNode actionPrompt) { @@ -85,21 +81,17 @@ private void supplyScenarioParameters(JsonNode actionPrompt) { String tdr = UUID.randomUUID().toString().replace("-", "").substring(0, 20); eblStatesById.put(tdr, EblSurrenderState.AVAILABLE_FOR_SURRENDER); - + persistentMap.save("response", actionPrompt.get("response")); var issueToParty = OBJECT_MAPPER.createObjectNode(); - issueToParty.put("partyName", "Issue To name") - .put("eblPlatform", "WAVE"); + issueToParty.put("partyName", "Issue To name").put("eblPlatform", "WAVE"); var carrierParty = OBJECT_MAPPER.createObjectNode(); - carrierParty.put("partyName", "Carrier name") - .put("eblPlatform", "WAVE"); + carrierParty.put("partyName", "Carrier name").put("eblPlatform", "WAVE"); var surrendereeParty = OBJECT_MAPPER.createObjectNode(); - surrendereeParty.put("partyName", "Surrenderee name") - .put("eblPlatform", "BOLE"); + surrendereeParty.put("partyName", "Surrenderee name").put("eblPlatform", "BOLE"); SuppliedScenarioParameters suppliedScenarioParameters = - new SuppliedScenarioParameters( - tdr, issueToParty, carrierParty, surrendereeParty); + new SuppliedScenarioParameters(tdr, issueToParty, carrierParty, surrendereeParty); asyncOrchestratorPostPartyInput( actionPrompt.required("actionId").asText(), suppliedScenarioParameters.toJson()); @@ -109,56 +101,6 @@ private void supplyScenarioParameters(JsonNode actionPrompt) { .formatted(suppliedScenarioParameters.toJson().toPrettyString())); } - private void voidAndReissue(JsonNode actionPrompt) { - log.info("EblSurrenderCarrier.voidAndReissue(%s)".formatted(actionPrompt.toPrettyString())); - SuppliedScenarioParameters ssp = SuppliedScenarioParameters.fromJson(actionPrompt.get("suppliedScenarioParameters")); - String tdr = ssp.transportDocumentReference(); - if (!Objects.equals(eblStatesById.get(tdr), EblSurrenderState.SURRENDERED_FOR_AMENDMENT)) { - throw new IllegalStateException( - "Cannot void and reissue in state: " + eblStatesById.get(tdr)); - } - eblStatesById.put(tdr, EblSurrenderState.AVAILABLE_FOR_SURRENDER); - asyncOrchestratorPostPartyInput( - actionPrompt.get("actionId").asText(), OBJECT_MAPPER.createObjectNode()); - addOperatorLogEntry( - "Voided and reissued the eBL with transportDocumentReference '%s'".formatted(tdr)); - } - - private void sendSurrenderResponse(JsonNode actionPrompt) { - log.info( - "EblSurrenderCarrier.sendSurrenderResponse(%s)".formatted(actionPrompt.toPrettyString())); - SuppliedScenarioParameters ssp = SuppliedScenarioParameters.fromJson(actionPrompt.get("suppliedScenarioParameters")); - String tdr = ssp.transportDocumentReference(); - boolean accept = actionPrompt.get("accept").asBoolean(); - switch (eblStatesById.get(tdr)) { - case AMENDMENT_SURRENDER_REQUESTED -> eblStatesById.put( - tdr, - accept - ? EblSurrenderState.SURRENDERED_FOR_AMENDMENT - : EblSurrenderState.AVAILABLE_FOR_SURRENDER); - case DELIVERY_SURRENDER_REQUESTED -> eblStatesById.put( - tdr, - accept - ? EblSurrenderState.SURRENDERED_FOR_DELIVERY - : EblSurrenderState.AVAILABLE_FOR_SURRENDER); - default -> {} // ignore -- sending from wrong state for testing purposes - } - String srr = actionPrompt.get("srr").asText(); - if ("*".equals(srr)) { - srr = UUID.randomUUID().toString(); - } - syncCounterpartPost( - "/v%s/ebl-surrender-responses".formatted(apiVersion.charAt(0)), - OBJECT_MAPPER - .createObjectNode() - .put("surrenderRequestReference", srr) - .put("action", accept ? "SURR" : "SREJ")); - - addOperatorLogEntry( - "%s surrender request with surrenderRequestReference '%s' for eBL with transportDocumentReference '%s' (now in state '%s')" - .formatted(accept ? "Accepted" : "Rejected", srr, tdr, eblStatesById.get(tdr))); - } - @Override public ConformanceResponse handleRequest(ConformanceRequest request) { log.info("EblSurrenderCarrier.handleRequest(%s)".formatted(request)); @@ -166,12 +108,28 @@ public ConformanceResponse handleRequest(ConformanceRequest request) { String src = jsonRequest.get("surrenderRequestCode").asText(); String srr = jsonRequest.get("surrenderRequestReference").asText(); String tdr = jsonRequest.get("transportDocumentReference").asText(); + String action = tdr.contains("WAVER") ? "SREJ" : "SURR"; + + if ("*".equals(srr)) { + srr = UUID.randomUUID().toString(); + } + if (persistentMap.load("response") != null) { + action = persistentMap.load("response").asText(); + } + + var carrierResponse = + OBJECT_MAPPER + .createObjectNode() + .put("surrenderRequestReference", srr) + .put("action", action); + asyncCounterpartNotification(null, "/v3/ebl-surrender-responses", carrierResponse); if (Objects.equals( EblSurrenderState.AVAILABLE_FOR_SURRENDER, eblStatesById.getOrDefault( tdr, - // workaround for supplyScenarioParameters() not getting called on parties in manual mode + // workaround for supplyScenarioParameters() not getting called on parties in manual + // mode this.partyConfiguration.isInManualMode() ? EblSurrenderState.AVAILABLE_FOR_SURRENDER : null))) { diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderPlatform.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderPlatform.java index 50c85a74..72747053 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderPlatform.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderPlatform.java @@ -19,7 +19,7 @@ import org.dcsa.conformance.core.traffic.ConformanceMessageBody; import org.dcsa.conformance.core.traffic.ConformanceRequest; import org.dcsa.conformance.core.traffic.ConformanceResponse; -import org.dcsa.conformance.standards.eblsurrender.action.SurrenderRequestAction; +import org.dcsa.conformance.standards.eblsurrender.action.SurrenderRequestResponseAction; @Slf4j public class EblSurrenderPlatform extends ConformanceParty { @@ -45,8 +45,7 @@ public EblSurrenderPlatform( @Override protected void exportPartyJsonState(ObjectNode targetObjectNode) { targetObjectNode.set( - "eblStatesById", - StateManagementUtil.storeMap(eblStatesById, EblSurrenderState::name)); + "eblStatesById", StateManagementUtil.storeMap(eblStatesById, EblSurrenderState::name)); targetObjectNode.set("tdrsBySrr", StateManagementUtil.storeMap(tdrsBySrr)); } @@ -65,7 +64,7 @@ protected void doReset() { @Override protected Map, Consumer> getActionPromptHandlers() { - return Map.ofEntries(Map.entry(SurrenderRequestAction.class, this::requestSurrender)); + return Map.ofEntries(Map.entry(SurrenderRequestResponseAction.class, this::requestSurrender)); } private void requestSurrender(JsonNode actionPrompt) { @@ -76,13 +75,24 @@ private void requestSurrender(JsonNode actionPrompt) { String tdr = ssp.transportDocumentReference(); boolean forAmendment = actionPrompt.get("forAmendment").booleanValue(); String src = forAmendment ? "AREQ" : "SREQ"; + String action = + ssp.issueToParty().get("eblPlatform") != null + ? ssp.issueToParty().get("eblPlatform").asText() + : null; + if (action != null && action.equals("WAVER")) { + tdr = tdr + action; + } tdrsBySrr.put(srr, tdr); eblStatesById.put( tdr, forAmendment ? EblSurrenderState.AMENDMENT_SURRENDER_REQUESTED : EblSurrenderState.DELIVERY_SURRENDER_REQUESTED); - + String reasonCode = + actionPrompt.get("isSwitchToPaper") != null + && actionPrompt.get("isSwitchToPaper").booleanValue() + ? "SWTP" + : ""; JsonNode jsonRequestBody = JsonToolkit.templateFileToJsonNode( "/standards/eblsurrender/messages/eblsurrender-api-v%s-request.json" @@ -91,14 +101,14 @@ private void requestSurrender(JsonNode actionPrompt) { Map.entry("SURRENDER_REQUEST_REFERENCE_PLACEHOLDER", srr), Map.entry("TRANSPORT_DOCUMENT_REFERENCE_PLACEHOLDER", tdr), Map.entry("SURRENDER_REQUEST_CODE_PLACEHOLDER", src), + Map.entry("REASON_CODE", reasonCode), Map.entry("ISSUE_TO_PARTY", ssp.issueToParty().toString()), Map.entry("SURRENDEREE_PARTY", ssp.surrendereeParty().toString()), Map.entry("CARRIER_PARTY", ssp.carrierParty().toString()), Map.entry("ACTION_DATE_TIME_PLACEHOLDER", Instant.now().toString()))); syncCounterpartPost( - "/v%s/ebl-surrender-requests".formatted(apiVersion.charAt(0)), - jsonRequestBody); + "/v%s/ebl-surrender-requests".formatted(apiVersion.charAt(0)), jsonRequestBody); addOperatorLogEntry( "Sent surrender request with surrenderRequestCode '%s' and surrenderRequestReference '%s' for eBL with transportDocumentReference '%s'" @@ -151,8 +161,12 @@ public ConformanceResponse handleRequest(ConformanceRequest request) { "Rejecting '%s' for document '%s' because it is in state '%s'" .formatted(action, tdr, eblStatesById.get(tdr))))); } + /*addOperatorLogEntry( + "Handling surrender response with action '%s' and surrenderRequestReference '%s' for eBL with transportDocumentReference '%s' (now in state '%s')" + .formatted(action, srr, tdr, eblStatesById.get(tdr)));*/ + addOperatorLogEntry( - "Handling surrender response with action '%s' and surrenderRequestReference '%s' for eBL with transportDocumentReference '%s' (now in state '%s')" + "Handling notification with action '%s' and surrenderRequestReference '%s' for eBL with transportDocumentReference '%s' (now in state '%s')" .formatted(action, srr, tdr, eblStatesById.get(tdr))); return response; } diff --git a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderState.java b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderState.java index 6fdf30e7..9e2baac8 100644 --- a/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderState.java +++ b/ebl-surrender/src/main/java/org/dcsa/conformance/standards/eblsurrender/party/EblSurrenderState.java @@ -1,9 +1,9 @@ package org.dcsa.conformance.standards.eblsurrender.party; public enum EblSurrenderState { - AVAILABLE_FOR_SURRENDER, - AMENDMENT_SURRENDER_REQUESTED, - SURRENDERED_FOR_AMENDMENT, - DELIVERY_SURRENDER_REQUESTED, - SURRENDERED_FOR_DELIVERY, + AVAILABLE_FOR_SURRENDER, + AMENDMENT_SURRENDER_REQUESTED, + SURRENDERED_FOR_AMENDMENT, + DELIVERY_SURRENDER_REQUESTED, + SURRENDERED_FOR_DELIVERY, } diff --git a/ebl-surrender/src/main/resources/standards/eblsurrender/messages/eblsurrender-api-v3.0.0-request.json b/ebl-surrender/src/main/resources/standards/eblsurrender/messages/eblsurrender-api-v3.0.0-request.json index 8a515350..9aafeb6a 100644 --- a/ebl-surrender/src/main/resources/standards/eblsurrender/messages/eblsurrender-api-v3.0.0-request.json +++ b/ebl-surrender/src/main/resources/standards/eblsurrender/messages/eblsurrender-api-v3.0.0-request.json @@ -2,7 +2,7 @@ "surrenderRequestReference": "SURRENDER_REQUEST_REFERENCE_PLACEHOLDER", "transportDocumentReference": "TRANSPORT_DOCUMENT_REFERENCE_PLACEHOLDER", "surrenderRequestCode": "SURRENDER_REQUEST_CODE_PLACEHOLDER", - "reasonCode": "SWTP", + "reasonCode": "REASON_CODE", "comments": "As requested...", "endorsementChain": [ {