Check that each emitted notification is properly described by its source.
547567
private void checkUndefinedNotification(Notification notification) {
        String type = notification.getType();
        PathAddress source = notification.getSource();
        Map<String, NotificationEntry> descriptions = getRootResourceRegistration().getNotificationDescriptions(source, true);
        if (!descriptions.keySet().contains(type)) {
            missingNotificationDescriptionWarnings.add(ControllerLogger.ROOT_LOGGER.notificationIsNotDescribed(type, source));
        }
    }
404629
def _emit(self, s):
    """"""
    if os.path.exists(self._html_dir):  # Make sure we're not immediately after a clean-all.
      self._report_file.write(s)
      self._report_file.flush()
966637
def notify(self, data):
        """"""
        for filter_function in self._filters:
            if not filter_function(data):
                return False
        self._notify(data)
        return True
725392
def check_alerts(self):
        """"""

        alerted = []

        for alert_time, task in self.alerts.items():
            task_time = dateutil.parser.parse(alert_time)
            if task_time < get_time():
                self.log('Alerting about task now:', task)

                address = objectmodels['user'].find_one({'uuid': task.owner}).mail
                subject = "Task alert: %s" % task.name
                text = """Task alert is due:\n%s""" % task.notes

                self.fireEvent(send_mail(address, subject, text))

                alerted.append(task.alert_time)

        for item in alerted:
            del self.alerts[item]
32912
private void notificationCallback(Notification notification) {
    if (notification instanceof MetricContextCleanupNotification) {
      removedMetricContext(((MetricContextCleanupNotification) notification).getMetricContext());
    }
    if (notification instanceof NewMetricContextNotification) {
      newMetricContext(((NewMetricContextNotification) notification).getMetricContext());
    }
  }
429251
def show
      notification = Notification.find_by(id: params[:id])
      activity     = notification.activity

      notification.mark_as_read if notification.unread?

      redirect_to activity_activities_path(activity_id: activity.id)
    end
630154
protected void notifyListeners()
   {
      synchronized (listeners)
      {
         Thread notifier = new NotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this);
         notifier.start();
      }
   }
244128
def _Notify(username, notification_type, message, object_reference):
  """"""

  # Do not try to notify system users (e.g. Cron).
  if username in aff4_users.GRRUser.SYSTEM_USERS:
    return

  if object_reference:
    uc = object_reference.UnionCast()
    if hasattr(uc, "client_id"):
      message = _HostPrefix(uc.client_id) + message

  n = rdf_objects.UserNotification(
      username=username,
      notification_type=notification_type,
      state=rdf_objects.UserNotification.State.STATE_PENDING,
      message=message,
      reference=object_reference)
  data_store.REL_DB.WriteUserNotification(n)
661110
public void onNotificationsResumed() {
        isNotificationsPaused = false;

        // If there are notifications during pause
        if (notificationsDuringPause.size() > 0) {

            if (isAppVisible) {
                if (visiblePeer != null && notificationsDuringPause.containsKey(visiblePeer)) {

                    // If there was message from visible chat
                    if (isMobilePlatform) {

                        // Playing sound effects for mobile platforms
                        playEffectIfEnabled();
                    } else {

                        // Don't play sounds in chat on non-mobile platforms
                    }
                } else {

                    // If there are no messages from visible peer
                    if (isMobilePlatform) {

                        // Don't play sounds not from current chat on mobile platforms
                    } else {

                        // Find any suitable peer and if found play sound effect
                        for (Peer p : notificationsDuringPause.keySet()) {

                            if (isNotificationsEnabled(p, notificationsDuringPause.get(p))) {
                                playEffectIfEnabled();
                                break; // Can't do return because we need to make more work later
                            }
                        }
                    }
                }
            } else {

                // Just show out-app notification
                for (Peer p : notificationsDuringPause.keySet()) {

                    if (isNotificationsEnabled(p, notificationsDuringPause.get(p))) {
                        showNotification();
                        break;
                    }
                }
            }

            // Clearing of notifications
            notificationsDuringPause.clear();
        }
    }
