int closeDelimPos = line.indexOf("%%", delimPos+1);
if (closeDelimPos < 0)
{
// There was an opening %% but not a closing one.
throw new ConfigException(
ERR_SMTP_ASNH_TEMPLATE_UNCLOSED_TOKEN.get(
delimPos, lineNumber));
}
else
{
String tokenStr = line.substring(delimPos+2, closeDelimPos);
String lowerTokenStr = toLowerCase(tokenStr);
if (lowerTokenStr.equals("notification-type"))
{
if (debugEnabled())
{
TRACER.debugInfo("Found a notification type token " +
tokenStr);
}
elementList.add(
new NotificationTypeNotificationMessageTemplateElement());
}
else if (lowerTokenStr.equals("notification-message"))
{
if (debugEnabled())
{
TRACER.debugInfo("Found a notification message token " +
tokenStr);
}
elementList.add(
new NotificationMessageNotificationMessageTemplateElement());
}
else if (lowerTokenStr.equals("notification-user-dn"))
{
if (debugEnabled())
{
TRACER.debugInfo("Found a notification user DN token " +
tokenStr);
}
elementList.add(
new UserDNNotificationMessageTemplateElement());
}
else if (lowerTokenStr.startsWith("notification-user-attr:"))
{
String attrName = lowerTokenStr.substring(23);
AttributeType attrType =
DirectoryServer.getAttributeType(attrName, false);
if (attrType == null)
{
throw new ConfigException(
ERR_SMTP_ASNH_TEMPLATE_UNDEFINED_ATTR_TYPE.get(
delimPos, lineNumber, attrName));
}
else
{
if (debugEnabled())
{
TRACER.debugInfo("Found a user attribute token for " +
attrType.getNameOrOID() + " -- " +
tokenStr);
}
elementList.add(
new UserAttributeNotificationMessageTemplateElement(
attrType));
}
}
else if (lowerTokenStr.startsWith("notification-property:"))
{
String propertyName = lowerTokenStr.substring(22);
AccountStatusNotificationProperty property =
AccountStatusNotificationProperty.forName(propertyName);
if (property == null)
{
throw new ConfigException(
ERR_SMTP_ASNH_TEMPLATE_UNDEFINED_PROPERTY.get(
delimPos, lineNumber, propertyName));
}
else
{
if (debugEnabled())
{
TRACER.debugInfo("Found a notification property token " +
"for " + propertyName + " -- " + tokenStr);
}
elementList.add(
new NotificationPropertyNotificationMessageTemplateElement(
property));
}
}
else
{
throw new ConfigException(
ERR_SMTP_ASNH_TEMPLATE_UNRECOGNIZED_TOKEN.get(
tokenStr, delimPos, lineNumber));
}
startPos = closeDelimPos + 2;
}
}
}
// We need to put a CRLF at the end of the line, as per the SMTP spec.
elementList.add(new TextNotificationMessageTemplateElement("\r\n"));
}
return elementList;
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
throw new ConfigException(ERR_SMTP_ASNH_TEMPLATE_CANNOT_PARSE.get(
f.getAbsolutePath(),
currentConfig.dn().toString(),
getExceptionMessage(e)));
}
finally