From 846d8d6633ac5085615efe66202ed7643684ed44 Mon Sep 17 00:00:00 2001 From: Escarsel Date: Tue, 14 Nov 2023 16:45:42 +0100 Subject: [PATCH] Creato CommonUtils --- .../service/model/utils/CommonUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/it/gov/pagopa/atmlayer/service/model/utils/CommonUtils.java diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/CommonUtils.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/CommonUtils.java new file mode 100644 index 00000000..739b4782 --- /dev/null +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/CommonUtils.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.atmlayer.service.model.utils; + +import org.apache.commons.io.FilenameUtils; + +public class CommonUtils { + + public static String getPathWithoutFilename(String path) { + return path.substring(0, path.length() - 1); + } + + public static String getFilenameWithExtension(String fileName, String extension){ + return fileName.concat(".").concat(extension); + } + + public static String getFilenameWithExtensionFromStorageKey(String storageKey){ + String fileName = FilenameUtils.getBaseName(storageKey); + String extension = FilenameUtils.getExtension(storageKey); + return getFilenameWithExtension(fileName,extension); + } +}