Examples of SMTPAccountStatusNotificationHandlerCfg


Examples of org.nasutekds.server.admin.std.server.SMTPAccountStatusNotificationHandlerCfg

  public boolean isConfigurationAcceptable(
                      AccountStatusNotificationHandlerCfg
                           configuration,
                      List<Message> unacceptableReasons)
  {
    SMTPAccountStatusNotificationHandlerCfg config =
         (SMTPAccountStatusNotificationHandlerCfg) configuration;
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
  }
View Full Code Here

Examples of org.nasutekds.server.admin.std.server.SMTPAccountStatusNotificationHandlerCfg

  /**
   * {@inheritDoc}
   */
  public void handleStatusNotification(AccountStatusNotification notification)
  {
    SMTPAccountStatusNotificationHandlerCfg config = currentConfig;
    HashMap<AccountStatusNotificationType,String> subjects = subjectMap;
    HashMap<AccountStatusNotificationType,
            List<NotificationMessageTemplateElement>> templates = templateMap;


    // First, see if the notification type is one that we handle.  If not, then
    // return without doing anything.
    AccountStatusNotificationType notificationType =
         notification.getNotificationType();
    List<NotificationMessageTemplateElement> templateElements =
         templates.get(notificationType);
    if (templateElements == null)
    {
      if (debugEnabled())
      {
        TRACER.debugInfo("No message template for notification type " +
                         notificationType.getName());
      }

      return;
    }


    // It is a notification that should be handled, so we can start generating
    // the e-mail message.  First, check to see if there are any mail attributes
    // that would cause us to send a message to the end user.
    LinkedList<String> recipients = new LinkedList<String>();
    Set<AttributeType> addressAttrs = config.getEmailAddressAttributeType();
    Set<String> recipientAddrs = config.getRecipientAddress();
    if ((addressAttrs != null) && (! addressAttrs.isEmpty()))
    {
      Entry userEntry = notification.getUserEntry();
      for (AttributeType t : addressAttrs)
      {
        List<Attribute> attrList = userEntry.getAttribute(t);
        if (attrList != null)
        {
          for (Attribute a : attrList)
          {
            for (AttributeValue v : a)
            {
              if (debugEnabled())
              {
                TRACER.debugInfo("Adding end user recipient " +
                                 v.getValue().toString() + " from attr " +
                                 a.getNameWithOptions());
              }

              recipients.add(v.getValue().toString());
            }
          }
        }
      }

      if (recipients.isEmpty())
      {
        if ((recipientAddrs == null) || recipientAddrs.isEmpty())
        {
          // There are no recipients at all, so there's no point in generating
          // the message.  Return without doing anything.
          if (debugEnabled())
          {
            TRACER.debugInfo("No end user recipients, and no explicit " +
                             "recipients");
          }

          return;
        }
        else
        {
          if (! config.isSendMessageWithoutEndUserAddress())
          {
            // We can't send the message to the end user, and the handler is
            // configured to not send only to administrators, so we shouln't
            // do anything.
            if (debugEnabled())
            {
              TRACER.debugInfo("No end user recipients, and shouldn't send " +
                               "without end user recipients");
            }

            return;
          }
        }
      }
    }


    // Next, add any explicitly-defined recipients.
    if (recipientAddrs != null)
    {
      if (debugEnabled())
      {
        for (String s : recipientAddrs)
        {
          TRACER.debugInfo("Adding explicit recipient " + s);
        }
      }

      recipients.addAll(recipientAddrs);
    }


    // Get the message subject to use.  If none is defined, then use a generic
    // subject.
    String subject = subjects.get(notificationType);
    if (subject == null)
    {
      subject = INFO_SMTP_ASNH_DEFAULT_SUBJECT.get().toString();

      if (debugEnabled())
      {
        TRACER.debugInfo("Using default subject of " + subject);
      }
    }
    else if (debugEnabled())
    {
      TRACER.debugInfo("Using per-type subject of " + subject);
    }



    // Generate the message body.
    MessageBuilder messageBody = new MessageBuilder();
    for (NotificationMessageTemplateElement e : templateElements)
    {
      e.generateValue(messageBody, notification);
    }


    // Create and send the e-mail message.
    EMailMessage message = new EMailMessage(config.getSenderAddress(),
                                            recipients, subject);
    message.setBody(messageBody);
    if (debugEnabled())
    {
      TRACER.debugInfo("Set message body of " + messageBody.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.