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);
}
Aggregations