Class AbstractFileConfigFileLoader

java.lang.Object
org.mapfish.print.servlet.fileloader.AbstractFileConfigFileLoader
All Implemented Interfaces:
ConfigFileLoaderPlugin
Direct Known Subclasses:
FileConfigFileLoader, ServletConfigFileLoader

public abstract class AbstractFileConfigFileLoader extends Object implements ConfigFileLoaderPlugin
Abstract implementation for files that are on the local file system.
  • Constructor Details

    • AbstractFileConfigFileLoader

      public AbstractFileConfigFileLoader()
  • Method Details

    • platformIndependentUriToFile

      protected static File platformIndependentUriToFile(URI fileURI)
      Convert a url to a file object. No checks are made to see if file exists but there are some hacks that are needed to convert uris to files across platforms.
      Parameters:
      fileURI - the uri to convert
    • resolveFiles

      protected abstract Iterator<File> resolveFiles(URI fileURI)
      Load the files referenced by the id (in the case of a classpath uri it could references several files, although normally it will only reference one).
      Parameters:
      fileURI - the uri identifying the config file.
    • toFile

      public final Optional<File> toFile(URI fileUri)
      Description copied from interface: ConfigFileLoaderPlugin
      Return the file object the uri refers to if it refers to a file. Otherwise Optional.absent().
      Specified by:
      toFile in interface ConfigFileLoaderPlugin
      Parameters:
      fileUri - the uri to use to resolve to a file (or not).
    • lastModified

      public final Optional<Long> lastModified(URI fileURI)
      Description copied from interface: ConfigFileLoaderPlugin
      return the last modified time of the file URI.
      Specified by:
      lastModified in interface ConfigFileLoaderPlugin
      Parameters:
      fileURI - the uri of the config file to load.
      Returns:
      return the last modified date of the file
    • isAccessible

      public final boolean isAccessible(URI fileURI)
      Description copied from interface: ConfigFileLoaderPlugin
      Check if the configuration File exists.
      Specified by:
      isAccessible in interface ConfigFileLoaderPlugin
      Parameters:
      fileURI - the uri of the file to load.
    • loadFile

      public final byte[] loadFile(URI fileURI) throws IOException
      Description copied from interface: ConfigFileLoaderPlugin
      Load the config data.
      Specified by:
      loadFile in interface ConfigFileLoaderPlugin
      Parameters:
      fileURI - the uri of the config file to load.
      Returns:
      the file that make up the file.
      Throws:
      IOException
    • isAccessible

      public final boolean isAccessible(URI configFileUri, String pathToSubResource) throws IOException
      Description copied from interface: ConfigFileLoaderPlugin
      check if the file exists and can be accessed by the user/template/config/etc...
      Specified by:
      isAccessible in interface ConfigFileLoaderPlugin
      Parameters:
      configFileUri - the uri of the configuration file
      pathToSubResource - 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:
      IOException
    • loadFile

      public final byte[] loadFile(URI configFileUri, String pathToSubResource) throws IOException
      Description copied from interface: ConfigFileLoaderPlugin
      Load the file related to the configuration file.
      Specified by:
      loadFile in interface ConfigFileLoaderPlugin
      Parameters:
      configFileUri - the uri of the configuration file
      pathToSubResource - 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:
      IOException
    • toFile

      public Optional<File> toFile(URI configFileUri, String pathToSubResource)
      Description copied from interface: ConfigFileLoaderPlugin
      Return the file object the uri refers to if it refers to a file. Otherwise Optional.absent().
      Specified by:
      toFile in interface ConfigFileLoaderPlugin
      Parameters:
      configFileUri - the uri of the configuration file
      pathToSubResource - 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).