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

OZG-6640 log ungueltiger postkorb handle error as warning

parent e36c5661
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,9 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import jakarta.annotation.PostConstruct;
import jakarta.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
......@@ -41,10 +44,9 @@ import de.ozgcloud.nachrichten.attributes.ClientAttributeService;
import de.ozgcloud.nachrichten.info.InfoManagerService;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht.Direction;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht.ReplyOption;
import de.ozgcloud.nachrichten.postfach.bayernid.BayernIdServerException;
import de.ozgcloud.nachrichten.postfach.osi.OsiPostfachServerProcessException;
import de.ozgcloud.vorgang.callcontext.CurrentUserService;
import jakarta.annotation.PostConstruct;
import jakarta.validation.Valid;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
......@@ -189,9 +191,13 @@ class PostfachService {
return proceedWithException(commandId, e);
}
SendPostfachNachrichtResponse proceedWithErrorException(String commandId, PostfachException e) {
LOG.error(e.getMessage(), e);
return proceedWithException(commandId, e);
SendPostfachNachrichtResponse proceedWithErrorException(String commandId, PostfachException exception) {
if (exception instanceof BayernIdServerException exp && exp.isUngueltigerPostkorbHandleKey()) {
LOG.warn(exception.getMessage(), exception);
} else {
LOG.error(exception.getMessage(), exception);
}
return proceedWithException(commandId, exception);
}
private SendPostfachNachrichtResponse proceedWithException(String commandId, PostfachException e) {
......
package de.ozgcloud.nachrichten.postfach.bayernid;
import java.util.Optional;
import de.ozgcloud.nachrichten.postfach.PostfachException;
import de.ozgcloud.nachrichten.postfach.PostfachMessageCode;
class BayernIdServerException extends PostfachException {
public class BayernIdServerException extends PostfachException { // NOSONAR "This class has 6 parents which is greater than 5 authorized."
static final String TABELLE_NUMMER_EMPFANG_ERGEBNISSTATUS = "9006";
private static final String ERROR_MESSAGE_TEMPLATE = TABELLE_NUMMER_EMPFANG_ERGEBNISSTATUS + " / %s / %s / %s";
private static final String KEY_UNGUELTIGER_POSTKORB_HANDLE = "30";
private final MailSendingResponseStatus mailSendingResponseStatus;
......@@ -20,11 +23,17 @@ class BayernIdServerException extends PostfachException {
this.mailSendingResponseStatus = mailSendingResponseStatus;
}
public boolean isUngueltigerPostkorbHandleKey() {
return Optional.ofNullable(mailSendingResponseStatus).map(MailSendingResponseStatus::getSchluessel)
.filter(KEY_UNGUELTIGER_POSTKORB_HANDLE::equals).isPresent();
}
@Override
public String getMessage() {
if (mailSendingResponseStatus == null) {
return super.getMessage();
}
return ERROR_MESSAGE_TEMPLATE.formatted(mailSendingResponseStatus.getSchluessel(), mailSendingResponseStatus.getMessage(), super.getMessage());
return ERROR_MESSAGE_TEMPLATE.formatted(mailSendingResponseStatus.getSchluessel(), mailSendingResponseStatus.getMessage(),
super.getMessage());
}
}
......@@ -33,7 +33,6 @@ import java.util.Optional;
import java.util.UUID;
import java.util.stream.Stream;
import org.apache.logging.log4j.Logger;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
......@@ -633,9 +632,6 @@ class PostfachServiceTest {
private final static String MESSAGE = "Postfach server returned false";
@Mock
private Logger logger;
@BeforeEach
void mockService() {
doThrow(OsiPostfachServerProcessExceptionTestFactory.create()).when(postfachRemoteService).sendMessage(any());
......@@ -799,7 +795,7 @@ class PostfachServiceTest {
@Nested
class TestSavingMukAnswer {
private final String refId = ObjectId.get().toHexString();
private PostfachNachricht answer = PostfachNachrichtTestFactory.createBuilder().vorgangId(null).referencedNachricht(refId).build();
private final PostfachNachricht answer = PostfachNachrichtTestFactory.createBuilder().vorgangId(null).referencedNachricht(refId).build();
@Test
void shouldIdentifyAsAnswer() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment