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

OZG-5636 refactor buildAttachment method

parent c0f8fdf5
No related branches found
No related tags found
No related merge requests found
...@@ -47,8 +47,6 @@ import lombok.extern.log4j.Log4j2; ...@@ -47,8 +47,6 @@ import lombok.extern.log4j.Log4j2;
@RequiredArgsConstructor @RequiredArgsConstructor
public class UploadStreamObserver implements StreamObserver<GrpcSendBayernIdMessageRequest> { public class UploadStreamObserver implements StreamObserver<GrpcSendBayernIdMessageRequest> {
static final String ATTACHMENT_FILE_SUFFIX = ".ozg-cloud.tmp";
private final StreamObserver<GrpcSendBayernIdMessageResponse> responseObserver; private final StreamObserver<GrpcSendBayernIdMessageResponse> responseObserver;
private final BayernIdProxyService proxyService; private final BayernIdProxyService proxyService;
private final BayernIdMessageMapper messageMapper; private final BayernIdMessageMapper messageMapper;
...@@ -82,15 +80,17 @@ public class UploadStreamObserver implements StreamObserver<GrpcSendBayernIdMess ...@@ -82,15 +80,17 @@ public class UploadStreamObserver implements StreamObserver<GrpcSendBayernIdMess
} }
Attachment buildAttachment(GrpcAttachmentMetadata attachmentMetadata) { Attachment buildAttachment(GrpcAttachmentMetadata attachmentMetadata) {
InputStream temporallyFile;
try { try {
temporallyFile = createTemporallyFile();
} catch (IOException e) {
throw new TechnicalException("Can not create temporary file for attachment " + attachmentMetadata.getFileName(), e);
}
return Attachment.builder() return Attachment.builder()
.name(attachmentMetadata.getFileName()) .name(attachmentMetadata.getFileName())
.type(attachmentMetadata.getFileType()) .type(attachmentMetadata.getFileType())
.content(createTemporallyFile()) .content(temporallyFile)
.build(); .build();
} catch (IOException e) {
throw new TechnicalException("Can not create temporary file for attachment " + attachmentMetadata.getFileName(), e);
}
} }
InputStream createTemporallyFile() throws IOException { InputStream createTemporallyFile() throws IOException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment