aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz')
-rw-r--r--src/main/java/at/gv/egiz/moazs/client/TnvzHelper.java34
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java36
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/NameSpace.java3
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java2
4 files changed, 39 insertions, 36 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/client/TnvzHelper.java b/src/main/java/at/gv/egiz/moazs/client/TnvzHelper.java
index 5cc4954..e6bacec 100644
--- a/src/main/java/at/gv/egiz/moazs/client/TnvzHelper.java
+++ b/src/main/java/at/gv/egiz/moazs/client/TnvzHelper.java
@@ -69,9 +69,9 @@ public class TnvzHelper {
var tnvzResponse = tnvzPort.queryPerson(tnvzQuery);
verifyResponse(tnvzResponse);
- var tnvzResult = getResult(tnvzResponse);
+ var tnvzResult = getFirstResult(tnvzResponse);
var typesInRequest = extractListOfMimemtypesIn(mzsRequest);
- checkMimetypes(tnvzResult, typesInRequest);
+ checkMimetypes(tnvzResponse, typesInRequest);
return tnvzResult.getSuccess().getIdentification();
}
@@ -196,14 +196,15 @@ public class TnvzHelper {
}
}
- private PersonResultType getResult(QueryPersonResponse tnvzResponse) {
+ private PersonResultType getFirstResult(QueryPersonResponse tnvzResponse) {
return tnvzResponse.getQueryResultList().getQueryResult().get(0);
}
- private void checkMimetypes(PersonResultType tnvzResult, Set<String> typesInRequest) {
- var mismatchedTypes = findMimeTypeMismatches(tnvzResult, typesInRequest);
+ private void checkMimetypes(QueryPersonResponse tnvzResponse, Set<String> typesInRequest) {
+
+ var mismatchedTypes = findMimeTypeMismatches(tnvzResponse, typesInRequest);
if (!mismatchedTypes.isEmpty()) {
- var acceptedTypesString = join(",", getAcceptedTypes(tnvzResult));
+ var acceptedTypesString = join(",", getAcceptedTypes(tnvzResponse));
var mismatchedTypesString = join(",", mismatchedTypes);
var message = String.format(MIMETYPE_MISSMATCH_ERROR_MSG, mismatchedTypesString, acceptedTypesString);
var code = MoaZSException.ERROR_MZS_MIMETYPE_MISSMATCH;
@@ -211,10 +212,11 @@ public class TnvzHelper {
}
}
- private Collection<String> findMimeTypeMismatches(PersonResultType result, Set<String> typesInRequest) {
- var acceptedTypes = getAcceptedTypes(result);
+ private Collection<String> findMimeTypeMismatches(QueryPersonResponse response, Set<String> typesInRequest) {
+ var acceptedTypes = getAcceptedTypes(response);
- if (acceptedTypes.contains("*/*")) {
+ var result = getFirstResult(response);
+ if (result.getSuccess().getAllStandardMimeTypes() != null) {
return List.of();
}
@@ -224,8 +226,18 @@ public class TnvzHelper {
return typesInRequestCopy;
}
- private List<String> getAcceptedTypes(PersonResultType result) {
- return result.getSuccess().getMimeTypeList().getMimeType();
+ private Set<String> getAcceptedTypes(QueryPersonResponse response) {
+
+ Set<String> union = new HashSet<>();
+ var standardTypes = response.getStandardMimeTypeList().getMimeType();
+ union.addAll(standardTypes);
+
+ var acceptedTypeList = getFirstResult(response).getSuccess().getMimeTypeList();
+ if(acceptedTypeList != null) {
+ union.addAll(acceptedTypeList.getMimeType());
+ }
+
+ return union;
}
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java
index 65b6425..cabb128 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java
@@ -24,53 +24,48 @@ import static java.util.stream.Collectors.toList;
@Component
public class Msg2MzsConverter {
- private static final Logger log = LoggerFactory.getLogger(Msg2MzsConverter.class);
-
- private static final String ANSWERS_MISSING_ERROR_MSG = "msg:DeliveryNotification contains no msg:Answer elements" +
- " and cannot be converted to mzs:DeliveryNotification.";
private static final String UNKNOWN_ANSWER_ERROR_MSG = "msg:DeliveryNotification/msg:Answer is of unknown type" +
" and cannot be converted.";
- private static final String TOO_MANY_ANSWERS_MSG = "msg:DeliveryNotification contains more msg:Answer elements than" +
- " expected. All answers except the first one will be ignored.";
public DeliveryResponseType convert(DeliveryRequestStatusType status, Optional<byte[]> signedStatus) {
var responseBuilder = deliveryResponseTypeBuilder();
if (status.getError() != null) {
- responseBuilder.withError(convert(status.getError(), signedStatus));
+ responseBuilder.withError(convert(status.getError(), signedStatus, status.getRelayedViaERV()));
} else if (status.getSuccess() != null) {
- responseBuilder.withSuccess(convert(status.getSuccess(), signedStatus));
+ responseBuilder.withSuccess(convert(status.getSuccess(), signedStatus, status.getRelayedViaERV()));
} else {
- responseBuilder.withPartialSuccess(convert(status.getPartialSuccess(), signedStatus));
+ responseBuilder.withPartialSuccess(convert(status.getPartialSuccess(), signedStatus, status.getRelayedViaERV()));
}
return responseBuilder.build();
}
- private SuccessType convert(DeliveryRequestStatusType.Success success, Optional<byte[]> signedStatus) {
+ private SuccessType convert(DeliveryRequestStatusType.Success success, Optional<byte[]> signedStatus, RelayedViaERV relayed) {
return successTypeBuilder()
.withAppDeliveryID(success.getAppDeliveryID())
.withDeliverySystem(success.getDeliverySystem())
.withGZ(success.getGZ())
.withZSDeliveryID(success.getZSDeliveryID())
.withSignedDeliveryRequestStatus(signedStatus.orElse(null))
- .withRelayedViaERV(success.isRelayedViaERV())
+ .withRelayedViaERV(relayed)
.withDeliveryTimestamp(success.getDeliveryTimestamp())
.build();
}
- private PartialSuccessType convert(DeliveryAnswerType answer, Optional<byte[]> signedStatus) {
+ private PartialSuccessType convert(DeliveryAnswerType answer, Optional<byte[]> signedStatus, RelayedViaERV relayed) {
return partialSuccessTypeBuilder()
.withAppDeliveryID(answer.getAppDeliveryID())
.withDeliverySystem(answer.getDeliverySystem())
.withGZ(answer.getGZ())
.withZSDeliveryID(answer.getZSDeliveryID())
+ .withRelayedViaERV(relayed)
.withSignedDeliveryRequestStatus(signedStatus.orElse(null))
.build();
}
- private ErrorType convert(DeliveryRequestStatusType.Error error, Optional<byte[]> signedStatus) {
+ private ErrorType convert(DeliveryRequestStatusType.Error error, Optional<byte[]> signedStatus, RelayedViaERV relayed) {
var builder = errorTypeBuilder()
.withAppDeliveryID(error.getAppDeliveryID())
.withDeliverySystem(error.getDeliverySystem())
@@ -78,6 +73,7 @@ public class Msg2MzsConverter {
.withZSDeliveryID(error.getZSDeliveryID())
.withSignedDeliveryRequestStatus(signedStatus.orElse(null))
.withPreAdviceNoteSent(error.getPreAdviceNoteSent())
+ .withRelayedViaERV(relayed)
.withCode(new BigInteger(error.getErrorInfo().getCode()));
if(error.getErrorInfo().getText() != null) builder.withText(error.getErrorInfo().getText());
@@ -90,15 +86,7 @@ public class Msg2MzsConverter {
var builder = deliveryNotificationTypeBuilder();
- if (msgNotification.getAnswer().isEmpty()) {
- throw moaZSException(ANSWERS_MISSING_ERROR_MSG);
- }
-
- if (msgNotification.getAnswer().size() > 1) {
- log.warn(TOO_MANY_ANSWERS_MSG);
- }
-
- JAXBElement<? extends AbstractOperationType> answer = msgNotification.getAnswer().get(0);
+ JAXBElement<? extends AbstractOperationType> answer = msgNotification.getAnswer();
if(answer.getValue() instanceof AcceptedType) {
var accepted = (AcceptedType) answer.getValue();
@@ -108,6 +96,9 @@ public class Msg2MzsConverter {
var error = (DeliveryErrorType) answer.getValue();
builder.withError(extractError(msgNotification, error, signedNotification))
.withNotificationsPerformed(error.getNotificationsPerformed());
+ } else if(answer.getValue() instanceof ERVConfirmedDeliveryType) {
+ ERVConfirmedDeliveryType ervConfirmed = (ERVConfirmedDeliveryType) answer.getValue();
+ builder.withERVConfirmedDelivery(ervConfirmed);
} else {
throw moaZSException(UNKNOWN_ANSWER_ERROR_MSG);
}
@@ -141,7 +132,6 @@ public class Msg2MzsConverter {
.withZSDeliveryID(msgNotification.getZSDeliveryID())
.withGZ(msgNotification.getGZ())
.withSignedDeliveryRequestStatus(signedNotification.orElse(null))
- .withRelayedViaERV(msgNotification.isRelayedViaERV())
.withDeliveryTimestamp(msgNotification.getTimestamp())
.build();
}
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NameSpace.java b/src/main/java/at/gv/egiz/moazs/scheme/NameSpace.java
index 23b19e7..8cf82da 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/NameSpace.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/NameSpace.java
@@ -7,7 +7,8 @@ public class NameSpace {
private static final at.gv.zustellung.msg.xsd.ObjectFactory MSG_FACTORY = new at.gv.zustellung.msg.xsd.ObjectFactory();
private static final at.gv.zustellung.app2mzs.xsd.ObjectFactory MZS_FACTORY = new at.gv.zustellung.app2mzs.xsd.ObjectFactory();
- public static final String MSG_VERSION = "2.2.0";
+ public static final String MSG_VERSION = "2.2.007";
+ public static final String TNVZ_VERSION = "2.2.006";
public static final String MSG = MSG_FACTORY.createDeliveryRequest(null).getName().getNamespaceURI();
public static final String MSGP = new at.gv.zustellung.msg.xsd.persondata.ObjectFactory().createPerson(null).getName().getNamespaceURI();
public static final String MZS = new at.gv.zustellung.app2mzs.xsd.ObjectFactory().createDeliveryRequest(null).getName().getNamespaceURI();
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
index 85e7737..1a1a8eb 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
@@ -67,7 +67,7 @@ public class NotificationResponse extends MsgResponse<DeliveryNotificationType>
.build();
var notificationType = deliveryNotificationTypeBuilder(notification)
- .withAnswer(List.of(factory.createAnswer(error)))
+ .withAnswer(factory.createAnswer(error))
.build();
return new NotificationResponse(notificationType);