Search in sources :

Example 1 with JaxbIncidentFullList

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);
    }
}
Also used : JaxbIncidentDigestList(org.opencastproject.job.api.JaxbIncidentDigestList) WebApplicationException(javax.ws.rs.WebApplicationException) IncidentServiceException(org.opencastproject.serviceregistry.api.IncidentServiceException) MediaType(javax.ws.rs.core.MediaType) JaxbIncidentList(org.opencastproject.job.api.JaxbIncidentList) NotFoundException(org.opencastproject.util.NotFoundException) JaxbIncident(org.opencastproject.job.api.JaxbIncident) Incident(org.opencastproject.job.api.Incident) JaxbIncidentFullList(org.opencastproject.job.api.JaxbIncidentFullList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 MediaType (javax.ws.rs.core.MediaType)1 Incident (org.opencastproject.job.api.Incident)1 JaxbIncident (org.opencastproject.job.api.JaxbIncident)1 JaxbIncidentDigestList (org.opencastproject.job.api.JaxbIncidentDigestList)1 JaxbIncidentFullList (org.opencastproject.job.api.JaxbIncidentFullList)1 JaxbIncidentList (org.opencastproject.job.api.JaxbIncidentList)1 IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)1 NotFoundException (org.opencastproject.util.NotFoundException)1 RestQuery (org.opencastproject.util.doc.rest.RestQuery)1