472624
def prepare_notification(self, *, subscribers=None, instance=None,
                             loop=None, notify_external=True):
        """"""
        # merge callbacks added to the class level with those added to the
        # instance, giving the formers precedence while preserving overall
        # order
        self_subscribers = self.subscribers.copy()
        # add in callbacks declared in the main class body and marked with
        # @handler
        if (instance is not None and self.name and
            isinstance(instance.__class__, SignalAndHandlerInitMeta)):
            class_handlers = type(instance)._get_class_handlers(
                self.name, instance)
            for ch in class_handlers:
                # eventual methods are ephemeral and normally the following
                # condition would always be True for methods but the dict used
                # has logic to take that into account
                if ch not in self_subscribers:
                    self_subscribers.append(ch)
        # add in the other instance level callbacks added at runtime
        if subscribers is not None:
            for el in subscribers:
                # eventual methods are ephemeral and normally the following
                # condition would always be True for methods but the dict used
                # has logic to take that into account
                if el not in self_subscribers:
                    self_subscribers.append(el)
        loop = loop or self.loop
        # maybe do a round of external publishing
        if notify_external and self.external_signaller is not None:
            self_subscribers.append(partial(self.ext_publish, instance, loop))
        if self._fnotify is None:
            fnotify = None
        else:
            if instance is None:
                fnotify = self._fnotify
            else:
                fnotify = types.MethodType(self._fnotify, instance)
        validator = self._fvalidation
        if validator is not None and instance is not None:
            validator = types.MethodType(validator, instance)
        return Executor(self_subscribers, owner=self,
                        concurrent=SignalOptions.EXEC_CONCURRENT in self.flags,
                        loop=loop, exec_wrapper=fnotify,
                        fvalidation=validator)
1302082
def WriteUserNotification(self, notification):
    """"""
    if notification.username not in self.users:
      raise db.UnknownGRRUserError(notification.username)

    cloned_notification = notification.Copy()
    if not cloned_notification.timestamp:
      cloned_notification.timestamp = rdfvalue.RDFDatetime.Now()

    self.notifications_by_username.setdefault(cloned_notification.username,
                                              []).append(cloned_notification)
799157
def notifications(self):
        """"""
        self.__init()
        items = []
        for n in self._notifications:
            if "id" in n:
                url = "%s/%s" % (self.root, n['id'])
                items.append(self.Notification(url=url,
                                               securityHandler=self._securityHandler,
                                               proxy_url=self._proxy_url,
                                               proxy_port=self._proxy_port))
        return items
196496
public boolean hasSubscriptions(final Notification notification) {
        final ArrayList<Subscription> subscriptions = SUBSCRIPTION_MAP.get(notification.getClass());
        return subscriptions != null;
    }
676493
def _get_notifications_status(self, notifications):
        
        if notifications:
            size = len(notifications["activeNotifications"])
        else:
            size = 0
        status = self.status_notif if size > 0 else self.status_no_notif

        return (size, status)
872535
public void diagnostics() {
        log.finest("Thread count = " + threadCounter);
        if (threadCounter.get() > 0) {
            log.finest("Thread names:");
            synchronized (threadNames) {
                for (String name : threadNames) {
                    log.finest("\t" + name);
                }
            }
        }
    }
1142057
def validate_harvester_notifications(user):
    ''''''
    if not user.sysadmin:
        return []

    notifications = []

    # Only fetch required fields for notification serialization
    # Greatly improve performances and memory usage
    qs = HarvestSource.objects(validation__state=VALIDATION_PENDING)
    qs = qs.only('id', 'created_at', 'name')

    for source in qs:
        notifications.append((source.created_at, {
            'id': source.id,
            'name': source.name,
        }))

    return notifications
168070
async def listen_all_notifications(self, callback):
        
        everything = [noti.asdict() for noti in self.notifications]
        if len(everything) > 0:
            await self._methods["switchNotifications"](
                {"enabled": everything}, _consumer=callback
            )
        else:
            _LOGGER.debug("No notifications available for %s", self.name)