Search in sources :

Example 1 with Response

use of com.sun.research.ws.wadl.Response in project jersey by jersey.

the class WadlBuilder method generateMethod.

private com.sun.research.ws.wadl.Method generateMethod(final org.glassfish.jersey.server.model.Resource parentResource, final Map<String, Param> wadlResourceParams, final org.glassfish.jersey.server.model.ResourceMethod resourceMethod) {
    try {
        if (!detailedWadl && resourceMethod.isExtended()) {
            return null;
        }
        com.sun.research.ws.wadl.Method wadlMethod = _wadlGenerator.createMethod(parentResource, resourceMethod);
        // generate the request part
        Request wadlRequest = generateRequest(parentResource, resourceMethod, wadlResourceParams);
        if (wadlRequest != null) {
            wadlMethod.setRequest(wadlRequest);
        }
        // generate the response part
        final List<Response> responses = generateResponses(parentResource, resourceMethod);
        if (responses != null) {
            wadlMethod.getResponse().addAll(responses);
        }
        return wadlMethod;
    } catch (Exception e) {
        throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_METHOD(resourceMethod, parentResource), e);
    }
}
Also used : Response(com.sun.research.ws.wadl.Response) Request(com.sun.research.ws.wadl.Request) ProcessingException(javax.ws.rs.ProcessingException) ProcessingException(javax.ws.rs.ProcessingException)

Example 2 with Response

use of com.sun.research.ws.wadl.Response in project jersey by jersey.

the class WadlGeneratorResourceDocSupport method createResponses.

/**
     * @param r Jersey resource component.
     * @param m resource method.
     * @return the enhanced {@link com.sun.research.ws.wadl.Response}.
     * @see org.glassfish.jersey.server.wadl.WadlGenerator#createResponses(org.glassfish.jersey.server.model.Resource,
     * org.glassfish.jersey.server.model.ResourceMethod)
     */
public List<Response> createResponses(final org.glassfish.jersey.server.model.Resource r, final 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 (final RepresentationDocType representationDoc : responseDoc.getRepresentations()) {
            final 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 (final 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 (final Response response : responses) {
                    response.getParam().add(param);
                }
            }
        }
        if (!isEmpty(responseDoc.getReturnDoc())) {
            for (final Response response : responses) {
                addDoc(response.getDoc(), responseDoc.getReturnDoc());
            }
        }
    } else {
        responses = delegate.createResponses(r, m);
    }
    return responses;
}
Also used : Response(com.sun.research.ws.wadl.Response) WadlParamType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.WadlParamType) ResponseDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResponseDocType) ArrayList(java.util.ArrayList) Param(com.sun.research.ws.wadl.Param) Representation(com.sun.research.ws.wadl.Representation) RepresentationDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.RepresentationDocType)

Example 3 with Response

use of com.sun.research.ws.wadl.Response in project jersey by jersey.

the class WadlGeneratorImpl method createResponses.

@Override
public List<Response> createResponses(org.glassfish.jersey.server.model.Resource r, ResourceMethod m) {
    final Response response = new Response();
    // add mediaType="*/*" in case that no mediaType was specified
    if (hasEmptyProducibleMediaTypeSet(m)) {
        Representation wadlRepresentation = createResponseRepresentation(r, m, MediaType.WILDCARD_TYPE);
        response.getRepresentation().add(wadlRepresentation);
    } else {
        for (MediaType mediaType : m.getProducedTypes()) {
            Representation wadlRepresentation = createResponseRepresentation(r, m, mediaType);
            response.getRepresentation().add(wadlRepresentation);
        }
    }
    List<Response> responses = new ArrayList<Response>();
    responses.add(response);
    return responses;
}
Also used : Response(com.sun.research.ws.wadl.Response) ArrayList(java.util.ArrayList) MediaType(javax.ws.rs.core.MediaType) Representation(com.sun.research.ws.wadl.Representation)

Aggregations

Response (com.sun.research.ws.wadl.Response)3 Representation (com.sun.research.ws.wadl.Representation)2 ArrayList (java.util.ArrayList)2 Param (com.sun.research.ws.wadl.Param)1 Request (com.sun.research.ws.wadl.Request)1 ProcessingException (javax.ws.rs.ProcessingException)1 MediaType (javax.ws.rs.core.MediaType)1 RepresentationDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.RepresentationDocType)1 ResponseDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResponseDocType)1 WadlParamType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.WadlParamType)1