com.bea.netuix.application.communities.invitations.email
Class EmailInviter

java.lang.Object
  extended by com.bea.netuix.application.communities.invitations.email.EmailInviter
All Implemented Interfaces
CommunityInviter, Serializable

public class EmailInviter
extends Object
implements CommunityInviter

Implemenation of a CommunityInviter that uses JavaMail as its underlying transport. This inviter provides for using Strings for the subject and body of the resulting email sent to each Invitee.

The overview of community functionality contains a description of the community framework.

See Also
Serialized Form

Field Summary
protected  String communityRegistrationURL
           
protected  String from
           
protected  String fromPersonalName
           
protected  InvitationDetails invitationDetails
           
protected  String replyTo
           
protected  String replyToPersonalName
           
protected  String sender
           
protected  String smtpServerAddress
           
protected  String smtpServerPort
           
protected  String staticBodyText
           
protected  String staticSubjectText
           
 
Constructor Summary
EmailInviter(String sender, String password, String smtpServerAddress, String replyTo, String invitationURL, EmailTextFormatter emailFormatter)
          Constructor that uses a specified EmailTextFormatter.
EmailInviter(String sender, String password, String smtpServerAddress, String replyTo, String invitationURL, String staticSubjectText, String staticBodyText)
          Constructor that uses a default static text EmailTextFormatter.
 
Method Summary
protected  EmailTextFormatter createDefaultEmailFormatter()
          Overrideable method that is used to instantiate a default EmailTextFormatter.
 void destroy()
          Allows InvitationValidationTextGenerator implementations the opportunity to release any resources obtained during init or to perform any necessary cleanup operations.
protected  EmailTextFormatter getEmailFormatter()
           
 void init(InvitationDetails details)
          Allows CommunityInviter implementations the opportunity to perform any necessary initialization operations such as obtaining necessary resources such as database connections or loading file contents.
protected  void onAuthenticationFailed(String user, String smtpServer, javax.mail.AuthenticationFailedException afex)
          Overrideable method that can be used to be notified of authentication errors when the sender and password cannot be used to connect to the smtp server for sending email messages.
protected  void onSendFailed(String user, String smtpServer, String failedAddress, javax.mail.SendFailedException sfex)
          Overrideable method that can be used to be notified of send failed errors when the sender and password cannot be used to send a message to a recipient via the smtp server.
 void sendInvitations(InviteeIterator invitees)
          Sends individual invitations to the set of Invitees contained within the input InviteeIterator, according to the details for the invitation as contained in the input InvitationDetails argument.
 void setFrom(String from)
          Sets the from email address to use for sending invitation emails.
 void setFromPersonalName(String personalName)
          Sets the personal name to be used for the from portion of the invitation email.
 void setMailSessionDebug(boolean debugOn)
          Turns on SMTP mail session debuging, which outputs SMTP protocol interactions between the EmailInviter client and the SMTP server.
 void setReplyTo(String replyTo)
          Sets the reply-to email address to use for sending invitation emails.
 void setReplyToPersonalName(String personalName)
          Sets the personal name to be used for the reply-to portion of the invitation email.
 void setSmtpServerPort(String port)
          Sets the smtp port for the smtp server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

staticSubjectText

protected String staticSubjectText

staticBodyText

protected String staticBodyText

invitationDetails

protected InvitationDetails invitationDetails

sender

protected String sender

from

protected String from

fromPersonalName

protected String fromPersonalName

smtpServerAddress

protected String smtpServerAddress

smtpServerPort

protected String smtpServerPort

replyTo

protected String replyTo

replyToPersonalName

protected String replyToPersonalName

communityRegistrationURL

protected String communityRegistrationURL
Constructor Detail

EmailInviter

public EmailInviter(String sender,
                    String password,
                    String smtpServerAddress,
                    String replyTo,
                    String invitationURL,
                    String staticSubjectText,
                    String staticBodyText)
Constructor that uses a default static text EmailTextFormatter. If another formatter is to be used, an alternate constructor is available to specify it.

Parameters
sender - the username of the sending entity
password - the smtp password for the sending entity. Can be null if using an open relay.
smtpServerAddress - address of the smtp server to use to send the invitation emails
replyTo - the email address that will be used as the reply-to in the invitation emails
invitationURL - the full URL to the community registration page or the community itself, depending on whether or not the community is public or private. This needs to be assembled by the creator of this EmailInviter since invitations happen in an asynchronous context wherein there is no access to a request to determine necessary information such as server and port.
staticSubjectText - the subject text to use for invitation emails
staticBodyText - the body text to use for invitation emails

EmailInviter

public EmailInviter(String sender,
                    String password,
                    String smtpServerAddress,
                    String replyTo,
                    String invitationURL,
                    EmailTextFormatter emailFormatter)
