Search in sources :

Example 6 with NotificationFeedNotFoundException

use of co.cask.cdap.notifications.feeds.NotificationFeedNotFoundException in project cdap by caskdata.

the class NotificationFeedHttpHandler method getFeed.

@GET
@Path("/feeds/categories/{feed-category}/names/{feed-name}")
public void getFeed(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("feed-category") String category, @PathParam("feed-name") String name) {
    try {
        NotificationFeedId feed;
        try {
            feed = new NotificationFeedId(namespaceId, category, name);
        } catch (IllegalArgumentException e) {
            responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
            return;
        }
        responder.sendJson(HttpResponseStatus.OK, GSON.toJson(feedManager.getFeed(feed)));
    } catch (NotificationFeedNotFoundException e) {
        responder.sendStatus(HttpResponseStatus.NOT_FOUND);
    } catch (NotificationFeedException e) {
        responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, String.format("Could not check subscribe permission for Notification Feed. %s", e.getMessage()));
    } catch (Throwable t) {
        LOG.debug("Error in getting notification feed.", t);
        responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, t.getMessage());
    }
}
Also used : NotificationFeedException(co.cask.cdap.notifications.feeds.NotificationFeedException) NotificationFeedId(co.cask.cdap.proto.id.NotificationFeedId) NotificationFeedNotFoundException(co.cask.cdap.notifications.feeds.NotificationFeedNotFoundException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

NotificationFeedException (co.cask.cdap.notifications.feeds.NotificationFeedException)6 NotificationFeedNotFoundException (co.cask.cdap.notifications.feeds.NotificationFeedNotFoundException)6 NotificationFeedId (co.cask.cdap.proto.id.NotificationFeedId)2 NotificationFeedInfo (co.cask.cdap.proto.notification.NotificationFeedInfo)2 HttpResponse (co.cask.common.http.HttpResponse)2 Path (javax.ws.rs.Path)2 CloseableIterator (co.cask.cdap.api.dataset.lib.CloseableIterator)1 RetryableException (co.cask.cdap.api.retry.RetryableException)1 RetryStrategy (co.cask.cdap.common.service.RetryStrategy)1 MessageFetcher (co.cask.cdap.messaging.MessageFetcher)1 RawMessage (co.cask.cdap.messaging.data.RawMessage)1 NotificationException (co.cask.cdap.notifications.service.NotificationException)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 Cancellable (org.apache.twill.common.Cancellable)1