com.arsdigita.notification
Class Notification

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.notification.Notification
All Implemented Interfaces:
com.arsdigita.notification.NotificationConstants

public class Notification
extends ACSObject
implements com.arsdigita.notification.NotificationConstants

The Notification class is used to create and send messages via email to ACS users and groups. It acts as a wrapper for a Message which contains the subject, sender, body and any attachments for the email. The recipient can be a User or a Group. In the case of Group, the message can be sent to the group's email address or expanded into a separate message for each member of the group.

Email Alerts

When using notifications for email alerts, applications often need to wrap a special header and signature around the contained Message object. This can be useful for including introductory remarks and action links in the email body. The setHeader and setSignature methods allow you to do this without the need to create a separate Message for the modified email.

For example, a bboard application might want to include a link so users can unsubscribe from the bboard. The alert processing code for the bboard can include this information in the alert as part of the signature:

 notice.setMessage(msg);
 notice.setHeader
     ("Posted by: " + userName + "\n" +
      "Topic    : " + topic + "\n" +
      "Subject  : " + msg.getSubject() + "\n");
 notice.setSignature
     ("To post a response, come back to the forum:\n" +
       forumURL +
      "Use the following URL to disable the alert that sent you this message:\n"
       forumUnsubscribeURL);
 notice.save();
 

Digests

Finally, notifications can be sent in "instant processing mode" or as part of a Digest. When sent as part of a digest all notifications to the same recipient are collected into a single email and sent at regular internal. For example, an hourly digest might send a user all of their workflow task updates that have changed in the past hour, rather a much larger number of individual messages everytime an tasks changed.

Version:
$Id: //core-platform/dev/src/com/arsdigita/notification/Notification.java#11 $
Author:
Ron Henderson, David Dao

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String CANCELLED
           
static String DIGEST_ID
           
static String EXPAND_GROUP
           
static String EXPUNGE_MSG_P
           
static String EXPUNGE_P
           
static String FAILED
           
static String FAILED_PARTIAL
           
static String FREQUENCY
           
static String FULFILL_DATE
           
static String GET_DIGEST_QUEUED_NOTIFICATIONS
           
static String GET_SIMPLE_QUEUED_NOTIFICATIONS
           
static String HEADER
           
static String MAX_RETRIES
           
static String MESSAGE_ID
           
static String NEXT_RUN
           
static String PARTY_FROM
           
static String PARTY_TO
           
static String PARTY_TO_ADDR
           
static String PENDING
           
static String QUEUED
           
static String REQUEST_DATE
           
static String REQUEST_ID
           
static String RETRY_COUNT
           
static String SENT
           
static String SEPARATOR
           
static String SIGNATURE
           
static String STATUS
           
static String SUBJECT
           
static String SUCCESS
           
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE, versionId
 
Constructor Summary
Notification()
          Creates an empty Notification.
Notification(BigDecimal id)
          Retrieves an existing notification from the database using its BigDecimal id.
Notification(Digest digest, Party to, Message msg)
          Creates a notification by supplying the digest, the receiver, and an existing message to send.
Notification(Digest digest, Party to, Party from, String subject, String body)
          Creates a notification by supplying the digest, sender, receiver, subject, and body of the message.
Notification(OID oid)
          Retrieves an existing notification from the database using its OID.
Notification(Party to, Message msg)
          Creates a notification by supplying the receiver and an existing message to send.
Notification(Party to, Party from, String subject, String body)
          Creates a notification by supplying the sender, receiver, subject, and body of the message.
 
