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

Merge pull request 'OZG-6710 Update common-lib' (#14) from OZG-6710-Update-common-lib into master

parents a64de171 f3e793a8
No related branches found
No related tags found
No related merge requests found
Showing
with 82 additions and 35 deletions
......@@ -28,3 +28,4 @@ lombok.log.log4j.flagUsage = ERROR
lombok.data.flagUsage = ERROR
lombok.nonNull.exceptionType = IllegalArgumentException
lombok.addLombokGeneratedAnnotation = true
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
\ No newline at end of file
......@@ -31,7 +31,7 @@
<parent>
<groupId>de.ozgcloud.common</groupId>
<artifactId>ozgcloud-common-parent</artifactId>
<version>4.3.0</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<groupId>de.ozgcloud.processor</groupId>
......@@ -42,10 +42,10 @@
<description>OZG-Cloud Processor Manager</description>
<properties>
<vorgang-manager.version>2.5.0</vorgang-manager.version>
<api-lib.version>0.10.0</api-lib.version>
<tyrus-standalone-client.version>2.1.3</tyrus-standalone-client.version>
<okio.version>3.9.0</okio.version>
<vorgang-manager.version>2.17.0-SNAPSHOT</vorgang-manager.version>
<api-lib.version>0.13.0-SNAPSHOT</api-lib.version>
<tyrus-standalone-client.version>2.2.0</tyrus-standalone-client.version>
<okio.version>3.9.1</okio.version>
</properties>
<dependencies>
<!-- OZG-Cloud -->
......@@ -60,13 +60,6 @@
<artifactId>command-manager</artifactId>
<version>${vorgang-manager.version}</version>
</dependency>
<dependency>
<groupId>de.ozgcloud.command</groupId>
<artifactId>command-manager</artifactId>
<version>${vorgang-manager.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.ozgcloud.api-lib</groupId>
......
......@@ -23,12 +23,14 @@
*/
package de.ozgcloud.processor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgangService;
import de.ozgcloud.apilib.vorgang.grpc.GrpcOzgCloudVorgangService;
import de.ozgcloud.apilib.vorgang.grpc.OzgCloudVorgangMapper;
import de.ozgcloud.apilib.vorgang.grpc.OzgCloudVorgangQueryMapper;
import de.ozgcloud.apilib.vorgang.grpc.OzgCloudVorgangStubMapper;
import de.ozgcloud.vorgang.vorgang.VorgangServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
......@@ -36,12 +38,27 @@ import net.devh.boot.grpc.client.inject.GrpcClient;
@Configuration
public class ProcessorManagerConfiguration {
@GrpcClient("vorgang-manager")
public static final String PROCESSOR_EVENT_LISTENER_NAME = "processorManager_ProcessorEventListener";
public static final String PROCESSOR_PROPERTIES_NAME = "processorManager_ProcessorProperties";
public static final String PROXY_PROPERTIES_NAME = "processorManager_ProxyProperties";
public static final String AKTENNOTIZ_FACTORY_NAME = "processorManager_AktennotizFactory";
public static final String VORGANG_MAPPER_NAME = "processorManager_VorgangMapper";
public static final String VORGANG_SERVICE_NAME = "processorManager_VorgangService";
public static final String PROCESSOR_SERVICE_NAME = "processorManager_ProcessorService";
public static final String RESULT_SERVICE_NAME = "processorManager_ResultService";
public static final String OZGCLOUD_VORGANG_SERVICE_NAME = "processorManager_OzgCloudVorgangService";
public static final String GRPC_VORGANG_SERVICE_ADDRESS = "vorgang-manager";
@GrpcClient(GRPC_VORGANG_SERVICE_ADDRESS)
private VorgangServiceGrpc.VorgangServiceBlockingStub vorgangServiceStub;
@Bean("processorManager_OzgCloudCommandService")
@ConditionalOnProperty(prefix = "ozgcloud.processors[0]", name = "address")
@Bean(OZGCLOUD_VORGANG_SERVICE_NAME) // NOSONAR
OzgCloudVorgangService grpcOzgCloudCommandService(OzgCloudVorgangMapper vorgangMapper, OzgCloudVorgangStubMapper vorgangStubMapper,
ProzessorManagerCallContextProvider contextProvider) {
return new GrpcOzgCloudVorgangService(vorgangServiceStub, vorgangMapper, vorgangStubMapper, contextProvider);
OzgCloudVorgangQueryMapper vorgangQueryMapper, ProzessorManagerCallContextProvider contextProvider) {
return new GrpcOzgCloudVorgangService(vorgangServiceStub, vorgangMapper, vorgangStubMapper, vorgangQueryMapper, contextProvider);
}
}
......@@ -28,18 +28,21 @@ import java.net.ProxySelector;
import java.net.http.HttpClient;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.client.reactive.JdkClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import lombok.RequiredArgsConstructor;
@Configuration
@RequiredArgsConstructor
class ProcessorConfiguration {
@Qualifier(ProcessorManagerConfiguration.PROXY_PROPERTIES_NAME) // NOSONAR
private final Optional<ProxyProperties> proxyProperties;
@Bean
......
......@@ -29,6 +29,7 @@ import java.util.function.Predicate;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
......@@ -38,6 +39,7 @@ import de.ozgcloud.command.Command;
import de.ozgcloud.command.CommandCreatedEvent;
import de.ozgcloud.command.CommandFailedEvent;
import de.ozgcloud.command.VorgangCreatedEvent;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import de.ozgcloud.processor.result.ResultService;
import de.ozgcloud.processor.vorgang.Vorgang;
import de.ozgcloud.processor.vorgang.VorgangId;
......@@ -46,15 +48,21 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import reactor.core.publisher.Mono;
@Component("processorVorgangEventListener")
@Component(ProcessorManagerConfiguration.PROCESSOR_EVENT_LISTENER_NAME) // NOSONAR
@ConditionalOnProperty(prefix = "ozgcloud.processors[0]", name = "address")
@RequiredArgsConstructor
@Log4j2
class ProcessorEventListener {
@Qualifier(ProcessorManagerConfiguration.VORGANG_SERVICE_NAME) // NOSONAR
private final VorgangService service;
@Qualifier(ProcessorManagerConfiguration.PROCESSOR_SERVICE_NAME) // NOSONAR
private final ProcessorService processorService;
@Qualifier(ProcessorManagerConfiguration.RESULT_SERVICE_NAME) // NOSONAR
private final ResultService resultService;
private final ApplicationEventPublisher publisher;
static final String PROCESS_VORGANG_ORDER = "PROCESS_VORGANG";
......
......@@ -32,6 +32,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
......@@ -43,7 +44,7 @@ import lombok.ToString;
@ToString
@Getter
@Setter
@Configuration
@Configuration(ProcessorManagerConfiguration.PROCESSOR_PROPERTIES_NAME) // NOSONAR
@ConfigurationProperties(prefix = "ozgcloud")
@Validated
@Builder
......
......@@ -29,6 +29,8 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
......@@ -39,6 +41,7 @@ import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;
import de.ozgcloud.common.errorhandling.TechnicalException;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import de.ozgcloud.processor.processor.ProcessorProperties.Form;
import de.ozgcloud.processor.processor.ProcessorProperties.Processor;
import de.ozgcloud.processor.result.ProcessorTechnicalException;
......@@ -47,13 +50,15 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import reactor.core.publisher.Mono;
@Service
@ConditionalOnProperty(prefix = "ozgcloud.processors[0]", name = "address")
@Service(ProcessorManagerConfiguration.PROCESSOR_SERVICE_NAME) // NOSONAR
@RequiredArgsConstructor
@Log4j2
public class ProcessorService {
private static final String KEY_VORGANG = "vorgang";
@Qualifier(ProcessorManagerConfiguration.PROCESSOR_PROPERTIES_NAME) // NOSONAR
private final ProcessorProperties properties;
private final WebClient webClient;
......
......@@ -31,6 +31,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
......@@ -38,7 +39,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Configuration
@Configuration(ProcessorManagerConfiguration.PROXY_PROPERTIES_NAME) // NOSONAR
@ConditionalOnProperty(prefix = "ozgcloud.http-proxy", name = { "host", "port" })
@ConfigurationProperties(prefix = "ozgcloud.http-proxy")
@Validated
......
......@@ -25,9 +25,10 @@ package de.ozgcloud.processor.result;
import org.springframework.stereotype.Component;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import de.ozgcloud.processor.processor.ProcessorResult;
@Component
@Component(ProcessorManagerConfiguration.AKTENNOTIZ_FACTORY_NAME) // NOSONAR
public class AktennotizFactory {
static final String AKTENNOTIZ_ERROR_TEXT = """
......
......@@ -25,21 +25,24 @@ package de.ozgcloud.processor.result;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import de.ozgcloud.apilib.alfa.AlfaService;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgangIdMapper;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import de.ozgcloud.processor.processor.ProcessorResult;
import lombok.RequiredArgsConstructor;
@Service
@Service(ProcessorManagerConfiguration.RESULT_SERVICE_NAME) // NOSONAR
@RequiredArgsConstructor
@Validated
public class ResultService {
private final AlfaService alfaService;
private final OzgCloudVorgangIdMapper vorgangIdMapper;
@Qualifier(ProcessorManagerConfiguration.AKTENNOTIZ_FACTORY_NAME) // NOSONAR
private final AktennotizFactory aktennotizFactory;
public void processResult(@Valid ProcessorResult result) {
......
......@@ -27,9 +27,11 @@ import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.AnnotateWith;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;
import de.ozgcloud.apilib.file.OzgCloudFileGroup;
import de.ozgcloud.apilib.file.OzgCloudFileId;
......@@ -42,8 +44,10 @@ import de.ozgcloud.apilib.vorgang.OzgCloudSubForm;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgang;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgangId;
import de.ozgcloud.common.binaryfile.FileId;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
@Mapper
@AnnotateWith(value = Component.class, elements = @AnnotateWith.Element(strings = ProcessorManagerConfiguration.VORGANG_MAPPER_NAME))
public interface ProcessorVorgangMapper {
@Mapping(target = "eingang", qualifiedByName = "mapEingang", source = "eingangs")
......
......@@ -23,22 +23,26 @@
*/
package de.ozgcloud.processor.vorgang;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgangId;
import de.ozgcloud.apilib.vorgang.OzgCloudVorgangService;
import de.ozgcloud.processor.ProcessorManagerConfiguration;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Service("processorVorgangService")
@ConditionalOnProperty(prefix = "ozgcloud.processors[0]", name = "address")
@Service(ProcessorManagerConfiguration.VORGANG_SERVICE_NAME) // NOSONAR
@RequiredArgsConstructor
public class VorgangService {
@Autowired
@Qualifier("processorManager_OzgCloudCommandService")
private OzgCloudVorgangService ozgCloudService;
@Autowired
private ProcessorVorgangMapper mapper;
@Qualifier(ProcessorManagerConfiguration.OZGCLOUD_VORGANG_SERVICE_NAME) // NOSONAR
private final OzgCloudVorgangService ozgCloudService;
@Qualifier(ProcessorManagerConfiguration.VORGANG_MAPPER_NAME) // NOSONAR
private final ProcessorVorgangMapper mapper;
public Vorgang getVorgang(@NonNull VorgangId id) {
var loaded = ozgCloudService.getById(OzgCloudVorgangId.from(id.toString()));
......
......@@ -23,14 +23,20 @@
*/
package de.ozgcloud.processor.vorgang;
import static de.ozgcloud.apilib.vorgang.AttachmentTestFactory.*;
import de.ozgcloud.processor.vorgang.FileGroup.FileGroupBuilder;
public class AttachmentTestFactory {
public static FileGroup createFileGroup() {
public static final String GROUP_NAME = "File Group Name";
public static FileGroup create() {
return createBuilder().build();
}
public static FileGroupBuilder createBuilder() {
return FileGroup.builder()
.name(GROUP_NAME)
.file(FileMetaDataTestFactory.create())
.build();
.file(FileMetaDataTestFactory.create());
}
}
......@@ -36,7 +36,7 @@ public class EingangTestFactory {
public static Eingang.EingangBuilder createBuilder() {
return Eingang.builder()
.antragsteller(AntragstellerTestFactory.create())
.attachment(AttachmentTestFactory.createFileGroup())
.attachment(AttachmentTestFactory.create())
.formData(List.<FormDataEntry>of(
FormField.builder().name(FIELD_NAME).label(FIELD_LABEL).value(FIELD_VALUE).build(),
SubForm.builder().name(SUB_FORM_NAME).label(SUB_FORM_LABEL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment