org.alltimeflashdreamer.mailwebform
Class MailFormProviderList

java.lang.Object
  extended byorg.alltimeflashdreamer.mailwebform.MailFormProviderList
All Implemented Interfaces:
Serializable

public class MailFormProviderList
extends Object
implements Serializable

Title: MailFormProviderList
Description: Represents a handler of a list of known/defined providers of a mailwebform site, as defined in the application's global properties file.

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

Constructor Summary
(package private) MailFormProviderList(GlobalProperties globalProperties)
          The constructor receives the Properties object where the providers' settings are stored, especially the comma-separated list of defined/active providers which is used to build the internal list of providers
 
Method Summary
(package private)  void checkProviderSettings()
          Steps through the list of registered providers and forces each one to check whether the provider-specific settings file has been changed since the last access.
(package private)  void checkProviderSettings(String sProviderName)
          Searches the given provider in the list and forces him to reread the settings from the individual property file.
(package private)  String getErrorURL(String sProviderName, String sDefaultErrorURL)
          Returns the given provider's "ERROR_URL" setting.
(package private)  String[] getGlobalPropertiesPart(String sProviderName)
          Returns the list of lines that are to be written into the global properties file for the given provider.
 String getPassword(String sProviderName)
          Returns the password parameter of the given provider or null, if the specified provider doesn't exist.
(package private)  MailFormProvider getProvider(String sProviderName)
          Returns the specified provider instance or null, if the specified provider name is not registered (case-insensitive check).
 String getProviderDirectory(String sProviderName)
          Returns the ProviderDirectory parameter of the given provider or null, if the specified provider doesn't exist.
(package private)  String[] getProviderNames()
          Returns a String[] containing the names of the registered providers.
(package private)  String getSMTPHost(String sProviderName, String sDefaultSMTPHost)
          Returns the given provider's "SMTP_HOST" setting.
(package private)  int getSMTPPort(String sProviderName, int iDefaultSMTPPort)
          Returns the given provider's "SMTP_PORT" setting.
(package private)  String getSuccessURL(String sProviderName, String sDefaultSuccessURL)
          Returns the given provider's "SUCCESS_URL" setting.
 String getToAddress(String sProviderName, String sDefaultToAddress)
          Returns the given provider's "TOADDRESS" setting.
 String getToName(String sProviderName, String sDefaultToName)
          Returns the given provider's "TONAME" setting.
(package private) static String getValidProperty(String sProperty, String sDefaultProperty)
          Returns the given property, if not null and not empty, else the given default one.
(package private)  boolean hasProvider(String sProviderName)
          Returns whether the given provider name is in the list of all registered providers or not (case-insensitive check).
 boolean isSMTPOverwriteAllowed(String sProviderName)
          Returns the boolean value of the given provider's "SMTP_ALLOWOVERWRITE" setting.
(package private)  void removeProvider(String sProviderName)
          Removes the given provider from the list.
(package private)  void updatePassword(String sProviderName, String sPassword)
          Sets/Updates the password property of the specified provider.
(package private)  void updateProvider(String sProviderName, String sProviderDirectory, String sToName, String sToAddress, String sAllowOverwrite, String sTemplate, GlobalProperties globalProperties)
          Updates the "personal" setting of the specified provider by recreating the MailFormProvider instance and overwriting the old one within this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailFormProviderList

MailFormProviderList(GlobalProperties globalProperties)
               throws MailWebFormException,
                      IOException
The constructor receives the Properties object where the providers' settings are stored, especially the comma-separated list of defined/active providers which is used to build the internal list of providers

Parameters:
globalProperties - a Properties object which loaded the data of the global properties file before
Throws:
MailWebFormException - thrown on problems with the config dir property
IOException - in case an I/O error occurred during the accessing of a provider's own properties file
Method Detail

getProviderNames

String[] getProviderNames()
Returns a String[] containing the names of the registered providers.

Returns:
the list of registered provider names, at least filled with the "system" one

hasProvider

boolean hasProvider(String sProviderName)
Returns whether the given provider name is in the list of all registered providers or not (case-insensitive check).

Parameters:
sProviderName - the provider name to search for
Returns:
whether this provider is a registered one or not

getProvider

MailFormProvider getProvider(String sProviderName)
Returns the specified provider instance or null, if the specified provider name is not registered (case-insensitive check).

Parameters:
sProviderName - the name of the provider to be returned
Returns:
the specified provider instance or null

getProviderDirectory

public String getProviderDirectory(String sProviderName)
Returns the ProviderDirectory parameter of the given provider or null, if the specified provider doesn't exist.

Parameters:
sProviderName - the name of the provider
Returns:
the path of the directory where the provider's own properties file and/or the mail template are stored

