Examples of HyperionException


Examples of com.dottydingo.hyperion.exception.HyperionException

    }

    private void checkMethodAllowed(EntityPlugin plugin, HttpMethod httpMethod)
    {
        if(!plugin.isMethodAllowed(httpMethod))
            throw new HyperionException(405,String.format("%s is not allowed.",httpMethod));
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

    }

    private void checkMethodAllowed(EntityPlugin plugin, HttpMethod httpMethod)
    {
        if(!plugin.isMethodAllowed(httpMethod))
            throw new HyperionException(405,String.format("%s is not allowed.",httpMethod));
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

    }

    protected void validateRevisionMatch(String type, Integer clientRevision,Integer persistentRevision)
    {
        if(clientRevision != null && !clientRevision.equals(persistentRevision))
            throw new HyperionException(409,
                    String.format("The value for %s is stale. The supplied revision %s does not match the existing revision %s.",
                            type,clientRevision,persistentRevision));
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

                executor = optionsPhaseExecutor;
                break;
        }

        if(executor == null)
            throw new HyperionException(405,"Method not allowed.");

        return executor;
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

    }

    protected void validateRevisionMatch(String type, Integer clientRevision,Integer persistentRevision)
    {
        if(clientRevision != null && !clientRevision.equals(persistentRevision))
            throw new HyperionException(409,
                    String.format("The value for %s is stale. The supplied revision %s does not match the existing revision %s.",
                            type,clientRevision,persistentRevision));
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

        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()));
        }


        if(version != null)
        {
            try
            {
                phaseContext.setVersion(Integer.parseInt(version));
            }
            catch(NumberFormatException e)
            {
                throw new BadRequestException(String.format("%s is not a valid value for version.",version));
            }
        }

        if(!validateMethod(httpMethod,uriRequestResult))
            throw new HyperionException(405,"Not allowed.");

        if(uriRequestResult.getId() != null)
            phaseContext.setId(URLDecoder.decode(uriRequestResult.getId()));
        phaseContext.setHistory(uriRequestResult.isHistory());

        ApiVersionPlugin versionPlugin = plugin.getApiVersionRegistry().getPluginForVersion(phaseContext.getVersion());
        phaseContext.setVersionPlugin(versionPlugin);

        logRequestInformation(phaseContext);

        if(phaseContext.getEffectiveMethod() == HttpMethod.GET)
        {
            response.setCacheMaxAge(plugin.getCacheMaxAge());
        }

        AuthorizationContext authorizationContext = authorizationProvider.authorize(phaseContext);
        phaseContext.setAuthorizationContext(authorizationContext);

        if(!authorizationContext.isAuthorized())
            throw new HyperionException(403,"Not Authorized");

    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

        {
            httpMethod = HttpMethod.valueOf(methodName);
        }
        catch (IllegalArgumentException e)
        {
            throw new HyperionException(405,String.format("%s is not allowed.", methodName));
        }
        return httpMethod;
    }
View Full Code Here

Examples of com.dottydingo.hyperion.exception.HyperionException

    protected RuntimeException mapException(RuntimeException ex)
    {
        if(ex instanceof OptimisticLockingFailureException)
        {
            return new HyperionException(409,"Item has been changed.");
        }
        return ex;
    }
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.