Class Configuration
- All Implemented Interfaces:
ConfigurationObject
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AccessAssertionfinal UriMatchersfinal CertificateStoreThe configuration for locating a custom certificate store.final List<HttpCredential> Get the http credentials.final org.geotools.api.style.StylegetDefaultStyle(String geometryType) Get a default style.final FileGet the file related to the configuration file.final StringGet the color used to draw the other tiles error default: pink.final StringGet the http proxies used by in all requests in this system.final StringGet the resource bundle name.getSmtp()final Optional<? extends org.geotools.api.style.Style> Return the named style of Optional.absent() if there is not a style with the given name.final TemplategetTemplate(String name) Retrieve the configuration of the named template.final StringGet the color used to draw the WMS tiles error default: transparent pink.final voidinit()Initialize some optionally wired fields.final booleanisAccessible(String pathToSubResource) check if the file exists and can be accessed by the user/template/config/etc...booleanGet the forceFailOnError parameter value.final booleanIf true and the request JSON has extra parameters in the layers definition, exceptions will be thrown.final byte[]Load the file related to the configuration file.final voidprintClientConfig(org.json.JSONWriter json) Print out the configuration that the client needs to make a request.final booleanrenderAsSvg(Boolean renderAsSvg) Either use the provided value (renderAsSvg) or if it is null then usedefaultToSvg.final voidThe roles required to access this configuration/app.final voidsetAllowedReferers(List<? extends URIMatcher> matchers) The matchers used to authorize the incoming requests in function of the referrer.final voidsetCertificateStore(CertificateStore certificateStore) The configuration for locating a custom certificate store.final voidsetConfigurationFile(File configurationFile) Sets the configuration file.final voidsetCredentials(List<HttpCredential> credentials) Http credentials to be used when making http requests.final voidsetDefaultStyle(Map<String, org.geotools.api.style.Style> defaultStyle) Set the default styles.final voidsetDefaultToSvg(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).final voidsetFileLoaderManager(ConfigFileLoaderManager fileLoaderManager) Set file loader manager.voidsetForceFailOnError(boolean forceFailOnError) Set the param forceFailOnError.final voidsetJdbcDrivers(Set<String> jdbcDrivers) Set the JDBC drivers that are required to connect to the databases in the configuration.final voidsetOpaqueTileErrorColor(String opaqueTileErrorColor) Color used for tiles in error on opaque layers.final voidsetOutputFilename(String outputFilename) The default output file name of the report.final voidsetPdfConfig(PDFConfig pdfConfig) Configure various properties related to the reports generated as PDFs.final voidsetProxies(List<HttpProxy> proxies) Configuration for proxying http requests.final voidsetResourceBundle(String resourceBundle) Set the resource bundle name.voidsetSmtp(SmtpConfig smtp) Sets the smtp config.final voidSet the named styles defined in the configuration for this.final voidsetTemplates(Map<String, Template> templates) Set the configuration of the named template.final voidsetThrowErrorOnExtraParameters(boolean throwErrorOnExtraParameters) If true and the request JSON has extra parameters in the layers definition, exceptions will be thrown.final voidsetTransparentTileErrorColor(String transparentTileErrorColor) Color used for tiles in error on transparent layers.validate()Validate that the configuration is valid.voidvalidate(List<Throwable> validationErrors, Configuration configuration) validate that the configuration was correct.
-
Constructor Details
-
Configuration
public Configuration()
-
-
Method Details
-
setPdfConfig
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
Either use the provided value (renderAsSvg) or if it is null then usedefaultToSvg.- 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
The configuration for locating a custom certificate store. -
setCertificateStore
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
Get the http credentials. Should also getProxies sinceHttpProxyis a subclass ofHttpCredential. -
setCredentials
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
Get the http proxies used by in all requests in this system.- See Also:
-
setProxies
Configuration for proxying http requests. Each proxy can be configured with authentication and with the uris that they apply to.See
HttpProxyfor 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
-
setOutputFilename
The default output file name of the report. This can be overridden byTemplate.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.pdfNote: the suffix will be appended to the end of the name.
- Parameters:
outputFilename- default output file name of the report.
-
getTemplates
-
setTemplates
Set the configuration of the named template.- Parameters:
templates- the templates;
-
getTemplate
Retrieve the configuration of the named template.- Parameters:
name- the template name;
-
getDirectory
-
setConfigurationFile
Sets the configuration file. -
setStyles
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
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
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
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
Description copied from interface:ConfigurationObjectvalidate that the configuration was correct.- Specified by:
validatein interfaceConfigurationObject- Parameters:
validationErrors- a list to add any detected errors to.configuration- the containing configuration
-
validate
Validate that the configuration is valid.- Returns:
- any validation errors.
-
isAccessible
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
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
Get the file related to the configuration file.- Throws:
IOException
-
setFileLoaderManager
Set file loader manager.- Parameters:
fileLoaderManager- new manager.
-
setJdbcDrivers
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
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
-
getTransparentTileErrorColor
Get the color used to draw the WMS tiles error default: transparent pink. -
setTransparentTileErrorColor
Color used for tiles in error on transparent layers.- Parameters:
transparentTileErrorColor- The color
-
getOpaqueTileErrorColor
Get the color used to draw the other tiles error default: pink. -
setOpaqueTileErrorColor
Color used for tiles in error on opaque layers.- Parameters:
opaqueTileErrorColor- The color
-
getResourceBundle
Get the resource bundle name. -
setResourceBundle
Set the resource bundle name.- Parameters:
resourceBundle- the resource bundle name
-
getAllowedReferersImpl
- Returns:
- the list of referrer checks (null = no check)
-
setAllowedReferers
The matchers used to authorize the incoming requests in function of the referrer. For example:allowedReferers: - !hostnameMatch host: example.com allowSubDomains: trueBy 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
-
setSmtp
Sets the smtp config. -
isForceFailOnError
public boolean isForceFailOnError()Get the forceFailOnError parameter value. -
setForceFailOnError
public void setForceFailOnError(boolean forceFailOnError) Set the param forceFailOnError.- Parameters:
forceFailOnError- if true all the rendered layers will have the parameterAbstractLayerParams.failOnErrorset to true.
-