novie-core/src/main/java/com/groupon/novie/internal/controllers/ApiController.java
@SuppressWarnings("unchecked")
    private Report processRequest(String schema, HttpServletRequest request) throws ServiceException, InvalidParameterException,
            InvalidSchemaException {

        long begin = System.currentTimeMillis();

        SchemaDefinition config = schemaRepository.getStarSchemaConfig(schema);
        if (config == null) {
            LOG.warn("Invalid endpoint \"" + schema + "\"");
            throw new InvalidSchemaException("Invalid endpoint");
        }

        Map<String, String[]> params = request.getParameterMap();

        for (String mandatory : MANDATORY_FIELDS) {
            if (!params.containsKey(mandatory)) {
                // mandatory fields are case sensitive
                LOG.error("Mandatory field \"" + mandatory + "\" missing");
                throw new InvalidParameterException("Missing mandatory field " + mandatory);
            }
        }

        QueryParameterEnvelope queryParameterDto = new QueryParameterEnvelope();

        for (String key : params.keySet()) {

            if (DOMAIN_PARAMETERS.contains(key)) {
                String domainParameter = params.get(key)[0];
                final DomainParserAware systemParameter = SystemParameter.valueOf(key);
                systemParameter.parseValue(domainParameter, config, queryParameterDto);

            } else {

                Pair<String, String> pair = splitKey(key);
                if (!config.isValidDimension(pair.getLeft(), pair.getRight())) {
                    LOG.warn("Invalid parameter \"" + key + "\" for endpoint \"" + schema + "\".");
                    throw new InvalidParameterException("Invalid parameter " + key + " for endpoint " + schema + "");
                }

                String[] multiParam = request.getParameterValues(key);
                for (String param : multiParam) {
                    queryParameterDto.addConstraints(new HttpQueryConstraint(config, key, param));
                }
            }
        }
        final Report report = schemaService.generateReport(config, queryParameterDto);
        report.setRecords(inMemoryPagination(report.getRecords(), queryParameterDto));
        if (LOG.isInfoEnabled()) {
            LOG.info("Query successfully processed for schema " + schema + " in " + (System.currentTimeMillis() - begin) + "s.");
        }
        return report;
    }
@SuppressWarnings("unchecked")
    private Report processRequest(String schema, HttpServletRequest request) throws ServiceException, InvalidParameterException,
            InvalidSchemaException {

        long begin = System.currentTimeMillis();

        SchemaDefinition config = schemaRepository.getStarSchemaConfig(schema);
        if (config == null) {
            LOG.warn("Invalid endpoint \"" + schema + "\"");
            throw new InvalidSchemaException("Invalid endpoint");
        }

        Map<String, String[]> params = request.getParameterMap();

        for (String mandatory : MANDATORY_FIELDS) {
            if (!params.containsKey(mandatory)) {
                // mandatory fields are case sensitive
                LOG.error("Mandatory field \"" + mandatory + "\" missing");
                throw new InvalidParameterException("Missing mandatory field " + mandatory);
            }
        }

        QueryParameterEnvelope queryParameterDto = new QueryParameterEnvelope();

        for (String key : params.keySet()) {

            if (DOMAIN_PARAMETERS.contains(key)) {
                String domainParameter = params.get(key)[0];
                final DomainParserAware systemParameter = SystemParameter.valueOf(key);
                systemParameter.parseValue(domainParameter, config, queryParameterDto);

            } else {

                Pair<String, String> pair = splitKey(key);
                if (!config.isValidDimension(pair.getLeft(), pair.getRight())) {
                    LOG.warn("Invalid parameter \"" + key + "\" for endpoint \"" + schema + "\".");
                    throw new InvalidParameterException("Invalid parameter " + key + " for endpoint " + schema + "");
                }

                String[] multiParam = request.getParameterValues(key);
                for (String param : multiParam) {
                    queryParameterDto.addConstraints(new HttpQueryConstraint(config, key, param));
                }
            }
        }
        final Report report = schemaService.generateReport(config, queryParameterDto);
        report.setRecords(inMemoryPagination(report.getRecords(), queryParameterDto));
        if (LOG.isInfoEnabled()) {
            LOG.info("Query successfully processed for schema " + schema + " in " + (System.currentTimeMillis() - begin) + "s.");
        }
        return report;
    }
@ SuppressWarnings ( "unchecked" ) private Report processRequest ( String schema , HttpServletRequest request ) throws ServiceException , InvalidParameterException , InvalidSchemaException { long begin = System . currentTimeMillis ( ) ; SchemaDefinition config = schemaRepository . getStarSchemaConfig ( schema ) ; if ( config == null ) { LOG . warn ( "Invalid endpoint \"" + schema + "\"" ) ; throw new InvalidSchemaException ( "Invalid endpoint" ) ; } Map < String , String [ ] > params = request . getParameterMap ( ) ; for ( String mandatory : MANDATORY_FIELDS ) { if ( ! params . containsKey ( mandatory ) ) { // mandatory fields are case sensitive LOG . error ( "Mandatory field \"" + mandatory + "\" missing" ) ; throw new InvalidParameterException ( "Missing mandatory field " + mandatory ) ; } } QueryParameterEnvelope queryParameterDto = new QueryParameterEnvelope ( ) ; for ( String key : params . keySet ( ) ) { if ( DOMAIN_PARAMETERS . contains ( key ) ) { String domainParameter = params . get ( key ) [ 0 ] ; final DomainParserAware systemParameter = SystemParameter . valueOf ( key ) ; systemParameter . parseValue ( domainParameter , config , queryParameterDto ) ; } else { Pair < String , String > pair = splitKey ( key ) ; if ( ! config . isValidDimension ( pair . getLeft ( ) , pair . getRight ( ) ) ) { LOG . warn ( "Invalid parameter \"" + key + "\" for endpoint \"" + schema + "\"." ) ; throw new InvalidParameterException ( "Invalid parameter " + key + " for endpoint " + schema + "" ) ; } String [ ] multiParam = request . getParameterValues ( key ) ; for ( String param : multiParam ) { queryParameterDto . addConstraints ( new HttpQueryConstraint ( config , key , param ) ) ; } } } final Report report = schemaService . generateReport ( config , queryParameterDto ) ; report . setRecords ( inMemoryPagination ( report . getRecords ( ) , queryParameterDto ) ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( "Query successfully processed for schema " + schema + " in " + ( System . currentTimeMillis ( ) - begin ) + "s." ) ; } return report ; }
<p>
Generic processor of all types of requests.
</p>
<p>
Validates schema availability, mandatory fields for the specified schema
and creates chains of {@link QueryParameterAware} to be processed by the
underlying {@link GenericSchemaService}.
</p>

@param schema  Schema from where to extract the information.
@param request Request in generic form so the parameters can be dynamically
extract.

@return Returns a {@link Report} Object delivered by the {@link GenericSchemaService}.

@throws ServiceException          Exception generated by the underlying Service.
@throws InvalidParameterException Exception generated by the controller due to an invalid
parameter for the chosen schema.
@throws InvalidSchemaException    Exception generated by the controller when an invalid schema
is requested.
<p > Generic processor of all types of requests . < / p > <p > Validates schema availability mandatory fields for the specified schema and creates chains of { @link QueryParameterAware } to be processed by the underlying { @link GenericSchemaService } . < / p >