Package com.betfair.cougar.core.api.exception

Examples of com.betfair.cougar.core.api.exception.CougarValidationException


        } else if (paramFormat.equalsIgnoreCase("json")) {
            paramFormat = MediaType.APPLICATION_JSON;
        } else if (paramFormat.equalsIgnoreCase("bin")) {
            paramFormat = MediaType.APPLICATION_OCTET_STREAM;
        } else {
            throw new CougarValidationException(ServerFaultCode.MediaTypeParseFailure, "Invalid alt param for media type - " + paramFormat);
        }
        return paramFormat;
    }
View Full Code Here


    @Override
    public MediaType getNormalisedRequestMediaType(HttpServletRequest request) {
        String contentType = request.getContentType();
        if (request.getMethod().equals("POST")) {
            if (contentType == null) {
                throw new CougarValidationException(ServerFaultCode.ContentTypeNotValid, "Input content type was not specified for deserialisable response");
            }
            MediaType requestMT;
            try {
                requestMT = MediaType.valueOf(contentType);
            } catch (Exception e) {
                throw new CougarValidationException(ServerFaultCode.MediaTypeParseFailure, "Input content type cannot be parsed: " + contentType,e);
            }
            if (requestMT.isWildcardType() || requestMT.isWildcardSubtype()) {
                throw new CougarValidationException(ServerFaultCode.InvalidInputMediaType, "Input content type may not be wildcard: " + requestMT);
            }
            if (!MediaTypeUtils.isValid(allContentTypes, requestMT)) {
                throw new CougarValidationException(ServerFaultCode.ContentTypeNotValid, "Input content type is not valid: " + requestMT);
            }
            String candidateContentType = requestMT.getType() + "/" + requestMT.getSubtype();
            MediaType normalizedMediaType = validContentTypes.get(candidateContentType);
            if (normalizedMediaType == null) {
                throw new CougarValidationException(ServerFaultCode.FrameworkError, "Input content type " + contentType + " failed to find a normalized type using key " + candidateContentType);
            }
            return normalizedMediaType;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of com.betfair.cougar.core.api.exception.CougarValidationException

Copyright © 2018 www.massapicom. 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.