From 5a99c51aee718336ea7d2212f25fec49e783551c Mon Sep 17 00:00:00 2001 From: Fabrice B Date: Fri, 13 Dec 2024 11:43:42 +0100 Subject: [PATCH] fix (print debug message with miniofiles) --- .../rmes/bauhaus_services/MinioFilesOperation.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java b/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java index ce16a7ad2..fd5318931 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java @@ -1,8 +1,11 @@ package fr.insee.rmes.bauhaus_services; +import fr.insee.rmes.bauhaus_services.operations.documentations.documents.DocumentsUtils; import fr.insee.rmes.exceptions.RmesFileException; import io.minio.*; import io.minio.errors.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; @@ -14,11 +17,15 @@ public record MinioFilesOperation(MinioClient minioClient, String bucketName, String directoryGestion, String directoryPublication) implements FilesOperations { + static final Logger logger = LoggerFactory.getLogger(MinioFilesOperation.class); + @Override public InputStream read(String pathFile){ String fileName= extractFileName(pathFile); String objectName = directoryGestion + "/" + fileName; + logger.debug("Reading file with name {} from path {} as object {} in bucket {}", fileName, pathFile, objectName, bucketName); + try { return minioClient.getObject(GetObjectArgs.builder() .bucket(bucketName) @@ -38,6 +45,7 @@ private static String extractFileName(String filePath) { @Override public boolean existsInStorage(String filename) { var objectName = extractFileName(requireNonNull(filename)); + logger.debug("Check existence of file with name {} as object {} in bucket {}", filename, objectName, bucketName); try { return minioClient.statObject(StatObjectArgs.builder() .bucket(bucketName) @@ -52,6 +60,7 @@ public boolean existsInStorage(String filename) { public void write(InputStream content, Path filePath) { String filename = filePath.getFileName().toString(); String objectName = directoryGestion + "/" + filename; + logger.debug("Writing to file with name {} from path {} as object {} in bucket {}", filename, filePath, objectName, bucketName); try { minioClient.putObject(PutObjectArgs.builder() .bucket(bucketName) @@ -71,6 +80,8 @@ public void copy(String srcObjectName, String destObjectName) { String srcObject = directoryGestion + "/" + extractFileName(srcObjectName); String destObject = directoryPublication + "/" + extractFileName(srcObjectName); + logger.debug("Copy from source {} as object {} to destination {} as object {} in bucket {}", srcObjectName, srcObject, destObjectName, destObject, bucketName); + try { CopySource source = CopySource.builder() .bucket(bucketName) @@ -96,6 +107,9 @@ public boolean dirExists(Path gestionStorageFolder) { @Override public void delete(Path absolutePath) { String objectName = absolutePath.getFileName().toString(); + + logger.debug("Delete file with path {} as object {} in bucket {}", absolutePath, objectName, bucketName); + try { minioClient.removeObject(RemoveObjectArgs.builder() .bucket(bucketName)