public static String getRequestParameterValue(HttpServletRequest httpServletRequest,
                                                  String parameter) throws InterceptorException, IOException {

        LOG.trace("Finding the request parameter [" + parameter + "]");

        String value = StringUtils.EMPTY;

        Map<String, String[]> queryParams = httpServletRequest.getParameterMap();

        if (!queryParams.isEmpty()) {

            LOG.trace("The request contains query parameters (GET or POST).");

            Map<String, String[]> params = new TreeMap<String, String[]>(
                String.CASE_INSENSITIVE_ORDER);

            params.putAll(queryParams);

            if (params.containsKey(parameter)) {
                value = StringUtils.join(params.get(parameter), ",");
            }

        } else {

            String xml = OgcXmlUtil.getRequestBody(httpServletRequest);

            if (!StringUtils.isEmpty(xml)) {

                LOG.trace("The request contains a POST body.");

                Document document = OgcXmlUtil.getDocumentFromString(xml);

                if (parameter.equalsIgnoreCase(OgcEnum.Service.SERVICE.toString())) {
                    value = OgcXmlUtil.getPathInDocument(
                        document, "/*/@service");
                } else if (parameter.equalsIgnoreCase(OgcEnum.Operation.OPERATION.toString())) {
                    value = OgcXmlUtil.getPathInDocument(
                        document, "name(/*)");

                    if (value.contains(":")) {
                        value = value.split(":")[1];
                    }

                } else if (Arrays.asList(OgcEnum.EndPoint.getAllValues()).contains(parameter)) {
                    value = OgcXmlUtil.getPathInDocument(document,
                        "//TypeName/text() | //TypeNames/text() | //GetCoverage/Identifier/text()");
                    if (StringUtils.isEmpty(value)) {
                        value = OgcXmlUtil.getPathInDocument(document,
                            "//@typeName | //@typeNames");
                    }
                }

            } else {
                LOG.error("No body found in the request.");
            }
        }

        LOG.trace("Found the request parameter value: " + value);

        return value;
    }
public static String getRequestParameterValue ( HttpServletRequest httpServletRequest , String parameter ) throws InterceptorException , IOException { LOG . trace ( "Finding the request parameter [" + parameter + "]" ) ; String value = StringUtils . EMPTY ; Map < String , String [ ] > queryParams = httpServletRequest . getParameterMap ( ) ; if ( ! queryParams . isEmpty ( ) ) { LOG . trace ( "The request contains query parameters (GET or POST)." ) ; Map < String , String [ ] > params = new TreeMap < String , String [ ] > ( String . CASE_INSENSITIVE_ORDER ) ; params . putAll ( queryParams ) ; if ( params . containsKey ( parameter ) ) { value = StringUtils . join ( params . get ( parameter ) , "," ) ; } } else { String xml = OgcXmlUtil . getRequestBody ( httpServletRequest ) ; if ( ! StringUtils . isEmpty ( xml ) ) { LOG . trace ( "The request contains a POST body." ) ; Document document = OgcXmlUtil . getDocumentFromString ( xml ) ; if ( parameter . equalsIgnoreCase ( OgcEnum . Service . SERVICE . toString ( ) ) ) { value = OgcXmlUtil . getPathInDocument ( document , "/*/@service" ) ; } else if ( parameter . equalsIgnoreCase ( OgcEnum . Operation . OPERATION . toString ( ) ) ) { value = OgcXmlUtil . getPathInDocument ( document , "name(/*)" ) ; if ( value . contains ( ":" ) ) { value = value . split ( ":" ) [ 1 ] ; } } else if ( Arrays . asList ( OgcEnum . EndPoint . getAllValues ( ) ) . contains ( parameter ) ) { value = OgcXmlUtil . getPathInDocument ( document , "//TypeName/text() | //TypeNames/text() | //GetCoverage/Identifier/text()" ) ; if ( StringUtils . isEmpty ( value ) ) { value = OgcXmlUtil . getPathInDocument ( document , "//@typeName | //@typeNames" ) ; } } } else { LOG . error ( "No body found in the request." ) ; } } LOG . trace ( "Found the request parameter value: " + value ) ; return value ; }
@param httpServletRequest
@param parameter
@return
@throws InterceptorException
@throws IOException