aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-11-29 12:55:06 +0100
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-11-29 12:55:06 +0100
commit5fffae99208c7a99a5e3e8f196a6004debcc9c81 (patch)
treeff375aac203d3e8429ab44e44075fa5a9044dbe0
parentb10ecd3dc4e2633065db6f3e6aa9fe0972a2ca07 (diff)
downloadmoa-zs-5fffae99208c7a99a5e3e8f196a6004debcc9c81.tar.gz
moa-zs-5fffae99208c7a99a5e3e8f196a6004debcc9c81.tar.bz2
moa-zs-5fffae99208c7a99a5e3e8f196a6004debcc9c81.zip
Fix NPE When Receiver Is Identified by Identity
- Problem: MOA ZS converts the mzs:Receiver/Person to msg:Receiver/Person even if mzs:Receiver/Person is null. - Solution: Distinguish Cases. - Add ClearingProfilID in mzs2msg conversion.
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
index b3ad044..26deea7 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Component;
import javax.xml.bind.JAXBElement;
import java.util.List;
+import static at.gv.egiz.moazs.MoaZSException.moaZSException;
import static at.gv.zustellung.msg.xsd.AttachmentType.attachmentTypeBuilder;
import static at.gv.zustellung.msg.xsd.AttachmentsType.attachmentsTypeBuilder;
import static at.gv.zustellung.msg.xsd.ConfirmationAddress.confirmationAddressBuilder;
@@ -91,6 +92,7 @@ public class Mzs2MsgConverter {
.withLogo(sender.getLogo())
.withAdditionalCriteria(sender.getAdditionalCriteria())
.withConfirmationAddress(convertConfirmationAddress(sender))
+ .withClearingProfilID(sender.getClearingProfilID())
.build();
}
@@ -160,12 +162,20 @@ public class Mzs2MsgConverter {
private Receiver.ReceiverBuilder setupReceiverBuilder(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Receiver receiver) {
var builder = receiverBuilder()
.withPreAdviceNote(receiver.getPreAdviceNote())
- .withAdditionalCriteria(receiver.getAdditionalCriteria())
- .withPerson(convertReceiverPerson(receiver.getPerson()))
- .withAddress(convertAddresses(receiver.getAddress()));
+ .withAdditionalCriteria(receiver.getAdditionalCriteria());
- if (receiver.getIdentification() != null) builder.withIdentification(convert(receiver.getIdentification()));
+ if (receiver.getIdentification() != null) {
+ builder.withIdentification(convert(receiver.getIdentification()));
+ } else if (receiver.getPerson() != null){
+ builder.withPerson(convertReceiverPerson(receiver.getPerson()))
+ .withAustrianAddressesOnly(receiver.getAustrianAddressesOnly());
+ if (receiver.getAddress() != null) {
+ builder.withAddress(convertAddresses(receiver.getAddress()));
+ }
+ } else {
+ throw moaZSException("Cannot create msg:Receiver. Neither Person nor Identification specified.");
+ }
return builder;
}