getGlobalPropertiesPart

String[] getGlobalPropertiesPart(String sProviderName)
Returns the list of lines that are to be written into the global properties file for the given provider. The return value can be used as-is to write it into the output file.

Parameters:
sProviderName - the name of the provider
Returns:
the list of "ready to write" lines (may be null)

getSMTPHost

String getSMTPHost(String sProviderName,
                   String sDefaultSMTPHost)
Returns the given provider's "SMTP_HOST" setting.

Parameters:
sProviderName - the name of the provider
sDefaultSMTPHost - the value to use in case the provider is not known
Returns:
the provider's own SMTP host or the given default SMTP host.

getSMTPPort

int getSMTPPort(String sProviderName,
                int iDefaultSMTPPort)
Returns the given provider's "SMTP_PORT" setting.

Parameters:
sProviderName - the name of the provider
iDefaultSMTPPort - the value to use in case the provider is not known
Returns:
the provider's own SMTP port or the given default SMTP Port.

getSuccessURL

String getSuccessURL(String sProviderName,
                     String sDefaultSuccessURL)
Returns the given provider's "SUCCESS_URL" setting.

Parameters:
sProviderName - the name of the provider
sDefaultSuccessURL - the value to use in case the provider is not known
Returns:
the provider's own success URL or the given default success URL.

getErrorURL

String getErrorURL(String sProviderName,
                   String sDefaultErrorURL)
Returns the given provider's "ERROR_URL" setting.

Parameters:
sProviderName - the name of the provider
sDefaultErrorURL - the value to use in case the provider is not known
Returns:
the provider's own error URL or the given default error URL.

getToName

public String getToName(String sProviderName,
                        String sDefaultToName)
Returns the given provider's "TONAME" setting.

Parameters:
sProviderName - the name of the provider
sDefaultToName - the value to use in case the provider is not known
Returns:
the provider's mail address name setting or the given default to-name

getToAddress

public String getToAddress(String sProviderName,
                           String sDefaultToAddress)
Returns the given provider's "TOADDRESS" setting.

Parameters:
sProviderName - the name of the provider
sDefaultToAddress - the value to use in case the provider is not known
Returns:
the provider's mail address setting or the given default to-address

isSMTPOverwriteAllowed

public boolean isSMTPOverwriteAllowed(String sProviderName)
Returns the boolean value of the given provider's "SMTP_ALLOWOVERWRITE" setting. If this setting is not defined, the default setting (which is true) is returned.

Parameters:
sProviderName - the name of the provider
Returns:
the provider's allow SMTP overwrite setting

getPassword

public String getPassword(String sProviderName)
Returns the password parameter of the given provider or null, if the specified provider doesn't exist.

Parameters:
sProviderName - the name of the provider
Returns:
the encoded admin tool password of the provider

checkProviderSettings

void checkProviderSettings()
                     throws MailWebFormException
Steps through the list of registered providers and forces each one to check whether the provider-specific settings file has been changed since the last access. If so, the properties of this provider are re-read.

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

checkProviderSettings

void checkProviderSettings(String sProviderName)
                     throws MailWebFormException
Searches the given provider in the list and forces him to reread the settings from the individual property file. It is recommended to call this method before each querying of the provider's settings!

Parameters:
sProviderName - name of the provider, to find its instance
Throws:
MailWebFormException - in case there are problems accessing the file or the config dir property isn't defined (yet)

updateProvider

void updateProvider(String sProviderName,
                    String sProviderDirectory,
                    String sToName,
                    String sToAddress,
                    String sAllowOverwrite,
                    String sTemplate,
                    GlobalProperties globalProperties)
              throws MailWebFormException,
                     IOException
Updates the "personal" setting of the specified provider by recreating the MailFormProvider instance and overwriting the old one within this list.

Parameters:
sProviderName - update whom?
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
sAllowOverwrite - 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
globalProperties - the list containing the global properties
Throws:
MailWebFormException - thrown on problems with the config dir property
IOException - in case problems occurred while accessing the provider's properties file

updatePassword

void updatePassword(String sProviderName,
                    String sPassword)
Sets/Updates the password property of the specified provider.

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

removeProvider

void removeProvider(String sProviderName)
Removes the given provider from the list. If the input is not the name of a registered provider, nothing is done.

Parameters:
sProviderName - remove whom?

getValidProperty

static String getValidProperty(String sProperty,
                               String sDefaultProperty)
Returns the given property, if not null and not empty, else the given default one.

Parameters:
sProperty - the - optional - individual property
sDefaultProperty - the fallback value, if the given property is null or empty
Returns:
the valid, i.e. the "usable" property