org.alltimeflashdreamer.mailwebform
Class MailFormProvider

java.lang.Object
  extended byorg.alltimeflashdreamer.mailwebform.MailFormProvider
All Implemented Interfaces:
MailWebFormConstants, Serializable

public class MailFormProvider
extends Object
implements MailWebFormConstants, Serializable

Title: MailFormProvider
Description: This class stores the values for one registered mailform provider. It is able to return the each separate as well as the highest active setting per type (see description of MailWebFormServlet) and reload the property files dynamically.

Version:
0.9
Author:
Copyright (c) 2001-2004 Florian Steinsiepe, Adrian Zaugg
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.alltimeflashdreamer.mailwebform.MailWebFormConstants
ADMIN, ADMINSERVLET, APPNAME, COOKIENAME, CURRENTUSER, ERROR_URL, FILESEPARATOR, JSPBEAN, MAILFORMPROVIDER, MAILFORMPROVIDERLIST, MAILWEBFORM, MAILWEBFORMSERVLET, NEWLINE, PARAM_ADD, PARAM_APPLYGLOBAL, PARAM_APPLYINDIVIDUAL, PARAM_CANCEL, PARAM_CHANGE_CREDENTIALS, PARAM_CONFIGFILE, PARAM_CREDENTIALS_ADMIN, PARAM_EDIT, PARAM_ERRORURL, PARAM_FROMEMAIL, PARAM_FROMNAME, PARAM_LOGIN, PARAM_LOGOUT, PARAM_OVERWRITE, PARAM_PASSWORD, PARAM_PASSWORD_PROVIDER, PARAM_PROVIDER, PARAM_PROVIDERDIRECTORY, PARAM_REMOVE, PARAM_SMTPHOST, PARAM_SMTPPORT, PARAM_SPAMURL, PARAM_STORE, PARAM_SUBJECT, PARAM_SUCCESSURL, PARAM_TEMPLATE, PARAM_TEXT, PARAM_TOADDRESS, PARAM_TONAME, PARAM_USERNAME, PASSWORD, PASSWORDFILE, PLACEHOLDER_END, PLACEHOLDER_START, PROPERTY_CONFIGDIR, PROPERTY_SUFFIX, PROVIDERDIRECTORY, RESOURCENAME, SITE_CHANGE_CREDENTIALS, SITE_DEFAULTFORM, SITE_EDIT, SITE_ERROR, SITE_FOOTER, SITE_HEADER, SITE_LOGIN, SITE_MAIN, SITE_PROVIDER, SMTP_ALLOWOVERWRITE, SMTP_HOST, SMTP_PORT, SPAMERROR_URL, SUCCESS_URL, SYSTEMPROVIDER, TEMPLATE, TEMPLATE_SUFFIX, TOADDRESS, TONAME, USERNAME
 
Constructor Summary
(package private) MailFormProvider(String sName, GlobalProperties globalProperties)
          The constructor receives the name of the current mailform provider together with the pointer to the ResourceBundle where the default settings are stored.
 
Method Summary
 String getDefaultErrorURL()
          Returns the default error url setting.
 String getDefaultSMTPHost()
          Returns the default SMTP host setting.
 int getDefaultSMTPPort()
          Returns the default SMTP port setting.
 String getDefaultSuccessURL()
          Returns the default success url setting.
 String getDefaultTemplate()
          Returns the default template setting.
 String getDefaultToAddress()
          Returns the default to-address setting.
 String getDefaultToName()
          Returns the default to-name setting.
 String getErrorURL()
          Returns the error url setting.
