use of org.opencastproject.job.api.JaxbIncidentTree in project opencast by opencast.
the class IncidentServiceEndpoint method getIncidentsOfJobAsTree.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("job/{id}.{type:xml|json}")
@RestQuery(name = "incidentsofjobastree", description = "Returns the job incident for the job with the given identifier.", returnDescription = "Returns the job incident.", pathParameters = { @RestParameter(name = "id", isRequired = true, description = "The job identifier.", type = Type.INTEGER), @RestParameter(name = "type", isRequired = true, description = "The media type of the response [xml|json]", defaultValue = "xml", type = Type.STRING) }, restParameters = { @RestParameter(name = "cascade", isRequired = false, description = "Whether to show the cascaded incidents.", type = Type.BOOLEAN, defaultValue = "false"), @RestParameter(name = "format", isRequired = false, description = "The response format [full|digest|sys]. Defaults to sys", defaultValue = "sys", type = Type.STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The job incident."), @RestResponse(responseCode = SC_NOT_FOUND, description = "No job incident with this identifier was found.") })
public Response getIncidentsOfJobAsTree(@Context HttpServletRequest request, @PathParam("id") final long jobId, @QueryParam("cascade") @DefaultValue("false") boolean cascade, @QueryParam("format") @DefaultValue(FMT_DEFAULT) final String format, @PathParam("type") final String type) throws NotFoundException {
try {
final IncidentTree tree = svc.getIncidentsOfJob(jobId, cascade);
final MediaType mt = getResponseType(type);
if (eq(FMT_SYS, format)) {
return ok(mt, new JaxbIncidentTree(tree));
} else if (eq(FMT_DIGEST, format)) {
return ok(mt, new JaxbIncidentFullTree(svc, request.getLocale(), tree));
} else if (eq(FMT_FULL, format)) {
return ok(mt, new JaxbIncidentFullTree(svc, request.getLocale(), tree));
} else {
return unknownFormat();
}
} catch (IncidentServiceException e) {
logger.warn("Unable to get job incident for id {}: {}", jobId, e.getMessage());
throw new WebApplicationException(INTERNAL_SERVER_ERROR);
}
}
Aggregations