diff --git a/nachrichten-manager/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java b/nachrichten-manager/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java index 8dc12e899041c5aba9a3125cb658971493c2dc2a..d7b6ca635a2f6940a7f28777a64ce0a8d6bc4089 100644 --- a/nachrichten-manager/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java +++ b/nachrichten-manager/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java @@ -90,12 +90,13 @@ public abstract class PostfachNachrichtMapper { } GrpcPostfachAddress buildGrpcPostfachAddress(Map<String, Object> postfachAddressMap) { - return GrpcPostfachAddress.newBuilder() + var postfachAddressBuilder = GrpcPostfachAddress.newBuilder() .setType(MapUtils.getIntValue(postfachAddressMap, PostfachAddress.TYPE_FIELD)) .setVersion(MapUtils.getString(postfachAddressMap, PostfachAddress.VERSION_FIELD)) - .setIdentifier(grpcObjectMapper.fromMap(postfachAddressMap)) - .setServiceKontoType(MapUtils.getString(postfachAddressMap, PostfachAddress.SERVICEKONTO_TYPE_FIELD)) - .build(); + .setIdentifier(grpcObjectMapper.fromMap(postfachAddressMap)); + Optional.ofNullable(MapUtils.getString(postfachAddressMap, PostfachAddress.SERVICEKONTO_TYPE_FIELD)) + .ifPresent(postfachAddressBuilder::setServiceKontoType); + return postfachAddressBuilder.build(); } PostfachNachricht fromMapToPostfachMail(Map<String, Object> mailMap) { diff --git a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/command/PersistPostfachNachrichtByCommandService.java b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/command/PersistPostfachNachrichtByCommandService.java index 0c5aedd9cf65651682383d7cc71723a192ce357e..2406a618b7ea9b82ae5515fd423cbc4e7a242aba 100644 --- a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/command/PersistPostfachNachrichtByCommandService.java +++ b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/command/PersistPostfachNachrichtByCommandService.java @@ -58,7 +58,9 @@ import de.ozgcloud.vorgang.callcontext.User; import de.ozgcloud.vorgang.files.FileService; import de.ozgcloud.vorgang.files.OzgFile; import de.ozgcloud.vorgang.files.UploadedFilesReference; + import jakarta.activation.MimetypesFileTypeMap; + import lombok.extern.log4j.Log4j2; /** @@ -164,10 +166,14 @@ class PersistPostfachNachrichtByCommandService implements PersistPostfachNachric } private Map<String, Object> buildPostfachAddressMap(PostfachAddress postfachAddress) { - return Map.of(PostfachAddress.IDENTIFIER_FIELD, buildPostfachAddressIdentifierMap(postfachAddress), - PostfachAddress.VERSION_FIELD, postfachAddress.getVersion(), - PostfachAddress.TYPE_FIELD, postfachAddress.getType(), - PostfachAddress.SERVICEKONTO_TYPE_FIELD, postfachAddress.getServiceKontoType()); + var resultMap = new HashMap<String, Object>(); + resultMap.put(PostfachAddress.IDENTIFIER_FIELD, buildPostfachAddressIdentifierMap(postfachAddress)); + resultMap.put(PostfachAddress.VERSION_FIELD, postfachAddress.getVersion()); + resultMap.put(PostfachAddress.TYPE_FIELD, postfachAddress.getType()); + Optional.ofNullable(postfachAddress.getServiceKontoType()).ifPresentOrElse( + serviceKontoType -> resultMap.put(PostfachAddress.SERVICEKONTO_TYPE_FIELD, serviceKontoType), + () -> LOG.warn("ServiceKontoType is null")); + return Collections.unmodifiableMap(resultMap); } private Map<String, Object> buildPostfachAddressIdentifierMap(PostfachAddress postfachAddress) {