(package private)  String[] getGlobalPropertiesPart()
          Returns an array filled with strings formatted like "<key>=<value>", ready to be written into the global properties file, together with the description of the section wherein these strings are located in the file.
 String getIndividualErrorURL()
          Returns the individual error url setting.
 String getIndividualSMTPHost()
          Returns the individual SMTP host setting.
 int getIndividualSMTPPort()
          Returns the individual SMTP host setting.
 String getIndividualSuccessURL()
          Returns the individual success url setting.
 String getIndividualTemplate()
          Returns the individual template setting.
 String getIndividualToAddress()
          Returns the individual to-address setting.
 String getIndividualToName()
          Returns the individual to-name setting.
 String getName()
          Returns the name of this provider.
 String getPassword()
          Returns the encoded password that the provider uses to log in into the admin tool.
 String getProviderDirectory()
          Returns the value of the provider's individual path property.
 String getSMTPHost()
          Returns the individual or the SMTP host setting or null, if both aren't defined.
 int getSMTPPort()
          Returns the SMTP port setting.
 String getSuccessURL()
          Returns the success url setting.
 String getTemplate()
          Returns the template setting.
 String getToAddress()
          Returns the individual or the default to-address setting or null, if both aren't defined.
 String getToName()
          Returns the individual or the default to-name setting or null, if both aren't defined.
 boolean isSMTPOverwritingAllowed()
          Returns whether the overwriting of the default SMTP server is allowed for this provider or not.
(package private)  boolean isSystemProvider()
          Returns whether this provider is the system provider or not.
(package private) static boolean isSystemProvider(String sProviderName)
          Returns whether the given provider name is the one of the system provider or not.
(package private)  void readIndividualProperties()
          Checks whether it's necessary to read/update the provider-specific settings.
(package private)  void updateGlobalSettings(String sProviderDirectory, String sToName, String sToAddress, String sSMTPOverwritingAllowed, String sTemplate)
          Sets/Updates the "global" properties of this provider after having verified the input.
(package private)  void updateIndividualSettings(String sToName, String sToAddress, String sSMTPHost, int iSMTPPort, String sSuccessURL, String sErrorURL, String sTemplate)
          Sets/Updates the individual properties of this provider after having verified the input.
(package private)  void updatePassword(String sPassword)
          Sets/Updates the password property of this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailFormProvider

MailFormProvider(String sName,
                 GlobalProperties globalProperties)
           throws MailWebFormException,
                  IOException
The constructor receives the name of the current mailform provider together with the pointer to the ResourceBundle where the default settings are stored.

Parameters:
sName - the name fo this provider
globalProperties - the list containing the global properties of the MailWebForm application
Throws:
MailWebFormException - thrown on problems with the config dir property
IOException - in case an I/O error occurred while accessing the provider's properties file
Method Detail

updateGlobalSettings

void updateGlobalSettings(String sProviderDirectory,
                          String sToName,
                          String sToAddress,
                          String sSMTPOverwritingAllowed,
                          String sTemplate)
Sets/Updates the "global" properties of this provider after having verified the input.

Parameters:
sProviderDirectory - the new setting for the path to the provider's individual files (overwriting property file and mail template)
sToName - the new setting for the "master" to-name
sToAddress - the new setting for the "master" to-address
sSMTPOverwritingAllowed - the new setting for the allowing of overwrite (if null, then the default value is used which is true)
sTemplate - the name of the mail template to be used

updatePassword

void updatePassword(String sPassword)
Sets/Updates the password property of this provider.

Parameters:
sPassword - the encoded password that the provider uses to log in into the admin tool

updateIndividualSettings

void updateIndividualSettings(String sToName,
                              String sToAddress,
                              String sSMTPHost,
                              int iSMTPPort,
                              String sSuccessURL,
                              String sErrorURL,
                              String sTemplate)
Sets/Updates the individual properties of this provider after having verified the input. Note: The SMTP host and port properties may be set here, but the "master" setting may prohibit the their activation.

Parameters:
sToName - the new setting for the individual to-name
sToAddress - the new setting for the individual to-address
sSMTPHost - the new setting for the SMTP host
iSMTPPort - the new setting for the SMTP port
sSuccessURL - the new setting of the site to be shown after having successfully sent a mail
sErrorURL - the new setting of the site to be shown in case an error occurred while trying to send a mail
sTemplate - the name of the mail template to be used

getName

public String getName()
Returns the name of this provider.

Returns:
as received in the constructor

getProviderDirectory

public String getProviderDirectory()
Returns the value of the provider's individual path property.

