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

OZG-6810 adjust configuration

parent 20e06f92
Branches
Tags
No related merge requests found
...@@ -26,8 +26,8 @@ public class NachrichtenManagerConfiguration { ...@@ -26,8 +26,8 @@ public class NachrichtenManagerConfiguration {
public static final String NACHRICHTEN_VORGANG_REMOTE_SERVICE = "nachrichten_vorgangRemoteService"; public static final String NACHRICHTEN_VORGANG_REMOTE_SERVICE = "nachrichten_vorgangRemoteService";
public static final String NACHRICHTEN_ATTACHED_ITEM_SERVICE = "nachrichten_attachedItemService"; public static final String NACHRICHTEN_ATTACHED_ITEM_SERVICE = "nachrichten_attachedItemService";
public static final String NACHRICHTEN_OZG_CLOUD_FILE_MAPPER = "nachrichten_OzgCloudFileMapperImpl"; public static final String NACHRICHTEN_OZG_CLOUD_FILE_MAPPER = "nachrichten_OzgCloudFileMapperImpl";
public static final String BINARY_FILE_SERVICE_NAME = "nachrichten_BinaryFileService"; public static final String ATTACHMENT_FILE_SERVICE_NAME = "nachrichten_AttachmentFileService";
public static final String BINARY_FILE_REMOTE_SERVICE_NAME = "nachrichten_BinaryFileRemoteService"; public static final String ATTACHMENT_FILE_MAPPER_NAME = "nachrichten_AttachmentFileMapper";
public static final String GRPC_VORGANG_MANAGER_NAME = "vorgang-manager"; public static final String GRPC_VORGANG_MANAGER_NAME = "vorgang-manager";
public static final String GRPC_COMMAND_MANAGER_NAME = "command-manager"; public static final String GRPC_COMMAND_MANAGER_NAME = "command-manager";
......
...@@ -23,13 +23,19 @@ ...@@ -23,13 +23,19 @@
*/ */
package de.ozgcloud.nachrichten.file; package de.ozgcloud.nachrichten.file;
import org.mapstruct.AnnotateWith;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.ReportingPolicy;
import org.springframework.stereotype.Component;
import de.ozgcloud.apilib.file.OzgCloudFile; import de.ozgcloud.apilib.file.OzgCloudFile;
import de.ozgcloud.apilib.file.OzgCloudUploadFile; import de.ozgcloud.apilib.file.OzgCloudUploadFile;
import de.ozgcloud.nachrichten.NachrichtenManagerConfiguration;
@Mapper @Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, unmappedTargetPolicy = ReportingPolicy.WARN)
@AnnotateWith(value = Component.class, elements = @AnnotateWith.Element(strings = NachrichtenManagerConfiguration.ATTACHMENT_FILE_MAPPER_NAME))
interface AttachmentFileMapper { interface AttachmentFileMapper {
@Mapping(target = "vorgangId", ignore = true) @Mapping(target = "vorgangId", ignore = true)
......
...@@ -38,6 +38,7 @@ import jakarta.activation.MimetypesFileTypeMap; ...@@ -38,6 +38,7 @@ import jakarta.activation.MimetypesFileTypeMap;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -49,7 +50,7 @@ import de.ozgcloud.nachrichten.postfach.FileId; ...@@ -49,7 +50,7 @@ import de.ozgcloud.nachrichten.postfach.FileId;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@Service(NachrichtenManagerConfiguration.BINARY_FILE_SERVICE_NAME) @Service(NachrichtenManagerConfiguration.ATTACHMENT_FILE_SERVICE_NAME)
@RequiredArgsConstructor @RequiredArgsConstructor
@Log4j2 @Log4j2
public class AttachmentFileService { public class AttachmentFileService {
...@@ -57,8 +58,10 @@ public class AttachmentFileService { ...@@ -57,8 +58,10 @@ public class AttachmentFileService {
private static final int BUFFER_SIZE = 4 * 1024; private static final int BUFFER_SIZE = 4 * 1024;
static final String ATTACHMENT_NAME = "PostfachAttachment"; static final String ATTACHMENT_NAME = "PostfachAttachment";
private final OzgCloudFileService fileService; @Qualifier(NachrichtenManagerConfiguration.OZG_CLOUD_FILE_SERVICE_NAME)
private final OzgCloudFileService ozgCloudFileService;
private final OzgCloudFileIdMapper fileIdMapper; private final OzgCloudFileIdMapper fileIdMapper;
@Qualifier(NachrichtenManagerConfiguration.ATTACHMENT_FILE_MAPPER_NAME)
private final AttachmentFileMapper attachmentFileMapper; private final AttachmentFileMapper attachmentFileMapper;
private final TaskExecutor taskExecutor; private final TaskExecutor taskExecutor;
...@@ -66,14 +69,14 @@ public class AttachmentFileService { ...@@ -66,14 +69,14 @@ public class AttachmentFileService {
private final MimetypesFileTypeMap mimetypesFileTypeMap; private final MimetypesFileTypeMap mimetypesFileTypeMap;
public AttachmentFile getFile(FileId fileId) { public AttachmentFile getFile(FileId fileId) {
var ozgCloudFile = fileService.getFile(fileIdMapper.toFileId(fileId.toString())); var ozgCloudFile = ozgCloudFileService.getFile(fileIdMapper.toFileId(fileId.toString()));
return attachmentFileMapper.fromOzgCloudFile(ozgCloudFile); return attachmentFileMapper.fromOzgCloudFile(ozgCloudFile);
} }
public InputStream getFileContent(FileId fileId) { public InputStream getFileContent(FileId fileId) {
var inputStream = createInputStream(); var inputStream = createInputStream();
var outputStream = connectToOutputStream(inputStream); var outputStream = connectToOutputStream(inputStream);
taskExecutor.execute(() -> fileService.writeFileDataToStream(fileIdMapper.toFileId(fileId.toString()), outputStream)); taskExecutor.execute(() -> ozgCloudFileService.writeFileDataToStream(fileIdMapper.toFileId(fileId.toString()), outputStream));
return inputStream; return inputStream;
} }
...@@ -90,7 +93,7 @@ public class AttachmentFileService { ...@@ -90,7 +93,7 @@ public class AttachmentFileService {
} }
public String createAttachmentFile(AttachmentFile attachmentFile, String fileContent) { public String createAttachmentFile(AttachmentFile attachmentFile, String fileContent) {
var ozgCloudFileId = fileService.uploadFile(attachmentFileMapper.toOzgCloudUploadFile(enhanceAttachmentFile(attachmentFile, fileContent)), var ozgCloudFileId = ozgCloudFileService.uploadFile(attachmentFileMapper.toOzgCloudUploadFile(enhanceAttachmentFile(attachmentFile, fileContent)),
toDecodedInputStream(fileContent)); toDecodedInputStream(fileContent));
return ozgCloudFileId.toString(); return ozgCloudFileId.toString();
} }
......
package de.ozgcloud.nachrichten; package de.ozgcloud.nachrichten;
import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.OzgCloudCommandService;
import de.ozgcloud.apilib.file.OzgCloudFileService; import de.ozgcloud.apilib.file.OzgCloudFileService;
import de.ozgcloud.apilib.vorgang.OzgCloudFileIdMapper;
import de.ozgcloud.nachrichten.postfach.muk.MukPostfachConfiguration; import de.ozgcloud.nachrichten.postfach.muk.MukPostfachConfiguration;
@SpringBootApplication @SpringBootApplication
...@@ -22,4 +25,9 @@ public class NachrichtenManagerTestApplication { ...@@ -22,4 +25,9 @@ public class NachrichtenManagerTestApplication {
@Qualifier(MukPostfachConfiguration.OZG_CLOUD_FILE_SERVICE_NAME) @Qualifier(MukPostfachConfiguration.OZG_CLOUD_FILE_SERVICE_NAME)
private OzgCloudFileService mukOzgCloudFileServices; private OzgCloudFileService mukOzgCloudFileServices;
@Bean
OzgCloudFileIdMapper ozgCloudFileIdMapper() {
return Mappers.getMapper(OzgCloudFileIdMapper.class);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment