diff --git a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidManagerConfiguration.java b/document-manager-server/src/main/java/de/ozgcloud/document/DocumentManagerConfiguration.java similarity index 64% rename from document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidManagerConfiguration.java rename to document-manager-server/src/main/java/de/ozgcloud/document/DocumentManagerConfiguration.java index 6c0b29124edb2604ea79fe6f0b843c8e17578f8b..fdc2559a258b731f8c9a1052761da1f6c681a933 100644 --- a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidManagerConfiguration.java +++ b/document-manager-server/src/main/java/de/ozgcloud/document/DocumentManagerConfiguration.java @@ -21,7 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -package de.ozgcloud.document.bescheid; +package de.ozgcloud.document; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -29,21 +29,36 @@ import org.springframework.context.annotation.Configuration; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; import de.ozgcloud.apilib.common.command.grpc.GrpcOzgCloudCommandService; +import de.ozgcloud.apilib.user.GrpcOzgCloudUserProfileService; +import de.ozgcloud.apilib.user.OzgCloudUserProfileService; +import de.ozgcloud.apilib.user.UserProfileMapper; import de.ozgcloud.document.bescheid.common.callcontext.BescheidManagerCallContextProvider; +import de.ozgcloud.user.grpc.userprofile.UserProfileServiceGrpc; import de.ozgcloud.vorgang.grpc.command.CommandServiceGrpc; import net.devh.boot.grpc.client.inject.GrpcClient; @Configuration -public class BescheidManagerConfiguration { +public class DocumentManagerConfiguration { - public static final String COMMAND_SERVICE_NAME = "bescheid_OzgCloudCommandService"; + private static final String GRPC_USER_MANAGER_NAME = "user-manager"; + private static final String GRPC_COMMAND_MANAGER_NAME = "command-manager"; - @GrpcClient("command-manager") + public static final String COMMAND_SERVICE_NAME = "document_OzgCloudCommandService"; + public static final String USER_PROFILE_SERVICE_NAME = "document_OzgCloudUserProfileService"; + + @GrpcClient(GRPC_COMMAND_MANAGER_NAME) private CommandServiceGrpc.CommandServiceBlockingStub commandServiceStub; + @GrpcClient(GRPC_USER_MANAGER_NAME) + private UserProfileServiceGrpc.UserProfileServiceBlockingStub userProfileServiceStub; @Bean(COMMAND_SERVICE_NAME) OzgCloudCommandService grpcOzgCloudCommandService(CommandMapper commandMapper, BescheidManagerCallContextProvider contextProvider) { return new GrpcOzgCloudCommandService(commandServiceStub, commandMapper, contextProvider, GrpcOzgCloudCommandService.DEFAULT_COMMAND_REQUEST_THRESHOLD_MILLIS); } + + @Bean(USER_PROFILE_SERVICE_NAME) + OzgCloudUserProfileService grpcOzgCloudUserProfileService(UserProfileMapper mapper, BescheidManagerCallContextProvider contextProvider) { + return new GrpcOzgCloudUserProfileService(userProfileServiceStub, mapper, contextProvider); + } } diff --git a/document-manager-server/src/main/java/de/ozgcloud/document/DocumentService.java b/document-manager-server/src/main/java/de/ozgcloud/document/DocumentService.java index d558e90b454a4251f8b02db3559c4b0d9391ae11..b2f966267da101fc2a339ac2c9d17a84e58d36f2 100644 --- a/document-manager-server/src/main/java/de/ozgcloud/document/DocumentService.java +++ b/document-manager-server/src/main/java/de/ozgcloud/document/DocumentService.java @@ -38,13 +38,13 @@ import org.springframework.stereotype.Service; import de.ozgcloud.apilib.common.command.OzgCloudCommand; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; +import de.ozgcloud.command.Command; +import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.document.bescheid.Bescheid; import de.ozgcloud.document.bescheid.BescheidCallContextAttachingInterceptor; import de.ozgcloud.document.bescheid.BescheidResponse; -import de.ozgcloud.command.Command; -import de.ozgcloud.document.common.attached_item.AttachedItemService; import de.ozgcloud.document.common.attached_item.AttachedItem; -import de.ozgcloud.common.errorhandling.TechnicalException; +import de.ozgcloud.document.common.attached_item.AttachedItemService; @Service public class DocumentService { @@ -60,7 +60,7 @@ public class DocumentService { @Autowired private AttachedItemService attachedItemService; @Autowired - @Qualifier("bescheid_OzgCloudCommandService") + @Qualifier(DocumentManagerConfiguration.COMMAND_SERVICE_NAME) private OzgCloudCommandService commandService; @Autowired private CommandMapper commandMapper; diff --git a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidService.java b/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidService.java index dab645b8e5410fa2c35cf3e50fe84b9ddc4586b3..a942c708721ff27ae8ccc2b6d9d317203520db02 100644 --- a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidService.java +++ b/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/BescheidService.java @@ -26,6 +26,11 @@ import de.ozgcloud.apilib.common.command.OzgCloudCommand; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.OzgCloudCreateSubCommandsRequest; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; +import de.ozgcloud.command.Command; +import de.ozgcloud.common.binaryfile.FileId; +import de.ozgcloud.common.errorhandling.TechnicalException; +import de.ozgcloud.document.Document; +import de.ozgcloud.document.DocumentManagerConfiguration; import de.ozgcloud.document.bescheid.administration.AdministrationService; import de.ozgcloud.document.bescheid.attributes.ClientAttributeService; import de.ozgcloud.document.bescheid.common.freemarker.TemplateHandler; @@ -33,12 +38,8 @@ import de.ozgcloud.document.bescheid.common.user.UserProfileService; import de.ozgcloud.document.bescheid.vorgang.Vorgang; import de.ozgcloud.document.bescheid.vorgang.VorgangId; import de.ozgcloud.document.bescheid.vorgang.VorgangService; -import de.ozgcloud.command.Command; import de.ozgcloud.document.common.attached_item.AttachedItem; import de.ozgcloud.document.common.attached_item.AttachedItemService; -import de.ozgcloud.common.binaryfile.FileId; -import de.ozgcloud.common.errorhandling.TechnicalException; -import de.ozgcloud.document.Document; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; @@ -68,7 +69,7 @@ public class BescheidService { private final VorgangService vorgangService; private final AttachedItemService attachedItemService; private final UserProfileService userProfileService; - @Qualifier(BescheidManagerConfiguration.COMMAND_SERVICE_NAME) + @Qualifier(DocumentManagerConfiguration.COMMAND_SERVICE_NAME) private final OzgCloudCommandService commandService; private final AdministrationService administrationService; diff --git a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/common/user/UserProfileService.java b/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/common/user/UserProfileService.java index 1e359c48249b333213d538ef5cc8d46dc6a5d7dd..70f4513613563583db235568f0871ff93e357e2b 100644 --- a/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/common/user/UserProfileService.java +++ b/document-manager-server/src/main/java/de/ozgcloud/document/bescheid/common/user/UserProfileService.java @@ -25,12 +25,14 @@ package de.ozgcloud.document.bescheid.common.user; import java.util.Optional; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import de.ozgcloud.apilib.user.OzgCloudUserId; import de.ozgcloud.apilib.user.OzgCloudUserProfileService; -import de.ozgcloud.document.bescheid.common.callcontext.CurrentUserService; import de.ozgcloud.common.errorhandling.TechnicalException; +import de.ozgcloud.document.DocumentManagerConfiguration; +import de.ozgcloud.document.bescheid.common.callcontext.CurrentUserService; import lombok.RequiredArgsConstructor; @Service @@ -38,11 +40,12 @@ import lombok.RequiredArgsConstructor; public class UserProfileService { private final CurrentUserService currentUserService; - private final Optional<OzgCloudUserProfileService> userProfileService; + @Qualifier(DocumentManagerConfiguration.USER_PROFILE_SERVICE_NAME) + private final Optional<OzgCloudUserProfileService> ozgCloudUserProfileService; private final UserProfileMapper mapper; public UserProfile getUserProfile() { - var service = userProfileService.orElseThrow(() -> new IllegalStateException("No connection to user-manager configured.")); + var service = ozgCloudUserProfileService.orElseThrow(() -> new IllegalStateException("No connection to user-manager configured.")); return currentUserService.getUser().getUserId().map(OzgCloudUserId::from) .map(service::getById) diff --git a/document-manager-server/src/main/java/de/ozgcloud/document/common/attached_item/AttachedItemService.java b/document-manager-server/src/main/java/de/ozgcloud/document/common/attached_item/AttachedItemService.java index 8881932dd1cb1f1b8ce9c0b7355eb2d1a6f10aed..db06b2a30ebd55fc14f183891ec8f2a7c895a8f7 100644 --- a/document-manager-server/src/main/java/de/ozgcloud/document/common/attached_item/AttachedItemService.java +++ b/document-manager-server/src/main/java/de/ozgcloud/document/common/attached_item/AttachedItemService.java @@ -37,15 +37,15 @@ import org.springframework.stereotype.Service; import de.ozgcloud.apilib.common.command.OzgCloudCommand; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; +import de.ozgcloud.command.Command; +import de.ozgcloud.common.errorhandling.TechnicalException; +import de.ozgcloud.document.Document; +import de.ozgcloud.document.DocumentManagerConfiguration; import de.ozgcloud.document.bescheid.Bescheid; import de.ozgcloud.document.bescheid.Bescheid.Status; import de.ozgcloud.document.bescheid.BescheidCallContextAttachingInterceptor; -import de.ozgcloud.document.bescheid.BescheidManagerConfiguration; import de.ozgcloud.document.bescheid.BescheidMapper; import de.ozgcloud.document.bescheid.vorgang.VorgangId; -import de.ozgcloud.command.Command; -import de.ozgcloud.common.errorhandling.TechnicalException; -import de.ozgcloud.document.Document; import lombok.RequiredArgsConstructor; @Service @@ -58,7 +58,7 @@ public class AttachedItemService { static final String UPDATE_ATTACHED_ITEM_ORDER = "UPDATE_ATTACHED_ITEM"; static final String DELETE_ATTACHED_ITEM = "DELETE_ATTACHED_ITEM"; - @Qualifier(BescheidManagerConfiguration.COMMAND_SERVICE_NAME) + @Qualifier(DocumentManagerConfiguration.COMMAND_SERVICE_NAME) private final OzgCloudCommandService commandService; private final VorgangAttachedItemRemoteService remoteService; diff --git a/document-manager-server/src/test/java/de/ozgcloud/document/DocumentManagerApplicationITCase.java b/document-manager-server/src/test/java/de/ozgcloud/document/DocumentManagerApplicationITCase.java index 14be79f3466dca3cd536a41cd5d572a15795e7b9..5bcebe7b9a51dfaabdcaa6356c4dcefc958b4d37 100644 --- a/document-manager-server/src/test/java/de/ozgcloud/document/DocumentManagerApplicationITCase.java +++ b/document-manager-server/src/test/java/de/ozgcloud/document/DocumentManagerApplicationITCase.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; +import de.ozgcloud.apilib.user.UserProfileMapper; import de.ozgcloud.common.test.ITCase; @ITCase @@ -11,6 +12,8 @@ class DocumentManagerApplicationITCase { @MockBean private CommandMapper commandMapper; + @MockBean + private UserProfileMapper userProfileMapper; @Test void shouldLoadContext() {// NOSONAR diff --git a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidEventListenerITCase.java b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidEventListenerITCase.java index cf444b519bbaabb4cbb2fcdf0bc49d4daf96975b..1ac7dfa53efb125e4b54553a9d3ce1b8a79794ab 100644 --- a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidEventListenerITCase.java +++ b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidEventListenerITCase.java @@ -14,15 +14,16 @@ import org.springframework.context.ApplicationEventPublisher; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; -import de.ozgcloud.document.bescheid.common.callcontext.CurrentUserService; -import de.ozgcloud.document.bescheid.common.user.UserProfile; -import de.ozgcloud.document.bescheid.common.user.UserProfileService; +import de.ozgcloud.apilib.user.UserProfileMapper; import de.ozgcloud.command.Command; import de.ozgcloud.command.CommandCreatedEventTestFactory; import de.ozgcloud.command.CommandExecutedEvent; import de.ozgcloud.command.CommandTestFactory; -import de.ozgcloud.document.common.attached_item.AttachedItemService; import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.document.bescheid.common.callcontext.CurrentUserService; +import de.ozgcloud.document.bescheid.common.user.UserProfile; +import de.ozgcloud.document.bescheid.common.user.UserProfileService; +import de.ozgcloud.document.common.attached_item.AttachedItemService; @ITCase class BescheidEventListenerITCase { @@ -45,6 +46,8 @@ class BescheidEventListenerITCase { @MockBean private CommandMapper commandMapper; @MockBean + private UserProfileMapper userProfileMapper; + @MockBean private AttachedItemService attachedItemService; @Mock diff --git a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/common/freemarker/TemplateHandlerITCase.java b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/common/freemarker/TemplateHandlerITCase.java index 34fe1deba1da459a92a6a2bc0e2053e12d3a82ad..0ce8e79b808aa996824ebb003e994b3ead7b9b17 100644 --- a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/common/freemarker/TemplateHandlerITCase.java +++ b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/common/freemarker/TemplateHandlerITCase.java @@ -13,8 +13,9 @@ import org.springframework.boot.test.mock.mockito.MockBean; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; -import de.ozgcloud.document.bescheid.BescheidService; +import de.ozgcloud.apilib.user.UserProfileMapper; import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.document.bescheid.BescheidService; @ITCase class TemplateHandlerITCase { @@ -27,6 +28,8 @@ class TemplateHandlerITCase { private OzgCloudCommandService commandService; @MockBean private CommandMapper commandMapper; + @MockBean + private UserProfileMapper userProfileMapper; @DisplayName("Get raw template") @Nested diff --git a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/smartdocuments/SmartDocumentsBescheidRemoteServiceITCase.java b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/smartdocuments/SmartDocumentsBescheidRemoteServiceITCase.java index 9c36356a30b28648d2a31ebc1c635bf9c8c47c2a..08b0709594092dad10c723a239bb4545c1f8296f 100644 --- a/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/smartdocuments/SmartDocumentsBescheidRemoteServiceITCase.java +++ b/document-manager-server/src/test/java/de/ozgcloud/document/bescheid/smartdocuments/SmartDocumentsBescheidRemoteServiceITCase.java @@ -14,12 +14,13 @@ import org.springframework.test.context.ActiveProfiles; import de.ozgcloud.apilib.common.command.OzgCloudCommandService; import de.ozgcloud.apilib.common.command.grpc.CommandMapper; -import de.ozgcloud.document.bescheid.BescheidRequestTestFactory; -import de.ozgcloud.document.bescheid.BescheidTestApplication; -import de.ozgcloud.document.bescheid.vorgang.VorgangTestFactory; +import de.ozgcloud.apilib.user.UserProfileMapper; import de.ozgcloud.common.binaryfile.TempFileUtils; import de.ozgcloud.common.test.ITCase; import de.ozgcloud.common.test.TestUtils; +import de.ozgcloud.document.bescheid.BescheidRequestTestFactory; +import de.ozgcloud.document.bescheid.BescheidTestApplication; +import de.ozgcloud.document.bescheid.vorgang.VorgangTestFactory; @SpringBootTest(classes = BescheidTestApplication.class) @ITCase @@ -32,6 +33,8 @@ class SmartDocumentsBescheidRemoteServiceITCase { private OzgCloudCommandService ozgCloudCommandService; @MockBean private CommandMapper commandMapper; + @MockBean + private UserProfileMapper userProfileMapper; @Disabled("This test request SmartDocuments service") @Test