@Override public NotificationResult findNotificationsAfterEpoch(String notificationManagerUri,Long epoch) { NotificationResult ret = api.findNotificationsAfterEpoch(callingCtx, notificationManagerUri, epoch); return ret; }
@Override public Long getLatestNotificationEpoch(String notificationManagerUri) { Long ret = api.getLatestNotificationEpoch(callingCtx, notificationManagerUri); return ret; }
@Override public NotificationInfo getNotification(String notificationUri,String id) { NotificationInfo ret = api.getNotification(callingCtx, notificationUri, id); return ret; }
@Override public String publishNotification(String notificationManagerUri,String referenceId,String content,String contentType) { String ret = api.publishNotification(callingCtx, notificationManagerUri, referenceId, content, contentType); return ret; }
@Override public RaptureNotificationConfig getNotificationManagerConfig(String notificationManagerUri) { RaptureNotificationConfig ret = api.getNotificationManagerConfig(callingCtx, notificationManagerUri); return ret; }
@Override public List<RaptureNotificationConfig> findNotificationManagerConfigsByPurpose(String purpose) { List<RaptureNotificationConfig> ret = api.findNotificationManagerConfigsByPurpose(callingCtx, purpose); return ret; }
@Override public void deleteNotificationManager(String notificationManagerUri) { api.deleteNotificationManager(callingCtx, notificationManagerUri); }
@Override public List<RaptureNotificationConfig> getNotificationManagerConfigs() { List<RaptureNotificationConfig> ret = api.getNotificationManagerConfigs(callingCtx); return ret; }
@Override public List<RaptureFolderInfo> listNotificationsByUriPrefix(String uriPrefix) { List<RaptureFolderInfo> ret = api.listNotificationsByUriPrefix(callingCtx, uriPrefix); return ret; }
@Override public RaptureNotificationConfig createNotificationManager(String notificationManagerUri,String config,String purpose) { RaptureNotificationConfig ret = api.createNotificationManager(callingCtx, notificationManagerUri, config, purpose); return ret; }
public void publishMessage(NotificationMessage msg) { String content = JacksonUtil.jsonFromObject(msg); String reference = msg.getMessageType(); notificationApi.publishNotification(context, notificationName, reference, content, NotificationType.STRING.toString()); }
public void run() { while (!shouldQuit) { try { NotificationResult result = notificationApi.findNotificationsAfterEpoch(context, notificationName, currentEpoch); currentEpoch = result.getCurrentEpoch(); for (String change : result.getReferences()) { handleReference(change); } } catch (RaptureException e) { resetApi(); } if (!shouldQuit) { try { sleep(1000); } catch (InterruptedException e) { } } } } }
public MessageNotificationManager(NotificationApiRetriever retriever, String notificationName) { this.retriever = retriever; this.notificationName = notificationName; resetApi(); currentEpoch = notificationApi.getLatestNotificationEpoch(context, notificationName); }
public void handleReference(String change) { // This change has occurred, do we need to signal someone? if (subscriptions.isEmpty()) { return; } NotificationInfo info = notificationApi.getNotification(context, notificationName, change); if (subscriptions.containsKey(info.getReference())) { Set<RaptureMessageListener<NotificationMessage>> refSubscriptions = subscriptions.get(info.getReference()); for (RaptureMessageListener<NotificationMessage> subscription : refSubscriptions) { try { NotificationMessage msg = JacksonUtil.objectFromJson(info.getContent(), NotificationMessage.class); subscription.signalMessage(msg); } catch (Exception e) { // at least acknowledge it log.debug(ExceptionToString.format(e)); } } } } }