aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-13 09:16:57 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-13 09:16:57 +0200
commit8306ffe75de8e6bfaa01fc5ee7657c168edbabc0 (patch)
treef9051db6dff3a30b6f759de09432cc925286f8d3
parentdd9f5860032e6aae08aa8d3a7630075ad65ad694 (diff)
downloadmoa-zs-8306ffe75de8e6bfaa01fc5ee7657c168edbabc0.tar.gz
moa-zs-8306ffe75de8e6bfaa01fc5ee7657c168edbabc0.tar.bz2
moa-zs-8306ffe75de8e6bfaa01fc5ee7657c168edbabc0.zip
Refactor and Format Fixes in Pipeline
- Fix: Replace MessageFormat.format with String.format - Refactor: Replace RuntimeException with MoaZSException - Refactor: Use Method Reference
-rw-r--r--src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java19
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);