Commit 160a17e6 authored by Siiri Tann's avatar Siiri Tann
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Siiri Tann

See merge request teis/files-service!60
parents 8185c5ec 1456c2a7
# Changelog
## [1.19.0] - 2021-04-12
* TEIS-2102: improved file upload and virus scan handling when file does not exist in Minio S3 bucket
* TEIS-2107: create index on file_reference table
## [1.18.0] - 2021-03-22
* TEIS-1566: Introduced @BpmProcess annotation which maps RequestMetaDto for logging and security context via
......
theGroup=ee.sm.ti.teis
theVersion=1.18.0
commonsVersion=1.22.0
commonApiGatewayVersion=1.22.0
theVersion=1.19.0
commonsVersion=1.23.0
commonApiGatewayVersion=1.23.0
pluginVersion=1.3.0
schedulerVersion=1.15.0
--liquibase formatted sql
--changeset enriko:2021-03-30.TEIS-2107.create-file_reference_object_index
CREATE INDEX IF NOT EXISTS file_reference_object_idx ON file_reference (object_id, object_type);
......@@ -6,5 +6,6 @@
<include file="file-reference.sql" relativeToChangelogFile="true"/>
<include file="2020-04-08.TEIS-835.update-official-system-scan-status.sql" relativeToChangelogFile="true"/>
<include file="2021-01-12.TEIS-1661.add-request-id-audited-entity-fields.sql" relativeToChangelogFile="true"/>
<include file="2021-03-30.TEIS-2107.create-file_reference_object_index" relativeToChangelogFile="true"/>
</databaseChangeLog>
......@@ -3,10 +3,12 @@ package ee.sm.ti.teis.file.virusscan.bpm;
import com.fasterxml.jackson.databind.ObjectMapper;
import ee.sm.ti.teis.bpm.BpmProcess;
import ee.sm.ti.teis.domain.filesvirusscan.StartVirusScan;
import ee.sm.ti.teis.exceptions.TeisStorageException;
import ee.sm.ti.teis.exceptions.TeisSystemAlertException;
import ee.sm.ti.teis.file.FileEntity;
import ee.sm.ti.teis.file.service.FileDataService;
import ee.sm.ti.teis.file.virusscan.serviceclient.FilesVirusScanServiceClient;
import ee.sm.ti.teis.fileclient.FileStorageServiceClient;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -29,6 +31,7 @@ public class UploadFileVirusScanTask implements JavaDelegate {
private final FileDataService dataService;
private final ObjectMapper objectMapper;
private final FilesVirusScanServiceClient filesVirusScanServiceClient;
private final FileStorageServiceClient fileStorageServiceClient;
@BpmProcess
@Override
......@@ -48,6 +51,9 @@ public class UploadFileVirusScanTask implements JavaDelegate {
}
requestVirusScanUpload(file, requestMetaDto);
} catch (TeisStorageException e) {
log.error("File not found from S3 bucket, virus scan process will be cancelled..");
handleTaskException(e, this.getClass().getSimpleName(), businessKey, requestMetaJson);
} catch (Exception e) {
String logMessage = logTaskException(e, this.getClass().getSimpleName(), businessKey, requestMetaJson);
throw new TeisSystemAlertException(logMessage, e);
......@@ -55,10 +61,15 @@ public class UploadFileVirusScanTask implements JavaDelegate {
}
private void requestVirusScanUpload(FileEntity file, RequestMetaDTO requestMetaDto) {
String bucket = file.getBucket();
UUID fileName = file.getId();
fileStorageServiceClient.getFileMetadata(bucket, fileName);
StartVirusScan domain = new StartVirusScan();
domain.setFileId(file.getId());
domain.setFileId(fileName);
domain.setFileName(file.getName());
domain.setBucket(file.getBucket());
domain.setBucket(bucket);
filesVirusScanServiceClient.start(domain, requestMetaDto);
}
......
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