Search in sources :

Example 6 with NotificationFeedId

use of co.cask.cdap.proto.id.NotificationFeedId 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, 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

NotificationFeedId (co.cask.cdap.proto.id.NotificationFeedId)6 NotificationFeedException (co.cask.cdap.notifications.feeds.NotificationFeedException)3 NotificationFeedNotFoundException (co.cask.cdap.notifications.feeds.NotificationFeedNotFoundException)3 NotificationContext (co.cask.cdap.notifications.service.NotificationContext)2 NotificationFeedInfo (co.cask.cdap.proto.notification.NotificationFeedInfo)2 Type (java.lang.reflect.Type)2 Path (javax.ws.rs.Path)2 MetricValues (co.cask.cdap.api.metrics.MetricValues)1 StreamSizeNotification (co.cask.cdap.common.stream.notification.StreamSizeNotification)1 StreamWriterHeartbeat (co.cask.cdap.data.stream.service.heartbeat.StreamWriterHeartbeat)1 Queue (java.util.Queue)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 ExecutorService (java.util.concurrent.ExecutorService)1 Nullable (javax.annotation.Nullable)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 Cancellable (org.apache.twill.common.Cancellable)1