diff options
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java index b93bb35..7943754 100644 --- a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java +++ b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java @@ -2,10 +2,11 @@ package at.gv.egiz.moazs.pipeline; import at.gv.egiz.moazs.MsgClient; -import at.gv.egiz.moazs.scheme.Mzs2MsgConverter; import at.gv.egiz.moazs.TnvzClient; import at.gv.egiz.moazs.repository.DeliveryRepository; +import at.gv.egiz.moazs.scheme.Mzs2MsgConverter; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; +import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Payload; import at.gv.zustellung.msg.xsd.persondata.IdentificationType; import at.gv.zustellung.tnvz.xsd.PersonResultType; import org.springframework.beans.factory.annotation.Autowired; @@ -15,7 +16,7 @@ import org.springframework.stereotype.Component; import java.util.Collection; import java.util.List; -import static java.lang.String.format; +import static at.gv.egiz.moazs.MoaZSException.moaZSException; import static java.lang.String.join; import static java.util.stream.Collectors.toSet; @@ -56,20 +57,18 @@ public class SameThreadDeliveryPipeline implements DeliveryPipeline { if (result.getError() != null) { var error = result.getError(); var info = error.getErrorInfo(); - var noteSent = format("Preadvice note was {0}sent", (error.getPreAdviceNoteSent() != null) ? "" : "not "); - var message = format("Receiver is not addressable. Code: {0} ; Text: {1}; {2}", - info.getCode(), info.getText(), noteSent); - throw new RuntimeException(message); + var noteSent = (error.getPreAdviceNoteSent() != null) ? "sent" : "not sent"; + var template = "Receiver is not addressable. Code: %s ; Text: %s; Preadvice note was %s."; + throw moaZSException(template, info.getCode(), info.getText(), noteSent); } var mismatchedTypes = findMimeTypeMismatches(result, request); if (!mismatchedTypes.isEmpty()) { - var template = "Request contains attachment of type(s) {0}, but receiver only accepts attachments of type(s) {1}"; + var template = "Request contains attachment of type(s) %s, but receiver only accepts attachments of type(s) %s"; var acceptedTypesString = join(",", getAcceptedTypes(result)); var mismatchedTypesString = join(",", mismatchedTypes); - var message = format(template, mismatchedTypesString, acceptedTypesString); - throw new RuntimeException(message); + throw moaZSException(template, mismatchedTypesString, acceptedTypesString); } return result.getSuccess().getIdentification(); @@ -83,7 +82,7 @@ public class SameThreadDeliveryPipeline implements DeliveryPipeline { } var typesInRequest = request.getPayload().stream() - .map(payload -> payload.getMIMEType()) + .map(Payload::getMIMEType) .collect(toSet()); typesInRequest.removeAll(acceptedTypes); |