Method Summary
protected  void beforeSave()
           
 void delete()
          Deletes the notification.
 Digest getDigest()
          Gets the digest associated with this notification.
 Boolean getExpandGroup()
          Gets the group expansion flag for this notification.
 Date getFulfillDate()
          Gets the fulfill date.
 Boolean getIsPermanent()
          Gets the flag for whether this notification remains in the database after processing.
 Boolean getMessageDelete()
          Gets the value of the MessageDelete flag if set.
 Date getRequestDate()
          Gets the request date.
 String getStatus()
          Get the status of this notification.
 void setDigest(Digest digest)
          Sets the digest parameter for a notification.
 void setExpandGroup(Boolean expandGroup)
          Sets the group expansion flag for this notification.
 void setHeader(String header)
          Sets the header of the alert.
 void setIsPermanent(Boolean permanent)
          Sets the flag for whether this notification remains in the database after processing.
 void setMessage(Message msg)
          Sets the message containing the sender, subject, and body of this notification.
 void setMessageDelete(Boolean value)
          Sets the flag for whether the underlying message should be deleted if and when this request is deleted.
 void setSignature(String signature)
          Sets the signature of the notification.
 void setTo(Party to)
          Sets the sender of the notification.
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getBaseDataObjectType, getContainer, getDefaultDomainClass, getDisplayName, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, initialize, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE

DIGEST_ID

public static final String DIGEST_ID
See Also:
Constant Field Values

REQUEST_ID

public static final String REQUEST_ID
See Also:
Constant Field Values

MESSAGE_ID

public static final String MESSAGE_ID
See Also:
Constant Field Values

PARTY_TO

public static final String PARTY_TO
See Also:
Constant Field Values

PARTY_TO_ADDR

public static final String PARTY_TO_ADDR
See Also:
Constant Field Values

PARTY_FROM

public static final String PARTY_FROM
See Also:
Constant Field Values

RETRY_COUNT

public static final String RETRY_COUNT
See Also:
Constant Field Values

SUCCESS

public static final String SUCCESS
See Also:
Constant Field Values

EXPAND_GROUP

public static final String EXPAND_GROUP
See Also:
Constant Field Values

REQUEST_DATE

public static final String REQUEST_DATE
See Also:
Constant Field Values

FULFILL_DATE

public static final String FULFILL_DATE
See Also:
Constant Field Values

STATUS

public static final String STATUS
See Also:
Constant Field Values

MAX_RETRIES

public static final String MAX_RETRIES
See Also:
Constant Field Values

EXPUNGE_P

public static final String EXPUNGE_P
See Also:
Constant Field Values

EXPUNGE_MSG_P

public static final String EXPUNGE_MSG_P
See Also:
Constant Field Values

HEADER

public static final String HEADER
See Also:
Constant Field Values

SIGNATURE

public static final String SIGNATURE
See Also:
Constant Field Values

SUBJECT

public static final String SUBJECT
See Also:
Constant Field Values

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values

FREQUENCY

public static final String FREQUENCY
See Also:
Constant Field Values

NEXT_RUN

public static final String NEXT_RUN
See Also:
Constant Field Values

PENDING

public static final String PENDING
See Also:
Constant Field Values

QUEUED

public static final String QUEUED
See Also:
Constant Field Values

SENT

public static final String SENT
See Also:
Constant Field Values

FAILED

public static final String FAILED
See Also:
Constant Field Values

FAILED_PARTIAL

public static final String FAILED_PARTIAL
See Also:
Constant Field Values

CANCELLED

public static final String CANCELLED
See Also:
Constant Field Values

GET_SIMPLE_QUEUED_NOTIFICATIONS

public static final String GET_SIMPLE_QUEUED_NOTIFICATIONS
See Also:
Constant Field Values

GET_DIGEST_QUEUED_NOTIFICATIONS

public static final String GET_DIGEST_QUEUED_NOTIFICATIONS
See Also:
Constant Field Values
Constructor Detail

Notification

public Notification()
Creates an empty Notification. This constructor is invoked by all others to initialize the following default parameters:
  1. REQUEST_DATE to the current time
  2. MAX_RETRIES to three (3)
  3. STATUS to "pending"
  4. EXPUNGE_P to FALSE (do not delete after processing)
  5. EXPAND_GROUP to TRUE (send to group members)
Any of these defaults can be overridden in a specialized constructor or by calling the appropriate methods to change these parameter settings.


Notification

public Notification(Digest digest,
                    Party to,
                    Party from,
                    String subject,
                    String body)
Creates a notification by supplying the digest, sender, receiver, subject, and body of the message.

