Interface ConfigFileLoaderPlugin
-
- All Known Implementing Classes:
AbstractFileConfigFileLoader
,ClasspathConfigFileLoader
,ConfigFileLoaderManager
,FileConfigFileLoader
,ServletConfigFileLoader
public interface ConfigFileLoaderPlugin
Strategy for loading configuration files and files that are used in printing that are relative (or related) to the configuration file. For example, if a file is loaded from the file system as requested by a client, (IE the file path was obtained by the client) then there must be restrictions placed on which files the client may load (you can't allow him to load the full database or a passwords file for example). The simple way is to ensure the file is within the same or sub-directory of the config file directory.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getUriScheme()
Returns the URI scheme that this loader supports.boolean
isAccessible(java.net.URI fileURI)
Check if the configuration File exists.boolean
isAccessible(java.net.URI configFileUri, java.lang.String pathToSubResource)
check if the file exists and can be accessed by the user/template/config/etc...java.util.Optional<java.lang.Long>
lastModified(java.net.URI fileURI)
return the last modified time of the file URI.byte[]
loadFile(java.net.URI fileURI)
Load the config data.byte[]
loadFile(java.net.URI configFileUri, java.lang.String pathToSubResource)
Load the file related to the configuration file.java.util.Optional<java.io.File>
toFile(java.net.URI fileUri)
Return the file object the uri refers to if it refers to a file.java.util.Optional<java.io.File>
toFile(java.net.URI configFileUri, java.lang.String pathToSubResource)
Return the file object the uri refers to if it refers to a file.
-
-
-
Method Detail
-
toFile
java.util.Optional<java.io.File> toFile(java.net.URI fileUri)
Return the file object the uri refers to if it refers to a file. Otherwise Optional.absent().- Parameters:
fileUri
- the uri to use to resolve to a file (or not).
-
toFile
java.util.Optional<java.io.File> toFile(java.net.URI configFileUri, java.lang.String pathToSubResource) throws java.io.IOException
Return the file object the uri refers to if it refers to a file. Otherwise Optional.absent().- Parameters:
configFileUri
- the uri of the configuration filepathToSubResource
- a string representing a file that is accessible for use in printing templates within the configuration file. In the case of a file based URI the path could be a relative path (relative to the configuration file) or an absolute path, but it must be an allowed file (you can't allow access to any file on the file system).- Throws:
java.io.IOException
-
getUriScheme
java.lang.String getUriScheme()
Returns the URI scheme that this loader supports.
-
lastModified
java.util.Optional<java.lang.Long> lastModified(java.net.URI fileURI)
return the last modified time of the file URI.- Parameters:
fileURI
- the uri of the config file to load.- Returns:
- return the last modified date of the file
-
isAccessible
boolean isAccessible(java.net.URI fileURI)
Check if the configuration File exists.- Parameters:
fileURI
- the uri of the file to load.
-
loadFile
byte[] loadFile(java.net.URI fileURI) throws java.io.IOException
Load the config data.- Parameters:
fileURI
- the uri of the config file to load.- Returns:
- the file that make up the file.
- Throws:
java.io.IOException
-
isAccessible
boolean isAccessible(java.net.URI configFileUri, java.lang.String pathToSubResource) throws java.io.IOException
check if the file exists and can be accessed by the user/template/config/etc...- Parameters:
configFileUri
- the uri of the configuration filepathToSubResource
- a string representing a file that is accessible for use in printing templates within the configuration file. In the case of a file based URI the path could be a relative path (relative to the configuration file) or an absolute path, but it must be an allowed file (you can't allow access to any file on the file system).- Throws:
java.io.IOException
-
loadFile
byte[] loadFile(java.net.URI configFileUri, java.lang.String pathToSubResource) throws java.io.IOException
Load the file related to the configuration file.- Parameters:
configFileUri
- the uri of the configuration filepathToSubResource
- a string representing a file that is accessible for use in printing templates within the configuration file. In the case of a file based URI the path could be a relative path (relative to the configuration file) or an absolute path, but it must be an allowed file (you can't allow access to any file on the file system).- Throws:
java.io.IOException
-
-