Sends an email to user and admin with information on suspension and when user will be reinstated.

@param  context    Notification context of the warden notifier
@param  subSystem  The sub system user has been suspended from
341398
protected void sendWardenEmailToUser(NotificationContext context, SubSystem subSystem) {
        EntityManager em = emf.get();
        PrincipalUser user = getWardenUser(context.getAlert().getName());
        SuspensionRecord record = SuspensionRecord.findByUserAndSubsystem(em, user, subSystem);
        Set<String> to = new HashSet<>();

        to.add(user.getEmail());

        String subject = "Warden Email Notification";
        StringBuilder message = new StringBuilder();

        message.append(MessageFormat.format("<p>{0} has been suspended from the Argus system for violating the following policy</p>",
                user.getUserName()));
        message.append(MessageFormat.format("Subsystem: {0}", subSystem.toString()));
        message.append(MessageFormat.format("<br>Policy: {0}",
                context.getAlert().getName().replace(WARDEN_ALERT_NAME_PREFIX + user.getUserName() + "-", "")));
        message.append(MessageFormat.format("<br>Threshold: {0}", context.getAlert().getTriggers().get(0).getThreshold()));
        message.append(MessageFormat.format("<br>Triggering Value: {0}", context.getTriggerEventValue()));
        if (record.getSuspendedUntil() == -1) {
            message.append("<br> You have been suspended indefinitely");
        } else {
            message.append(MessageFormat.format("<br>Reinstatement Time: {0}", DATE_FORMATTER.get().format(new Date(record.getSuspendedUntil()))));
        }
        _mailService.sendMessage(to, subject, message.toString(), "text/html; charset=utf-8", MailService.Priority.HIGH);
        to.clear();
        to.add("argus-admin@salesforce.com");
        message.append("<p><a href='").append(getAlertUrl(context.getAlert().getId())).append("'>Click here to view alert definition.</a><br/>");
        _mailService.sendMessage(to, subject, message.toString(), "text/html; charset=utf-8", MailService.Priority.HIGH);
    }
456405
protected <E extends Event> void subscribeSystemEvent(Class<E> eventClass, final Listener<E> listener) {
        locator.inject(listener);
        locator.postConstruct(listener);
        SystemEventBus.subscribe(eventClass, listener);
    }
481709
public function notifyMentioned(AnCommandContext $context)
    {
        $entity = $this->getItem();
        $subscribers = array();

        foreach ($this->_newly_mentioned as $username) {
            $person = $this->getService('repos:people.person')->find(array('username' => $username));

            if ($person && $person->authorize('mention')) {
                $subscribers[] = $person->id;
            }
        }

        if (count($subscribers) == 0) {
            return;
        }

        if ($entity instanceof ComBaseDomainEntityComment) {
            $parentIdentifier = $entity->parent->getIdentifier()->name;
            $parentController = $this->getService('com:'.AnInflector::pluralize($parentIdentifier).'.controller.'.$parentIdentifier);

            if ($parentController->isNotifier() && $entity->parent->isSubscribable()) {
                $data = array(
                    'name' => 'actor_mention_comment',
                    'object' => $entity,
                    'comment' => $entity,
                    'component' => $entity->parent->component,
                    'subscribers' => $subscribers,
                );

                $parentController->createNotification($data);
            }
        } else {
            $data = array(
                'name' => 'actor_mention',
                'object' => $entity,
                'component' => $entity->component,
                'subscribers' => $subscribers,
            );

            $notification = $this->_mixer->createNotification($data);
        }
    }
97228
public void setSubscribedResourceAsDeleted(CmsRequestContext context, String poolName, CmsResource resource)
    throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        try {
            m_driverManager.setSubscribedResourceAsDeleted(dbc, poolName, resource);
        } catch (Exception e) {

            dbc.report(
                null,
                Messages.get().container(
                    Messages.ERR_SET_SUBSCRIBED_RESOURCE_AS_DELETED_1,
                    context.getSitePath(resource)),
                e);

        } finally {
            dbc.clear();
        }
    }
1061703
@TargetApi(Build.VERSION_CODES.ECLAIR)
    public static void cancel(final Context context) {
        final NotificationManager nm = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
            nm.cancel(NOTIFICATION_TAG, 0);
        } else {
            nm.cancel(NOTIFICATION_TAG.hashCode());
        }
    }
595854
protected void sendEvent(T event, Object receiver, CreationalContext<?> creationalContext) {
        try {
            preNotify(event, receiver);
            // As we are working with the contextual instance, we may not have the
            // actual object, but a container proxy (e.g. EJB)
            notificationStrategy.invoke(receiver, observerMethod, event, beanManager, creationalContext);
        } finally {
            postNotify(event, receiver);
        }
    }
