Skip to content

Commit

Permalink
Uat (#196)
Browse files Browse the repository at this point in the history
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: ElisKina-dev <[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
13 people authored Oct 2, 2024
1 parent 79dfa59 commit e911572
Show file tree
Hide file tree
Showing 12 changed files with 17,488 additions and 17,685 deletions.
8 changes: 4 additions & 4 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.64% |
| :heavy_check_mark: Number of Lines Covered | 2292 |
| :x: Number of Lines Missed | 209 |
| Total Number of Lines | 2501 |
| Code Coverage % | 91.42% |
| :heavy_check_mark: Number of Lines Covered | 2301 |
| :x: Number of Lines Missed | 216 |
| Total Number of Lines | 2517 |


## Details:
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.30.0
version: v1.32.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
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.30.0</version>
<version>1.32.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 @@ -41,9 +41,11 @@ public class ResourceCreationDto {
@DefaultValue("")
@Schema(description = "Description of the path parameter: example/path",
pattern = "(^$)|(^(?!/)[a-zA-Z0-9/]+(?<!/)$)", maxLength = 255)
@Length(max = 150)
private String path;

@FormParam("description")
@Schema(format = "byte", maxLength = 255)
@Length(max = 255)
private String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.hibernate.validator.constraints.Length;

import java.util.List;

Expand All @@ -19,8 +20,8 @@ public class ResourceMultipleCreationDtoJSON {
private List<String> filenameList;
@NonNull
private NoDeployableResourceType resourceType;

@Length(max = 150)
private String path;

@Length(max = 255)
private String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public enum AppErrorCodeEnum {
NO_ASSOCIATION_FOUND("ATMLM_4000060","Nessuna associazione trovata", CONSTRAINT_VIOLATION),
ALL_FIELDS_ARE_BLANK("ATMLM_4000061", "Tutti i campi sono vuoti", AppErrorType.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 );
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);
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 @@ -58,7 +58,13 @@ public Uni<List<ResourceEntity>> getAll() {
@Override
@WithTransaction
public Uni<ResourceEntity> save(ResourceEntity resourceEntity) {
return resourceEntityRepository.persist(resourceEntity);
return resourceEntityRepository.persist(resourceEntity)
.onFailure().recoverWithUni(dbException -> {
log.info(dbException.getMessage());
return Uni.createFrom().failure(new AtmLayerException(
String.format("Errore nel salvataggio della risorsa. %s", dbException.getMessage()),
Response.Status.INTERNAL_SERVER_ERROR, DATABASE_SAVE_FILE_ERROR));
});
}

@Override
Expand Down Expand Up @@ -190,19 +196,18 @@ public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEnt
FileUtilities.cleanDecodedFilesDirectory();
return Uni.createFrom().item(errors); // This will be empty if no errors occurred
});

}

public Uni<List<String>> deleteResourcesFromStorage(List<String> storageKeys, List<String> errorMessages){
public Uni<List<String>> deleteResourcesFromStorage(List<String> storageKeys, List<String> errorMessages) {
return Multi.createFrom().items(storageKeys.stream())
.onItem().transformToUniAndConcatenate(uploadedStorageKey -> resourceEntityStorageService.delete(uploadedStorageKey)
.onItem().transform(objectStoreResponse -> String.format("Deleted %s",objectStoreResponse.getStorageKey())))
.collect().asList()
.onItem().transform(deletedKeys -> {
.onItem().transform(objectStoreResponse -> String.format("Deleted %s", objectStoreResponse.getStorageKey())))
.collect().asList()
.onItem().transform(Unchecked.function(deletedKeys -> {
FileUtilities.cleanDecodedFilesDirectory();
throw new AtmLayerException("Errore nel caricamento dovuto ai seguenti file: " + String.join(", ", errorMessages),
Response.Status.BAD_REQUEST, RESOURCES_CREATION_ERROR);
});
Response.Status.BAD_REQUEST, RESOURCES_CREATION_ERROR);
}));
}

@Override
Expand Down Expand Up @@ -263,6 +268,7 @@ public Uni<PageInfo<ResourceEntity>> findResourceFiltered(int pageIndex, int pag
@Override
@WithTransaction
public Uni<Void> disable(UUID uuid) {
String errorMessage = "Errore durante la cancellazione della risorsa: Controllare i log per i dettagli";
return resourceEntityRepository.findById(uuid)
.onItem()
.transformToUni(resourceEntity -> {
Expand All @@ -278,8 +284,20 @@ public Uni<Void> disable(UUID uuid) {
.transformToUni(itemToDelete -> resourceEntityStorageService.delete(originalStorageKey)
.onItem()
.transformToUni(deletedFile -> Uni.createFrom().voidItem())
.onFailure()
.recoverWithUni(deleteException -> resourceEntityStorageService.delete(resourceFileUpdated.getStorageKey())
.onItem()
.transform(Unchecked.function(deletedCopy -> {
throw new AtmLayerException(
errorMessage,
Response.Status.INTERNAL_SERVER_ERROR, OBJECT_STORE_COPY_FILE_ERROR);})))
)
)
.onFailure().recoverWithUni(failure ->
Uni.createFrom().failure(new AtmLayerException(
errorMessage,
Response.Status.INTERNAL_SERVER_ERROR, DATABASE_SAVE_FILE_ERROR))
)
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import io.vertx.core.buffer.Buffer;
import it.gov.pagopa.atmlayer.service.model.entity.ResourceEntity;
import it.gov.pagopa.atmlayer.service.model.entity.ResourceFile;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.NoDeployableResourceType;
import it.gov.pagopa.atmlayer.service.model.enumeration.ObjectStoreStrategyEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.S3ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
import it.gov.pagopa.atmlayer.service.model.model.ObjectStoreResponse;
import it.gov.pagopa.atmlayer.service.model.properties.ObjectStoreProperties;
import it.gov.pagopa.atmlayer.service.model.service.ObjectStoreService;
Expand All @@ -18,6 +20,7 @@
import it.gov.pagopa.atmlayer.service.model.strategy.ObjectStoreStrategy;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringSubstitutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Optional;

import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.DATABASE_SAVE_FILE_ERROR;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.RESOURCE_DOES_NOT_EXIST;
import static it.gov.pagopa.atmlayer.service.model.utils.FileStorageS3Utils.modifyPath;
import static java.lang.String.valueOf;
Expand Down Expand Up @@ -71,7 +72,12 @@ public Uni<ResourceFile> updateStorageKey(ResourceEntity resourceEntity) {
return resourceFileRepository.persist(resourceFileFound)
.onItem()
.transformToUni(newResourceFile -> Uni.createFrom().item(newResourceFile));
});
})
.onFailure().recoverWithUni(failure ->
Uni.createFrom().failure(new AtmLayerException(
"Impossibile eliminare la risorsa. Aggiornamento della storage key interrotto",
Response.Status.INTERNAL_SERVER_ERROR, DATABASE_SAVE_FILE_ERROR))
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testUpdateStorageKey_ResourceNotFound() {
resourceFileService.updateStorageKey(resourceEntity)
.subscribe()
.withSubscriber(UniAssertSubscriber.create())
.assertFailedWith(AtmLayerException.class, "La risorsa di riferimento non esiste: impossibile aggiornare la chiave di archiviazione");
.assertFailedWith(AtmLayerException.class, "Impossibile eliminare la risorsa. Aggiornamento della storage key interrotto");

verify(resourceFileRepository, times(1)).findByStorageKey(storageKey);
}
Expand Down
Loading

0 comments on commit e911572

Please sign in to comment.