com.supermap.services.wms.request

Class WMSParameterValidator

  • java.lang.Object
    • com.supermap.services.wms.request.WMSParameterValidator
  • Direct Known Subclasses:
    MapParameterValidator111, MapParameterValidator130


    public abstract class WMSParameterValidator
    extends java.lang.Object
    

    The parameter verifier of the WMS GetMap and GetFeatureInfo operations.

    The class constructs the required parameter name and regular expression according to the WMSCapabilities object, then generates the ParameterValidator object, then uses the object for basic parameter verification.

    This class is an abstract class, only the verification expresson of the general parameters of the GetMap operation of the WMS 1.1.1 and WMS 1.3.0 version is constructed, the following parameters are not constructed for regular expression:

  • EXCEPTIONS, the default values of WMS 1.1.1 and WMS 1.3.0 are different.
  • CRS, the coordinate system parameters of WMS 1.3.0.
  • SRS, the coordinate system parameters of WMS 1.1.1.
    • Constructor Summary

      Constructors 
      Constructor and Description
      WMSParameterValidator(WMSCapabilities capabilities)
      Construct a WMSParameterValidator object according to WMS meta data information.
      WMSParameterValidator(WMSCapabilities capabilities, java.lang.String defaultBgColor)
      Construct a WMSParameterValidator object according to WMS meta data information.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected java.util.regex.Pattern createBBOXPattern()
      Create the regular expression to verify BBOX parameter.
      protected java.util.regex.Pattern createBooleanPattern()
      Create a regular expression that verifies a Boolean string (true or false).
      protected java.util.regex.Pattern createColorPattern()
      Create the regular expression for verifying color string.
      protected java.util.regex.Pattern createElevationPattern()
      Create the regular expression to verify ELEVATION parameter.
      protected java.util.regex.Pattern createLayerPattern(java.util.List<WMSLayer> layers)
      Create the regular expression to verify LAYERS parameter.
      protected OGCParameterException createOGCException(ValidateResult validateResult, java.lang.String format)
      According to the verified result and exception format of the WMS request parameter, create the OGCParameterException exception object.
      protected java.util.regex.Pattern createPositiveIntegerPattern()
      Create the regular expression to verify positive integer.
      protected java.util.regex.Pattern createStringArrayPattern(java.lang.String[] strArray, int flags)
      Create a regular expression for verifying the string array.
      protected java.util.regex.Pattern createStylesPattern()
      Create the regular expression to verify STYLES parameter.
      protected java.util.regex.Pattern createTimePattern()
      Create the regular expression to verify TIME parameter.
      protected abstract java.util.Map<java.lang.String,java.util.regex.Pattern> initDefinePattern()
      Create a regular expression for verifying the parameters of an operation definition.
      protected java.util.Map<java.lang.String,OptionalParameter> initOptionalPattern()
      Create the description information of optional parameters.
      protected java.util.Map<java.lang.String,java.util.regex.Pattern> initRequiredPattern()
      Create a regular expression for verifying the necessary parameters.
      protected java.lang.String[] splitString(java.lang.String strToSplit, java.lang.String splitReg)
      Match the separator string with the specified regular expression.
      void validate(java.util.Map<java.lang.String,java.lang.String> paramMap)
      Verify the parameter in keyword-value format of the WMS request.
      protected void validateBBOX(java.lang.String bbox, java.lang.String exceptionFormat)
      Verify BBOX parameter.
      protected java.lang.String validateFormat(java.lang.String format)
      Verify whether the image format represented by the FORMAT parameter in the WMS GetMap request is supported.
      protected void validateStyles(java.lang.String styles, java.lang.String layerNames, java.lang.String format)
      Verify STYLES parameter.
      • Methods inherited from class java.lang.Object

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

      • MSG_KEY_INVALIDBBOX

        protected static final java.lang.String MSG_KEY_INVALIDBBOX
        

        Invalid BBOX keyword.

        The default value is “WMS.ValidateParameter.InvalidBBOX”.

      • EXCEPTION_CODE_INVALIDBBOX

        protected static final java.lang.String EXCEPTION_CODE_INVALIDBBOX
        

        Invalid BBOX exception code.

        The default value is “InvalidBBOX”.

      • capabilities

        protected WMSCapabilities capabilities
        

        WMS meta information.

      • resource

        protected ResourceManager resource
        

        Resource manager.

      • validator

        protected ParameterValidator validator
        

        Parameter verifier based on regular expression.

    • Constructor Detail

      • WMSParameterValidator

        public WMSParameterValidator(WMSCapabilities capabilities)
        

        Construct a WMSParameterValidator object according to WMS meta data information.

        Parameters:
        capabilities - WMS meta information.
      • WMSParameterValidator

        public WMSParameterValidator(WMSCapabilities capabilities,
                             java.lang.String defaultBgColor)
        

        Construct a WMSParameterValidator object according to WMS meta data information.

        Parameters:
        capabilities - WMS meta information.
    • Method Detail

      • validate

        public void validate(java.util.Map<java.lang.String,java.lang.String> paramMap)
                      throws OGCParameterException
        

        Verify the parameter in keyword-value format of the WMS request.

        Parameters:
        paramMap - the parameter is a java.util.Map object, the key is the parameter name of the request, the value is the parameter value.
        Throws:
        OGCParameterException - parameter exception of OGC service. If the WMS request parameter is illegal, the exception is thrown.
      • initDefinePattern

        protected abstract java.util.Map<java.lang.String,java.util.regex.Pattern> initDefinePattern()
        

        Create a regular expression for verifying the parameters of an operation definition.

        Returns:
        java.util.Map object, which indicates the name and regular expression of the operation defined parameter where the key is the parameter name, and the value is the relevant regular expression.
      • initOptionalPattern

        protected java.util.Map<java.lang.String,OptionalParameter> initOptionalPattern()
        

        Create the description information of optional parameters.

        Including TRANSPARENT, BGCOLOR, TIME and ELEVATION optional parameters.

        Returns:
        java.util.Map object, which indicates the name and description of optional parameter, where the key is the parameter name, and the value is the description object (OptionalParameter).
      • initRequiredPattern

        protected java.util.Map<java.lang.String,java.util.regex.Pattern> initRequiredPattern()
        

        Create a regular expression for verifying the necessary parameters.

        Including LAYERS, STYLES, BBOX, WIDTH, HEIGHT, FORMAT and SLD_BODY parameters.

        Returns:
        java.util.Map object, which indicates the name and regular expression of the necessary parameter where the key is the parameter name, and the value is the relevant regular expression.
      • createElevationPattern

        protected final java.util.regex.Pattern createElevationPattern()
        

        Create the regular expression to verify ELEVATION parameter.

        There is no validation of the ELEVATION parameter currently, returns a regular expression which can match any string.

        Returns:
        The regular expression to verify ELEVATION parameter.
      • createTimePattern

        protected final java.util.regex.Pattern createTimePattern()
        

        Create the regular expression to verify TIME parameter.

        There is no validation of the TIME parameter currently, returns a regular expression which can match any string.

        Returns:
        regular expression for verifying time string.
      • createStringArrayPattern

        protected final java.util.regex.Pattern createStringArrayPattern(java.lang.String[] strArray,
                                                       int flags)
        

        Create a regular expression for verifying the string array.

        A regular expression can be created to match the value of any one (and only one) element in an array of strings.

        Parameters:
        strArray - the string array to be verified.
        flags - regular expression matching flag, may include CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL and COMMENTS.
        Returns:
        a regular expression for verifying the string array.
      • createColorPattern

        protected final java.util.regex.Pattern createColorPattern()
        

        Create the regular expression for verifying color string.

        Using case insensitive (Pattern.CASE_INSENSITIVE) matching.

        Returns:
        regular expression for verifying color string.
      • createBooleanPattern

        protected final java.util.regex.Pattern createBooleanPattern()
        

        Create a regular expression that verifies a Boolean string (true or false).

        Using case insensitive (Pattern.CASE_INSENSITIVE) matching.

        Returns:
        a regular expression that verifies a Boolean string (true or false).
      • createPositiveIntegerPattern

        protected final java.util.regex.Pattern createPositiveIntegerPattern()
        

        Create the regular expression to verify positive integer.

        Returns:
        The regular expression to verify positive integer parameter.
      • createBBOXPattern

        protected final java.util.regex.Pattern createBBOXPattern()
        

        Create the regular expression to verify BBOX parameter.

        Returns:
        The regular expression to verify BBOX parameter.
      • createStylesPattern

        protected final java.util.regex.Pattern createStylesPattern()
        

        Create the regular expression to verify STYLES parameter.

        There is no validation of the STYLES parameter currently, returns a regular expression which can match any string.

        Returns:
        The regular expression to verify STYLES parameter.
      • createLayerPattern

        protected final java.util.regex.Pattern createLayerPattern(java.util.List<WMSLayer> layers)
        

        Create the regular expression to verify LAYERS parameter.

        The layer is verified in {@link com.supermap.services.wms.DefaultWMS DefaultWMS. Here returns a regular expression that matches any non - space string.

        Parameters:
        layers - layer list.
        Returns:
        The regular expression to verify LAYERS parameter.
      • createOGCException

        protected OGCParameterException createOGCException(ValidateResult validateResult,
                                               java.lang.String format)
        

        According to the verified result and exception format of the WMS request parameter, create the OGCParameterException exception object.

        Parameters:
        validateResult - the verified result of the WMS request parameter.
        format - the format of the exception information.
        Returns:
        parameter exception of the OGC service.
      • validateBBOX

        protected void validateBBOX(java.lang.String bbox,
                        java.lang.String exceptionFormat)
                             throws OGCParameterException
        

        Verify BBOX parameter.

        Parameters:
        bbox - BBOX parameter.
        exceptionFormat - The format of the exception thrown when the BBOX parameter is verified to be wrong.
        Throws:
        OGCParameterException - parameter exception of OGC service. This exception is thrown when the following conditions occur: Exception code Code = InvalidBBOX:
    • BBOX parameter is empty.
    • BBOX parameter is not represented by four values, i.e., the length of the "BBOX" parameter which is separated by “,” is not equal to 4.
    • When the BBOX parameter's minx/miny/maxx/maxy is not Double type, it occurs an exception, the OGCParameterException exception of NumberFormatException.
    • When the rectangular area constituted by the BBOX parameter's minx/miny/maxx/maxy has error, such as the minimum X is greater than or equals to the maximum X.
  • validateFormat

    protected java.lang.String validateFormat(java.lang.String format)
    

    Verify whether the image format represented by the FORMAT parameter in the WMS GetMap request is supported.

    Parameters:
    format - WMS GetMap the FORMAT parameter in the WMS GetMap request.
    Returns:
    if it supports the image format represented by the FORMAT parameter in the request, return true, otherwise return null, when the parameter format is empty, it will return null.
  • splitString

    protected java.lang.String[] splitString(java.lang.String strToSplit,
                                 java.lang.String splitReg)
    

    Match the separator string with the specified regular expression.

    For example, the string is "SuperMap, iServer, WMS", splitReg is ",", the result is {"SuperMap", "iServer", "iServer"}. When the string is ",,", splitReg is "," and the segmentation result is {"", "", ""}.

    Parameters:
    strToSplit - string to be split.
    splitReg - regular expression.
    Returns:
    string array, which is based on the given regular expression matching split this string.
  • validateStyles

    protected void validateStyles(java.lang.String styles,
                      java.lang.String layerNames,
                      java.lang.String format)
                           throws OGCParameterException
    

    Verify STYLES parameter.

    STYLES is not implemented, and if the STYLES argument is empty, it is not validated.

    Parameters:
    styles - the map layer style of the WMS request.
    layerNames - the map layer of the WMS request.
    format - The format of the exception thrown when the STYLES parameter is verified to be wrong.
    Throws:
    OGCParameterException - OGC service parameter exception. When the STYLES parameter is not empty, the number of layers is not the same as the number of layer styles, the exception will be thrown, the exception code Code = StyleNotDefined.