* @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;
}