Search in sources :

Example 6 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project candlepin by candlepin.

the class OwnerResource method getEvents.

/**
 * Retrieves a list of Events for an Owner
 *
 * @return a list of Event objects
 * @httpcode 404
 * @httpcode 200
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{owner_key}/events")
@ApiOperation(notes = "Retrieves a list of Events for an Owner", value = "Get Events")
@ApiResponses({ @ApiResponse(code = 404, message = "Owner not found") })
public List<EventDTO> getEvents(@PathParam("owner_key") @Verify(Owner.class) String ownerKey) {
    Owner o = findOwnerByKey(ownerKey);
    List<Event> events = this.eventCurator.listMostRecent(FEED_LIMIT, o).list();
    List<EventDTO> eventDTOs = null;
    if (events != null) {
        eventAdapter.addMessageText(events);
        eventDTOs = new ArrayList<>();
        for (Event event : events) {
            eventDTOs.add(this.translator.translate(event, EventDTO.class));
        }
    }
    return eventDTOs;
}
Also used : Owner(org.candlepin.model.Owner) EventDTO(org.candlepin.dto.api.v1.EventDTO) Event(org.candlepin.audit.Event) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

EventDTO (org.candlepin.dto.api.v1.EventDTO)5 Event (org.candlepin.audit.Event)4 ApiOperation (io.swagger.annotations.ApiOperation)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 ApiResponses (io.swagger.annotations.ApiResponses)2 Path (javax.ws.rs.Path)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 EventAdapter (org.candlepin.audit.EventAdapter)1 CandlepinQuery (org.candlepin.model.CandlepinQuery)1 Consumer (org.candlepin.model.Consumer)1 DeletedConsumer (org.candlepin.model.DeletedConsumer)1 Owner (org.candlepin.model.Owner)1 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)1 Event (org.opennms.netmgt.xml.eventconf.Event)1 EventDTO (org.opennms.web.rest.model.v2.EventDTO)1