com.softslate.commerce.customer.core
Class ActionUtilsImpl

java.lang.Object
  extended by com.softslate.commerce.customer.core.ActionUtilsImpl
All Implemented Interfaces:
ActionUtils

public class ActionUtilsImpl
extends java.lang.Object
implements ActionUtils

ActionUtilsImpl is the default implementation of the ActionUtils interface for the application.

Author:
David Tobey
See Also:
ActionUtils

Field Summary
(package private) static org.apache.commons.logging.Log log
           
 
Constructor Summary
ActionUtilsImpl()
           
 
Method Summary
 java.lang.String findCheckoutScreen(BaseForm baseForm)
          Determines what checkout screen to direct the user to based on the status of the session and the store's database configuration.
 java.lang.String formatDate(java.lang.String dbDate, java.util.Locale locale)
          Given a String representing a date as stored in the database, returns a more human-readable version suitable for display.
 java.lang.String makeFilenameNice(java.lang.String originalFileName)
          Eliminates non-standard characters from a file name so it can be safely saved across various file systems.
 boolean onAdministratorPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Runs at the beggining of each request to the administrator interface, after system objects have been initialized.
 boolean onCustomerPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Runs at the beggining of each request to the customer interface, after system objects have been initialized.
 boolean onPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Runs at the beggining of each request, after system objects have been initialized.
 java.lang.String parseGenericTemplate(BaseForm baseForm, java.lang.String template)
          Parses a string template with variables contained in a given BaseForm.
 java.lang.String parseLostPasswordTemplate(Customer customer, BaseForm baseForm, java.lang.String template)
          Parses a string template with variables contained in a given BaseForm and Customer.
 java.lang.String parseLowStockTemplate(BaseForm baseForm, java.util.Map lowStockEmail, java.lang.String template)
          Parses a string template with variables contained in a given BaseForm and a Map holding information about a SKU.
 java.lang.StringBuffer replaceOrderItems(java.lang.StringBuffer source, java.util.Collection orderItems, java.lang.String currencyCode, java.util.Locale locale, BusinessObjectUtils utils)
          Parses a StringBuffer, inserting order item data.
 java.lang.StringBuffer replaceValue(java.lang.StringBuffer source, java.lang.String value, java.lang.String token)
          Replaces the given token, or placeholder, with the given value in the given StringBuffer.
 boolean saveFile(java.lang.String filename, java.io.InputStream file)
          Saves an input stream as a file at a given location.
 void sendMultipartEmail(java.lang.String toEmails, java.lang.String ccEmails, java.lang.String bccEmails, java.lang.String fromEmail, java.lang.String smtpServer, java.lang.String subject, java.lang.String textMessage, java.lang.String htmlMessage, java.lang.String username, java.lang.String password)
          Sends a multipart text and HTML email from the store.
 boolean validateBillingFields(BaseForm baseForm)
          Validates the required billing address fields in the user's cart.
 boolean validateDeliveryFields(BaseForm baseForm)
          Validates the required delivery address fields in the user's cart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log
Constructor Detail

ActionUtilsImpl

public ActionUtilsImpl()
Method Detail

parseGenericTemplate

public java.lang.String parseGenericTemplate(BaseForm baseForm,
                                             java.lang.String template)
Description copied from interface: ActionUtils
Parses a string template with variables contained in a given BaseForm. Used to parse email templates for dynamically generated emails the store generates.

The string template may have a number of placeholders deliniated by "%%". (E.g. "%%STORE_NAME%%"). This method replaces the placeholders with values from the BaseForm, be they settings from the database such as the store's name, or values from the current user's order.

Note that with the release of 2.0, order invoice emails are now generated from JSP templates in the /WEB-INF/layouts/default/order directory, rather than by using this method.

Specified by:
parseGenericTemplate in interface ActionUtils
Parameters:
baseForm - Contains variables that will be used to replace the template's placeholders.
template - A String containing placeholders that this method will replace.
Returns:
The parsed template.

replaceValue

public java.lang.StringBuffer replaceValue(java.lang.StringBuffer source,
                                           java.lang.String value,
                                           java.lang.String token)
Replaces the given token, or placeholder, with the given value in the given StringBuffer.

Parameters:
source - The StringBuffer being parsed.
value - The value the placeholder is being replaced with.
token - The placeholder being replaced.
Returns:
The parsed StringBuffer.

replaceOrderItems

public java.lang.StringBuffer replaceOrderItems(java.lang.StringBuffer source,
                                                java.util.Collection orderItems,
                                                java.lang.String currencyCode,
                                                java.util.Locale locale,
                                                BusinessObjectUtils utils)
Parses a StringBuffer, inserting order item data. Loops through the "%%START_ITEMS%%" and "%%END_ITEMS%%" placeholders, inserting data from a given Collection of OrderItem objects. Used to parse the invoice email template upon order completion.

Parameters:
source - The StringBuffer being parsed.
orderItems - A Collection of OrderItem objects whose data is used to parse the source.
Returns:
The parsed StringBuffer.

parseLostPasswordTemplate

public java.lang.String parseLostPasswordTemplate(Customer customer,
                                                  BaseForm baseForm,
                                                  java.lang.String template)
Description copied from interface: ActionUtils
Parses a string template with variables contained in a given BaseForm and Customer. Used to parse the lost password email template.

The string template may have a number of placeholders deliniated by "%%". (E.g. "%%USERNAME%%"). This method replaces the placeholders with values from the BaseForm and Customer, be they settings from the database such as the store's name, or the current customer's user name and password.

Specified by:
parseLostPasswordTemplate in interface ActionUtils
Parameters:
customer - The current Customer whose lost password is being emailed.
baseForm - Contains variables that will be used to replace the template's placeholders.
template - The template for the lost password email, which is being parsed.
Returns:
The parsed template.

