Commit 3966d153 authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Jürgen Hannus

See merge request teis/files-service!45
parents e78be6cf 0b8b5111
theGroup=ee.sm.ti.teis
theVersion=1.13.0
theVersion=1.13.1
commonsVersion=1.16.0
commonApiGatewayVersion=1.16.0
pluginVersion=1.2.0
......
......@@ -12,8 +12,10 @@ import ee.sm.ti.teis.servicecommon.config.PropertyLogger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.retry.annotation.EnableRetry;
@SpringBootApplication
@EnableRetry
@Import({PropertyLogger.class, JpaAuditingConfiguration.class, ExchangeConfig.class, QueueConfigurator.class,
RabbitListenerAspect.class, DataSourceConfig.class})
public class FilesServiceApp {
......
......@@ -4,7 +4,11 @@ import ee.sm.ti.teis.file.FileEntity;
import ee.sm.ti.teis.file.service.FileDataService;
import ee.sm.ti.teis.types.enums.FileScanStatusType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.MismatchingMessageCorrelationException;
import org.camunda.bpm.engine.RuntimeService;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -18,19 +22,28 @@ import static ee.sm.ti.teis.types.enums.FileScanStatusType.SYSTEM_ERROR;
@Service
@Validated
@Slf4j
@RequiredArgsConstructor
public class VirusScanBusinessService {
private final RuntimeService bpmRuntimeService;
private final FileDataService fileDataService;
@Retryable(
value = {MismatchingMessageCorrelationException.class},
maxAttempts = 20,
backoff = @Backoff(delay = 1000))
public void processUploadFailed(UUID fileId, String requestId) {
String businessKey = getBusinessKey(fileId, requestId);
bpmRuntimeService.createMessageCorrelation(VIRUS_SCAN_UPLOAD_FAILED)
.processInstanceBusinessKey(businessKey)
.correlateAll();
.correlate();
}
@Retryable(
value = {MismatchingMessageCorrelationException.class},
maxAttempts = 20,
backoff = @Backoff(delay = 1000))
@Transactional
public void processUploadSuccessful(UUID fileId, String dataId, String requestId) {
FileEntity file = fileDataService.getCurrentFile(fileId);
......@@ -44,6 +57,10 @@ public class VirusScanBusinessService {
.correlate();
}
@Retryable(
value = {MismatchingMessageCorrelationException.class},
maxAttempts = 20,
backoff = @Backoff(delay = 1000))
public void processPollResultFailed(UUID fileId, FileScanStatusType scanStatusType, String requestId) {
String businessKey = getBusinessKey(fileId, requestId);
......@@ -52,22 +69,27 @@ public class VirusScanBusinessService {
.processInstanceBusinessKey(businessKey)
.setVariable(IS_FAILED_SCAN_STATUS, true)
.setVariable(IS_SYSTEM_ERROR, false)
.correlateAll();
.correlate();
} else if (SYSTEM_ERROR.equals(scanStatusType)) {
bpmRuntimeService.createMessageCorrelation(POLL_VIRUS_SCAN_RESULT_FAILED)
.processInstanceBusinessKey(businessKey)
.setVariable(IS_SYSTEM_ERROR, true)
.setVariable(IS_FAILED_SCAN_STATUS, false)
.correlateAll();
.correlate();
}
}
@Retryable(
value = {MismatchingMessageCorrelationException.class},
maxAttempts = 20,
backoff = @Backoff(delay = 1000))
public void processResultSuccessful(UUID fileId, FileScanStatusType status, String requestId) {
log.info("Virus scan result received for file ID {} and status: {}", fileId, status);
String businessKey = getBusinessKey(fileId, requestId);
bpmRuntimeService.createMessageCorrelation(POLL_VIRUS_SCAN_RESULT)
.processInstanceBusinessKey(businessKey)
.setVariables(Map.of(VIRUS_SCAN_STATUS, status))
.correlateAll();
.correlate();
}
}
......@@ -35,6 +35,7 @@ public class UpdateVirusScanResultTask implements JavaDelegate {
@Transactional(value = REQUIRES_NEW)
public void execute(DelegateExecution execution) {
String businessKey = execution.getBusinessKey();
log.info("Initiating UpdateVirusScanResultTask for businessKey: {}", businessKey);
UUID fileId = (UUID) execution.getVariable(FILE_ID);
String requestMetaJson = (String) execution.getVariable(REQUEST_META_DTO);
......
......@@ -205,7 +205,7 @@
<bpmn:sequenceFlow id="Flow_1wcv1z2" name="isFailedScan Status" sourceRef="Gateway_03bab3y" targetRef="Event_0lok0t8">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${isFailedScanStatus==true}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="Activity_17jmwr3" name="Poll for virus scan result" camunda:asyncBefore="true" camunda:delegateExpression="${pollVirusScanResultTask}">
<bpmn:serviceTask id="Activity_17jmwr3" name="Poll for virus scan result" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:delegateExpression="${pollVirusScanResultTask}">
<bpmn:incoming>Flow_1wrucs1</bpmn:incoming>
<bpmn:incoming>Flow_1qq0243</bpmn:incoming>
<bpmn:outgoing>Flow_0k47wtr</bpmn:outgoing>
......@@ -284,12 +284,28 @@
<bpmndi:BPMNShape id="Event_0l7v38r_di" bpmnElement="StartEvent_1">
<dc:Bounds x="152" y="382" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0433buk_di" bpmnElement="Event_1p8ewwq">
<dc:Bounds x="1892" y="392" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0v9j9pq_di" bpmnElement="Activity_0v9j9pq" isExpanded="true">
<dc:Bounds x="240" y="80" width="660" height="469" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1mn9enh_di" bpmnElement="Flow_1mn9enh">
<di:waypoint x="830" y="220" />
<di:waypoint x="860" y="220" />
<di:waypoint x="860" y="350" />
<di:waypoint x="800" y="350" />
<di:waypoint x="800" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0eckqhe_di" bpmnElement="Flow_0eckqhe">
<di:waypoint x="700" y="374" />
<di:waypoint x="700" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0kbqgaq_di" bpmnElement="Flow_0kbqgaq">
<di:waypoint x="455" y="399" />
<di:waypoint x="520" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0omqwct_di" bpmnElement="Flow_0omqwct">
<di:waypoint x="620" y="399" />
<di:waypoint x="675" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1pd8iop_di" bpmnElement="Flow_1pd8iop">
<di:waypoint x="725" y="399" />
<di:waypoint x="764" y="399" />
......@@ -298,10 +314,6 @@
<di:waypoint x="796" y="399" />
<di:waypoint x="842" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0omqwct_di" bpmnElement="Flow_0omqwct">
<di:waypoint x="620" y="399" />
<di:waypoint x="675" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ma3kjz_di" bpmnElement="Flow_1ma3kjz">
<di:waypoint x="430" y="424" />
<di:waypoint x="430" y="471" />
......@@ -310,31 +322,13 @@
<di:waypoint x="448" y="489" />
<di:waypoint x="532" y="489" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0kbqgaq_di" bpmnElement="Flow_0kbqgaq">
<di:waypoint x="455" y="399" />
<di:waypoint x="520" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09zj1x9_di" bpmnElement="Flow_09zj1x9">
<di:waypoint x="308" y="399" />
<di:waypoint x="405" y="399" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0eckqhe_di" bpmnElement="Flow_0eckqhe">
<di:waypoint x="700" y="374" />
<di:waypoint x="700" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1mn9enh_di" bpmnElement="Flow_1mn9enh">
<di:waypoint x="830" y="220" />
<di:waypoint x="860" y="220" />
<di:waypoint x="860" y="350" />
<di:waypoint x="800" y="350" />
<di:waypoint x="800" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0g118ex_di" bpmnElement="Event_0g118ex">
<dc:Bounds x="272" y="381" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0s6ycnm_di" bpmnElement="Activity_0k3r5ts">
<dc:Bounds x="520" y="359" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0o0nqeg_di" bpmnElement="Event_0o0nqeg">
<dc:Bounds x="412" y="471" width="36" height="36" />
<bpmndi:BPMNLabel>
......@@ -362,21 +356,21 @@
<bpmndi:BPMNShape id="Activity_0jl72iv_di" bpmnElement="Activity_0jl72iv" isExpanded="true">
<dc:Bounds x="340" y="120" width="490" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0uhmhrv_di" bpmnElement="Flow_0uhmhrv">
<di:waypoint x="416" y="220" />
<di:waypoint x="462" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0sh3d2p_di" bpmnElement="Flow_0sh3d2p">
<di:waypoint x="498" y="220" />
<di:waypoint x="552" y="220" />
<bpmndi:BPMNEdge id="Flow_0901iu2_di" bpmnElement="Flow_0901iu2">
<di:waypoint x="720" y="220" />
<di:waypoint x="752" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0q2bngh_di" bpmnElement="Flow_0q2bngh">
<di:waypoint x="588" y="220" />
<di:waypoint x="620" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0901iu2_di" bpmnElement="Flow_0901iu2">
<di:waypoint x="720" y="220" />
<di:waypoint x="752" y="220" />
<bpmndi:BPMNEdge id="Flow_0sh3d2p_di" bpmnElement="Flow_0sh3d2p">
<di:waypoint x="498" y="220" />
<di:waypoint x="552" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0uhmhrv_di" bpmnElement="Flow_0uhmhrv">
<di:waypoint x="416" y="220" />
<di:waypoint x="462" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0rvou7q_di" bpmnElement="Event_0rvou7q">
<dc:Bounds x="380" y="202" width="36" height="36" />
......@@ -396,17 +390,38 @@
<bpmndi:BPMNShape id="Event_1lqt1xp_di" bpmnElement="Event_1lqt1xp">
<dc:Bounds x="752" y="202" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0s6ycnm_di" bpmnElement="Activity_0k3r5ts">
<dc:Bounds x="520" y="359" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0433buk_di" bpmnElement="Event_1p8ewwq">
<dc:Bounds x="1892" y="392" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_0j8hidg_di" bpmnElement="SubProcess_0j8hidg" isExpanded="true">
<dc:Bounds x="950" y="110" width="720" height="435" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_092js8y_di" bpmnElement="Flow_092js8y">
<di:waypoint x="1198" y="405" />
<di:waypoint x="1230" y="405" />
<bpmndi:BPMNEdge id="Flow_1nfrh6k_di" bpmnElement="Flow_1nfrh6k">
<di:waypoint x="1620" y="240" />
<di:waypoint x="1640" y="240" />
<di:waypoint x="1640" y="340" />
<di:waypoint x="1560" y="340" />
<di:waypoint x="1560" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sanoqw_di" bpmnElement="Flow_1sanoqw">
<di:waypoint x="1414" y="405" />
<di:waypoint x="1524" y="405" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12dqo3u_di" bpmnElement="Flow_12dqo3u">
<di:waypoint x="1389" y="380" />
<di:waypoint x="1389" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1cqvu4k_di" bpmnElement="Flow_1cqvu4k">
<di:waypoint x="1330" y="405" />
<di:waypoint x="1364" y="405" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_092js8y_di" bpmnElement="Flow_092js8y">
<di:waypoint x="1198" y="405" />
<di:waypoint x="1230" y="405" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1s32ngy_di" bpmnElement="Flow_1s32ngy">
<di:waypoint x="1556" y="405" />
<di:waypoint x="1612" y="405" />
......@@ -420,10 +435,6 @@
<di:waypoint x="1110" y="490" />
<di:waypoint x="1352" y="490" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1cqvu4k_di" bpmnElement="Flow_1cqvu4k">
<di:waypoint x="1330" y="405" />
<di:waypoint x="1364" y="405" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0kljlh1_di" bpmnElement="SequenceFlow_0kljlh1">
<di:waypoint x="1026" y="405" />
<di:waypoint x="1085" y="405" />
......@@ -432,17 +443,6 @@
<di:waypoint x="1388" y="490" />
<di:waypoint x="1552" y="490" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12dqo3u_di" bpmnElement="Flow_12dqo3u">
<di:waypoint x="1389" y="380" />
<di:waypoint x="1389" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1nfrh6k_di" bpmnElement="Flow_1nfrh6k">
<di:waypoint x="1620" y="240" />
<di:waypoint x="1640" y="240" />
<di:waypoint x="1640" y="340" />
<di:waypoint x="1560" y="340" />
<di:waypoint x="1560" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="StartEvent_11oq7yn_di" bpmnElement="StartEvent_11oq7yn">
<dc:Bounds x="990" y="387" width="36" height="36" />
</bpmndi:BPMNShape>
......@@ -479,6 +479,19 @@
<bpmndi:BPMNShape id="Activity_0737jis_di" bpmnElement="Activity_0737jis" isExpanded="true">
<dc:Bounds x="1050" y="130" width="570" height="190" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1wrucs1_di" bpmnElement="Flow_1wrucs1">
<di:waypoint x="1358" y="200" />
<di:waypoint x="1396" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0k47wtr_di" bpmnElement="Flow_0k47wtr">
<di:waypoint x="1496" y="200" />
<di:waypoint x="1562" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1qq0243_di" bpmnElement="Flow_1qq0243">
<di:waypoint x="1358" y="280" />
<di:waypoint x="1446" y="280" />
<di:waypoint x="1446" y="240" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1wcv1z2_di" bpmnElement="Flow_1wcv1z2">
<di:waypoint x="1240" y="225" />
<di:waypoint x="1240" y="280" />
......@@ -487,15 +500,6 @@
<dc:Bounds x="1262" y="246" width="63" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1qq0243_di" bpmnElement="Flow_1qq0243">
<di:waypoint x="1358" y="280" />
<di:waypoint x="1446" y="280" />
<di:waypoint x="1446" y="240" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_019fb77_di" bpmnElement="Flow_019fb77">
<di:waypoint x="1188" y="200" />
<di:waypoint x="1215" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0602n10_di" bpmnElement="Flow_0602n10">
<di:waypoint x="1265" y="200" />
<di:waypoint x="1322" y="200" />
......@@ -503,26 +507,16 @@
<dc:Bounds x="1259" y="173" width="70" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1wrucs1_di" bpmnElement="Flow_1wrucs1">
<di:waypoint x="1358" y="200" />
<di:waypoint x="1396" y="200" />
<bpmndi:BPMNEdge id="Flow_019fb77_di" bpmnElement="Flow_019fb77">
<di:waypoint x="1188" y="200" />
<di:waypoint x="1215" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0edd983_di" bpmnElement="Flow_0edd983">
<di:waypoint x="1106" y="200" />
<di:waypoint x="1152" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0k47wtr_di" bpmnElement="Flow_0k47wtr">
<di:waypoint x="1496" y="200" />
<di:waypoint x="1562" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0lok0t8_di" bpmnElement="Event_0lok0t8">
<dc:Bounds x="1322" y="262" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_03bab3y_di" bpmnElement="Gateway_03bab3y" isMarkerVisible="true">
<dc:Bounds x="1215" y="175" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0373jom_di" bpmnElement="Event_0gwujhr">
<dc:Bounds x="1322" y="182" width="36" height="36" />
<bpmndi:BPMNShape id="Event_0zpp0nu_di" bpmnElement="Event_0zpp0nu">
<dc:Bounds x="1070" y="182" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_16aun2o_di" bpmnElement="Event_120huj4">
<dc:Bounds x="1152" y="182" width="36" height="36" />
......@@ -530,8 +524,14 @@
<dc:Bounds x="1125" y="155.5" width="90" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0zpp0nu_di" bpmnElement="Event_0zpp0nu">
<dc:Bounds x="1070" y="182" width="36" height="36" />
<bpmndi:BPMNShape id="Gateway_03bab3y_di" bpmnElement="Gateway_03bab3y" isMarkerVisible="true">
<dc:Bounds x="1215" y="175" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0lok0t8_di" bpmnElement="Event_0lok0t8">
<dc:Bounds x="1322" y="262" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0373jom_di" bpmnElement="Event_0gwujhr">
<dc:Bounds x="1322" y="182" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_17jmwr3_di" bpmnElement="Activity_17jmwr3">
<dc:Bounds x="1396" y="160" width="100" height="80" />
......@@ -539,12 +539,12 @@
<bpmndi:BPMNShape id="Event_1uj7vu7_di" bpmnElement="Event_1uj7vu7">
<dc:Bounds x="1562" y="182" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0owqj51_di" bpmnElement="Event_1g7qtna">
<dc:Bounds x="537" y="531" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BoundaryEvent_12au63r_di" bpmnElement="IntermediateThrowEvent_19b6w2o">
<dc:Bounds x="990" y="527" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0owqj51_di" bpmnElement="Event_1g7qtna">
<dc:Bounds x="537" y="531" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment