Search in sources :

Example 1 with OutageSummaryCollection

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();
    }
}
Also used : OutageSummaryCollection(org.opennms.netmgt.model.outage.OutageSummaryCollection) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OutageSummary(org.opennms.netmgt.model.outage.OutageSummary) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)1 OutageSummary (org.opennms.netmgt.model.outage.OutageSummary)1 OutageSummaryCollection (org.opennms.netmgt.model.outage.OutageSummaryCollection)1 Transactional (org.springframework.transaction.annotation.Transactional)1