Returns:
as read from the list of the provider-specific properties ("", if not set)

isSMTPOverwritingAllowed

public boolean isSMTPOverwritingAllowed()
Returns whether the overwriting of the default SMTP server is allowed for this provider or not.

Returns:
as read from the list of the provider-specific properties

getPassword

public String getPassword()
Returns the encoded password that the provider uses to log in into the admin tool.

Returns:
the MD5 hash of the provider's password ("", if not set)

readIndividualProperties

void readIndividualProperties()
                        throws MailWebFormException
Checks whether it's necessary to read/update the provider-specific settings. If so, the SMTP host and port, the success and the error url are read. The SMTP host, SMTP port and to-address settings are only updated if the provider is allowed to do this.

Throws:
MailWebFormException - in case there are problems accessing the file or the config dir property isn't defined (yet)

getDefaultToName

public String getDefaultToName()
Returns the default to-name setting.

Returns:
"", if not set

getIndividualToName

public String getIndividualToName()
Returns the individual to-name setting.

Returns:
"", if not set

getToName

public String getToName()
Returns the individual or the default to-name setting or null, if both aren't defined.

Returns:
may be null or "", if not set

getDefaultToAddress

public String getDefaultToAddress()
Returns the default to-address setting.

Returns:
"", if not set

getIndividualToAddress

public String getIndividualToAddress()
Returns the individual to-address setting.

Returns:
"", if not set

getToAddress

public String getToAddress()
Returns the individual or the default to-address setting or null, if both aren't defined.

Returns:
may be null or "", if not set

getDefaultSMTPHost

public String getDefaultSMTPHost()
Returns the default SMTP host setting.

Returns:
"", if not set

getIndividualSMTPHost

public String getIndividualSMTPHost()
Returns the individual SMTP host setting.

Returns:
"", if not set

getSMTPHost

public String getSMTPHost()
Returns the individual or the SMTP host setting or null, if both aren't defined.

Returns:
may be null or "", if not set

getDefaultSMTPPort

public int getDefaultSMTPPort()
Returns the default SMTP port setting.

Returns:
may be null or "", if not set

getIndividualSMTPPort

public int getIndividualSMTPPort()
Returns the individual SMTP host setting.

Returns:
may be null or "", if not set

getSMTPPort

public int getSMTPPort()
Returns the SMTP port setting.

Returns:
may be null or "", if not set

getDefaultSuccessURL

public String getDefaultSuccessURL()
Returns the default success url setting.

Returns:
"", if not set

getIndividualSuccessURL

public String getIndividualSuccessURL()
Returns the individual success url setting.

Returns:
"", if not set

getSuccessURL

public String getSuccessURL()
Returns the success url setting.

Returns:
may be null or "", if not set

getDefaultErrorURL

public String getDefaultErrorURL()
Returns the default error url setting.

Returns:
"", if not set

getIndividualErrorURL

public String getIndividualErrorURL()
Returns the individual error url setting.

Returns:
"", if not set

getErrorURL

public String getErrorURL()
Returns the error url setting.

Returns:
may be null or "", if not set

getDefaultTemplate

public String getDefaultTemplate()
Returns the default template setting.

Returns:
"", if not set

getIndividualTemplate

public String getIndividualTemplate()
Returns the individual template setting.

Returns:
"", if not set

getTemplate

public String getTemplate()
Returns the template setting.

Returns:
may be null or "", if not set

getGlobalPropertiesPart

String[] getGlobalPropertiesPart()
Returns an array filled with strings formatted like "<key>=<value>", ready to be written into the global properties file, together with the description of the section wherein these strings are located in the file.

Returns:
list to be copied as-is into the global properties file

isSystemProvider

boolean isSystemProvider()
Returns whether this provider is the system provider or not.

Returns:
is this the system provider instance?

isSystemProvider

static boolean isSystemProvider(String sProviderName)
Returns whether the given provider name is the one of the system provider or not.

Parameters:
sProviderName - the provider name to be checked
Returns:
equals "system" (case-insensitive check)?