Class Configuration

    • Constructor Summary

      Constructors 
      Constructor Description
      Configuration()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AccessAssertion getAccessAssertion()  
      UriMatchers getAllowedReferersImpl()  
      CertificateStore getCertificateStore()
      The configuration for locating a custom certificate store.
      java.util.List<HttpCredential> getCredentials()
      Get the http credentials.
      org.geotools.api.style.Style getDefaultStyle​(java.lang.String geometryType)
      Get a default style.
      java.io.File getDirectory()  
      java.util.Optional<java.io.File> getFile​(java.lang.String pathToSubResource)
      Get the file related to the configuration file.
      java.lang.String getOpaqueTileErrorColor()
      Get the color used to draw the other tiles error default: pink.
      java.lang.String getOutputFilename()  
      java.util.List<HttpProxy> getProxies()
      Get the http proxies used by in all requests in this system.
      java.lang.String getResourceBundle()
      Get the resource bundle name.
      SmtpConfig getSmtp()  
      java.util.Optional<? extends org.geotools.api.style.Style> getStyle​(java.lang.String styleName)
      Return the named style of Optional.absent() if there is not a style with the given name.
      Template getTemplate​(java.lang.String name)
      Retrieve the configuration of the named template.
      java.util.Map<java.lang.String,​Template> getTemplates()  
      java.lang.String getTransparentTileErrorColor()
      Get the color used to draw the WMS tiles error default: transparent pink.
      void init()
      Initialize some optionally wired fields.
      boolean isAccessible​(java.lang.String pathToSubResource)
      check if the file exists and can be accessed by the user/template/config/etc...
      boolean isThrowErrorOnExtraParameters()
      If true and the request JSON has extra parameters in the layers definition, exceptions will be thrown.
      byte[] loadFile​(java.lang.String pathToSubResource)
      Load the file related to the configuration file.
      void printClientConfig​(org.json.JSONWriter json)
      Print out the configuration that the client needs to make a request.
      boolean renderAsSvg​(java.lang.Boolean renderAsSvg)
      Either use the provided value (renderAsSvg) or if it is null then use defaultToSvg.
      void setAccess​(java.util.List<java.lang.String> access)
      The roles required to access this configuration/app.
      void setAllowedReferers​(java.util.List<? extends URIMatcher> matchers)
      The matchers used to authorize the incoming requests in function of the referrer.
      void setCertificateStore​(CertificateStore certificateStore)
      The configuration for locating a custom certificate store.
      void setConfigurationFile​(java.io.File configurationFile)  
      void setCredentials​(java.util.List<HttpCredential> credentials)
      Http credentials to be used when making http requests.
      void setDefaultStyle​(java.util.Map<java.lang.String,​org.geotools.api.style.Style> defaultStyle)
      Set the default styles.
      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).
      void setFileLoaderManager​(ConfigFileLoaderManager fileLoaderManager)
      Set file loader manager.
      void setJdbcDrivers​(java.util.Set<java.lang.String> jdbcDrivers)
      Set the JDBC drivers that are required to connect to the databases in the configuration.
      void setOpaqueTileErrorColor​(java.lang.String opaqueTileErrorColor)
      Color used for tiles in error on opaque layers.
      void setOutputFilename​(java.lang.String outputFilename)
      The default output file name of the report.
      void setPdfConfig​(PDFConfig pdfConfig)
      Configure various properties related to the reports generated as PDFs.
      void setProxies​(java.util.List<HttpProxy> proxies)
      Configuration for proxying http requests.
      void setResourceBundle​(java.lang.String resourceBundle)
      Set the resource bundle name.
      void setSmtp​(SmtpConfig smtp)  
      void setStyles​(java.util.Map<java.lang.String,​java.lang.String> styles)
      Set the named styles defined in the configuration for this.
      void setTemplates​(java.util.Map<java.lang.String,​Template> templates)
      Set the configuration of the named template.
      void setThrowErrorOnExtraParameters​(boolean throwErrorOnExtraParameters)
      If true and the request JSON has extra parameters in the layers definition, exceptions will be thrown.
      void setTransparentTileErrorColor​(java.lang.String transparentTileErrorColor)
      Color used for tiles in error on transparent layers.
      java.util.List<java.lang.Throwable> validate()
      Validate that the configuration is valid.
      void validate​(java.util.List<java.lang.Throwable> validationErrors, Configuration configuration)
      validate that the configuration was correct.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Configuration

        public Configuration()
    • Method Detail

      • 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​(java.lang.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
      • setCredentials

        public final void setCredentials​(java.util.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
      • setProxies

        public final void setProxies​(java.util.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 java.lang.String getOutputFilename()
      • setOutputFilename

        public final void setOutputFilename​(java.lang.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 java.util.Map<java.lang.String,​Template> getTemplates()
      • setTemplates

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

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

        public final java.io.File getDirectory()
      • setConfigurationFile

        public final void setConfigurationFile​(java.io.File configurationFile)
      • setStyles

        public final void setStyles​(java.util.Map<java.lang.String,​java.lang.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 java.util.Optional<? extends org.geotools.api.style.Style> getStyle​(java.lang.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
                                                                  java.lang.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​(java.util.Map<java.lang.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​(java.util.List<java.lang.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 java.util.List<java.lang.Throwable> validate()
        Validate that the configuration is valid.
        Returns:
        any validation errors.
      • isAccessible

        public final boolean isAccessible​(java.lang.String pathToSubResource)
                                   throws java.io.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:
        java.io.IOException
      • loadFile

        public final byte[] loadFile​(java.lang.String pathToSubResource)
                              throws java.io.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:
        java.io.IOException
      • getFile

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

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

        public final void setJdbcDrivers​(java.util.Set<java.lang.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​(java.util.List<java.lang.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
      • getTransparentTileErrorColor

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

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

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

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

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

        public final void setResourceBundle​(java.lang.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
                                             java.util.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:
        URIMatcher
      • setSmtp

        public void setSmtp​(SmtpConfig smtp)