Search in sources :

Example 1 with FeedInitializationChangeEvent

use of com.thinkbiganalytics.metadata.rest.model.event.FeedInitializationChangeEvent in project kylo by Teradata.

the class FeedsController method putInitializationStatus.

@PUT
@Path("{id}/initstatus")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation("Sets the registration status for the specified feed.")
@ApiResponses({ @ApiResponse(code = 204, message = "The registration status was updated."), @ApiResponse(code = 404, message = "The feed could not be found.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "The registration status could not be updated.", response = RestResponseStatus.class) })
public void putInitializationStatus(@PathParam("id") String feedIdStr, InitializationStatus status) {
    LOG.debug("Get feed initialization status {}", feedIdStr);
    // TODO Move behavior to a service?
    this.metadata.commit(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID feedId = feedProvider.resolveFeed(feedIdStr);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(feedId);
        if (feed != null) {
            com.thinkbiganalytics.metadata.api.feed.InitializationStatus.State newState = com.thinkbiganalytics.metadata.api.feed.InitializationStatus.State.valueOf(status.getState().name());
            feed.updateInitStatus(new com.thinkbiganalytics.metadata.api.feed.InitializationStatus(newState));
        } else {
            throw new WebApplicationException("A feed with the given ID does not exist: " + feedId, Status.NOT_FOUND);
        }
    });
    FeedInitializationChangeEvent event = new FeedInitializationChangeEvent(feedIdStr, status.getState());
    this.jmsMessagingTemplate.convertAndSend(this.initStatusChangeTopic, event);
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) InitializationStatus(com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus) FeedInitializationChangeEvent(com.thinkbiganalytics.metadata.rest.model.event.FeedInitializationChangeEvent) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

FeedInitializationChangeEvent (com.thinkbiganalytics.metadata.rest.model.event.FeedInitializationChangeEvent)1 Feed (com.thinkbiganalytics.metadata.rest.model.feed.Feed)1 InitializationStatus (com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1