From 81551fecb6a30a04d3b6cfab2c9311661eb19383 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 14 Oct 2024 14:32:49 +0200 Subject: [PATCH] OZG-6522 refactor deprecated old bayernid type --- .../nachrichten/postfach/PostfachService.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java index 2d6341f..0a72b6c 100644 --- a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java +++ b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java @@ -25,10 +25,10 @@ package de.ozgcloud.nachrichten.postfach; import java.time.ZonedDateTime; import java.util.Collection; import java.util.EnumSet; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.Supplier; import java.util.stream.Stream; import jakarta.annotation.PostConstruct; @@ -241,19 +241,15 @@ class PostfachService { } public Stream<Postfach> getPostfachs() { - Supplier<Stream<PostfachRemoteService>> postfachRemoteServicesStream = () -> postfachRemoteServices.stream().flatMap(Collection::stream); - var oldBayernIdPostfachStream = buildOldBayernIdPostfach(postfachRemoteServicesStream.get()); - var postfachsStream = postfachRemoteServicesStream.get().map(this::buildPostfach); - return Stream.concat(postfachsStream, oldBayernIdPostfachStream); + return postfachRemoteServices.stream().flatMap(Collection::stream).map(this::getPostfaecher).flatMap(Collection::stream); } // TODO Nach Umstellung auf BAYERN_ID entfernen - private Stream<Postfach> buildOldBayernIdPostfach(Stream<PostfachRemoteService> postfachRemoteServicesStream) { - return postfachRemoteServicesStream.filter(remotePostfach -> "BAYERN_ID".equals(remotePostfach.getPostfachType())) - .map(remotePostfach -> Postfach.builder() - .type("BayernId") - .isReplyAllowed(isReplyAllowed(remotePostfach)) - .build()); + private List<Postfach> getPostfaecher(PostfachRemoteService remoteService) { + var postfach = buildPostfach(remoteService); + return "BAYERN_ID".equals(remoteService.getPostfachType()) + ? List.of(postfach, Postfach.builder().type("BayernId").isReplyAllowed(postfach.isReplyAllowed()).build()) + : List.of(postfach); } Postfach buildPostfach(PostfachRemoteService postfachRemoteService) { -- GitLab