use of org.opencastproject.capture.admin.api.AgentStateUpdate in project opencast by opencast.
the class CaptureAgentStateRestService method getKnownAgents.
@GET
@Produces({ MediaType.TEXT_XML, MediaType.APPLICATION_JSON })
@Path("agents.{type:xml|json}")
@RestQuery(name = "getKnownAgents", description = "Return all of the known capture agents on the system", pathParameters = { @RestParameter(description = "The Document type", isRequired = true, name = "type", type = Type.STRING) }, restParameters = {}, reponses = { @RestResponse(description = "An XML representation of the agent capabilities", responseCode = SC_OK) }, returnDescription = "")
public Response getKnownAgents(@PathParam("type") String type) {
if (service == null)
return Response.serverError().status(Response.Status.SERVICE_UNAVAILABLE).build();
logger.debug("Returning list of known agents...");
LinkedList<AgentStateUpdate> update = new LinkedList<AgentStateUpdate>();
Map<String, Agent> data = service.getKnownAgents();
logger.debug("Agents: {}", data);
// Run through and build a map of updates (rather than states)
for (Entry<String, Agent> e : data.entrySet()) {
update.add(new AgentStateUpdate(e.getValue()));
}
if ("json".equals(type)) {
return Response.ok(new AgentStateUpdateList(update)).type(MediaType.APPLICATION_JSON).build();
} else {
return Response.ok(new AgentStateUpdateList(update)).type(MediaType.TEXT_XML).build();
}
}
use of org.opencastproject.capture.admin.api.AgentStateUpdate in project opencast by opencast.
the class AgentStateUpdateTest method setUp.
@Before
public void setUp() throws InterruptedException {
agent = new AgentImpl("test", DefaultOrganization.DEFAULT_ORGANIZATION_ID, IDLE, "", null);
Assert.assertNotNull(agent);
Thread.sleep(5);
asu = new AgentStateUpdate(agent);
Assert.assertNotNull(asu);
}
use of org.opencastproject.capture.admin.api.AgentStateUpdate in project opencast by opencast.
the class AgentStateUpdateTest method blank.
@Test
public // This is a stupid test, but it gets us up to 100%...
void blank() {
asu = new AgentStateUpdate();
Assert.assertNotNull(asu);
Assert.assertNull(asu.getName());
Assert.assertNull(asu.getState());
Assert.assertNull(asu.getTimeSinceLastUpdate());
}
use of org.opencastproject.capture.admin.api.AgentStateUpdate in project opencast by opencast.
the class CaptureAgentStateRestService method getAgentState.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("agents/{name}.{format:xml|json}")
@RestQuery(name = "getAgent", description = "Return the state of a given capture agent", pathParameters = { @RestParameter(name = "name", description = "Name of the capture agent", isRequired = true, type = Type.STRING), @RestParameter(name = "format", description = "The output format (json or xml) of the response body.", isRequired = true, type = RestParameter.Type.STRING) }, restParameters = {}, reponses = { @RestResponse(description = "{agentState}", responseCode = SC_OK), @RestResponse(description = "The agent {agentName} does not exist", responseCode = SC_NOT_FOUND), @RestResponse(description = "If the {format} is not xml or json", responseCode = SC_METHOD_NOT_ALLOWED), @RestResponse(description = "iCapture agent state service unavailable", responseCode = SC_SERVICE_UNAVAILABLE) }, returnDescription = "")
public Response getAgentState(@PathParam("name") String agentName, @PathParam("format") String format) throws NotFoundException {
if (service == null)
return Response.serverError().status(Response.Status.SERVICE_UNAVAILABLE).build();
Agent ret = service.getAgent(agentName);
logger.debug("Returning agent state for {}", agentName);
if ("json".equals(format)) {
return Response.ok(new AgentStateUpdate(ret)).type(MediaType.APPLICATION_JSON).build();
} else {
return Response.ok(new AgentStateUpdate(ret)).type(MediaType.APPLICATION_XML).build();
}
}
Aggregations