Examples of HyperionRequest


Examples of com.dottydingo.hyperion.service.context.HyperionRequest

    protected void executePhase(HyperionContext phaseContext) throws Exception
    {
        if(serviceStatus.getForceDown())
            throw new ServiceUnavailableException("Service not available");

        HyperionRequest request = phaseContext.getEndpointRequest();
        HyperionResponse response = phaseContext.getEndpointResponse();

        UriRequestResult uriRequestResult = uriParser.parseRequestUri(request.getResourceUri());

        if(uriRequestResult == null)
            throw new NotFoundException(String.format("%s is not recognized.",request.getResourceUri()));

        String entityName = uriRequestResult.getEndpoint();

        EntityPlugin plugin = serviceRegistry.getPluginForName(entityName);
        if(plugin == null)
            throw new NotFoundException(String.format("%s is not a valid entity.",entityName));

        phaseContext.setEntityPlugin(plugin);

        phaseContext.setRequestMethod(getHttpMethod(request.getRequestMethod()));
        String requestMethod = getEffectiveMethod(request);
        HttpMethod httpMethod = getHttpMethod(requestMethod);

        if(!plugin.isMethodAllowed(httpMethod))
            throw new NotAllowedException(String.format("%s is not allowed.",httpMethod));

        if(serviceStatus.getReadOnly() && httpMethod.isWriteOperation())
            throw new NotAllowedException("Service is in read only mode.");

        phaseContext.setEffectiveMethod(httpMethod);

        // special case where version is in the URI
        String version = uriRequestResult.getVersion();

        if(version == null || version.length() == 0)
        {
            version = request.getFirstParameter(hyperionEndpointConfiguration.getVersionParameterName());
            if(version == null || version.length() == 0)
                version = request.getFirstHeader(hyperionEndpointConfiguration.getVersionHeaderName());

            if(hyperionEndpointConfiguration.isRequireVersion() && httpMethod != HttpMethod.DELETE &&
                    (version == null || version.length()==0))
                throw new BadRequestException(String.format("The %s parameter must be specified",
                        hyperionEndpointConfiguration.getVersionParameterName()));
View Full Code Here

Examples of com.dottydingo.hyperion.service.context.HyperionRequest

    protected void logRequestInformation(HyperionContext context)
    {
        if(!logger.isDebugEnabled())
            return;

        HyperionRequest request = context.getEndpointRequest();

        logger.debug("Correlation ID: {}",context.getCorrelationId());
        logger.debug("Request URL: {}",request.getRequestUrl());
        logger.debug("Base URL: {}",request.getBaseUrl());
        logger.debug("Request URI: {}",request.getRequestUri());
        logger.debug("Resource URI: {}",request.getResourceUri());
        logger.debug("Request Query String: {}",request.getQueryString());
        logger.debug("Request Method: {}",request.getRequestMethod());
        logger.debug("Effective Method: {}",context.getEffectiveMethod());
        logger.debug("Endpoint Name: {}",context.getEntityPlugin().getEndpointName());
        logger.debug("ContentType: {}",request.getContentType());
        logger.debug("User ID: {}",context.getUserContext().getUserId());
        logger.debug("User Name: {}",context.getUserContext().getUserName());
        logger.debug("Id: {}",context.getId());
        logger.debug("History: {}",context.isHistory());

        for (String name : request.getHeaderNames())
        {
            logger.debug("Header name: {} value:{}",name,request.getHeader(name));
        }

        for (String name : request.getParameterNames())
        {
            logger.debug("Parameter name: {} value:{}",name,request.getParameter(name));
        }

        logger.debug("Request Version: {}",context.getVersion());
    }
View Full Code Here

Examples of com.dottydingo.hyperion.service.context.HyperionRequest

    }

    @Override
    protected void executePhase(HyperionContext phaseContext) throws Exception
    {
        HyperionRequest request = phaseContext.getEndpointRequest();
        HyperionResponse response = phaseContext.getEndpointResponse();

        Set<HttpMethod> allowedMethods = getAllowedMethods(phaseContext);

        StringBuilder sb = new StringBuilder();
        int ct = 0;
        for (HttpMethod allowedMethod : allowedMethods)
        {
            if(ct++ > 0)
                sb.append(", ");
            sb.append(allowedMethod.toString());
        }
        response.setHeader("Access-Control-Allow-Methods",sb.toString());

        String requestedHeaders =  request.getFirstHeader("Access-Control-Request-Headers");
        if(requestedHeaders != null && requestedHeaders.length() > 0)
            response.setHeader("Access-Control-Allow-Headers",requestedHeaders);

        //response.setHeader("Access-Control-Expose-Headers",""); todo
        //response.setHeader("Control-Allow-Credentials",""); todo
View Full Code Here

Examples of com.dottydingo.hyperion.service.context.HyperionRequest

    }

    @Override
    protected void executePhase(HyperionContext phaseContext) throws Exception
    {
        HyperionRequest request = phaseContext.getEndpointRequest();
        HyperionResponse response = phaseContext.getEndpointResponse();

        UriRequestResult uriRequestResult = uriParser.parseRequestUri(request.getResourceUri());

        if(uriRequestResult == null)
            throw new NotFoundException(String.format("%s is not recognized.",request.getResourceUri()));

        String entityName = uriRequestResult.getEndpoint();

        EntityPlugin plugin = serviceRegistry.getPluginForName(entityName);
        if(plugin == null)
            throw new NotFoundException(String.format("%s is not a valid entity.",entityName));

        phaseContext.setEntityPlugin(plugin);

        phaseContext.setRequestMethod(getHttpMethod(request.getRequestMethod()));
        String requestMethod = getEffectiveMethod(request);
        HttpMethod httpMethod = getHttpMethod(requestMethod);

        if(!plugin.isMethodAllowed(httpMethod))
            throw new HyperionException(405,String.format("%s is not allowed.",httpMethod));

        phaseContext.setEffectiveMethod(httpMethod);

        // special case where version is in the URI
        String version = uriRequestResult.getVersion();

        if(version == null || version.length() == 0)
        {
            version = request.getFirstParameter(hyperionEndpointConfiguration.getVersionParameterName());
            if(version == null || version.length() == 0)
                version = request.getFirstHeader(hyperionEndpointConfiguration.getVersionHeaderName());

            if(hyperionEndpointConfiguration.isRequireVersion() && httpMethod != HttpMethod.DELETE &&
                    (version == null || version.length()==0))
                throw new BadRequestException(String.format("The %s parameter must be specified",hyperionEndpointConfiguration.getVersionParameterName()));
        }
View Full Code Here

Examples of com.dottydingo.hyperion.service.context.HyperionRequest

    protected void logRequestInformation(HyperionContext context)
    {
        if(!logger.isDebugEnabled())
            return;

        HyperionRequest request = context.getEndpointRequest();

        logger.debug("Correlation ID: {}",context.getCorrelationId());
        logger.debug("Request URL: {}",request.getRequestUrl());
        logger.debug("Base URL: {}",request.getBaseUrl());
        logger.debug("Request URI: {}",request.getRequestUri());
        logger.debug("Resource URI: {}",request.getResourceUri());
        logger.debug("Request Query String: {}",request.getQueryString());
        logger.debug("Request Method: {}",request.getRequestMethod());
        logger.debug("Effective Method: {}",context.getEffectiveMethod());
        logger.debug("Endpoint Name: {}",context.getEntityPlugin().getEndpointName());
        logger.debug("ContentType: {}",request.getContentType());
        logger.debug("User ID: {}",context.getUserContext().getUserId());
        logger.debug("User Name: {}",context.getUserContext().getUserName());
        logger.debug("Id: {}",context.getId());
        logger.debug("History: {}",context.isHistory());

        for (String name : request.getHeaderNames())
        {
            logger.debug("Header name: {} value:{}",name,request.getHeader(name));
        }

        for (String name : request.getParameterNames())
        {
            logger.debug("Parameter name: {} value:{}",name,request.getParameter(name));
        }

        logger.debug("Request Version: {}",context.getVersion());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.