Constructor that uses a specified EmailTextFormatter. The Weblogic Portal Framework provides two implementations of EmailTextFormatter, the first a simple StaticEmailTextFormatter, which uses fixed Strings as the email text source, and a JspEmailTextFormatter which allows developers to use JSP's as the source for the email text, allowing for greater customizability. Additionally, custom implementations of the EmailTextFormatter interface may be supplied if developers wish to use a completely custom email text formatter.

Parameters
sender - the username of the sending entity
password - the smtp password for the sending entity. Can be null if using an open relay.
smtpServerAddress - address of the smtp server to use to send the invitation emails
replyTo - the email address that will be used as the reply-to in the invitation emails
invitationURL - the full URL to the community registration page or the community itself, depending on whether or not the community is public or private. This needs to be assembled by the creator of this EmailInviter since invitations happen in an asynchronous context wherein there is no access to a request to determine necessary information such as server and port.
Method Detail

init

public void init(InvitationDetails details)
          throws InviteException
Description copied from interface: CommunityInviter
Allows CommunityInviter implementations the opportunity to perform any necessary initialization operations such as obtaining necessary resources such as database connections or loading file contents.

Specified by:
init in interface CommunityInviter
Parameters
details - the specific details of the invitation
Throws
InviteException

sendInvitations

public void sendInvitations(InviteeIterator invitees)
                     throws InviteException
Description copied from interface: CommunityInviter
Sends individual invitations to the set of Invitees contained within the input InviteeIterator, according to the details for the invitation as contained in the input InvitationDetails argument.

Specified by:
sendInvitations in interface CommunityInviter
Parameters
invitees - an iterator containing all invitees to invite
Throws
InviteException

createDefaultEmailFormatter

protected EmailTextFormatter createDefaultEmailFormatter()
Overrideable method that is used to instantiate a default EmailTextFormatter. The default formatter for the EmailInviter is the StaticEmailTextFormatter.

Returns
the default StaticEmailTextFormatter

onAuthenticationFailed

protected void onAuthenticationFailed(String user,
                                      String smtpServer,
                                      javax.mail.AuthenticationFailedException afex)
Overrideable method that can be used to be notified of authentication errors when the sender and password cannot be used to connect to the smtp server for sending email messages. This implementation simply logs the authentication exception.

Parameters
user - the user id
smtpServer - the smtp server to which the authentication operation was attempted
afex - the AuthenticationFailedException which was thrown

onSendFailed

protected void onSendFailed(String user,
                            String smtpServer,
                            String failedAddress,
                            javax.mail.SendFailedException sfex)
Overrideable method that can be used to be notified of send failed errors when the sender and password cannot be used to send a message to a recipient via the smtp server. This can occur when the smtp server's configuration disallows relaying of messages from the user because of either authentication requirements or other policy settings. This implementation simply logs the send failed exception.

Parameters
user - the user id attempting to send the message
smtpServer - the smtp server the delivery request was made to
failedAddress - the email address that delivery failed for
sfex - the SendFailedException which was thrown

destroy

public void destroy()
Description copied from interface: CommunityInviter
Allows InvitationValidationTextGenerator implementations the opportunity to release any resources obtained during init or to perform any necessary cleanup operations.

Specified by:
destroy in interface CommunityInviter

getEmailFormatter

protected EmailTextFormatter getEmailFormatter()

setFrom

public void setFrom(String from)
Sets the from email address to use for sending invitation emails. If this is not set, the email will default to come from the account associated with sender.

Parameters
from -

setFromPersonalName

public void setFromPersonalName(String personalName)
Sets the personal name to be used for the from portion of the invitation email. The personal name will be applied to the email message using the charset of the email formatter's subject. If personalName cannot be encoded using that charset, only the email address portion of the from address will be available in the resulting email.

Parameters
personalName - personal name for the from email address

setReplyTo

public void setReplyTo(String replyTo)
Sets the reply-to email address to use for sending invitation emails.

Parameters
replyTo -

setReplyToPersonalName

public void setReplyToPersonalName(String personalName)
Sets the personal name to be used for the reply-to portion of the invitation email. The personal name will be applied to the email message using the charset of the email formatter's subject. If personalName cannot be encoded using that charset, only the email address portion of the reply-to address will be available in the resulting email.

Parameters
personalName - personal name for the from email address

setSmtpServerPort

public void setSmtpServerPort(String port)
Sets the smtp port for the smtp server. If not explicitly set, the default will be used.

Parameters
port - the port the smtp server is setup to listen on

setMailSessionDebug

public final void setMailSessionDebug(boolean debugOn)
Turns on SMTP mail session debuging, which outputs SMTP protocol interactions between the EmailInviter client and the SMTP server.

Parameters
debugOn - if true, debug is enabled


Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.