Package fr.gouv.vitam.common
Class PropertiesUtils
java.lang.Object
fr.gouv.vitam.common.PropertiesUtils
Property Utility class
NOTE for developers: Do not add LOGGER there
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
fileFromConfigFolder
(String subpath) Return a full file path using Config folder as root and subpath as sub paths.static File
fileFromDataFolder
(String subpath) Return a full file path using Data folder as root and subpath as sub paths.static File
fileFromTmpFolder
(String subpath) Return a full file path using Tmp folder as root and subpath as sub paths.static File
Get the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as Resources filestatic InputStream
getConfigAsStream
(String resourcesFile) Get the InputStream representation from the local path to the Resources directorystatic File
getConfigFile
(String resourcesFile) Get the InputStream representation from the local path to the Resources directorystatic InputStream
getResourceAsStream
(String resourcesFile) Get the InputStream representation from the Resources directorystatic String
getResourceAsString
(String resourcesFile) Get the String content from the Resources directorystatic File
getResourceFile
(String resourcesFile) Get the File representation from the local path to the Resources directorygetResourceListing
(Class clazz, String path) static Path
getResourcePath
(String resourcesFile) Get the Path representation from the local path to the Resources directorystatic Properties
readProperties
(File propertiesFile) Read a properties file and returns the associated Propertiesstatic <C> C
Read the Yaml file and return the object readstatic <C> C
Read the Yaml file and return the object readstatic <C> C
readYaml
(InputStream yamlInputStream, Class<C> clasz) Read the Yaml InputStream and return the object readstatic <C> C
Read the Yaml file and return the object readstatic void
Write the Yaml file
-
Method Details
-
getConfigAsStream
Get the InputStream representation from the local path to the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException
- if the resource file not found
-
getConfigFile
Get the InputStream representation from the local path to the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException
- if the resource file not found
-
getResourceAsStream
Get the InputStream representation from the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException
- if the resource file not found
-
getResourceFile
Get the File representation from the local path to the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException
- if the resource file not found
-
getResourcePath
Get the Path representation from the local path to the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated Path
- Throws:
FileNotFoundException
- if resource file not found
-
getResourceListing
public static Stream<String> getResourceListing(Class clazz, String path) throws URISyntaxException, IOException - Throws:
URISyntaxException
IOException
-
findFile
Get the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as Resources file- Parameters:
filename
- the file name- Returns:
- the File if found
- Throws:
FileNotFoundException
- if not fount
-
fileFromConfigFolder
Return a full file path using Config folder as root and subpath as sub paths.- Parameters:
subpath
- the subpath under Config folder- Returns:
- the full file path (no check on existing is done)
-
fileFromDataFolder
Return a full file path using Data folder as root and subpath as sub paths.- Parameters:
subpath
- the subpath under Data folder- Returns:
- the full file path (no check on existing is done)
-
fileFromTmpFolder
Return a full file path using Tmp folder as root and subpath as sub paths.- Parameters:
subpath
- the subpath under Tmp folder- Returns:
- the full file path (no check on existing is done)
-
readProperties
Read a properties file and returns the associated Properties- Parameters:
propertiesFile
- properties file- Returns:
- the associated Properties
- Throws:
IOException
- if cannot load file
-
readYaml
Read the Yaml file and return the object read- Parameters:
yamlFile
- the yaml file to readclasz
- the class representing the target object- Returns:
- the object read
- Throws:
IOException
- if read yaml input stream to class template exception occurred
-
readYaml
public static <C> C readYaml(File yamlFile, com.fasterxml.jackson.core.type.TypeReference<C> typeReference) throws IOException Read the Yaml file and return the object read- Parameters:
yamlFile
- the yaml filetypeReference
- the type reference representing the target interface object- Returns:
- the object read
- Throws:
IOException
- if read yaml input stream to class template exception occurred
-
readYaml
Read the Yaml InputStream and return the object read- Parameters:
yamlInputStream
- the yaml input stream to readclasz
- the class representing the target object- Returns:
- the object read
- Throws:
IOException
- if read yaml input stream to class template exception occurred
-
readYaml
Read the Yaml file and return the object read- Parameters:
yamlPath
- yaml file pathclasz
- the class representing the target object- Returns:
- the object read
- Throws:
IOException
- if file not found exception
-
writeYaml
Write the Yaml file- Parameters:
destination
- the destination fileconfig
- the configuration object to write using Yaml format- Throws:
IOException
- if write object config exception occurred
-
getResourceAsString
Get the String content from the Resources directory- Parameters:
resourcesFile
- properties file from resources directory- Returns:
- the associated File content as a String
- Throws:
FileNotFoundException
- if the resource file not found
-