Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uat #200

Merged
merged 123 commits into from
Nov 12, 2024
Merged

Uat #200

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
9807556
Dev (#165)
SMANUM May 31, 2024
0429705
mergin dev into uat (#168)
LuciaM1 Jun 4, 2024
305bc23
feat: 042970510bab5190374bac3c3be11d3ecac9cb1c
actions-user Jun 4, 2024
73be9f0
pom.xml updated with new version 1.17.0
actions-user Jun 4, 2024
9e392a2
Chart.yaml updated with new version v1.17.0
actions-user Jun 4, 2024
634b6a1
feat: docker-image: v1.17.0, chart: v1.17.0
actions-user Jun 4, 2024
d9b2bf4
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Jun 4, 2024
ba18749
Dev (#170)
GiacomoBrancazi Jun 4, 2024
1d184c8
feat: ba18749c68f993452c12b1d1fca1fa90d477c831
actions-user Jun 4, 2024
f03e112
pom.xml updated with new version 1.18.0
actions-user Jun 4, 2024
5a313ab
Chart.yaml updated with new version v1.18.0
actions-user Jun 4, 2024
08a051d
feat: docker-image: v1.18.0, chart: v1.18.0
actions-user Jun 4, 2024
fa4e97d
merging dev into uat (#171)
LuciaM1 Jun 21, 2024
d3016d2
feat: fa4e97d5f76c2b6b1674b571beee9d339d7e07d4
actions-user Jun 21, 2024
95c7baf
pom.xml updated with new version 1.19.0
actions-user Jun 21, 2024
8394b14
Chart.yaml updated with new version v1.19.0
actions-user Jun 21, 2024
2492f8f
feat: docker-image: v1.19.0, chart: v1.19.0
actions-user Jun 21, 2024
7540193
test 2 repliche
adrrss Jul 11, 2024
016c2e2
test 2 repliche
adrrss Jul 11, 2024
ed3c50e
test 1 repliche
adrrss Jul 11, 2024
c4ddcc8
test 3 repliche
adrrss Jul 12, 2024
f882b44
test 3 repliche
adrrss Jul 12, 2024
6bc79c3
test 3 repliche
adrrss Jul 12, 2024
d3d33ce
test 3 repliche
adrrss Jul 16, 2024
16be66d
disable autoscaling
adrrss Jul 16, 2024
59fc9f1
ripristino autoscaling
adrrss Jul 31, 2024
fe5eec4
merging dev into uat (#176)
LuciaM1 Jul 31, 2024
44c98ac
feat: fe5eec4af8bacbd26dbc7e6ffed29a84a76c4514
actions-user Jul 31, 2024
dc19bb5
pom.xml updated with new version 1.20.0
actions-user Jul 31, 2024
0e3d0ab
Chart.yaml updated with new version v1.20.0
actions-user Jul 31, 2024
896a1a3
feat: docker-image: v1.20.0, chart: v1.20.0
actions-user Jul 31, 2024
3225f42
merging dev into uat (#178)
LuciaM1 Aug 1, 2024
dcee3bd
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
43f6180
pom.xml updated with new version 1.21.0
actions-user Aug 1, 2024
8e81c31
Chart.yaml updated with new version v1.21.0
actions-user Aug 1, 2024
a1e61b9
feat: docker-image: v1.21.0, chart: v1.21.0
actions-user Aug 1, 2024
e3cc263
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
f170924
pom.xml updated with new version 1.22.0
actions-user Aug 1, 2024
194a6ee
Chart.yaml updated with new version v1.22.0
actions-user Aug 1, 2024
e1986c1
feat: docker-image: v1.22.0, chart: v1.22.0
actions-user Aug 1, 2024
a13b82c
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
77efc82
pom.xml updated with new version 1.23.0
actions-user Aug 1, 2024
ce9dca7
Chart.yaml updated with new version v1.23.0
actions-user Aug 1, 2024
a9b1e9f
feat: docker-image: v1.23.0, chart: v1.23.0
actions-user Aug 1, 2024
bcfdb3c
Dev (#179)
EmanueleValentini1 Sep 18, 2024
2101ff1
feat: bcfdb3c37039aa4ea0ab6c68b92beab2489b1246
actions-user Sep 18, 2024
18f5dbc
pom.xml updated with new version 1.24.0
actions-user Sep 18, 2024
bdf02b4
Chart.yaml updated with new version v1.24.0
actions-user Sep 18, 2024
a0a20e8
feat: docker-image: v1.24.0, chart: v1.24.0
actions-user Sep 18, 2024
ab19dac
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 19, 2024
6a6d325
merging dev into uat (#181)
LuciaM1 Sep 20, 2024
5388896
feat: 6a6d325041b31ecadeab47659b8107ae63879933
actions-user Sep 20, 2024
a38e29a
pom.xml updated with new version 1.25.0
actions-user Sep 20, 2024
5652dbb
Chart.yaml updated with new version v1.25.0
actions-user Sep 20, 2024
1273db7
feat: docker-image: v1.25.0, chart: v1.25.0
actions-user Sep 20, 2024
a610183
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Sep 20, 2024
3ae136d
merging dev into uat (#184)
LuciaM1 Sep 23, 2024
7b25f52
feat: 3ae136dd494d73bf2284e6bfce80cc3cd4ef1dde
actions-user Sep 23, 2024
d7d2ae4
pom.xml updated with new version 1.26.0
actions-user Sep 23, 2024
0793b3b
Chart.yaml updated with new version v1.26.0
actions-user Sep 23, 2024
b6fe4a6
feat: docker-image: v1.26.0, chart: v1.26.0
actions-user Sep 23, 2024
ae74425
merging dev into uat (#186)
LuciaM1 Sep 23, 2024
aeb13ae
feat: ae744253d23d5a56836b7a417a82c4a3c0f289c6
actions-user Sep 23, 2024
a9c362b
pom.xml updated with new version 1.27.0
actions-user Sep 23, 2024
e7409eb
Chart.yaml updated with new version v1.27.0
actions-user Sep 23, 2024
854f6cc
feat: docker-image: v1.27.0, chart: v1.27.0
actions-user Sep 23, 2024
e86a950
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Sep 23, 2024
488d079
Dev (#188)
EmanueleValentini1 Sep 25, 2024
9b0e0fa
feat: 488d079b82f4b3625884c5f93a8d2d363725b6cf
actions-user Sep 25, 2024
e977add
pom.xml updated with new version 1.28.0
actions-user Sep 25, 2024
26cece8
Chart.yaml updated with new version v1.28.0
actions-user Sep 25, 2024
5ce2867
feat: docker-image: v1.28.0, chart: v1.28.0
actions-user Sep 25, 2024
bfb076e
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 25, 2024
060f371
Dev (#190)
EmanueleValentini1 Sep 25, 2024
a128086
feat: 060f37154fb23219f4d47c81a559110e99f160e2
actions-user Sep 25, 2024
9651aef
pom.xml updated with new version 1.29.0
actions-user Sep 25, 2024
c8faf2b
Chart.yaml updated with new version v1.29.0
actions-user Sep 25, 2024
5f9263f
feat: docker-image: v1.29.0, chart: v1.29.0
actions-user Sep 25, 2024
0d2e34c
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 25, 2024
a466066
merge dev in uat (#192)
ElisKina-dev Sep 26, 2024
100bdee
feat: a46606672a5ac114ab6b22ad084c8812fec058b7
actions-user Sep 26, 2024
ada274c
pom.xml updated with new version 1.30.0
actions-user Sep 26, 2024
444f037
Chart.yaml updated with new version v1.30.0
actions-user Sep 26, 2024
d656f30
feat: docker-image: v1.30.0, chart: v1.30.0
actions-user Sep 26, 2024
a964baa
Merge remote-tracking branch 'origin/main' into uat
ElisKina-dev Sep 26, 2024
d2e3141
Dev (#195)
EmanueleValentini1 Oct 2, 2024
fc69965
feat: d2e314114205e20ed3d2a2fd869a2f604d17010f
actions-user Oct 2, 2024
9f9599d
pom.xml updated with new version 1.31.0
actions-user Oct 2, 2024
68ce818
Chart.yaml updated with new version v1.31.0
actions-user Oct 2, 2024
8cf44b5
feat: docker-image: v1.31.0, chart: v1.31.0
actions-user Oct 2, 2024
740f6dd
feat: d2e314114205e20ed3d2a2fd869a2f604d17010f
actions-user Oct 2, 2024
570acae
pom.xml updated with new version 1.32.0
actions-user Oct 2, 2024
c3126b7
Chart.yaml updated with new version v1.32.0
actions-user Oct 2, 2024
8e38dd8
feat: docker-image: v1.32.0, chart: v1.32.0
actions-user Oct 2, 2024
cc93f71
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Oct 2, 2024
f4b05d7
Dev (#197)
EmanueleValentini1 Oct 10, 2024
b576806
feat: f4b05d7250a8f7998eebf72c66c72229a043c0fb
actions-user Oct 10, 2024
d87eab3
pom.xml updated with new version 1.33.0
actions-user Oct 10, 2024
585dd4d
Chart.yaml updated with new version v1.33.0
actions-user Oct 10, 2024
80fb873
feat: docker-image: v1.33.0, chart: v1.33.0
actions-user Oct 10, 2024
2f421e5
Dev (#198)
EmanueleValentini1 Oct 10, 2024
b8f9416
feat: 2f421e5047ce6c3218525fe5a428e2005c0f1568
actions-user Oct 10, 2024
faf441f
pom.xml updated with new version 1.34.0
actions-user Oct 10, 2024
69b9f5a
Chart.yaml updated with new version v1.34.0
actions-user Oct 10, 2024
670e249
feat: docker-image: v1.34.0, chart: v1.34.0
actions-user Oct 10, 2024
f642e44
Dev (#199)
EmanueleValentini1 Oct 15, 2024
7da4bcc
feat: f642e44fee6bb3d48284edcbe857ccbef5a4cbee
actions-user Oct 15, 2024
d895537
pom.xml updated with new version 1.35.0
actions-user Oct 15, 2024
5c38480
Chart.yaml updated with new version v1.35.0
actions-user Oct 15, 2024
b204153
feat: docker-image: v1.35.0, chart: v1.35.0
actions-user Oct 15, 2024
c4fa0fc
feat: f642e44fee6bb3d48284edcbe857ccbef5a4cbee
actions-user Oct 15, 2024
a993a4a
pom.xml updated with new version 1.36.0
actions-user Oct 15, 2024
5507565
Chart.yaml updated with new version v1.36.0
actions-user Oct 15, 2024
3c4e982
feat: docker-image: v1.36.0, chart: v1.36.0
actions-user Oct 15, 2024
6c18221
feat: f642e44fee6bb3d48284edcbe857ccbef5a4cbee
actions-user Oct 15, 2024
5ff3af1
pom.xml updated with new version 1.37.0
actions-user Oct 15, 2024
f9e46ca
Chart.yaml updated with new version v1.37.0
actions-user Oct 15, 2024
5314479
feat: docker-image: v1.37.0, chart: v1.37.0
actions-user Oct 15, 2024
d6e9121
feat: f642e44fee6bb3d48284edcbe857ccbef5a4cbee
actions-user Oct 15, 2024
3bd6e38
pom.xml updated with new version 1.38.0
actions-user Oct 15, 2024
613b50e
Chart.yaml updated with new version v1.38.0
actions-user Oct 15, 2024
b9d9794
feat: docker-image: v1.38.0, chart: v1.38.0
actions-user Oct 15, 2024
dae8b5b
Merge branch 'main' into uat
EmanueleValentini1 Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions _TMP/coverage-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

| Outcome | Value |
|-------------------------|---------------------------------------------------------------------|
| Code Coverage % | 91.42% |
| :heavy_check_mark: Number of Lines Covered | 2301 |
| :x: Number of Lines Missed | 216 |
| Total Number of Lines | 2517 |
| 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,6 +600,10 @@

#### Lines Missed:

- Line #190
```
} catch (AtmLayerException ex) {
```
</details>


Expand All @@ -612,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.32.0
version: v1.38.0
# 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
5 changes: 1 addition & 4 deletions helm-chart/environments/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ objectStore:
resource_template_path: RESOURCE/files/[RESOURCE_TYPE]

cdn:
resourceBasePath: "https://resources.dev.atmlayer-pagopa.it"
offset_path: RESOURCE/
credentialsSecretEnabled: true
credentialsSecretName: "pagopa-dev-atm-layer-model-cdn-base-path"
credentialsSecretKeys:
cdn_base_path: CDN_BASE_PATH

secretProviderClass:
enabled: true
Expand Down
5 changes: 1 addition & 4 deletions helm-chart/environments/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ objectStore:
resource_template_path: RESOURCE/files/[RESOURCE_TYPE]

cdn:
resourceBasePath: "https://resources.atmlayer-pagopa.it"
offset_path: RESOURCE/
credentialsSecretEnabled: true
credentialsSecretName: "pagopa-prod-atm-layer-model-cdn-base-path"
credentialsSecretKeys:
cdn_base_path: CDN_BASE_PATH

secretProviderClass:
enabled: true
Expand Down
6 changes: 2 additions & 4 deletions helm-chart/environments/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ objectStore:
resource_template_path: RESOURCE/files/[RESOURCE_TYPE]

cdn:
resourceBasePath: "https://resources.uat.atmlayer-pagopa.it"
offset_path: RESOURCE/
credentialsSecretEnabled: true
credentialsSecretName: "pagopa-uat-atm-layer-model-cdn-base-path"
credentialsSecretKeys:
cdn_base_path: CDN_BASE_PATH


secretProviderClass:
enabled: true
Expand Down
10 changes: 3 additions & 7 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ spec:
value: "{{ .Values.tracing.endpointBasePath }}"
- name: TRACING_ENABLE_JDBC_MONITORING
value: "{{ .Values.tracing.enableJDBCMonitoring }}"
{{- if .Values.cdn.credentialsSecretEnabled }}
- name: CDN_BASE_PATH
valueFrom:
secretKeyRef:
name: {{ .Values.cdn.credentialsSecretName }}
key: {{ .Values.cdn.credentialsSecretKeys.cdn_base_path }}
{{- end }}
- name: RESOURCES_BASE_PATH
value: "{{ .Values.cdn.resourceBasePath }}"

volumeMounts:
{{- if .Values.secretProviderClass.enabled }}
- name: secrets-store-inline
Expand Down
10 changes: 0 additions & 10 deletions helm-chart/templates/secretproviderclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ spec:
objectAlias: username
- path: password
objectAlias: password
- objectName: "pagopa-{{ .Values.secretProviderClass.env }}-atm-layer/cloudfront"
objectType: "secretsmanager"
jmesPath:
- path: url
objectAlias: url
secretObjects:
- secretName: {{ .Values.database.credentialsSecretName }}
type: Opaque
Expand All @@ -27,9 +22,4 @@ spec:
key: {{ .Values.database.credentialsSecretKeys.username }}
- objectName: "password" # reference the corresponding parameter
key: {{ .Values.database.credentialsSecretKeys.password }}
- secretName: {{ .Values.cdn.credentialsSecretName }}
type: Opaque
data:
- objectName: "url" # reference the corresponding parameter
key: {{ .Values.cdn.credentialsSecretKeys.cdn_base_path }}
{{- end }}
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.32.0</version>
<version>1.38.0</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 @@ -59,11 +59,13 @@ public enum AppErrorCodeEnum {
BPMN_INTERNAL_ERROR("ATMLM_4000051", "Nessun file associato a BPMN o nessuna storageKey trovata", INTERNAL),
BPMN_FILE_CANNOT_BE_UNDEPLOYED("ATMLM_4000052", "La risorsa di processo indicata non può essere rilasciata", INTERNAL),
NO_ASSOCIATION_FOUND("ATMLM_4000060","Nessuna associazione trovata", CONSTRAINT_VIOLATION),
ALL_FIELDS_ARE_BLANK("ATMLM_4000061", "Tutti i campi sono vuoti", AppErrorType.BLANK_FIELDS),
ALL_FIELDS_ARE_BLANK("ATMLM_4000061", "Tutti i campi sono vuoti", BLANK_FIELDS),
RESOURCES_CREATION_ERROR("ATMLM_4000062", "Errore nella creazione di resource multipli", GENERIC ),
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);
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),
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 @@ -26,5 +26,7 @@ public enum AppErrorType {
CANNOT_ASSOCIATE,
NOT_EXISTING_USER_ID,
NOT_EXISTING_USER_PROFILE, CANNOT_REPLACE_ASSOCIATION,
BLANK_FIELDS
BLANK_FIELDS,
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 @@ -29,7 +29,6 @@
import org.eclipse.microprofile.rest.client.inject.RestClient;

import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.*;

Expand Down Expand Up @@ -120,12 +119,14 @@ public Uni<ResourceFile> upload(ResourceEntity resourceEntity, File file,
@Override
public Uni<ResourceEntity> createResource(ResourceEntity resourceEntity, File file,
String filename, String path, String description) {
validateFileExtension(filename, Arrays.asList("html", "jpeg", "jpg", "png", "svg"));

return findBySHA256(resourceEntity.getSha256())
.onItem().transformToUni(Unchecked.function(x -> {
if (x.isPresent()) {
throw new AtmLayerException(String.format("Esiste già una risorsa con lo stesso contenuto: %s", x.get().getResourceFile().getStorageKey().substring(15)),
Response.Status.BAD_REQUEST,
RESOURCE_WITH_SAME_SHA256_ALREADY_EXISTS);
throw new AtmLayerException(String.format("Esiste già una risorsa con lo stesso contenuto: %s",
x.get().getResourceFile().getStorageKey().substring(15)),
Response.Status.BAD_REQUEST, RESOURCE_WITH_SAME_SHA256_ALREADY_EXISTS);
}
return resourceFileService.findByStorageKey(resourceEntity.getStorageKey())
.onItem()
Expand All @@ -148,16 +149,49 @@ public Uni<ResourceEntity> createResource(ResourceEntity resourceEntity, File fi
}));
}


private void validateFileExtension(String filename, List<String> validExtensions) {
String fileExtension = Optional.ofNullable(filename)
.filter(f -> f.contains("."))
.map(f -> f.substring(filename.lastIndexOf(".") + 1).toLowerCase())
.orElse("");

if (!validExtensions.contains(fileExtension)) {
throw new AtmLayerException(String.format("Estensione del file non valida: %s. Estensioni consentite: %s",
fileExtension, String.join(", ", validExtensions)),
Response.Status.BAD_REQUEST, AppErrorCodeEnum.INVALID_FILE_EXTENSION);
}
}


@Override
@WithTransaction
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);
File file = resourceCreationDtoList.get(index).getFile();
String filename = resourceCreationDtoList.get(index).getFilename();

try {
validateFileExtension(filename, Arrays.asList("html", "jpeg", "jpg", "png", "svg"));
} catch (AtmLayerException ex) {
errors.add(String.format("%s-%s", filename, ex.getMessage()));
return Uni.createFrom().nullItem();
}

return findBySHA256(resourceEntity.getSha256())
.onItem().transformToUni(x -> {
if (x.isPresent()) {
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
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ quarkus.rest-client.process-deploy.url=${MODEL_PROCESS_BASE_PATH:http://pagopa-d
###################
# CDN
###################
cdn.base-url=${CDN_BASE_PATH}
cdn.base-url=${RESOURCES_BASE_PATH}
cdn.offset-path=${CDN_OFFSET_PATH:RESOURCE/}
#quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n
###################
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void testCreateAlreadyExists() {
resourceEntity.setStorageKey("storageKey");
when(resourceEntityRepository.findBySHA256(any(String.class))).thenReturn(Uni.createFrom().nullItem());
when(resourceFileService.findByStorageKey(any(String.class))).thenReturn(Uni.createFrom().item(Optional.of(resourceFile)));
resourceEntityService.createResource(resourceEntity, file, "filename", "path", "description")
resourceEntityService.createResource(resourceEntity, file, "filename.html", "path", "description")
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertFailedWith(AtmLayerException.class, "Impossibile caricare storageKey: la risorsa con lo stesso nome file e percorso esiste già");
}
Expand All @@ -92,7 +92,7 @@ void testCreateSyncError() {
when(resourceEntityStorageService.saveFile(any(ResourceEntity.class), any(File.class), any(String.class), any(String.class)))
.thenReturn(Uni.createFrom().item(resourceFile));
when(resourceEntityRepository.findById(any(UUID.class))).thenReturn(Uni.createFrom().nullItem());
resourceEntityService.createResource(resourceEntity, new File("path/to/file"), "filename.xml", "path", "description")
resourceEntityService.createResource(resourceEntity, new File("path/to/file"), "filename.jpeg", "path", "description")
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertFailedWith(AtmLayerException.class, "Problema di sincronizzazione sulla creazione della risorsa");
}
Expand All @@ -110,7 +110,7 @@ void testCreateResourceWithDuplicateSHA256() {

when(resourceEntityRepository.findBySHA256(sha256)).thenReturn(Uni.createFrom().item(existingResourceEntity));

resourceEntityService.createResource(existingResourceEntity, file, "filename", "path", "description")
resourceEntityService.createResource(existingResourceEntity, file, "filename.jpg", "path", "description")
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertFailedWith(AtmLayerException.class, "Esiste già una risorsa con lo stesso contenuto");
}
Expand All @@ -128,10 +128,10 @@ void testCreateResourceSuccess() {
when(resourceEntityRepository.findBySHA256(sha256)).thenReturn(Uni.createFrom().nullItem());
when(resourceFileService.findByStorageKey(any(String.class))).thenReturn(Uni.createFrom().item(Optional.empty()));
when(resourceEntityRepository.persist(any(ResourceEntity.class))).thenReturn(Uni.createFrom().item(resourceEntity1));
when(resourceEntityStorageService.saveFile(resourceEntity1, file, "prova.txt", "/file/prova")).thenReturn(Uni.createFrom().item(resourceFile));
when(resourceEntityStorageService.saveFile(resourceEntity1, file, "prova.png", "/file/prova")).thenReturn(Uni.createFrom().item(resourceFile));
when(resourceEntityRepository.findById(uuid)).thenReturn(Uni.createFrom().item(resourceEntity1));

resourceEntityService.createResource(resourceEntity1, file, "filename", "path", "description")
resourceEntityService.createResource(resourceEntity1, file, "filename.svg", "path", "description")
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertCompleted()
.assertItem(resourceEntity1);
Expand Down Expand Up @@ -315,7 +315,7 @@ void testCreateResourceMultipleOK() {
}

private List<ResourceCreationDto> getResourceCreationDtoInstance(){
ResourceCreationDto resourceCreationDto = new ResourceCreationDto(new File("test.txt"), "filename", NoDeployableResourceType.HTML, "path", "description");
ResourceCreationDto resourceCreationDto = new ResourceCreationDto(new File("test.jpg"), "filename.jpg", NoDeployableResourceType.HTML, "path", "description");
List<ResourceCreationDto> dtoList = new ArrayList<>();
dtoList.add(resourceCreationDto);
return dtoList;
Expand Down
Loading
Loading