use of org.opencastproject.job.api.JaxbIncidentFullList in project opencast by opencast.
the class IncidentServiceEndpoint method getIncidentsOfJobAsList.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("job/incidents.{type:xml|json}")
@RestQuery(name = "incidentsofjobaslist", description = "Returns the job incidents with the given identifiers.", returnDescription = "Returns the job incidents.", pathParameters = { @RestParameter(name = "type", isRequired = true, description = "The media type of the response [xml|json]", defaultValue = "xml", type = Type.STRING) }, restParameters = { @RestParameter(name = "id", isRequired = true, description = "The job identifiers.", type = Type.INTEGER), @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 incidents.") })
public Response getIncidentsOfJobAsList(@Context HttpServletRequest request, @QueryParam("id") final List<Long> jobIds, @QueryParam("format") @DefaultValue(FMT_DEFAULT) final String format, @PathParam("type") final String type) {
try {
final List<Incident> incidents = svc.getIncidentsOfJob(jobIds);
final MediaType mt = getResponseType(type);
if (eq(FMT_SYS, format)) {
return ok(mt, new JaxbIncidentList(incidents));
} else if (eq(FMT_DIGEST, format)) {
return ok(mt, new JaxbIncidentDigestList(svc, request.getLocale(), incidents));
} else if (eq(FMT_FULL, format)) {
return ok(mt, new JaxbIncidentFullList(svc, request.getLocale(), incidents));
} else {
return unknownFormat();
}
} catch (NotFoundException e) {
// should not happen
logger.error("Unable to get job incident for id {}! Consistency issue!");
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
} catch (IncidentServiceException e) {
logger.warn("Unable to get job incident for id {}: {}", jobIds, e.getMessage());
throw new WebApplicationException(INTERNAL_SERVER_ERROR);
}
}
Aggregations