com.softslate.commerce.customer.core
Interface ActionUtils

All Known Implementing Classes:
ActionUtilsImpl

public interface ActionUtils

Interface for utility methods used by Struts Action classes.

When the application needs to create an instance that implements ActionUtils, it calls BusinessObjectFactory.createUtilsObject(java.lang.String) , which finds the name of the Java class to instantiate from the "actionUtilsImplemeter" setting in the appComponents.properties file.

The default "actionUtilsImplemeter" is ActionUtilsImpl.

Author:
David Tobey

Method Summary
 void addInventoryMessages(java.util.Map results, BaseForm baseForm)
          Adds non-error messages to the request related to inventory.
 java.util.Map buildParameterMap(javax.servlet.http.HttpServletRequest request)
          Creates a string-based Map based on all the request parameters.
 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.util.Collection loadEstimatedShippingOptions(BaseForm baseForm)
          Load a set of estimated shipping options for the current cart.
 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.String processCartAddResults(java.util.Map results, BaseForm baseForm)
          Process the results of adding an item or items to the cart.
 void processSavedCartCookie(BaseForm baseForm, java.util.Map parameters, javax.servlet.http.HttpServletResponse response)
          If the system settings permit it, add a persistent cookie to the user's browser identifying the cart so it can be loaded on a later visit.
 boolean saveFile(java.lang.String filename, java.io.InputStream file)
          Saves an input stream as a file at a given location.
 void sendLowStockEmails(java.util.Collection lowStockEmails, BaseForm baseForm)
          Sends low stock emails related to the item or items being added to the cart.
 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.
 

Method Detail

parseGenericTemplate

java.lang.String parseGenericTemplate(BaseForm baseForm,
                                      java.lang.String template)
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.

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.

parseLostPasswordTemplate

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. 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.

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

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. Used to parse the low stock email template.

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

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
Sends a multipart text and HTML email from the store. Used for sending order notifications, invoices, lost password emails, and low stock emails.

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

findCheckoutScreen

java.lang.String findCheckoutScreen(BaseForm baseForm)
                                    throws java.lang.Exception
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.

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

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

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

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

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

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

Parameters:
originalFileName -
Returns:
A modified version of the file name with non-standard characters eliminated
Throws:
java.lang.Exception

saveFile

boolean saveFile(java.lang.String filename,
                 java.io.InputStream file)
                 throws java.lang.Exception
Saves an input stream as a file at a given location.

Parameters:
filename -
file -
Returns:
true, if saving the file succeeded
Throws:
java.lang.Exception

onPreRequestEnd

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. Called from the BaseRequestProcessor.

Parameters:
request -
response -
Returns:
true, if the request should proceed
Throws:
java.lang.Exception

onCustomerPreRequestEnd

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. Called from the CustomerRequestProcessor.

Parameters:
request -
response -
Returns:
true, if the request should proceed
Throws:
java.lang.Exception

onAdministratorPreRequestEnd

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. Called from the CustomerRequestProcessor.

Parameters:
request -
response -
Returns:
true, if the request should proceed
Throws:
java.lang.Exception

processSavedCartCookie

void processSavedCartCookie(BaseForm baseForm,
                            java.util.Map parameters,
                            javax.servlet.http.HttpServletResponse response)
If the system settings permit it, add a persistent cookie to the user's browser identifying the cart so it can be loaded on a later visit.

A cookie with the name "sscsctoken" and the value of the user's session id will be saved in the browser and recorded in the sscOrder database table's "savedCartToken" field.

Parameters:
baseForm - The instance of CartAddForm corresponding to the request.
parameters - The parameters of the add to cart request.
response - The servlet's response object, used to save the cookie to the browser.

processCartAddResults

java.lang.String processCartAddResults(java.util.Map results,
                                       BaseForm baseForm)
Process the results of adding an item or items to the cart. This method first sends out low stock inventory emails. It then adds error messages for customers if required attributes were missing from the request or the item or items are out of stock.

In the case of an error, the attribute "errorProductCode" is set in the request, corresponding to the product code of the first item being added to the cart. If the submission came from a product page, this will tell the ProductForm to populate the request with that product's data, so the errors can be displayed on the product page.

Finally, this method calls the addInventoryMessages method, to populate the request with (non-error) messages relating to inventory.

Parameters:
results - The Map of results returned by the call to the execute method of this class.
baseForm - The instance of CartAddForm corresponding to the request.
Returns:
A String, "success" or "failure", corresponding to the ActionFoward that the execute method will return.

addInventoryMessages

void addInventoryMessages(java.util.Map results,
                          BaseForm baseForm)
Adds non-error messages to the request related to inventory. Two types of messages may be added.
  • Messages indicating that the quantity of an item was more than its inventory level and that therefore the quantity was automatically lowered to match the amount in stock.
  • Messages indicating that with this request a product has just hit its out of stock level.

Parameters:
results - The Map of results returned by the call to the execute method of this class.
baseForm - The instance of CartAddForm corresponding to the current request.

sendLowStockEmails

void sendLowStockEmails(java.util.Collection lowStockEmails,
                        BaseForm baseForm)
Sends low stock emails related to the item or items being added to the cart. Settings defining how these emails are produced exist in the sscSetting and (for specific products) in the sscProductSetting database tables. Among the settings are who receives the low-stock emails, what inventory level triggers the emails, and a template for the subject and body of the emails.

Parameters:
lowStockEmails - A Collection of Maps containing information on what items have reached their low stock levels. This Collection is returned by the call to CartProcessor.processAddItems(Map) in the execute method.
baseForm - The instance of CartAddForm corresponding to the current request.

loadEstimatedShippingOptions

java.util.Collection loadEstimatedShippingOptions(BaseForm baseForm)
Load a set of estimated shipping options for the current cart. The options may be merely estimates because the shopper may not have defined a delivery address yet, if he has not logged in or entered addresses during checkout. In these cases, the default city, state, country, and ZIP defined in the database settings are used.

Parameters:
baseForm -
Returns:
A Collection of Maps representing the various shipping options and their rates.

buildParameterMap

java.util.Map buildParameterMap(javax.servlet.http.HttpServletRequest request)
                                throws java.lang.Exception
Creates a string-based Map based on all the request parameters.

Parameters:
request -
Returns:
A map representing all the request parameters.
Throws:
java.lang.Exception


Copyright © SoftSlate, LLC 2003–2005