Skip to content

Commit

Permalink
1457 resolve review annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
markostreich committed Jul 4, 2024
1 parent bc20523 commit 305c924
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ void saveDocumentInStorageWithGetRequest() {
final GenerateDocument generateDocument = new GenerateDocument("Client", "Role", "guid", null, listOfURls);

BpmnError bpmnError = assertThrows(BpmnError.class, () -> s3Adapter.saveDocumentInStorage(generateDocument, DATA_AS_BYTE_ARRAY));
s3Adapter.saveDocumentInStorage(generateDocument, dataAsByteArray);
});

String expectedMessage = "Document storage action GET is not supported.";
String actualMessage = bpmnError.getErrorMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ digiwf:
s3:
client:
document-storage-url: '${DIGIWF_S3_HTTPAPI:http://localhost:8086}'
max-file-size: ${S3_MAX_FILE_SIZE:10MB}
max-file-size: ${S3_MAX_FILE_SIZE:100MB}

management:
endpoint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,21 @@ private List<Content> getFilesFromFolder(final String folderPath, final String s
}
}

private Content getFile(final String filepath, final String s3Storage) {
private Content getFile(final String filePath, final String s3Storage) {
try {
final byte[] bytes;
bytes = this.documentStorageFileRepository.getFile(filepath, 3, s3Storage);
bytes = this.documentStorageFileRepository.getFile(filePath, 3, s3Storage);
final String mimeType = fileService.detectFileType(bytes);
final String filename = FilenameUtils.getBaseName(filepath);
final String filename = FilenameUtils.getBaseName(filePath);

// check if mimeType exists
if (!fileService.isSupported(mimeType))
throw new BpmnError("FILE_TYPE_NOT_SUPPORTED", "The type of this file is not supported: " + filepath);
throw new BpmnError("FILE_TYPE_NOT_SUPPORTED", "The type of this file is not supported: " + filePath);

return new Content(fileService.getFileExtension(mimeType), filename, bytes);
} catch (final DocumentStorageException | DocumentStorageServerErrorException |
DocumentStorageClientErrorException e) {
throw new BpmnError("LOAD_FILE_FAILED", "An file could not be loaded from url: " + filepath);
throw new BpmnError("LOAD_FILE_FAILED", "An file could not be loaded from url: " + filePath);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@ digiwf:
client:
document-storage-url: "${DOCUMENT_STORAGE_HOST:http://localhost}:${DOCUMENT_STORAGE_PORT:8080}"
enable-security: true
max-file-size: ${S3_MAX_FILE_SIZE:10MB}
max-file-size: ${S3_MAX_FILE_SIZE:100MB}
max-batch-size: ${S3_MAX_BATCH_SIZE:100MB}
security:
client-id: ${SSO_DMS_CLIENT_ID}
client-secret: ${SSO_DMS_CLIENT_SECRET}
s3:
client:
document-storage-url: "${DOCUMENT_STORAGE_HOST:http://localhost}:${DOCUMENT_STORAGE_PORT:8080}"
enable-security: true

io:
muenchendigital:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ private long getFileSize(final String filePath, final String s3Storage) {
private List<FileContent> getFilesFromFolder(String folderPath, final String domainSpecificS3Storage) {
try {
final List<FileContent> contents = new ArrayList<>();
final Set<String> filepath;
filepath = documentStorageFolderRepository.getAllFilesInFolderRecursively(folderPath, domainSpecificS3Storage).block();
if (Objects.isNull(filepath)) throw new BpmnError(LOAD_FOLDER_FAILED, "An folder could not be loaded from url: " + folderPath);
filepath.forEach(file -> contents.add(getFile(file, domainSpecificS3Storage)));
final Set<String> filePath;
filePath = documentStorageFolderRepository.getAllFilesInFolderRecursively(folderPath, domainSpecificS3Storage).block();

Check warning on line 118 in digiwf-integrations/digiwf-ticket-integration/digiwf-ticket-integration-core/src/main/java/de/muenchen/oss/digiwf/ticket/integration/adapter/out/s3/S3Adapter.java

View check run for this annotation

Codecov / codecov/patch

digiwf-integrations/digiwf-ticket-integration/digiwf-ticket-integration-core/src/main/java/de/muenchen/oss/digiwf/ticket/integration/adapter/out/s3/S3Adapter.java#L118

Added line #L118 was not covered by tests
if (Objects.isNull(filePath)) throw new BpmnError(LOAD_FOLDER_FAILED, "An folder could not be loaded from url: " + folderPath);
filePath.forEach(file -> contents.add(getFile(file, domainSpecificS3Storage)));

Check warning on line 120 in digiwf-integrations/digiwf-ticket-integration/digiwf-ticket-integration-core/src/main/java/de/muenchen/oss/digiwf/ticket/integration/adapter/out/s3/S3Adapter.java

View check run for this annotation

Codecov / codecov/patch

digiwf-integrations/digiwf-ticket-integration/digiwf-ticket-integration-core/src/main/java/de/muenchen/oss/digiwf/ticket/integration/adapter/out/s3/S3Adapter.java#L120

Added line #L120 was not covered by tests
return contents;
} catch (final NullPointerException | DocumentStorageException | DocumentStorageServerErrorException | DocumentStorageClientErrorException e) {
throw new BpmnError(LOAD_FOLDER_FAILED, "An folder could not be loaded from url: " + folderPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ digiwf:
client:
document-storage-url: "${DOCUMENT_STORAGE_HOST:http://localhost}:${DOCUMENT_STORAGE_PORT:8080}"
enable-security: true
max-file-size: ${S3_MAX_FILE_SIZE:20MB}
max-file-size: ${S3_MAX_FILE_SIZE:100MB}
max-batch-size: ${S3_MAX_BATCH_SIZE:100MB}

feign:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public TicketOutPort ticketOutPort(final TicketsApi ticketsApi) {
@Bean
public LoadFileOutPort loadFileOutPort(final DocumentStorageFileRepository documentStorageFileRepository,
final DocumentStorageFolderRepository documentStorageFolderRepository, final FileService fileService,
final S3StorageUrlProvider s3StorageUrlProvider) {
final S3StorageUrlProvider s3StorageUrlProvider) {
return new S3Adapter(documentStorageFileRepository, documentStorageFolderRepository, fileService, s3StorageUrlProvider);
}

Expand All @@ -55,9 +55,7 @@ public WriteArticleInPort writeArticleUseCase(final TicketOutPort ticketOutPort,

@ConditionalOnMissingBean
@Bean
public TicketStreamingAdapter ticketStreamingAdapter(final WriteArticleInPort writeArticleInPort,
final ProcessApi processApi,
final ErrorApi errorApi) {
public TicketStreamingAdapter ticketStreamingAdapter(final WriteArticleInPort writeArticleInPort, final ProcessApi processApi, final ErrorApi errorApi) {
return new TicketStreamingAdapter(writeArticleInPort, processApi, errorApi);
}

Expand Down

0 comments on commit 305c924

Please sign in to comment.