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);
}
}
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();
}
}
Aggregations