Class FileUtils

java.lang.Object
org.mapfish.print.FileUtils

public final class FileUtils extends Object
Methods for interacting with files. Such things and verifying the files are in the correct directory, Converting URLs to file objects.
  • Method Details

    • testForLegalFileUrl

      public 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.

      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 test
      configuration - the configuration to test relativity.
    • assertFileIsInConfigDir

      public static void assertFileIsInConfigDir(Configuration configuration, File file)
      Verify that the file is within the configuration directory.
      Parameters:
      configuration - the configuration to test relativity.
      file - the file to test
    • assertIsSubDirectory

      public static boolean assertIsSubDirectory(String descriptorOfBase, File child, File... baseFiles)
      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: configuration
      child - the file to test that is is a child of base.
      baseFiles - the directories that can legally contain the child.