use of org.opennms.netmgt.model.outage.OutageSummaryCollection in project opennms by OpenNMS.
the class OutageRestService method getOutage.
/**
* <p>getOutage</p>
*
* @param outageId a {@link java.lang.String} object.
* @return a {@link org.opennms.netmgt.model.OnmsOutage} object.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Path("{outageId}")
@Transactional
public Response getOutage(@Context final UriInfo uriInfo, @PathParam("outageId") final String outageId) {
if ("summaries".equals(outageId)) {
final MultivaluedMap<String, String> parms = uriInfo.getQueryParameters(true);
int limit = 10;
if (parms.containsKey("limit")) {
limit = Integer.parseInt(parms.getFirst("limit"));
}
final List<OutageSummary> collection = m_outageDao.getNodeOutageSummaries(limit);
return collection == null ? Response.status(Status.NOT_FOUND).build() : Response.ok(new OutageSummaryCollection(collection)).build();
} else {
final OnmsOutage outage = m_outageDao.get(Integer.valueOf(outageId));
return outage == null ? Response.status(Status.NOT_FOUND).build() : Response.ok(outage).build();
}
}
Aggregations