Search in sources :

Example 1 with RecordingStateUpdate

use of org.opencastproject.capture.admin.impl.RecordingStateUpdate in project opencast by opencast.

the class CaptureAgentStateRestService method getAllRecordings.

@GET
@Produces(MediaType.TEXT_XML)
@Path("recordings")
@RestQuery(name = "getAllRecordings", description = "Return all registered recordings and their state", pathParameters = {}, restParameters = {}, reponses = { @RestResponse(description = "Returns all known recordings.", responseCode = SC_OK) }, returnDescription = "")
public List<RecordingStateUpdate> getAllRecordings() {
    try {
        LinkedList<RecordingStateUpdate> update = new LinkedList<RecordingStateUpdate>();
        Map<String, Recording> data = schedulerService.getKnownRecordings();
        // Run through and build a map of updates (rather than states)
        for (Entry<String, Recording> e : data.entrySet()) {
            update.add(new RecordingStateUpdate(e.getValue()));
        }
        return update;
    } catch (SchedulerException e) {
        logger.debug("Unable to get all recordings: {}", ExceptionUtils.getStackTrace(e));
        throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : SchedulerException(org.opencastproject.scheduler.api.SchedulerException) WebApplicationException(javax.ws.rs.WebApplicationException) Recording(org.opencastproject.scheduler.api.Recording) RecordingStateUpdate(org.opencastproject.capture.admin.impl.RecordingStateUpdate) LinkedList(java.util.LinkedList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Example 2 with RecordingStateUpdate

use of org.opencastproject.capture.admin.impl.RecordingStateUpdate in project opencast by opencast.

the class CaptureAgentStateRestService method getRecordingState.

@GET
@Produces({ MediaType.TEXT_XML, MediaType.APPLICATION_JSON })
@Path("recordings/{id}.{type:xml|json|}")
@RestQuery(name = "getRecordingState", description = "Return the state of a given recording", pathParameters = { @RestParameter(description = "The ID of a given recording", isRequired = true, name = "id", type = Type.STRING), @RestParameter(description = "The Documenttype", isRequired = true, name = "type", type = Type.STRING) }, restParameters = {}, reponses = { @RestResponse(description = "Returns the state of the recording with the correct id", responseCode = SC_OK), @RestResponse(description = "The recording with the specified ID does not exist", responseCode = SC_NOT_FOUND) }, returnDescription = "")
public Response getRecordingState(@PathParam("id") String id, @PathParam("type") String type) throws NotFoundException {
    try {
        Recording rec = schedulerService.getRecordingState(id);
        logger.debug("Submitting state for recording {}", id);
        if ("json".equals(type)) {
            return Response.ok(new RecordingStateUpdate(rec)).type(MediaType.APPLICATION_JSON).build();
        } else {
            return Response.ok(new RecordingStateUpdate(rec)).type(MediaType.TEXT_XML).build();
        }
    } catch (SchedulerException e) {
        logger.debug("Unable to get recording state of {}: {}", id, ExceptionUtils.getStackTrace(e));
        return Response.serverError().build();
    }
}
Also used : SchedulerException(org.opencastproject.scheduler.api.SchedulerException) Recording(org.opencastproject.scheduler.api.Recording) RecordingStateUpdate(org.opencastproject.capture.admin.impl.RecordingStateUpdate) 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)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 RecordingStateUpdate (org.opencastproject.capture.admin.impl.RecordingStateUpdate)2 Recording (org.opencastproject.scheduler.api.Recording)2 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)2 RestQuery (org.opencastproject.util.doc.rest.RestQuery)2 LinkedList (java.util.LinkedList)1 WebApplicationException (javax.ws.rs.WebApplicationException)1