Class Configuration

java.lang.Object
org.mapfish.print.config.Configuration
All Implemented Interfaces:
ConfigurationObject

public class Configuration extends Object implements ConfigurationObject
The Main Configuration Bean.
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • setPdfConfig

      public final void setPdfConfig(PDFConfig pdfConfig)
      Configure various properties related to the reports generated as PDFs.
      Parameters:
      pdfConfig - the pdf configuration
    • init

      @PostConstruct public final void init()
      Initialize some optionally wired fields.
    • renderAsSvg

      public final boolean renderAsSvg(Boolean renderAsSvg)
      Either use the provided value (renderAsSvg) or if it is null then use defaultToSvg.
      Parameters:
      renderAsSvg - the value to use if non-null.
    • setDefaultToSvg

      public final void setDefaultToSvg(boolean defaultToSvg)
      If true then all vector layers (and other parts of the system that can be either SVG or Bitmap, like scalebar) will be rendered as SVG (unless layer specifically indicates useSvg as false).

      The default is false.

      Parameters:
      defaultToSvg - whether or not to create svg layers by default
    • getCertificateStore

      @Nullable public final CertificateStore getCertificateStore()
      The configuration for locating a custom certificate store.
    • setCertificateStore

      public final void setCertificateStore(CertificateStore certificateStore)
      The configuration for locating a custom certificate store. This is only required if the default certificate store which ships with all java installations does not contain the certificates needed by this server. Usually it is to accept a self-signed certificate, for example on a test server.
      Parameters:
      certificateStore - The configuration for locating a custom certificate store
    • getCredentials

      public final List<HttpCredential> getCredentials()
      Get the http credentials. Should also getProxies since HttpProxy is a subclass of HttpCredential.
    • setCredentials

      public final void setCredentials(List<HttpCredential> credentials)
      Http credentials to be used when making http requests.

      If a proxy needs credentials you don't need to configure it here because the proxy configuration object also has options for declaring the credentials.

      Parameters:
      credentials - the credentials
    • getProxies

      public final List<HttpProxy> getProxies()
      Get the http proxies used by in all requests in this system.
      See Also:
    • setProxies

      public final void setProxies(List<HttpProxy> proxies)
      Configuration for proxying http requests. Each proxy can be configured with authentication and with the uris that they apply to.

      See HttpProxy for details on how to configure them.

      Parameters:
      proxies - the proxy configuration objects
    • printClientConfig

      public final void printClientConfig(org.json.JSONWriter json) throws org.json.JSONException
      Print out the configuration that the client needs to make a request.
      Parameters:
      json - the output writer.
      Throws:
      org.json.JSONException
    • getOutputFilename

      public final String getOutputFilename()
    • setOutputFilename

      public final void setOutputFilename(String outputFilename)
      The default output file name of the report. This can be overridden by Template.setOutputFilename(String) and the outputFilename parameter in the request JSON.

      This can be a string and can also have a date section in the string that will be filled when the report is created for example a section with ${<dateFormatString>} will be replaced with the current date formatted in the way defined by the <dateFormatString> string. The format rules are the rules in java.text.SimpleDateFormat (do a google search if the link above is broken).

      Example: outputFilename: print-${dd-MM-yyyy} should output: print-22-11-2014.pdf

      Note: the suffix will be appended to the end of the name.

      Parameters:
      outputFilename - default output file name of the report.
    • getTemplates

      public final Map<String,Template> getTemplates()
    • setTemplates

      public final void setTemplates(Map<String,Template> templates)
      Set the configuration of the named template.
      Parameters:
      templates - the templates;
    • getTemplate

      public final Template getTemplate(String name)
      Retrieve the configuration of the named template.
      Parameters:
      name - the template name;
    • getDirectory

      public final File getDirectory()
    • setConfigurationFile

      public final void setConfigurationFile(File configurationFile)
      Sets the configuration file.
    • setStyles

      public final void setStyles(Map<String,String> styles)
      Set the named styles defined in the configuration for this.
      Parameters:
      styles - the style definition. StyleParser plugins will be used to load the style.
    • getStyle

      public final Optional<? extends org.geotools.api.style.Style> getStyle(String styleName)
      Return the named style of Optional.absent() if there is not a style with the given name.
      Parameters:
      styleName - the name of the style to look up
    • getDefaultStyle

      @Nonnull public final org.geotools.api.style.Style getDefaultStyle(@Nonnull String geometryType)
      Get a default style. If null a simple black line style will be returned.
      Parameters:
      geometryType - the name of the geometry type (point, line, polygon)
    • setDefaultStyle

      public final void setDefaultStyle(Map<String,org.geotools.api.style.Style> defaultStyle)
      Set the default styles. the case of the keys are not important. The retrieval will be case insensitive.
      Parameters:
      defaultStyle - the mapping from geometry type name (point, polygon, etc...) to the style to use for that type.
    • isThrowErrorOnExtraParameters

      public final boolean isThrowErrorOnExtraParameters()
      If true and the request JSON has extra parameters in the layers definition, exceptions will be thrown. Otherwise the information will be logged.
    • setThrowErrorOnExtraParameters

      public final void setThrowErrorOnExtraParameters(boolean throwErrorOnExtraParameters)
      If true and the request JSON has extra parameters in the layers definition, exceptions will be thrown. Otherwise the information will be logged.
      Parameters:
      throwErrorOnExtraParameters - the value
    • validate

      public void validate(List<Throwable> validationErrors, Configuration configuration)
      Description copied from interface: ConfigurationObject
      validate that the configuration was correct.
      Specified by:
      validate in interface ConfigurationObject
      Parameters:
      validationErrors - a list to add any detected errors to.
      configuration - the containing configuration
    • validate

      public final List<Throwable> validate()
      Validate that the configuration is valid.
      Returns:
      any validation errors.
    • isAccessible

      public final boolean isAccessible(String pathToSubResource) throws IOException
      check if the file exists and can be accessed by the user/template/config/etc...
      Parameters:
      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(String pathToSubResource) throws IOException
      Load the file related to the configuration file.
      Parameters:
      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
    • getFile

      public final Optional<File> getFile(String pathToSubResource) throws IOException
      Get the file related to the configuration file.
      Throws:
      IOException
    • setFileLoaderManager

      public final void setFileLoaderManager(ConfigFileLoaderManager fileLoaderManager)
      Set file loader manager.
      Parameters:
      fileLoaderManager - new manager.
    • setJdbcDrivers

      public final void setJdbcDrivers(Set<String> jdbcDrivers)
      Set the JDBC drivers that are required to connect to the databases in the configuration. JDBC drivers are needed (for example) when database sources are used in templates. For example if in one of the template you have:
      
           jdbcUrl: "jdbc:postgresql://localhost:5432/morges_dpfe"
       

      then you need to add:

      
           jdbcDrivers: [org.postgresql.Driver]
       
       

      or

      
           jdbcDrivers:
             - org.postgresql.Driver
       
      Parameters:
      jdbcDrivers - the set of JDBC drivers to load before performing a print (this ensures they are registered with the JVM)
    • setAccess

      public final void setAccess(List<String> access)
      The roles required to access this configuration/app. If empty or not set then it is a public app. If there are many roles then a user must have one of the roles in order to access the configuration/app.

      The security (how authentication/authorization is done) is configured in the /WEB-INF/classes/mapfish-spring-security.xml

      Any user without the required role will get an error when trying to access any of the templates and no templates will be listed in the capabilities requests.

      Parameters:
      access - the roles needed to access this
    • getAccessAssertion

      public final AccessAssertion getAccessAssertion()
    • getTransparentTileErrorColor

      public final String getTransparentTileErrorColor()
      Get the color used to draw the WMS tiles error default: transparent pink.
    • setTransparentTileErrorColor

      public final void setTransparentTileErrorColor(String transparentTileErrorColor)
      Color used for tiles in error on transparent layers.
      Parameters:
      transparentTileErrorColor - The color
    • getOpaqueTileErrorColor

      public final String getOpaqueTileErrorColor()
      Get the color used to draw the other tiles error default: pink.
    • setOpaqueTileErrorColor

      public final void setOpaqueTileErrorColor(String opaqueTileErrorColor)
      Color used for tiles in error on opaque layers.
      Parameters:
      opaqueTileErrorColor - The color
    • getResourceBundle

      public final String getResourceBundle()
      Get the resource bundle name.
    • setResourceBundle

      public final void setResourceBundle(String resourceBundle)
      Set the resource bundle name.
      Parameters:
      resourceBundle - the resource bundle name
    • getAllowedReferersImpl

      public final UriMatchers getAllowedReferersImpl()
      Returns:
      the list of referrer checks (null = no check)
    • setAllowedReferers

      public final void setAllowedReferers(@Nullable List<? extends URIMatcher> matchers)
      The matchers used to authorize the incoming requests in function of the referrer. For example:
      
       allowedReferers:
         - !hostnameMatch
           host: example.com
           allowSubDomains: true
       

      By default, the referrer is not checked

      Parameters:
      matchers - the list of matcher to use to check if a referrer is permitted or null for no check
      See Also:
    • getSmtp

      public SmtpConfig getSmtp()
    • setSmtp

      public void setSmtp(SmtpConfig smtp)
      Sets the smtp config.