From 2a58c335f2fa5893d33dae15ae91c7dca046ce35 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Wed, 13 Mar 2024 15:48:28 +0100 Subject: [PATCH] Apply les trucs de l'exception --- backend/build.gradle.kts | 1 + .../Clyde/Exceptions/CouldntDeleteFileException.java | 4 ---- .../java/ovh/herisson/Clyde/Services/StorageService.java | 7 ++----- 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 backend/src/main/java/ovh/herisson/Clyde/Exceptions/CouldntDeleteFileException.java diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index f105250..6557b82 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -41,3 +41,4 @@ tasks.register("run") { tasks.withType { useJUnitPlatform() } + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Exceptions/CouldntDeleteFileException.java b/backend/src/main/java/ovh/herisson/Clyde/Exceptions/CouldntDeleteFileException.java deleted file mode 100644 index ce0d637..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Exceptions/CouldntDeleteFileException.java +++ /dev/null @@ -1,4 +0,0 @@ -package ovh.herisson.Clyde.Exceptions; - -public class CouldntDeleteFileException extends Exception{ -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java index 36e39ca..cb3ceb0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java @@ -1,15 +1,12 @@ package ovh.herisson.Clyde.Services; -import org.springframework.core.io.UrlResource; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import ovh.herisson.Clyde.Exceptions.CouldntDeleteFileException; import ovh.herisson.Clyde.Repositories.FileRepository; import ovh.herisson.Clyde.Tables.*; import java.io.File; import java.io.IOException; -import org.springframework.core.io.Resource; import java.nio.file.Files; import java.nio.file.Path; @@ -57,13 +54,13 @@ public class StorageService { return url; } - public void delete(StorageFile file) throws CouldntDeleteFileException { + public void delete(StorageFile file) throws SecurityException { File f = new File(file.getUrl()); //Delete le fichier try{ f.delete(); } catch (Exception e) { - throw new CouldntDeleteFileException(); + throw new SecurityException(); } //Delete l'entité fileRepo.delete(file);