Parameters:
digest - the digest this notification is part of
to - the party receiving the message
from - the party sending the message
subject - the subject of the message
body - the body of the message

Notification

public Notification(Digest digest,
                    Party to,
                    Message msg)
Creates a notification by supplying the digest, the receiver, and an existing message to send.

Parameters:
digest - notification belongs to this digest
to - the party recieving the message
msg - the message to send

Notification

public Notification(Party to,
                    Party from,
                    String subject,
                    String body)
Creates a notification by supplying the sender, receiver, subject, and body of the message. Creates an internal Message object to store this information and sets the MessageDelete flag to true so the internal object is deleted when the notification is deleted. Also sets the isPermanent flag to false so the notification will be deleted after processing.

Parameters:
to - the party receiving the message
from - the party sending the message
subject - the subject of the message
body - the body of the message

Notification

public Notification(Party to,
                    Message msg)
Creates a notification by supplying the receiver and an existing message to send. All other information (subject, body, and sender) is encapsulated by the message.

Parameters:
to - the party recieving the message
msg - the message to send

Notification

public Notification(OID oid)
             throws DataObjectNotFoundException
Retrieves an existing notification from the database using its OID.

Parameters:
oid - the OID of the notification

Notification

public Notification(BigDecimal id)
             throws DataObjectNotFoundException
Retrieves an existing notification from the database using its BigDecimal id.

Parameters:
id - the BigDecimal ID of the notification
Method Detail

setTo

public void setTo(Party to)
Sets the sender of the notification.

Parameters:
to - the sender of the notification

setMessage

public void setMessage(Message msg)
Sets the message containing the sender, subject, and body of this notification. Note: should we disable this for anything not isNew()?

Parameters:
msg - the message of this notification

getStatus

public String getStatus()
Get the status of this notification.


getIsPermanent

public Boolean getIsPermanent()
Gets the flag for whether this notification remains in the database after processing.

Returns:
true if this notification remains in the database after processing; false otherwise.

setIsPermanent

public void setIsPermanent(Boolean permanent)
Sets the flag for whether this notification remains in the database after processing. If permanent is set, then this notification will remain in the database.

Parameters:
permanent - true if this notification should remain in the database after processing

getMessageDelete

public Boolean getMessageDelete()
Gets the value of the MessageDelete flag if set.

Returns:
true if the MessageDelete flag is set; false otherwise.

setMessageDelete

public void setMessageDelete(Boolean value)
Sets the flag for whether the underlying message should be deleted if and when this request is deleted.

Parameters:
value - true if the underlying message should be deleted when this request is deleted

getExpandGroup

public Boolean getExpandGroup()
Gets the group expansion flag for this notification.

Returns:
the group expansion flag for this notification.

setExpandGroup

public void setExpandGroup(Boolean expandGroup)
Sets the group expansion flag for this notification.


getDigest

public Digest getDigest()
                 throws DataObjectNotFoundException
Gets the digest associated with this notification. Returns null if there is no digest.

Returns:
the digest of this notification, or null if there is no digest.
Throws:
DataObjectNotFoundException

setDigest

public void setDigest(Digest digest)
Sets the digest parameter for a notification.

Parameters:
digest - the digest this message belongs to

getRequestDate

public Date getRequestDate()
Gets the request date. The API does not allow for setting the request date, since this handled automatically when the request is saved.

Returns:
the date of the request

getFulfillDate

public Date getFulfillDate()
Gets the fulfill date.

Returns:
the date the request was fulfilled

setHeader

public void setHeader(String header)
Sets the header of the alert. The header is prepended to the body of the email message (before the content of the contained Message body).

Parameters:
header - the header of the alert
Since:
4.8.1

setSignature

public void setSignature(String signature)
Sets the signature of the notification. The signature is appended to the body of the email message (after the content of the contained Message body).

Parameters:
signature - the signature of the alert
Since:
4.8.1

beforeSave

protected void beforeSave()
Overrides:
beforeSave in class ACSObject

delete

public void delete()
Deletes the notification. This also checks to see if the corresponding message should be deleted at the same time.

Overrides:
delete in class DomainObject
See Also:
DataObject.delete()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC