Delete all notifications

@throws HttpException Throws an exception if the notification is not
found, or if it don't belongs to the logged in user
761508
public function actionDeleteAll()
    {
        $notificationsIds = Yii::$app->request->post('ids', []);

        foreach ($notificationsIds as $id) {
            $notification = $this->getNotification($id);

            $notification->delete();
        }

        return true;
    }
221316
public function deleteNotification(NotificationInterface $notification, $flush = false)
    {
        $this->om->remove($notification);
        $this->flush($flush);

        $event = new NotificationEvent($notification);
        $this->dispatcher->dispatch(MgiletNotificationEvents::DELETED, $event);
    }
603601
def closed(self, error=None):
        

        if self._application:
            try:
                self._application.closed(error)
            except Exception:
                # Ignore exceptions from the notification
                pass
1246835
private void cleanUpHistory() {
    long oldestAllowedTimestamp = System.currentTimeMillis() - historyLength;
    int trashedNotifications = 0;
    
    if (LOG.isDebugEnabled()) {
      LOG.debug("History cleanup: Checking old notifications to remove from history list ...");
    }
    
    HistoryTreeEntry key = new HistoryTreeEntry(oldestAllowedTimestamp, 0, (byte)0);
    int notificationsCount = 0;
    historyLock.writeLock().lock();
    try {
      notificationsCount = orderedHistoryList.size();
      LOG.warn("History cleanup: size of the history before cleanup: " + notificationsCount);

      if (!historyLimitDisabled && notificationsCount > historyLimit) {
        LOG.warn("History cleanup: Reached physical limit. Number of stored notifications: " + 
            notificationsCount + ". Clearing ...");
      }
      
      int index = Collections.binarySearch(orderedHistoryList, key, comparatorByTS);
      int toDeleteByTS = index >= 0 ? index : - (index + 1);
      int toDeleteByLimit = historyLimitDisabled ? 0 : notificationsCount - (int)historyLimit;
      toDeleteByLimit = toDeleteByLimit > 0 ? toDeleteByLimit : 0;
      
      int toDelete = Math.max(toDeleteByTS, toDeleteByLimit);
      
      // Delete items which are too old
      if (toDelete > 0) {
        LOG.warn("History cleanup: number of the history to cleanup: " + toDelete);
        for (int i = 0; i < toDelete; i++) {
          orderedHistoryList.get(i).removeFromTree();
        }
        
        orderedHistoryList.subList(0, toDelete).clear();
        
        if (toDeleteByLimit > toDeleteByTS) {
          // If we delete a notification because we don't have space left
          trashedNotifications ++;
        }
        notificationsCount = orderedHistoryList.size();
        LOG.warn("History cleanup: size of the history after cleanup: " + notificationsCount);
        
        // clean up history tree, remove the node that has no children and
        // no notifications associated with them.
        cleanUpHistoryTree(historyTree);
      }
      
    } finally {
      historyLock.writeLock().unlock();
    }
    
    core.getMetrics().trashedHistoryNotifications.inc(trashedNotifications);
    core.getMetrics().historySize.set(notificationsCount);
    core.getMetrics().historyQueues.set(historyQueuesCount);
  }
302579
public function delete()
	{
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        } else {
			$deleted = false;
			if($this->getRequestParameter('uri')){

				$role = $this->getCurrentInstance();

				if(!in_array($role->getUri(), $this->forbidden)){
						//check if no user is using this role:
						$userClass = $this->getClass(GenerisRdf::CLASS_GENERIS_USER);
						$options = array('recursive' => true, 'like' => false);
						$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
						$users = $userClass->searchInstances($filters, $options);
						if(empty($users)){
							//delete role here:
							$deleted = $this->getClassService()->removeRole($role);
						}else{
							//set message error
							throw new UserErrorException(__('This role is still given to one or more users. Please remove the role to these users first.'));
						}
				}else{
					throw new UserErrorException($role->getLabel() . ' could not be deleted');
				}
			}

			$this->returnJson(array('deleted' => $deleted));
		}
	}
1125630
public DeleteNotificationResponse deleteNotification(String name) {
        DeleteNotificationRequest request = new DeleteNotificationRequest();
        request.setName(name);
        return deleteNotification(request);
    }
1171031
public boolean removeNotificationListener(String mbeanName, NotificationListener listener) throws Exception {
        if (isConnected()) {
            ObjectName objectName = new ObjectName(mbeanName);
            mbsc.removeNotificationListener(objectName, listener, null, null);
            jmxc.removeConnectionNotificationListener(listener);
            return true;
        } else {
            return false;
        }
    }
444303
def NotificationsDelete(self, notification_id):
        
        if self.__SenseApiCall__('/notifications/{0}.json'.format(notification_id), 'DELETE'):
            return True
        else:
            self.__error__ = "api call unsuccessful"
            return False
560950
@Override
    public void removeNotificationHandler(String serviceName, NotificationHandler handler) throws ServiceException {

        if(! isStarted){
            ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_MANAGER_FACTORY_CLOSED);
            throw new ServiceException(error);
        }

        if(handler == null || serviceName == null || serviceName.isEmpty()){
            throw new IllegalArgumentException();
        }

        getLookupService().removeNotificationHandler(serviceName, handler);
    }
1193271
@Override
	public synchronized void deleteAlert(int alertId) throws DatabaseException {
        try {
			psDeleteAlert.setInt(1, alertId);
			psDeleteAlert.execute();
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
970432
public function actionClean()
	{
		$class = $this->module->notificationClass;

		// Delete all notifications seen or flashed
		$criteria = ['or', ['seen=1'], ['flashed=1']];

		// Delete old notification according to expiration time setting
		if ( $this->module->expirationTime > 0 ) {
			$criteria[] = ['<', 'created_at', time()-$this->module->expirationTime ];
		}

		$records_deleted = $class::deleteAll($criteria);

		echo "$records_deleted obsolete notifications removed\n";
	}
430707
public void removeListener(HttpListener listener)
    {
        if (listener==null)
            return;
        
        for (int l=0;l<_listeners.size();l++)
        {
            if (listener.equals(_listeners.get(l)))
            {
                _listeners.remove(l);
                removeComponent(listener);
                if (listener.isStarted())
                    try{listener.stop();}catch(InterruptedException e){log.warn(LogSupport.EXCEPTION,e);}
                listener.setHttpServer(null);
            }
        }
    }
749710
public synchronized void removeObserver(final String notification, final ApptentiveNotificationObserver observer) {
		final ApptentiveNotificationObserverList list = findObserverList(notification);
		if (list != null) {
			list.removeObserver(observer);
		}
	}
48546
public function deleteAll()
    {
        $responses = array();
        $notifications = self::paginatedList();
        if ($notifications['success']) {
            foreach ($notifications['response']['data'] as $notification) {
                $responses[] = self::delete($notification->uuid);
            }
        } else {
            return array($notifications);
        }
        return $responses;
    }
809253
def clean(self, *args, **kwargs):
        
        if self.from_user and self.from_user_id == self.to_user_id:
            raise ValidationError(_('A user cannot send a notification to herself/himself'))
415779
@Override
	public void removeBySent(boolean sent) {
		for (CommerceNotificationQueueEntry commerceNotificationQueueEntry : findBySent(
				sent, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceNotificationQueueEntry);
		}
	}
330195
def DeleteNotifications(self, session_ids, start=None, end=None):
    """"""
    if not session_ids:
      return

    for session_id in session_ids:
      if not isinstance(session_id, rdfvalue.SessionID):
        raise RuntimeError(
            "Can only delete notifications for rdfvalue.SessionIDs.")

    if start is None:
      start = 0
    else:
      start = int(start)

    if end is None:
      end = self.frozen_timestamp or rdfvalue.RDFDatetime.Now()

    for queue, ids in iteritems(
        collection.Group(session_ids, lambda session_id: session_id.Queue())):
      queue_shards = self.GetAllNotificationShards(queue)
      self.data_store.DeleteNotifications(queue_shards, ids, start, end)