567850
public void send(String recipients, String subj, String text) {
        final String usr = JibuConfig.getProperty("mail.username");
        final String pwd = JibuConfig.getProperty("mail.password");
        Session session =
            Session.getDefaultInstance(JibuConfig.getProperties(),
                                       new javax.mail.Authenticator() {
                                           protected PasswordAuthentication getPasswordAuthentication() {
                                               return new PasswordAuthentication(usr,pwd);
                                           }
                                       });
        try {
            Message msg = new MimeMessage(session);
            msg.addRecipients(Message.RecipientType.TO,
                              InternetAddress.parse(recipients));
            msg.setSubject(subj);
            msg.setText(text);
            Transport.send(msg);
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
699923
@SuppressWarnings({"UnusedDeclaration"})
    public void doSubmit(StaplerRequest req, StaplerResponse resp) throws IOException, ServletException {
        getACL().checkPermission(getPermission());

        bindParameters(req);
        // current user is bound to the thread and will be lost in the perform method
        User user = User.current();
        String ciUser = (user == null) ? "anonymous" : user.getId();

        JSONObject formData = req.getSubmittedForm();
        if (formData.has("promotionPlugin")) {
            JSONObject pluginSettings = formData.getJSONObject("promotionPlugin");
            if (pluginSettings.has("pluginName")) {
                String pluginName = pluginSettings.getString("pluginName");
                if (!UserPluginInfo.NO_PLUGIN_KEY.equals(pluginName)) {
                    PluginSettings settings = new PluginSettings();
                    Map<String, String> paramMap = Maps.newHashMap();
                    settings.setPluginName(pluginName);
                    Map<String, Object> filteredPluginSettings = Maps.filterKeys(pluginSettings,
                            new Predicate<String>() {
                                public boolean apply(String input) {
                                    return StringUtils.isNotBlank(input) && !"pluginName".equals(input);
                                }
                            });
                    for (Map.Entry<String, Object> settingsEntry : filteredPluginSettings.entrySet()) {
                        String key = settingsEntry.getKey();
                        paramMap.put(key, pluginSettings.getString(key));
                    }
                    paramMap.put("ciUser", ciUser);
                    if (!paramMap.isEmpty()) {
                        settings.setParamMap(paramMap);
                    }
                    setPromotionPlugin(settings);
                }
            }
        }

        final BuildInfoAwareConfigurator configurator = getCurrentConfigurator();
        ArtifactoryServer server = configurator.getArtifactoryServer();

        new PromoteWorkerThread(server, CredentialManager.getPreferredDeployer((DeployerOverrider) configurator, server), ciUser).start();

        resp.sendRedirect(".");
    }
732123
def requestSubsystem(self, subsystem):
        
        data = common.NS(subsystem)
        return self.sendRequest('subsystem', data, wantReply=True)
1254738
protected void subscriptionResponseReceived(IoSession session,
			SubscriptionMessage subscriptionMessage) {
		log.info("Received {}", subscriptionMessage);
		this.receivedSubscription = subscriptionMessage;

		if (this.sentSubscription == null) {
			log.error(
					"Protocol error: Received a subscription response without sending a request.\n{}",
					subscriptionMessage);
			this._disconnect();
			return;
		}

		if (!this.sentSubscription.equals(this.receivedSubscription)) {
			log.info(
					"Server did not fully accept subscription request.\nOriginal:\n{}\nAmended\n{}",
					this.sentSubscription, this.receivedSubscription);
		}

		for (ConnectionListener listener : this.connectionListeners) {
			listener.subscriptionReceived(this, subscriptionMessage);
		}
	}
364080
public synchronized void sendNotification(String text, U userData, long timestamp)
    {
        map.allValues()
                .forEach((ListenerWrapper w)->executor.execute(()->w.sendNotification(text, userData, timestamp)));
    }
504149
public void tellSubscribers( Actor sender, String topic, Object message) {
        List<ReceiverActor> subscriber = topic2Subscriber.get(topic);
        if ( subscriber != null ) {
            subscriber.stream()
                .filter(subs -> !subs.equals(sender)) // do not receive self sent
                .forEach(subs -> subs.receiveTell(topic, message) );
        }
    }
395722
private void checkTopicSubscribePermission(String topic) {
        SecurityManager sm = System.getSecurityManager();
        if (sm == null)
            return;

        sm.checkPermission(new TopicPermission(topic, SUBSCRIBE));
    }
327650
void handleSubscriberException(Throwable e, SubscriberExceptionContext context) {
    checkNotNull(e);
    checkNotNull(context);
    try {
      exceptionHandler.handleException(e, context);
    } catch (Throwable e2) {
      // if the handler threw an exception... well, just log it
      logger.log(Level.SEVERE,
          String.format("Exception %s thrown while handling exception: %s", e2, e), e2);
    }
  }
1232797
protected function _actionEditsubscription(AnCommandContext $context)
    {
        if ($subscription = $this->_subscriber->changeSubscriptionTo($this->getItem())) {
            $subscription->endDate = $context->data->endDate;
        }
    }
425089
public static void registerSubordinateControl(final String controlId) {
		UIContext uic = UIContextHolder.getCurrentPrimaryUIContext();
		if (uic == null) {
			throw new SystemException("No User Context available to register Subordinate Control.");
		}
		Set<String> controls = (Set<String>) uic.getFwkAttribute(SUBORDINATE_CONTROL_SESSION_KEY);
		if (controls == null) {
			controls = new HashSet<>();
			uic.setFwkAttribute(SUBORDINATE_CONTROL_SESSION_KEY, controls);
		}
		controls.add(controlId);
	}
812210
public void sendContextControlMessage(final EvaluatorRuntimeProtocol.ContextControlProto contextControlProto) {
    synchronized (this.evaluatorDescriptor) {
      LOG.log(Level.FINEST, "Context control message to {0}", this.evaluatorId);
      this.contextControlHandler.send(contextControlProto);
    }
  }