/** * @param rmd see {@link ResourceMethodDescriptor} * @param wadlResourceParams for adding parameters which must be in parent * @return {@link org.exoplatform.services.rest.wadl.research.Request} */ private org.exoplatform.services.rest.wadl.research.Request processRequest( ResourceMethodDescriptor rmd, Map<String, Param> wadlResourceParams) { org.exoplatform.services.rest.wadl.research.Request wadlRequest = wadlGenerator.createRequest(); for (MethodParameter methodParameter : rmd.getMethodParameters()) { if (methodParameter.getAnnotation() == null) { for (MediaType mediaType : rmd.consumes()) { RepresentationType wadlRepresentation = wadlGenerator.createRequestRepresentation(mediaType); wadlRequest.getRepresentation().add(wadlRepresentation); } } Param wadlParam = processParam(methodParameter); if (wadlParam != null) { if (wadlParam.getStyle() == ParamStyle.QUERY || wadlParam.getStyle() == ParamStyle.HEADER /* || wadlParam.getStyle() == ParamStyle.MATRIX */ ) { wadlRequest.getParam().add(wadlParam); } else { // If matrix or path template parameter then add in map for add in // parent element wadlResourceParams.put(wadlParam.getName(), wadlParam); } } } // NOTE If there are no any representation and parameters then request is // null. return wadlRequest.getRepresentation().isEmpty() && wadlRequest.getParam().isEmpty() ? null : wadlRequest; }
/** * @param rmd see {@link ResourceMethodDescriptor} * @return {@link org.exoplatform.services.rest.wadl.research.Response} */ private org.exoplatform.services.rest.wadl.research.Response processResponse( ResourceMethodDescriptor rmd) { org.exoplatform.services.rest.wadl.research.Response wadlResponse = null; if (rmd.getResponseType() != void.class) { wadlResponse = wadlGenerator.createResponse(); for (MediaType mediaType : rmd.produces()) { RepresentationType wadlRepresentation = wadlGenerator.createResponseRepresentation(mediaType); // Element can represent normal response or fault response JAXBElement<RepresentationType> wadlRepresentationElement = new JAXBElement<RepresentationType>( new QName("http://research.sun.com/wadl/2006/10", "representation"), RepresentationType.class, wadlRepresentation); wadlResponse.getRepresentationOrFault().add(wadlRepresentationElement); } } return wadlResponse; }