Examples of ResponseDocType


Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

     * @param m
     * @return the enhanced {@link Response}
     * @see com.sun.jersey.server.wadl.WadlGenerator#createResponses(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)
     */
    public List<Response> createResponses( AbstractResource r, AbstractResourceMethod m ) {
        final ResponseDocType responseDoc = _resourceDoc.getResponse( r.getResourceClass(), m.getMethod() );
        List<Response> responses = new ArrayList<Response>();
        if ( responseDoc != null && responseDoc.hasRepresentations() ) {
            for ( RepresentationDocType representationDoc : responseDoc.getRepresentations() ) {
                Response response = new Response();

                final Representation wadlRepresentation = new Representation();
                wadlRepresentation.setElement( representationDoc.getElement() );
                wadlRepresentation.setMediaType( representationDoc.getMediaType() );
                addDocForExample( wadlRepresentation.getDoc(), representationDoc.getExample() );
                addDoc( wadlRepresentation.getDoc(), representationDoc.getDoc() );

                response.getStatus().add(representationDoc.getStatus());
                response.getRepresentation().add(wadlRepresentation);

                responses.add(response);
            }

            if (!responseDoc.getWadlParams().isEmpty() ) {
                for ( WadlParamType wadlParamType : responseDoc.getWadlParams() ) {
                    final Param param = new Param();
                    param.setName( wadlParamType.getName() );
                    param.setStyle( ParamStyle.fromValue( wadlParamType.getStyle() ) );
                    param.setType( wadlParamType.getType() );
                    addDoc( param.getDoc(), wadlParamType.getDoc() );
                    for(Response response : responses) {
                        response.getParam().add(param);
                    }
                }
            }

            if (!isEmpty( responseDoc.getReturnDoc() ) ) {
                for(Response response : responses) {
                    addDoc( response.getDoc(), responseDoc.getReturnDoc() );
                }
            }

        } else {
            responses = _delegate.createResponses(r, m);
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

     * @param m
     * @return
     * @see com.sun.jersey.server.impl.wadl.WadlGenerator#createResponse(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)
     */
    public Response createResponse( AbstractResource r, AbstractResourceMethod m ) {
        final ResponseDocType responseDoc = _resourceDoc.getResponse( r.getResourceClass(), m.getMethod() );
        final Response response;
        if ( responseDoc != null && responseDoc.hasRepresentations() ) {
            response = new Response();
           
            for ( RepresentationDocType representationDoc : responseDoc.getRepresentations() ) {
               
                final RepresentationType wadlRepresentation = new RepresentationType();
                wadlRepresentation.setElement( representationDoc.getElement() );
                wadlRepresentation.getStatus().add( representationDoc.getStatus() );
                wadlRepresentation.setMediaType( representationDoc.getMediaType() );
                addDocForExample( wadlRepresentation.getDoc(), representationDoc.getExample() );
                addDoc( wadlRepresentation.getDoc(), representationDoc.getDoc() );
               
                JAXBElement<RepresentationType> element = new JAXBElement<RepresentationType>(
                        new QName("http://research.sun.com/wadl/2006/10","representation"),
                        RepresentationType.class,
                        wadlRepresentation);
               
                response.getRepresentationOrFault().add(element);
            }
           
            return response;
        }
        else {
            response = _delegate.createResponse( r, m );
        }
       
        /* add response params from resourcedoc
         */
        if ( responseDoc != null && !responseDoc.getWadlParams().isEmpty() ) {
            for ( WadlParamType wadlParamType : responseDoc.getWadlParams() ) {
                final Param param = new Param();
                param.setName( wadlParamType.getName() );
                param.setStyle( ParamStyle.fromValue( wadlParamType.getStyle() ) );
                param.setType( wadlParamType.getType() );
                addDoc( param.getDoc(), wadlParamType.getDoc() );
                response.getParam().add( param );
            }
        }
       
        if ( responseDoc != null && !isEmpty( responseDoc.getReturnDoc() ) ) {
            addDoc( response.getDoc(), responseDoc.getReturnDoc() );
        }
       
        return response;
    }
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

     * @param m
     * @return the enhanced {@link Response}
     * @see com.sun.jersey.server.wadl.WadlGenerator#createResponse(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)
     */
    public List<Response> createResponses( AbstractResource r, AbstractResourceMethod m ) {
        final ResponseDocType responseDoc = _resourceDoc.getResponse( r.getResourceClass(), m.getMethod() );
        List<Response> responses = new ArrayList<Response>();
        if ( responseDoc != null && responseDoc.hasRepresentations() ) {
            for ( RepresentationDocType representationDoc : responseDoc.getRepresentations() ) {
                Response response = new Response();

                final Representation wadlRepresentation = new Representation();
                wadlRepresentation.setElement( representationDoc.getElement() );
                wadlRepresentation.setMediaType( representationDoc.getMediaType() );
                addDocForExample( wadlRepresentation.getDoc(), representationDoc.getExample() );
                addDoc( wadlRepresentation.getDoc(), representationDoc.getDoc() );

                response.getStatus().add(representationDoc.getStatus());
                response.getRepresentation().add(wadlRepresentation);

                responses.add(response);
            }

            if (!responseDoc.getWadlParams().isEmpty() ) {
                for ( WadlParamType wadlParamType : responseDoc.getWadlParams() ) {
                    final Param param = new Param();
                    param.setName( wadlParamType.getName() );
                    param.setStyle( ParamStyle.fromValue( wadlParamType.getStyle() ) );
                    param.setType( wadlParamType.getType() );
                    addDoc( param.getDoc(), wadlParamType.getDoc() );
                    for(Response response : responses) {
                        response.getParam().add(param);
                    }
                }
            }

            if (!isEmpty( responseDoc.getReturnDoc() ) ) {
                for(Response response : responses) {
                    addDoc( response.getDoc(), responseDoc.getReturnDoc() );
                }
            }

        } else {
            responses = _delegate.createResponses(r, m);
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

     * @param m
     * @return the enhanced {@link Response}
     * @see com.sun.jersey.server.wadl.WadlGenerator#createResponse(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)
     */
    public Response createResponse( AbstractResource r, AbstractResourceMethod m ) {
        final ResponseDocType responseDoc = _resourceDoc.getResponse( r.getResourceClass(), m.getMethod() );
        final Response response;
        if ( responseDoc != null && responseDoc.hasRepresentations() ) {
            response = new Response();
           
            for ( RepresentationDocType representationDoc : responseDoc.getRepresentations() ) {
               
                final RepresentationType wadlRepresentation = new RepresentationType();
                wadlRepresentation.setElement( representationDoc.getElement() );
                wadlRepresentation.getStatus().add( representationDoc.getStatus() );
                wadlRepresentation.setMediaType( representationDoc.getMediaType() );
                addDocForExample( wadlRepresentation.getDoc(), representationDoc.getExample() );
                addDoc( wadlRepresentation.getDoc(), representationDoc.getDoc() );
               
                JAXBElement<RepresentationType> element = new JAXBElement<RepresentationType>(
                        new QName("http://research.sun.com/wadl/2006/10","representation"),
                        RepresentationType.class,
                        wadlRepresentation);
               
                response.getRepresentationOrFault().add(element);
            }
           
            return response;
        }
        else {
            response = _delegate.createResponse( r, m );
        }
       
        /* add response params from resourcedoc
         */
        if ( responseDoc != null && !responseDoc.getWadlParams().isEmpty() ) {
            for ( WadlParamType wadlParamType : responseDoc.getWadlParams() ) {
                final Param param = new Param();
                param.setName( wadlParamType.getName() );
                param.setStyle( ParamStyle.fromValue( wadlParamType.getStyle() ) );
                param.setType( wadlParamType.getType() );
                addDoc( param.getDoc(), wadlParamType.getDoc() );
                response.getParam().add( param );
            }
        }
       
        if ( responseDoc != null && !isEmpty( responseDoc.getReturnDoc() ) ) {
            addDoc( response.getDoc(), responseDoc.getReturnDoc() );
        }
       
        return response;
    }
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

    }

    private static void addResponseDoc( MethodDoc methodDoc,
            final MethodDocType methodDocType ) {
       
        final ResponseDocType responseDoc = new ResponseDocType();
       
        final Tag returnTag = getSingleTagOrNull( methodDoc, "return" );
        if ( returnTag != null ) {
            responseDoc.setReturnDoc( returnTag.text() );
        }
       
        final Tag[] responseParamTags = methodDoc.tags( "response.param" );
        for ( Tag responseParamTag : responseParamTags ) {
            // LOG.info( "Have responseparam tag: " + print( responseParamTag ) );
            final WadlParamType wadlParam = new WadlParamType();
            for ( Tag inlineTag : responseParamTag.inlineTags() ) {
                final String tagName = inlineTag.name();
                final String tagText = inlineTag.text();
                /* skip empty tags
                 */
                if ( isEmpty( tagText ) ) {
                    if ( LOG.isLoggable( Level.FINE ) ) {
                        LOG.fine( "Skipping empty inline tag of @response.param in method " +
                            methodDoc.qualifiedName() + ": " + tagName  );
                    }
                    continue;
                }
                if ( "@name".equals( tagName ) ) {
                    wadlParam.setName( tagText );
                }
                else if ( "@style".equals( tagName ) ) {
                    wadlParam.setStyle( tagText );
                }
                else if ( "@type".equals( tagName ) ) {
                    wadlParam.setType( QName.valueOf( tagText ) );
                }
                else if ( "@doc".equals( tagName ) ) {
                    wadlParam.setDoc( tagText );
                }
                else {
                    LOG.warning( "Unknown inline tag of @response.param in method " +
                            methodDoc.qualifiedName() + ": " + tagName +
                            " (value: " + tagText + ")" );
                }
            }
            responseDoc.getWadlParams().add( wadlParam );
        }

        final Map<String, List<Tag>> tagsByStatus = getResponseRepresentationTags( methodDoc );
        for ( Entry<String, List<Tag>> entry : tagsByStatus.entrySet() ) {
            final RepresentationDocType representationDoc = new RepresentationDocType();
            representationDoc.setStatus( Long.valueOf( entry.getKey() ) );
            for ( Tag tag : entry.getValue() ) {
                if ( tag.name().endsWith( ".qname" ) ) {
                    representationDoc.setElement( QName.valueOf( tag.text() ) );
                }
                else if ( tag.name().endsWith( ".mediaType" ) ) {
                    representationDoc.setMediaType( tag.text() );
                }
                else if ( tag.name().endsWith( ".example" ) ) {
                    representationDoc.setExample( getSerializedExample( tag ) );
                }
                else if ( tag.name().endsWith( ".doc" ) ) {
                    representationDoc.setDoc( tag.text() );
                }
                else {
                    LOG.warning( "Unknown response representation tag " + tag.name() );
                }
            }
            responseDoc.getRepresentations().add( representationDoc );
        }
       
        methodDocType.setResponseDoc( responseDoc );
    }
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

    }

    private static void addResponseDoc( MethodDoc methodDoc,
            final MethodDocType methodDocType ) {
       
        final ResponseDocType responseDoc = new ResponseDocType();
       
        final Tag returnTag = getSingleTagOrNull( methodDoc, "return" );
        if ( returnTag != null ) {
            responseDoc.setReturnDoc( returnTag.text() );
        }
       
        final Tag[] responseParamTags = methodDoc.tags( "response.param" );
        for ( Tag responseParamTag : responseParamTags ) {
            // LOG.info( "Have responseparam tag: " + print( responseParamTag ) );
            final WadlParamType wadlParam = new WadlParamType();
            for ( Tag inlineTag : responseParamTag.inlineTags() ) {
                final String tagName = inlineTag.name();
                final String tagText = inlineTag.text();
                /* skip empty tags
                 */
                if ( isEmpty( tagText ) ) {
                    if ( LOG.isLoggable( Level.FINE ) ) {
                        LOG.fine( "Skipping empty inline tag of @response.param in method " +
                            methodDoc.qualifiedName() + ": " + tagName  );
                    }
                    continue;
                }
                if ( "@name".equals( tagName ) ) {
                    wadlParam.setName( tagText );
                }
                else if ( "@style".equals( tagName ) ) {
                    wadlParam.setStyle( tagText );
                }
                else if ( "@type".equals( tagName ) ) {
                    wadlParam.setType( QName.valueOf( tagText ) );
                }
                else if ( "@doc".equals( tagName ) ) {
                    wadlParam.setDoc( tagText );
                }
                else {
                    LOG.warning( "Unknown inline tag of @response.param in method " +
                            methodDoc.qualifiedName() + ": " + tagName +
                            " (value: " + tagText + ")" );
                }
            }
            responseDoc.getWadlParams().add( wadlParam );
        }

        final Map<String, List<Tag>> tagsByStatus = getResponseRepresentationTags( methodDoc );
        for ( Entry<String, List<Tag>> entry : tagsByStatus.entrySet() ) {
            final RepresentationDocType representationDoc = new RepresentationDocType();
            representationDoc.setStatus( Long.valueOf( entry.getKey() ) );
            for ( Tag tag : entry.getValue() ) {
                if ( tag.name().endsWith( ".qname" ) ) {
                    representationDoc.setElement( QName.valueOf( tag.text() ) );
                }
                else if ( tag.name().endsWith( ".mediaType" ) ) {
                    representationDoc.setMediaType( tag.text() );
                }
                else if ( tag.name().endsWith( ".example" ) ) {
                    representationDoc.setExample( getSerializedExample( tag ) );
                }
                else if ( tag.name().endsWith( ".doc" ) ) {
                    representationDoc.setDoc( tag.text() );
                }
                else {
                    LOG.warning( "Unknown response representation tag " + tag.name() );
                }
            }
            responseDoc.getRepresentations().add( representationDoc );
        }
       
        methodDocType.setResponseDoc( responseDoc );
    }
View Full Code Here

Examples of com.sun.jersey.server.wadl.generators.resourcedoc.model.ResponseDocType

     * @param m
     * @return
     * @see com.sun.jersey.server.impl.wadl.WadlGenerator#createResponse(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)
     */
    public Response createResponse( AbstractResource r, AbstractResourceMethod m ) {
        final ResponseDocType responseDoc = _resourceDoc.getResponse( r.getResourceClass(), m.getMethod() );
        final Response response;
        if ( responseDoc != null && responseDoc.hasRepresentations() ) {
            response = new Response();
           
            for ( RepresentationDocType representationDoc : responseDoc.getRepresentations() ) {
               
                final RepresentationType wadlRepresentation = new RepresentationType();
                wadlRepresentation.setElement( representationDoc.getElement() );
                wadlRepresentation.getStatus().add( representationDoc.getStatus() );
                wadlRepresentation.setMediaType( representationDoc.getMediaType() );
                addDocForExample( wadlRepresentation.getDoc(), representationDoc.getExample() );
                addDoc( wadlRepresentation.getDoc(), representationDoc.getDoc() );
               
                JAXBElement<RepresentationType> element = new JAXBElement<RepresentationType>(
                        new QName("http://research.sun.com/wadl/2006/10","representation"),
                        RepresentationType.class,
                        wadlRepresentation);
               
                response.getRepresentationOrFault().add(element);
            }
           
            return response;
        }
        else {
            response = _delegate.createResponse( r, m );
        }
       
        /* add response params from resourcedoc
         */
        if ( responseDoc != null && !responseDoc.getWadlParams().isEmpty() ) {
            for ( WadlParamType wadlParamType : responseDoc.getWadlParams() ) {
                final Param param = new Param();
                param.setName( wadlParamType.getName() );
                param.setStyle( ParamStyle.fromValue( wadlParamType.getStyle() ) );
                param.setType( wadlParamType.getType() );
                addDoc( param.getDoc(), wadlParamType.getDoc() );
                response.getParam().add( param );
            }
        }
       
        if ( responseDoc != null && !isEmpty( responseDoc.getReturnDoc() ) ) {
            addDoc( response.getDoc(), responseDoc.getReturnDoc() );
        }
       
        return response;
    }
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResponseDocType

     * @see org.glassfish.jersey.server.wadl.WadlGenerator#createResponses(org.glassfish.jersey.server.model.Resource,
     * org.glassfish.jersey.server.model.ResourceMethod)
     */
    public List<Response> createResponses(org.glassfish.jersey.server.model.Resource r,
                                          org.glassfish.jersey.server.model.ResourceMethod m) {
        final ResponseDocType responseDoc = resourceDoc.getResponse(m.getInvocable().getDefinitionMethod().getDeclaringClass(),
                m.getInvocable().getDefinitionMethod());
        List<Response> responses = new ArrayList<Response>();
        if (responseDoc != null && responseDoc.hasRepresentations()) {
            for (RepresentationDocType representationDoc : responseDoc.getRepresentations()) {
                Response response = new Response();

                final Representation wadlRepresentation = new Representation();
                wadlRepresentation.setElement(representationDoc.getElement());
                wadlRepresentation.setMediaType(representationDoc.getMediaType());
                addDocForExample(wadlRepresentation.getDoc(), representationDoc.getExample());
                addDoc(wadlRepresentation.getDoc(), representationDoc.getDoc());

                response.getStatus().add(representationDoc.getStatus());
                response.getRepresentation().add(wadlRepresentation);

                responses.add(response);
            }

            if (!responseDoc.getWadlParams().isEmpty()) {
                for (WadlParamType wadlParamType : responseDoc.getWadlParams()) {
                    final Param param = new Param();
                    param.setName(wadlParamType.getName());
                    param.setStyle(ParamStyle.fromValue(wadlParamType.getStyle()));
                    param.setType(wadlParamType.getType());
                    addDoc(param.getDoc(), wadlParamType.getDoc());
                    for (Response response : responses) {
                        response.getParam().add(param);
                    }
                }
            }

            if (!isEmpty(responseDoc.getReturnDoc())) {
                for (Response response : responses) {
                    addDoc(response.getDoc(), responseDoc.getReturnDoc());
                }
            }

        } else {
            responses = delegate.createResponses(r, m);
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResponseDocType

    }

    private static void addResponseDoc(MethodDoc methodDoc,
                                       final MethodDocType methodDocType) {

        final ResponseDocType responseDoc = new ResponseDocType();

        final Tag returnTag = getSingleTagOrNull(methodDoc, "return");
        if (returnTag != null) {
            responseDoc.setReturnDoc(returnTag.text());
        }

        final Tag[] responseParamTags = methodDoc.tags("response.param");
        for (Tag responseParamTag : responseParamTags) {
            // LOG.info( "Have responseparam tag: " + print( responseParamTag ) );
            final WadlParamType wadlParam = new WadlParamType();
            for (Tag inlineTag : responseParamTag.inlineTags()) {
                final String tagName = inlineTag.name();
                final String tagText = inlineTag.text();
                /* skip empty tags
                 */
                if (isEmpty(tagText)) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Skipping empty inline tag of @response.param in method " +
                                methodDoc.qualifiedName() + ": " + tagName);
                    }
                    continue;
                }
                if ("@name".equals(tagName)) {
                    wadlParam.setName(tagText);
                } else if ("@style".equals(tagName)) {
                    wadlParam.setStyle(tagText);
                } else if ("@type".equals(tagName)) {
                    wadlParam.setType(QName.valueOf(tagText));
                } else if ("@doc".equals(tagName)) {
                    wadlParam.setDoc(tagText);
                } else {
                    LOG.warning("Unknown inline tag of @response.param in method " +
                            methodDoc.qualifiedName() + ": " + tagName +
                            " (value: " + tagText + ")");
                }
            }
            responseDoc.getWadlParams().add(wadlParam);
        }

        final Map<String, List<Tag>> tagsByStatus = getResponseRepresentationTags(methodDoc);
        for (Entry<String, List<Tag>> entry : tagsByStatus.entrySet()) {
            final RepresentationDocType representationDoc = new RepresentationDocType();
            representationDoc.setStatus(Long.valueOf(entry.getKey()));
            for (Tag tag : entry.getValue()) {
                if (tag.name().endsWith(".qname")) {
                    representationDoc.setElement(QName.valueOf(tag.text()));
                } else if (tag.name().endsWith(".mediaType")) {
                    representationDoc.setMediaType(tag.text());
                } else if (tag.name().endsWith(".example")) {
                    representationDoc.setExample(getSerializedExample(tag));
                } else if (tag.name().endsWith(".doc")) {
                    representationDoc.setDoc(tag.text());
                } else {
                    LOG.warning("Unknown response representation tag " + tag.name());
                }
            }
            responseDoc.getRepresentations().add(representationDoc);
        }

        methodDocType.setResponseDoc(responseDoc);
    }
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResponseDocType

    }

    private static void addResponseDoc(final MethodDoc methodDoc,
                                       final MethodDocType methodDocType) {

        final ResponseDocType responseDoc = new ResponseDocType();

        final Tag returnTag = getSingleTagOrNull(methodDoc, "return");
        if (returnTag != null) {
            responseDoc.setReturnDoc(returnTag.text());
        }

        final Tag[] responseParamTags = methodDoc.tags("response.param");
        for (final Tag responseParamTag : responseParamTags) {
            // LOG.info( "Have responseparam tag: " + print( responseParamTag ) );
            final WadlParamType wadlParam = new WadlParamType();
            for (final Tag inlineTag : responseParamTag.inlineTags()) {
                final String tagName = inlineTag.name();
                final String tagText = inlineTag.text();
                /* skip empty tags
                 */
                if (isEmpty(tagText)) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Skipping empty inline tag of @response.param in method " +
                                methodDoc.qualifiedName() + ": " + tagName);
                    }
                    continue;
                }
                switch (tagName) {
                    case "@name":
                        wadlParam.setName(tagText);
                        break;
                    case "@style":
                        wadlParam.setStyle(tagText);
                        break;
                    case "@type":
                        wadlParam.setType(QName.valueOf(tagText));
                        break;
                    case "@doc":
                        wadlParam.setDoc(tagText);
                        break;
                    default:
                        LOG.warning("Unknown inline tag of @response.param in method " +
                                methodDoc.qualifiedName() + ": " + tagName +
                                " (value: " + tagText + ")");
                        break;
                }
            }
            responseDoc.getWadlParams().add(wadlParam);
        }

        final Map<String, List<Tag>> tagsByStatus = getResponseRepresentationTags(methodDoc);
        for (final Entry<String, List<Tag>> entry : tagsByStatus.entrySet()) {
            final RepresentationDocType representationDoc = new RepresentationDocType();
            representationDoc.setStatus(Long.valueOf(entry.getKey()));
            for (final Tag tag : entry.getValue()) {
                if (tag.name().endsWith(".qname")) {
                    representationDoc.setElement(QName.valueOf(tag.text()));
                } else if (tag.name().endsWith(".mediaType")) {
                    representationDoc.setMediaType(tag.text());
                } else if (tag.name().endsWith(".example")) {
                    representationDoc.setExample(getSerializedExample(tag));
                } else if (tag.name().endsWith(".doc")) {
                    representationDoc.setDoc(tag.text());
                } else {
                    LOG.warning("Unknown response representation tag " + tag.name());
                }
            }
            responseDoc.getRepresentations().add(representationDoc);
        }

        methodDocType.setResponseDoc(responseDoc);
    }
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.