-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: adrrossi <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: adrrss <[email protected]> Co-authored-by: SMANUM <[email protected]> Co-authored-by: LuciaM1 <[email protected]> Co-authored-by: GiacomoB <[email protected]> Co-authored-by: Simone Munao <[email protected]> Co-authored-by: LuciaM1 <[email protected]> Co-authored-by: EmVal <[email protected]> Co-authored-by: Gabriele Maiocchi <[email protected]> Co-authored-by: Giacomo Brancazi <[email protected]>
- Loading branch information
1 parent
0d2e34c
commit a466066
Showing
8 changed files
with
15,760 additions
and
15,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package it.gov.pagopa.atmlayer.service.model.configurations; | ||
|
||
import io.quarkus.runtime.Shutdown; | ||
import io.quarkus.runtime.ShutdownEvent; | ||
import io.quarkus.runtime.Startup; | ||
import io.quarkus.runtime.StartupEvent; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
import lombok.Getter; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.lang3.SystemUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.attribute.PosixFilePermission; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
@ApplicationScoped | ||
public class DirManager { | ||
|
||
@Getter | ||
public static File decodedFilesDirectory; | ||
|
||
@Startup | ||
static void init(@Observes StartupEvent ev) throws IOException { | ||
String secureDirPath = System.getProperty("java.io.tmpdir") + "/decodedFilesDirectory"; | ||
decodedFilesDirectory = new File(secureDirPath); | ||
if (!decodedFilesDirectory.exists() && !decodedFilesDirectory.mkdirs()) { | ||
throw new IOException("Impossibile creare una directory sicura per il salvataggio di file temporanei."); | ||
} | ||
if (SystemUtils.IS_OS_UNIX) { | ||
Set<PosixFilePermission> dirPermissions = EnumSet.of( | ||
PosixFilePermission.OWNER_READ, | ||
PosixFilePermission.OWNER_WRITE, | ||
PosixFilePermission.OWNER_EXECUTE | ||
); | ||
java.nio.file.Files.setPosixFilePermissions(decodedFilesDirectory.toPath(), dirPermissions); | ||
} | ||
} | ||
|
||
@Shutdown | ||
static void shutdown(@Observes ShutdownEvent ev) throws IOException { | ||
FileUtils.deleteDirectory(decodedFilesDirectory); | ||
} | ||
|
||
private DirManager() { | ||
throw new IllegalStateException("Utility class DirManager should not be instantiated"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.