Search in sources :

Example 11 with IncidentTree

use of org.opencastproject.job.api.IncidentTree 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

IncidentTree (org.opencastproject.job.api.IncidentTree)11 Incident (org.opencastproject.job.api.Incident)7 IncidentTreeImpl (org.opencastproject.job.api.IncidentTreeImpl)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)3 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Job (org.opencastproject.job.api.Job)2 JValue (com.entwinemedia.fn.data.json.JValue)1 File (java.io.File)1 URI (java.net.URI)1 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 Before (org.junit.Before)1 JobEndpointException (org.opencastproject.adminui.exception.JobEndpointException)1