org.edg.security.voms.notification
Class Notification

java.lang.Object
  |
  +--org.edg.security.voms.notification.Notification
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EmailNotification

public class Notification
extends java.lang.Object
implements java.io.Serializable

Abstract class representing a notification sent to one or more recipients.

This abstract class focuses on the message and the status of the notification. Subclasses shall implement the actual notification mechanism and the way of deriving the recipients from various sources.

Version:
$Name: v0_7_0 $
Author:
Akos Frohner
See Also:
Serialized Form

Field Summary
private static org.apache.log4j.Logger log
           
protected  java.lang.String message
           
protected  java.lang.String recipients
           
protected  java.lang.String sender
           
protected  boolean sent
           
protected  java.lang.String subject
           
 
Constructor Summary
Notification()
           
 
Method Summary
protected  void fillMap(java.util.Map map, CreateUserAction action)
          Fills the substitution map for newMessage from the action.
protected  void fillMap(java.util.Map map, Request req)
          Fills the substitution map for newMessage from the request.
 java.lang.String getMessage()
          Returns the message itself.
 java.lang.String getRecipients()
          Returns the recipients (To:) of this notification.
 java.lang.String getSender()
          Returns the sender (From:) of this message.
 java.lang.String getSubject()
          Returns the subject (Subject:).
 boolean isPending()
          Pending = not sent (convenience method).
 boolean isSent()
          Status of this notification.
protected  void newMessage(java.lang.String templateName, java.util.Map subst)
          Creates a new message using a template file and substitution map.
 boolean send()
          Once the notification is created this method tries to send the message.
protected  void setRecipientsToAdmins(Action action)
          Sets the recipients to the email addresses of the action's administrators.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

sent

protected boolean sent

recipients

protected java.lang.String recipients

message

protected java.lang.String message

subject

protected java.lang.String subject

sender

protected java.lang.String sender
Constructor Detail

Notification

public Notification()
Method Detail

isSent

public boolean isSent()
Status of this notification.


isPending

public boolean isPending()
Pending = not sent (convenience method).


send

public boolean send()
Once the notification is created this method tries to send the message. The success can be also checked via the isSent() method.

Returns:
success of the operation

getRecipients

public java.lang.String getRecipients()
Returns the recipients (To:) of this notification.


getMessage

public java.lang.String getMessage()
Returns the message itself.


getSubject

public java.lang.String getSubject()
Returns the subject (Subject:).


getSender

public java.lang.String getSender()
Returns the sender (From:) of this message.


newMessage

protected void newMessage(java.lang.String templateName,
                          java.util.Map subst)
                   throws VOMSException
Creates a new message using a template file and substitution map. The template is looked up in the notification subdirectory of the
  1. VO configuration directory,
  2. central VOMS configuration directory or
The file has to have a .msg extension.

The substitutions are processed in the alphabetical order of the map keys. Every string in the template with '%' pre- and postfix is substituted. For example if the map has a CN -- Joe entry and the template has a %CN% wants to ... string, then the message will contain the Joe wants to ... string.

The generated message is stored in this Notification object.

Parameters:
templateName - name of the template file
subst - substitution map
VOMSException

fillMap

protected void fillMap(java.util.Map map,
                       Request req)
                throws VOMSException
Fills the substitution map for newMessage from the request. This method copies the action parameters and the optional parameters from the request, which may include the following fields for substitution:

Parameters:
map - the substitution map (has to exist)
req - the request itself
VOMSException

fillMap

protected void fillMap(java.util.Map map,
                       CreateUserAction action)
Fills the substitution map for newMessage from the action. This method copies the user's details, which include the following fields for substitution:

Parameters:
map - the substitution map (has to exist)
action - the user creation action

setRecipientsToAdmins

protected void setRecipientsToAdmins(Action action)
                              throws VOMSException
Sets the recipients to the email addresses of the action's administrators.

VOMSException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object