parseLowStockTemplate

public java.lang.String parseLowStockTemplate(BaseForm baseForm,
                                              java.util.Map lowStockEmail,
                                              java.lang.String template)
Description copied from interface: ActionUtils
Parses a string template with variables contained in a given BaseForm and a Map holding information about a SKU. Used to parse the low stock email template.

Specified by:
parseLowStockTemplate in interface ActionUtils
Parameters:
baseForm - Contains variables that will be used to replace the template's placeholders.
lowStockEmail - A Map containing information about a SKU that has hit its low stock level.
template - The template for the low stock email, which is being parsed.
Returns:
The parsed template.

sendMultipartEmail

public void sendMultipartEmail(java.lang.String toEmails,
                               java.lang.String ccEmails,
                               java.lang.String bccEmails,
                               java.lang.String fromEmail,
                               java.lang.String smtpServer,
                               java.lang.String subject,
                               java.lang.String textMessage,
                               java.lang.String htmlMessage,
                               java.lang.String username,
                               java.lang.String password)
                        throws java.lang.Exception
Description copied from interface: ActionUtils
Sends a multipart text and HTML email from the store. Used for sending order notifications, invoices, lost password emails, and low stock emails.

Specified by:
sendMultipartEmail in interface ActionUtils
Parameters:
toEmails - A comma-separated list of email addresses the email is being sent to.
ccEmails - A comma-separated list of email addresses the email is being copied to.
bccEmails - A comma-separated list of email addresses the email is being blind copied to.
fromEmail - The email address used as the email's from address.
smtpServer - The SMTP server to be used to send the email.
subject - The subject used for the email.
textMessage - The message for the text part of the email.
htmlMessage - The message for the HTML part of the email.
username - Username for SMTP authentication, or null if no authentication is required.
password - Password for SMTP authentication, or null if no authentication is required.
Throws:
java.lang.Exception

formatDate

public java.lang.String formatDate(java.lang.String dbDate,
                                   java.util.Locale locale)
Given a String representing a date as stored in the database, returns a more human-readable version suitable for display. (Specifically, uses this mask to format the date: MMM d, yyyy HH:mm:ss.)

Parameters:
dbDate - The date as stored in the database.
locale - The local to use to format the date.
Returns:
A more human-readable date suitable for display.

findCheckoutScreen

public java.lang.String findCheckoutScreen(BaseForm baseForm)
                                    throws java.lang.Exception
Description copied from interface: ActionUtils
Determines what checkout screen to direct the user to based on the status of the session and the store's database configuration. The possible screen names returned are:

The above screen names correspond to ActionForwards defined in the "/WEB-INF/conf/order/struts-config-order.xml" file.

Specified by:
findCheckoutScreen in interface ActionUtils
Parameters:
baseForm - The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
Returns:
A string identifying the name of the checkout screen to direct the user to.
Throws:
java.lang.Exception

validateBillingFields

public boolean validateBillingFields(BaseForm baseForm)
                              throws java.lang.Exception
Description copied from interface: ActionUtils
Validates the required billing address fields in the user's cart. Loops through the "billingRequired" database setting to check which fields are required.

Specified by:
validateBillingFields in interface ActionUtils
Parameters:
baseForm - The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
Returns:
true if all the required billing fields are present in the user's cart. false if not.
Throws:
java.lang.Exception

validateDeliveryFields

public boolean validateDeliveryFields(BaseForm baseForm)
                               throws java.lang.Exception
Description copied from interface: ActionUtils
Validates the required delivery address fields in the user's cart. Loops through the "deliveryRequired" database setting to check which fields are required.

Specified by:
validateDeliveryFields in interface ActionUtils
Parameters:
baseForm - The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
Returns:
true if all the required billing fields are present in the user's cart. false if not.
Throws:
java.lang.Exception

makeFilenameNice

public java.lang.String makeFilenameNice(java.lang.String originalFileName)
                                  throws java.lang.Exception
Description copied from interface: ActionUtils
Eliminates non-standard characters from a file name so it can be safely saved across various file systems.

Specified by:
makeFilenameNice in interface ActionUtils
Returns:
A modified version of the file name with non-standard characters eliminated
Throws:
java.lang.Exception

saveFile

public boolean saveFile(java.lang.String filename,
                        java.io.InputStream file)
                 throws java.lang.Exception
Description copied from interface: ActionUtils
Saves an input stream as a file at a given location.

Specified by:
saveFile in interface ActionUtils
Returns:
true, if saving the file succeeded
Throws:
java.lang.Exception

onPreRequestEnd

public boolean onPreRequestEnd(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
Description copied from interface: ActionUtils
Runs at the beggining of each request, after system objects have been initialized. Called from the BaseRequestProcessor.

Specified by:
onPreRequestEnd in interface ActionUtils
Returns:
true, if the request should proceed

onCustomerPreRequestEnd

public boolean onCustomerPreRequestEnd(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
Description copied from interface: ActionUtils
Runs at the beggining of each request to the customer interface, after system objects have been initialized. Called from the CustomerRequestProcessor.

Specified by:
onCustomerPreRequestEnd in interface ActionUtils
Returns:
true, if the request should proceed

onAdministratorPreRequestEnd

public boolean onAdministratorPreRequestEnd(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response)
Description copied from interface: ActionUtils
Runs at the beggining of each request to the administrator interface, after system objects have been initialized. Called from the CustomerRequestProcessor.

Specified by:
onAdministratorPreRequestEnd in interface ActionUtils
Returns:
true, if the request should proceed


Copyright ? SoftSlate, LLC 2003?2005