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

WIP: OZG-6275 temporary fix for nullpointer because of missing nachrichtId

parent 9b8a442d
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,7 @@ public class ElsterTransferRemoteService { ...@@ -92,7 +92,7 @@ public class ElsterTransferRemoteService {
bereitstellungAuftrag.setAbsender(getAbsender()); bereitstellungAuftrag.setAbsender(getAbsender());
if (anhangNeedToBeUploaded(bereitstellungAuftrag)) { if (anhangNeedToBeUploaded(bereitstellungAuftrag)) {
bereitstellungAuftrag.setAnhaenge(nachricht.getAttachments().stream().map(this::uploadAnhang).toList()); bereitstellungAuftrag.setAnhaenge(nachricht.getAttachments().stream().map(fileId -> uploadAnhang(fileId, nachricht.getVorgangId())).toList());
} }
if (isMitteilung(bereitstellungAuftrag)) { if (isMitteilung(bereitstellungAuftrag)) {
...@@ -122,11 +122,12 @@ public class ElsterTransferRemoteService { ...@@ -122,11 +122,12 @@ public class ElsterTransferRemoteService {
return postfachProperties.getSender(); return postfachProperties.getSender();
} }
BereitstellungAnhangWithUploadId uploadAnhang(String fileId) { BereitstellungAnhangWithUploadId uploadAnhang(String fileId, String vorgangId) {
var file = attachmentService.getCloudFile(fileId); var file = attachmentService.getCloudFile(fileId);
try { try {
var uploadInfo = uploadFile(file); var uploadInfo = uploadFile(file);
var bereitstellungAnhang = fileMapper.toBereitstellungAnhangWithUploadId(file); var bereitstellungAnhang = fileMapper.toBereitstellungAnhangWithUploadId(file);
bereitstellungAnhang.setDateiBezeichnung(vorgangId);
bereitstellungAnhang.setUploadId(uploadInfo.getUploadId()); bereitstellungAnhang.setUploadId(uploadInfo.getUploadId());
return bereitstellungAnhang; return bereitstellungAnhang;
...@@ -149,8 +150,9 @@ public class ElsterTransferRemoteService { ...@@ -149,8 +150,9 @@ public class ElsterTransferRemoteService {
BereitstellungAntwort createAntwort(PostfachNachricht nachricht) { BereitstellungAntwort createAntwort(PostfachNachricht nachricht) {
var antwort = new BereitstellungAntwort(); var antwort = new BereitstellungAntwort();
antwort.setZuordnungskriterium(ObjectIdToUUIDConverter.toUUID(nachricht.getId())); // FIXME: nachricht needs to have a nachricht id already set. Needs to be fixed in de.ozgcloud.nachrichten.postfach.PostfachService or de.ozgcloud.nachrichten.postfach.PostfachEventListener.buildNachricht
antwort.setAntwortBetreffe(Set.of(postfachProperties.getReplySubjectPrefix() + nachricht.getSubject())); antwort.setZuordnungskriterium(ObjectIdToUUIDConverter.toUUID(Objects.isNull(nachricht.getId()) ? ObjectId.get().toHexString() : nachricht.getId()));
antwort.setAntwortBetreffe(Set.of(postfachProperties.getReplySubjectPrefix() + nachricht.getSubject() + " VorgangId: " + nachricht.getVorgangId()));
antwort.setAntwortFrist(LocalDate.now().plusDays(postfachProperties.getReplyInDays())); antwort.setAntwortFrist(LocalDate.now().plusDays(postfachProperties.getReplyInDays()));
return antwort; return antwort;
} }
...@@ -173,6 +175,7 @@ public class ElsterTransferRemoteService { ...@@ -173,6 +175,7 @@ public class ElsterTransferRemoteService {
PostfachNachricht getAntwort(AntwortDetails antwortDetails) { PostfachNachricht getAntwort(AntwortDetails antwortDetails) {
LOG.info("Processing AntwortDetail {} with DownloadDate {}", antwortDetails, antwortDetails.getDownloadZeitpunkt()); LOG.info("Processing AntwortDetail {} with DownloadDate {}", antwortDetails, antwortDetails.getDownloadZeitpunkt());
var nachrichtBuilder = PostfachNachricht.builder() var nachrichtBuilder = PostfachNachricht.builder()
.direction(PostfachNachricht.Direction.IN) .direction(PostfachNachricht.Direction.IN)
.mailBody(postfachProperties.getBody()); .mailBody(postfachProperties.getBody());
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
package de.ozgcloud.nachrichten.postfach.muk.transfer; package de.ozgcloud.nachrichten.postfach.muk.transfer;
import static de.ozgcloud.apilib.common.command.grpc.OzgCloudCommandTestFactory.*;
import static de.ozgcloud.nachrichten.postfach.muk.BereitstellungAuftragTestFactory.*; import static de.ozgcloud.nachrichten.postfach.muk.BereitstellungAuftragTestFactory.*;
import static de.ozgcloud.nachrichten.postfach.muk.PostfachNachrichtTestFactory.*; import static de.ozgcloud.nachrichten.postfach.muk.PostfachNachrichtTestFactory.*;
import static de.ozgcloud.nachrichten.postfach.muk.transfer.AntwortDetailsTestFactory.*; import static de.ozgcloud.nachrichten.postfach.muk.transfer.AntwortDetailsTestFactory.*;
...@@ -182,7 +183,7 @@ class ElsterTransferRemoteServiceTest { ...@@ -182,7 +183,7 @@ class ElsterTransferRemoteServiceTest {
void shouldCallUploadAnhang() { void shouldCallUploadAnhang() {
elsterTransferService.send(PostfachNachrichtTestFactory.create()); elsterTransferService.send(PostfachNachrichtTestFactory.create());
verify(elsterTransferService).uploadAnhang(anyString()); verify(elsterTransferService).uploadAnhang(anyString(), anyString());
} }
@Test @Test
...@@ -379,7 +380,7 @@ class ElsterTransferRemoteServiceTest { ...@@ -379,7 +380,7 @@ class ElsterTransferRemoteServiceTest {
doThrow(IOException.class).when(elsterTransferService).uploadFile(any()); doThrow(IOException.class).when(elsterTransferService).uploadFile(any());
var id = OzgCloudFileTestFactory.ID.toString(); var id = OzgCloudFileTestFactory.ID.toString();
assertThatExceptionOfType(TechnicalException.class).isThrownBy(() -> elsterTransferService.uploadAnhang(id)); assertThatExceptionOfType(TechnicalException.class).isThrownBy(() -> elsterTransferService.uploadAnhang(id, VORGANG_ID.toString()));
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment