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);
}
}
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;
}
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;
}
Aggregations