Package org.exquery.restxq.annotation

Examples of org.exquery.restxq.annotation.RestAnnotationException


    protected PathInformation parsePath() throws RestAnnotationException {
       
        final Literal[] annotationValue = getLiterals();
       
        if(annotationValue.length != 1) {
            throw new RestAnnotationException(RestXqErrorCodes.RQST0001);
        }
       
        final Literal pathValue = annotationValue[0];
        if(pathValue.getType() != Type.STRING) {
            throw new RestAnnotationException(RestXqErrorCodes.RQST0002);
        }
       
        final String pathStr = pathValue.getValue();
        if(pathStr.isEmpty()) {
            throw new RestAnnotationException(RestXqErrorCodes.RQST0003);
        }

        //validate the Path
        final Matcher mchPath = ptnPath.matcher(pathStr);
        if(!mchPath.matches()) {
            throw new RestAnnotationException(RestXqErrorCodes.RQST0004);
        }

        //extract the Path segments
        final StringBuilder thisPathExprRegExp = new StringBuilder();
        final List<String> pathFnParams = new ArrayList<String>();
View Full Code Here


            if(fnArgument.getName().equals(fnArgumentName)) {
               
                //if(!fnArgument.getType().isSubTypeOf(requiredArgumentType)) {
                if(!hasCompatibleType(fnArgument.getType(), requiredArgumentType)) {
                    throw new RestAnnotationException(errorCode);
                }

                found = true;
                break;
            }
        }
       
        if(!found) {
            throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
        }
    }
View Full Code Here

            for(final FunctionArgument fnArgument : fnArguments) {
               
                if(fnArgument.getName().equals(fnArgumentName)) {
                   
                    if(!fnArgument.getCardinality().hasRequiredCardinality(requiredCardinality)) {
                        throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
                    }
                   
                    //if(!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().hasSubType(fnArgument.getType()))) {
                    if(!hasCompatibleType(fnArgument.getType(), getRequiredFunctionParameterType())) {
                        throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
                    }
                   
                    found = true;
                    break;
                }
            }
           
            if(!found) {
                throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
            }
        }
    }
View Full Code Here

    //protected Set<String> parseAnnotationValue() throws RestAnnotationException {
    protected Set<String> parseAnnotationValue() throws RestAnnotationException {
        final Literal[] annotationLiterals = getLiterals();
       
        if(annotationLiterals.length == 0) {
            throw new RestAnnotationException(getEmptyAnnotationParamsErr());
        }
       
        return parseAnnotationLiterals(annotationLiterals);
    }
View Full Code Here

        final Set<String> mediaTypes = new HashSet<String>();
       
        for(final Literal mediaTypeLiteral : mediaTypesLiterals) {
       
            if(mediaTypeLiteral.getType() != Type.STRING) {
                throw new RestAnnotationException(getInvalidMediaTypeLiteralErr());
            }
       
            final String mediaType = mediaTypeLiteral.getValue();
            if(mediaType.isEmpty()) {
                throw new RestAnnotationException(getInvalidMediaTypeErr());
            }
           
            if(mtcMediaType == null) {
                mtcMediaType = ptnMediaType.matcher(mediaType);
            } else {
                mtcMediaType = mtcMediaType.reset(mediaType);
            }
           
            if(!mtcMediaType.matches()) {
                throw new RestAnnotationException(getInvalidMediaTypeErr());
            }
           
            mediaTypes.add(mediaType);
        }
       
View Full Code Here

     */
    protected ParameterAnnotationMapping parseAnnotationValue() throws RestAnnotationException {
        final Literal[] annotationLiterals = getLiterals();
       
        if(annotationLiterals.length != 2) {
            throw new RestAnnotationException(getInvalidAnnotationParamsErr());
        }
       
        return parseAnnotationLiterals(annotationLiterals[0], annotationLiterals[1], Cardinality.ZERO_OR_MORE);
    }
View Full Code Here

     *
     * @throws RestAnnotationException if the mapping is invalid
     */
    protected final ParameterAnnotationMapping parseAnnotationLiterals(final Literal parameterName, final Literal functionArgumentName, final Cardinality requiredCardinality) throws RestAnnotationException {
        if(parameterName.getType() != Type.STRING) {
            throw new RestAnnotationException(getInvalidParameterNameErr());
        }
       
        if(functionArgumentName.getType() != Type.STRING) {
            throw new RestAnnotationException(getInvalidFunctionArgumentNameErr());
        }
       
        final String keyStr = parameterName.getValue();
        final String varStr = functionArgumentName.getValue();
        if(keyStr.isEmpty()) {
            throw new RestAnnotationException(getInvalidParameterNameErr());
        }

        if(varStr.isEmpty()) {
            throw new RestAnnotationException(getInvalidFunctionArgumentNameErr());
        }

        //validate the varStr
        final Matcher mtcFnParameter = functionArgumentPattern.matcher(varStr);
        if(!mtcFnParameter.matches()) {
            throw new RestAnnotationException(getInvalidAnnotationParametersSyntaxErr());
        }

        final String varName = mtcFnParameter.group(1);

        //check the function declares the var with the correct cardinality
View Full Code Here

     */
    protected Pattern parseAnnotationValue() throws RestAnnotationException {
        final Literal[] annotationLiterals = getLiterals();
       
        if(annotationLiterals.length == 0) {
            throw new RestAnnotationException(getEmptyAnnotationParamsErr());
        }
       
        return parseAnnotationLiterals(annotationLiterals);
    }
View Full Code Here

        final StringBuilder builder = new StringBuilder();
       
        for(final Literal mediaTypeLiteral : mediaTypesLiterals) {
       
            if(mediaTypeLiteral.getType() != Type.STRING) {
                throw new RestAnnotationException(getInvalidMediaTypeLiteralErr());
            }
       
            final String mediaType = mediaTypeLiteral.getValue();
            if(mediaType.isEmpty()) {
                throw new RestAnnotationException(getInvalidMediaTypeErr());
            }
           
            if(mtcMediaType == null) {
                mtcMediaType = ptnMediaType.matcher(mediaType);
            } else {
                mtcMediaType = mtcMediaType.reset(mediaType);
            }
           
            if(!mtcMediaType.matches()) {
                throw new RestAnnotationException(getInvalidMediaTypeErr());
            }
           
            //add to match pattern
            if(builder.length() != 0) {
                builder.append("|");
View Full Code Here

    @Override
    protected ParameterAnnotationMapping parseAnnotationValue() throws RestAnnotationException {
        final Literal[] annotationLiterals = getLiterals();
       
        if(annotationLiterals.length < 2) {
            throw new RestAnnotationException(getInvalidAnnotationParamsErr());
        }
        final Literal[] defaultValueLiterals = Arrays.copyOfRange(annotationLiterals, 2, annotationLiterals.length);
       
        //check that the decalred literals are themselves valid
        //TODO probably not needed enforced by the XQuery parser/grammar
        for(final Literal defaultValueLiteral : defaultValueLiterals) {
            if(!defaultValueLiteral.getType().isSubTypeOf(Type.ANY_SIMPLE_TYPE)){
                throw new RestAnnotationException(getInvalidDefaultValueErr());
            }
        }
       
        return parseAnnotationLiterals(annotationLiterals[0], annotationLiterals[1], defaultValueLiterals);
    }
View Full Code Here

TOP

Related Classes of org.exquery.restxq.annotation.RestAnnotationException

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.