RED-6860 - Transaction timeout while preparing download #95
@ -3,7 +3,6 @@ package com.iqser.red.persistence.service.v1.external.api.impl.controller;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.PROCESS_DOWNLOAD;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.READ_DOWNLOAD_STATUS;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -211,7 +210,7 @@ public class DownloadController implements DownloadResource {
|
||||
var downloadStatus = getDownloadStatus(storageId, userId);
|
||||
var fileDownloadStream = getFileForDownload(storageId, userId);
|
||||
|
||||
return getResponseEntity(inline, new InputStreamResource(fileDownloadStream), downloadStatus.getFilename(), MediaType.parseMediaType("application/zip"), downloadStatus.getFileSize());
|
||||
return getResponseEntity(inline, fileDownloadStream, downloadStatus.getFilename(), MediaType.parseMediaType("application/zip"), downloadStatus.getFileSize());
|
||||
});
|
||||
}
|
||||
|
||||
@ -225,10 +224,10 @@ public class DownloadController implements DownloadResource {
|
||||
}
|
||||
|
||||
|
||||
private InputStream getFileForDownload(String storageId, String userId) {
|
||||
private InputStreamResource getFileForDownload(String storageId, String userId) {
|
||||
|
||||
try {
|
||||
var response = fileManagementStorageService.getObject(TenantContext.getTenantId(), storageId);
|
||||
var response = storageService.getObject(TenantContext.getTenantId(), storageId);
|
||||
|
||||
auditPersistenceService.audit(AuditRequest.builder()
|
||||
.userId(userId)
|
||||
@ -276,14 +275,14 @@ public class DownloadController implements DownloadResource {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
TenantContext.setTenantId(tenantId);
|
||||
|
||||
log.debug("downloadFileUsingOTT '{}'", oneTimeToken);
|
||||
log.debug("downloadFileUsingOTT {}", oneTimeToken);
|
||||
var token = oneTimeTokenDownloadService.getToken(oneTimeToken);
|
||||
var downloadStatus = getDownloadStatus(token.getStorageId(), token.getUserId());
|
||||
var fileDownloadStream = getFileForDownload(token.getStorageId(), token.getUserId());
|
||||
|
||||
TenantContext.clear();
|
||||
|
||||
return getResponseEntity(inline, new InputStreamResource(fileDownloadStream), downloadStatus.getFilename(), MediaType.parseMediaType("application/zip"), downloadStatus.getFileSize());
|
||||
return getResponseEntity(inline, fileDownloadStream, downloadStatus.getFilename(), MediaType.parseMediaType("application/zip"), downloadStatus.getFileSize());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -117,4 +117,16 @@ public class FileSystemBackedStorageService implements StorageService {
|
||||
this.dataMap.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public InputStreamResource getObject(String tenantId, String objectId) {
|
||||
|
||||
var res = dataMap.get(objectId);
|
||||
if (res == null) {
|
||||
throw new StorageObjectDoesNotExist(new RuntimeException());
|
||||
}
|
||||
return new InputStreamResource(new FileInputStream(res));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>com.iqser.red</groupId>
|
||||
<artifactId>platform-commons-dependency</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<version>2.9.0</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user