Search in sources :

Example 1 with JaxbIncidentFullTree

use of org.opencastproject.job.api.JaxbIncidentFullTree 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);
    }
}
Also used : JaxbIncidentFullTree(org.opencastproject.job.api.JaxbIncidentFullTree) WebApplicationException(javax.ws.rs.WebApplicationException) IncidentServiceException(org.opencastproject.serviceregistry.api.IncidentServiceException) MediaType(javax.ws.rs.core.MediaType) JaxbIncidentTree(org.opencastproject.job.api.JaxbIncidentTree) IncidentTree(org.opencastproject.job.api.IncidentTree) JaxbIncidentTree(org.opencastproject.job.api.JaxbIncidentTree) 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 IncidentTree (org.opencastproject.job.api.IncidentTree)1 JaxbIncidentFullTree (org.opencastproject.job.api.JaxbIncidentFullTree)1 JaxbIncidentTree (org.opencastproject.job.api.JaxbIncidentTree)1 IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)1 RestQuery (org.opencastproject.util.doc.rest.RestQuery)1