Search in sources :

Example 1 with Request

use of com.sun.research.ws.wadl.Request 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 Request

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

the class WadlBuilder method generateRequest.

private Request generateRequest(org.glassfish.jersey.server.model.Resource parentResource, final org.glassfish.jersey.server.model.ResourceMethod resourceMethod, Map<String, Param> wadlResourceParams) {
    try {
        final List<Parameter> requestParams = new LinkedList<>(resourceMethod.getInvocable().getParameters());
        // Adding handler instance parameters to the list of potential request parameters.
        requestParams.addAll(resourceMethod.getInvocable().getHandler().getParameters());
        if (requestParams.isEmpty()) {
            return null;
        }
        Request wadlRequest = _wadlGenerator.createRequest(parentResource, resourceMethod);
        processRequestParameters(parentResource, resourceMethod, wadlResourceParams, requestParams, wadlRequest);
        if (wadlRequest.getRepresentation().size() + wadlRequest.getParam().size() == 0) {
            return null;
        } else {
            return wadlRequest;
        }
    } catch (Exception e) {
        throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_REQUEST(resourceMethod, parentResource), e);
    }
}
Also used : Request(com.sun.research.ws.wadl.Request) Parameter(org.glassfish.jersey.server.model.Parameter) LinkedList(java.util.LinkedList) ProcessingException(javax.ws.rs.ProcessingException) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

Request (com.sun.research.ws.wadl.Request)2 ProcessingException (javax.ws.rs.ProcessingException)2 Response (com.sun.research.ws.wadl.Response)1 LinkedList (java.util.LinkedList)1 Parameter (org.glassfish.jersey.server.model.Parameter)1