Skip to content

Commit

Permalink
Dev (#199)
Browse files Browse the repository at this point in the history
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
  • Loading branch information
7 people authored Oct 15, 2024
1 parent 670e249 commit f642e44
Show file tree
Hide file tree
Showing 12 changed files with 16,150 additions and 15,991 deletions.
16 changes: 8 additions & 8 deletions _TMP/coverage-results.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# Coverage Report: JaCoCo

* S3PreSignerLocalTest (QuarkusTest)
* IntegrationTest (QuarkusTest)


| Outcome | Value |
|-------------------------|---------------------------------------------------------------------|
| Code Coverage % | 91.36% |
| :heavy_check_mark: Number of Lines Covered | 2315 |
| :x: Number of Lines Missed | 219 |
| Total Number of Lines | 2534 |
| Code Coverage % | 91.32% |
| :heavy_check_mark: Number of Lines Covered | 2325 |
| :x: Number of Lines Missed | 221 |
| Total Number of Lines | 2546 |


## Details:
Expand Down Expand Up @@ -600,7 +600,7 @@
#### Lines Missed:
- Line #180
- Line #190
```
} catch (AtmLayerException ex) {
```
Expand All @@ -616,11 +616,11 @@
#### Lines Missed:
- Line #96
- Line #97
```
.recoverWithUni(failure -> {
```
- Line #257
- Line #259
```
.recoverWithUni(failure -> {
```
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v1.34.0
version: v1.34.0-dev.8
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>it.gov.pagopa</groupId>
<artifactId>atm-layer-model</artifactId>
<version>1.34.0</version>
<version>1.34.0-dev.8</version>
<name>atm-layer-model</name>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public enum AppErrorCodeEnum {
FILE_DECODE_ERROR("ATMLM_4000063", "Errore nella decodifica del file", GENERIC ),
DATABASE_SAVE_FILE_ERROR("ATMLM_4000064", "Errore nella persistenza del file sul database", INTERNAL),
OBJECT_STORE_COPY_FILE_ERROR("ATMLM_4000065", "Errore nella copia del file nella cartella DELETE su Object Store", INTERNAL),
INVALID_FILE_EXTENSION("ATMLM_4000066", "Estensione del file non valida", INVALID_EXTENSION);
INVALID_FILE_EXTENSION("ATMLM_4000066", "Estensione del file non valida", INVALID_EXTENSION),
BPMN_FILE_SIZE_EXCEEDS_LIMIT("ATMLM_4000066", "La dimensione del file supera quella consentita", FILE_SIZE_EXCEEDED);
private final String errorCode;
private final String errorMessage;
private final AppErrorType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public enum AppErrorType {
NOT_EXISTING_USER_ID,
NOT_EXISTING_USER_PROFILE, CANNOT_REPLACE_ASSOCIATION,
BLANK_FIELDS,
INVALID_EXTENSION
INVALID_EXTENSION,
FILE_SIZE_EXCEEDED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.regex.Pattern;

import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.*;
import static it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils.checkFileSize;
import static it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils.getSingleConfig;
import static it.gov.pagopa.atmlayer.service.model.utils.FileUtilities.extractIdValue;

Expand Down Expand Up @@ -215,6 +216,7 @@ public Uni<BpmnVersion> saveAndUpload(BpmnVersion bpmnVersion, File file, String

@Override
public Uni<BpmnVersion> createBPMN(BpmnVersion bpmnVersion, File file, String filename) {
checkFileSize(file);
String definitionKey = extractIdValue(file, resourceType);
bpmnVersion.setDefinitionKey(definitionKey);
return findByDefinitionKey(definitionKey)
Expand Down Expand Up @@ -442,8 +444,9 @@ public Uni<BpmnVersion> getLatestVersion(UUID uuid, String functionType) {
});
}

@Override
public Uni<BpmnDTO> upgrade(BpmnUpgradeDto bpmnUpgradeDto) {
checkFileSize(bpmnUpgradeDto.getFile());

String definitionKey = extractIdValue(bpmnUpgradeDto.getFile(), resourceType);
return this.getLatestVersion(bpmnUpgradeDto.getUuid(), bpmnUpgradeDto.getFunctionType())
.onItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ private void validateFileExtension(String filename, List<String> validExtensions
public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEntityList, List<ResourceCreationDto> resourceCreationDtoList) {
List<String> errors = new ArrayList<>();
List<String> uploadedFiles = new ArrayList<>();

long totalFileSize = resourceCreationDtoList.stream()
.mapToLong(dto -> dto.getFile().length()) // ottieni la dimensione del file in byte
.sum();

// Se la somma delle dimensioni dei file supera 10MB, solleva un'eccezione
if (totalFileSize > 10 * 1024 * 1024) {
throw new AtmLayerException("La dimensione totale dei file supera il limite di 10MB", Response.Status.INTERNAL_SERVER_ERROR, ATMLM_500);
}

return Multi.createFrom().items(resourceEntityList.stream())
.onItem().transformToUniAndConcatenate(resourceEntity -> {
int index = resourceEntityList.indexOf(resourceEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import jakarta.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.util.*;
import java.util.stream.Collectors;

import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.DUPLICATE_ASSOCIATION_CONFIGS;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.ILLEGAL_CONFIGURATION_TRIPLET;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.*;

@ApplicationScoped
public class BpmnUtils {
Expand Down Expand Up @@ -129,4 +129,10 @@ public static BpmnBankConfig getSingleConfig(BpmnVersionPK bpmnVersionPK, String
bpmnBankConfig.setFunctionType(functionType);
return bpmnBankConfig;
}

public static void checkFileSize(File file) {
if (file.length() > 1024 * 1024) {
throw new AtmLayerException("La dimensione del file supera 1MB", Response.Status.BAD_REQUEST, BPMN_FILE_SIZE_EXCEEDS_LIMIT);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ quarkus.devservices.enabled=false
quarkus.log.category."software.amazon.awssdk.services.s3".level=DEBUG
quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
quarkus.rest-client.process-deploy.url=http://localhost:3001
quarkus.http.limits.max-body-size=15M
###################
# OBJECT STORE
###################
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ quarkus.otel.traces.enabled=${TRACING_ENABLED:false}
quarkus.otel.exporter.otlp.traces.endpoint=${TRACING_ENDPOINT_BASE_PATH:http://jaeger-collector.default.svc.cluster.local:4317}
quarkus.datasource.jdbc.telemetry=${TRACING_ENABLE_JDBC_MONITORING:true}



# Client config
quarkus.http.limits.max-body-size=15M
Loading

0 comments on commit f642e44

Please sign in to comment.