Skip to content
Snippets Groups Projects
Commit abd99cb8 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6362 Laden der Ausgangsnachricht verbessert.

parent adef2143
No related branches found
No related tags found
No related merge requests found
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
*/ */
package de.ozgcloud.nachrichten.postfach; package de.ozgcloud.nachrichten.postfach;
import static de.ozgcloud.nachrichten.postfach.PersistPostfachNachrichtServiceImpl.*;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
...@@ -41,7 +39,6 @@ import org.springframework.context.ApplicationEventPublisher; ...@@ -41,7 +39,6 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import de.ozgcloud.common.errorhandling.TechnicalException;
import de.ozgcloud.nachrichten.antragraum.AntragraumService; import de.ozgcloud.nachrichten.antragraum.AntragraumService;
import de.ozgcloud.nachrichten.attributes.ClientAttributeService; import de.ozgcloud.nachrichten.attributes.ClientAttributeService;
import de.ozgcloud.nachrichten.info.InfoManagerService; import de.ozgcloud.nachrichten.info.InfoManagerService;
...@@ -57,16 +54,13 @@ import lombok.extern.log4j.Log4j2; ...@@ -57,16 +54,13 @@ import lombok.extern.log4j.Log4j2;
@Validated @Validated
class PostfachService { class PostfachService {
private static final Predicate<PostfachNachricht> IS_FROM_HUMAN_USER = nachricht -> !StringUtils.startsWith(nachricht.getCreatedBy(), "system");
static final Predicate<PostfachNachricht> IS_MUK_ANTWORT = nachricht -> StringUtils.isEmpty(nachricht.getVorgangId()) && StringUtils.isNotEmpty( static final Predicate<PostfachNachricht> IS_MUK_ANTWORT = nachricht -> StringUtils.isEmpty(nachricht.getVorgangId()) && StringUtils.isNotEmpty(
nachricht.getReferencedNachricht()); nachricht.getReferencedNachricht());
static final Set<ReplyOption> REPLY_POSSIBLE_OPTION = EnumSet.of(ReplyOption.POSSIBLE, ReplyOption.MANDATORY);
private static final Predicate<PostfachNachricht> IS_FROM_HUMAN_USER = nachricht -> !StringUtils.startsWith(nachricht.getCreatedBy(), "system");
private static final Set<String> POSTFACH_TYPES_WITH_ANTRAGSRAUM = Set.of("BayernId"); private static final Set<String> POSTFACH_TYPES_WITH_ANTRAGSRAUM = Set.of("BayernId");
@Autowired(required = false) @Autowired(required = false)
private PostfachRemoteService postfachRemoteService; private PostfachRemoteService postfachRemoteService;
static final Set<ReplyOption> REPLY_POSSIBLE_OPTION = EnumSet.of(ReplyOption.POSSIBLE, ReplyOption.MANDATORY);
@Autowired @Autowired
private PostfachNachrichtMapper mapper; private PostfachNachrichtMapper mapper;
...@@ -131,27 +125,19 @@ class PostfachService { ...@@ -131,27 +125,19 @@ class PostfachService {
} }
private void persistReceivedMail(PostfachNachricht nachricht) { private void persistReceivedMail(PostfachNachricht nachricht) {
Optional<PostfachNachricht> linkedNachrichtOptional = Optional.of(nachricht);
if (IS_MUK_ANTWORT.test(nachricht)) { if (IS_MUK_ANTWORT.test(nachricht)) {
var vorgangMapOptional = findById(nachricht.getReferencedNachricht()); var persistedNachricht = getNachricht(nachricht.getReferencedNachricht());
linkedNachrichtOptional = vorgangMapOptional.map( nachricht = nachricht.toBuilder().vorgangId(persistedNachricht.getVorgangId()).build();
vorgangMap -> Optional.of(setVorgangId((String) vorgangMap.get(VORGANG_ID_FIELD), nachricht)))
.orElseThrow();
} }
linkedNachrichtOptional.ifPresent(linkedNachricht -> { persistMail(Optional.empty(), nachricht);
persistMail(Optional.empty(), linkedNachricht);
postfachRemoteService.deleteMessage(linkedNachricht.getMessageId()); postfachRemoteService.deleteMessage(nachricht.getMessageId());
});
}
PostfachNachricht setVorgangId(String vorgangId, PostfachNachricht nachricht) { }
if (StringUtils.isNotEmpty(vorgangId)) {
return nachricht.toBuilder().vorgangId(vorgangId).build();
}
throw new TechnicalException("Cannot link nachricht [" + nachricht + "] to vorgang because vorgangId is empty"); PostfachNachricht getNachricht(String id) {
return mapper.fromMapToPostfachMail(persistingService.getById(id));
} }
void persistMail(Optional<String> userId, PostfachNachricht mail) { void persistMail(Optional<String> userId, PostfachNachricht mail) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment