From 5fffae99208c7a99a5e3e8f196a6004debcc9c81 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Fri, 29 Nov 2019 12:55:06 +0100 Subject: 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. --- .../java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java | 18 ++++++++++++++---- 1 file 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; } -- cgit v1.2.3