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:
Modifier and Type | Field and Description |
---|---|
protected WMSCapabilities |
capabilities
WMS meta information.
|
protected static java.lang.String |
EXCEPTION_CODE_INVALIDBBOX
Invalid BBOX exception code.
|
protected static java.lang.String |
MSG_KEY_INVALIDBBOX
Invalid BBOX keyword.
|
protected ResourceManager |
resource
Resource manager.
|
protected ParameterValidator |
validator
Parameter verifier based on regular expression.
|
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.
|
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.
|
protected static final java.lang.String MSG_KEY_INVALIDBBOX
Invalid BBOX keyword.
The default value is “WMS.ValidateParameter.InvalidBBOX”.
protected static final java.lang.String EXCEPTION_CODE_INVALIDBBOX
Invalid BBOX exception code.
The default value is “InvalidBBOX”.
protected WMSCapabilities capabilities
WMS meta information.
protected ResourceManager resource
Resource manager.
protected ParameterValidator validator
Parameter verifier based on regular expression.
public WMSParameterValidator(WMSCapabilities capabilities)
Construct a WMSParameterValidator object according to WMS meta data information.
capabilities
- WMS meta information.public WMSParameterValidator(WMSCapabilities capabilities, java.lang.String defaultBgColor)
Construct a WMSParameterValidator object according to WMS meta data information.
capabilities
- WMS meta information.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.
paramMap
- the parameter is a java.util.Map object, the key is the parameter name of the request, the value is the parameter value.OGCParameterException
- parameter exception of OGC service. If the WMS request parameter is illegal, the exception is thrown.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.
Including TRANSPARENT, BGCOLOR, TIME and ELEVATION optional parameters.
OptionalParameter
).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.
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.
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.
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.
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.protected final java.util.regex.Pattern createColorPattern()
Create the regular expression for verifying color string.
Using case insensitive (Pattern.CASE_INSENSITIVE) matching.
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.
protected final java.util.regex.Pattern createPositiveIntegerPattern()
Create the regular expression to verify positive integer.
protected final java.util.regex.Pattern createBBOXPattern()
Create the regular expression to verify BBOX parameter.
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.
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.
layers
- layer list.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.
validateResult
- the verified result of the WMS request parameter.format
- the format of the exception information.protected void validateBBOX(java.lang.String bbox, java.lang.String exceptionFormat) throws OGCParameterException
Verify BBOX parameter.
bbox
- BBOX parameter.exceptionFormat
- The format of the exception thrown when the BBOX parameter is verified to be wrong.OGCParameterException
- parameter exception of OGC service. This exception is thrown when the following conditions occur: Exception code Code = InvalidBBOX: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.
format
- WMS GetMap the FORMAT parameter in the WMS GetMap request.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 {"", "", ""}.
strToSplit
- string to be split.splitReg
- regular expression.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.
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.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.