Package org.mapfish.print
Class FileUtils
java.lang.Object
org.mapfish.print.FileUtils
Methods for interacting with files. Such things and verifying the files are in the correct
directory, Converting URLs to file objects.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertFileIsInConfigDir
(Configuration configuration, File file) Verify that the file is within the configuration directory.static boolean
assertIsSubDirectory
(String descriptorOfBase, File child, File... baseFiles) Verify that the file is within the base directory.static URL
testForLegalFileUrl
(Configuration configuration, URL url) Check if the url is a file url which is either relative to the configuration directory or refers to a file in the configuration directory.
-
Method Details
-
testForLegalFileUrl
Check if the url is a file url which is either relative to the configuration directory or refers to a file in the configuration directory.The correct file url is returned or the original if not a file url. If an illegal file url (one that does not refer to a file within the configuration directory or is relative to the configuration directory) then an exception is thrown.
- Parameters:
url
- the url to testconfiguration
- the configuration to test relativity.
-
assertFileIsInConfigDir
Verify that the file is within the configuration directory.- Parameters:
configuration
- the configuration to test relativity.file
- the file to test
-
assertIsSubDirectory
Verify that the file is within the base directory.IllegalFileAccessException
will be thrown if the assertion does not hold.- Parameters:
descriptorOfBase
- a simple description of the base file, for example: configurationchild
- the file to test that is is a child of base.baseFiles
- the directories that can legally contain the child.
-