Package org.nasutekds.server.types

Examples of org.nasutekds.server.types.AccountStatusNotificationType


        throw new ConfigException(ERR_SMTP_ASNH_SUBJECT_NO_COLON.get(s,
                                       configuration.dn().toString()));
      }

      String notificationTypeName = s.substring(0, colonPos).trim();
      AccountStatusNotificationType t =
           AccountStatusNotificationType.typeForName(notificationTypeName);
      if (t == null)
      {
        throw new ConfigException(
                       ERR_SMTP_ASNH_SUBJECT_INVALID_NOTIFICATION_TYPE.get(
                            s, configuration.dn().toString(),
                            notificationTypeName));
      }
      else if (map.containsKey(t))
      {
        throw new ConfigException(ERR_SMTP_ASNH_SUBJECT_DUPLICATE_TYPE.get(
                                       configuration.dn().toString(),
                                       notificationTypeName));
      }

      map.put(t, s.substring(colonPos+1).trim());
      if (debugEnabled())
      {
        TRACER.debugInfo("Subject for notification type " + t.getName() +
                         ":  " + map.get(t));
      }
    }

    return map;
View Full Code Here


        throw new ConfigException(ERR_SMTP_ASNH_TEMPLATE_NO_COLON.get(s,
                                       configuration.dn().toString()));
      }

      String notificationTypeName = s.substring(0, colonPos).trim();
      AccountStatusNotificationType t =
           AccountStatusNotificationType.typeForName(notificationTypeName);
      if (t == null)
      {
        throw new ConfigException(
                       ERR_SMTP_ASNH_TEMPLATE_INVALID_NOTIFICATION_TYPE.get(
                            s, configuration.dn().toString(),
                            notificationTypeName));
      }
      else if (map.containsKey(t))
      {
        throw new ConfigException(ERR_SMTP_ASNH_TEMPLATE_DUPLICATE_TYPE.get(
                                       configuration.dn().toString(),
                                       notificationTypeName));
      }

      String path = s.substring(colonPos+1).trim();
      File f = new File(path);
      if (! f.isAbsolute() )
      {
        f = new File(DirectoryServer.getInstanceRoot() + File.separator +
            path);
      }
      if (! f.exists())
      {
        throw new ConfigException(ERR_SMTP_ASNH_TEMPLATE_NO_SUCH_FILE.get(
                                       path, configuration.dn().toString()));
      }

      map.put(t, parseTemplateFile(f));
      if (debugEnabled())
      {
        TRACER.debugInfo("Decoded template elment list for type " +
                         t.getName());
      }
    }

    return map;
  }
View Full Code Here

            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());
    }


    try
    {
      message.send();

      if (debugEnabled())
      {
        TRACER.debugInfo("Successfully sent the message");
      }
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      logError(ERR_SMTP_ASNH_CANNOT_SEND_MESSAGE.get(notificationType.getName(),
                    notification.getUserDN().toString(),
                    getExceptionMessage(e)));
    }
  }
View Full Code Here

  private AccountStatusNotificationType getNotificationType(
      ErrorLogAccountStatusNotificationHandlerCfgDefn.
         AccountStatusNotificationType configNotificationType
      )
  {
    AccountStatusNotificationType nt = null;

    switch (configNotificationType)
    {
    case ACCOUNT_TEMPORARILY_LOCKED:
         nt = AccountStatusNotificationType.ACCOUNT_TEMPORARILY_LOCKED;
View Full Code Here

TOP

Related Classes of org.nasutekds.server.types.AccountStatusNotificationType

Copyright © 2018 www.massapicom. 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.