Class BasicCustomerProcessor
- All Implemented Interfaces:
BusinessObject
,BusinessProcessor
,CustomerProcessor
BasicCustomerProcessor
is the default implementation of the
CustomerProcessor
interface for the application.
- Author:
- David Tobey
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCustomer
(Map parameters) protected String
void
customerChangePassword
(String newDecryptedPassword, Customer customer) void
deleteCustomer
(Map parameters) editCustomer
(Map parameters) editDeleteCustomers
(Map parameters) protected String
formatPreviousPasswords
(Customer customer, String newPasswordEncrypted) protected void
incrementNumberOfFailedLogins
(Customer customer) protected boolean
isCustomerLockedOut
(Customer customer) protected boolean
isPasswordExpired
(Customer customer) protected boolean
isSameAsPreviousPassword
(Customer customer, String newPasswordEncrypted, int numberOfPreviousPasswordsToCheck) loadCustomerAdvancedLostPassword
(Map parameters) loadCustomerFromID
(Map parameters) loadCustomerFromResetToken
(Map parameters) loadCustomerFromUserName
(Map parameters) loadCustomerLostPassword
(Map parameters) Loads theCustomer
property of thisCustomerProcesor
from the database given aMap
containing theuserName
.loadCustomersAndCount
(Map parameters) Loads the set of download files that the customer has purchased from the database.int
loadOrderDetails
(Map parameters) Loads all of the database information corresponding to a given order number for a given customer.Loads a customer's order history from the database.loadPreviousOrder
(Map parameters) Loads a previously placed order for a customer from the database, assigning it as the customer's current cart.loadSavedCart
(Map parameters) Loads a saved cart for a customer from the database, assigning it as the customer's current cart.Loads a customer's list of saved carts from the database.protected void
lockOutIfTooManyFailedLogins
(Customer customer) processAutoLogin
(Map parameters) Processes an automatic login given a user's autoLoginToken.processChangePassword
(String currentDecryptedPassword, String newDecryptedPassword) processLogin
(Map parameters) Processes a login attempt given a user name and password.processRegister
(Map parameters) Processes a request to register or add a new customer account into the system.removeSavedCart
(Map parameters) Removes a saved cart for a customer from the database, changing the order record to a status of "Saved".protected void
resetPassword
(String token, String newPassword) Saves anOrder
in the database as a saved cart, with a status of "Saved", which a customer can pick up later.protected boolean
sendAccountActivationEmail
(Customer customer) boolean
sendCompleteResetPasswordEmail
(Customer customer) boolean
sendLostPasswordAdvancedEmail
(Customer customer) updateAddresses
(Map parameters) Updates a customer's address information.updateCustomer
(Map parameters) Updates a customer's account information.validateCustomer
(Customer customer) Methods inherited from class com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
formatDateTime, formatPrice, getAppComponents, getAppSettings, getAttributeIDs, getBusinessObjectFactory, getDaoFactory, getEventBus, getInjector, getProductIDs, getSettings, getUser, initialize, isProcessorClassActive, loadMatchingSkus, parseDateTime, parseResponseData, prepareRequestData, sendHTTPGet, sendHTTPPost, sendHTTPPost, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setEventBus, setInjector, setSettings, setUser, updateOrderTotals, updateOrderTotals, updateOrderTotals, utils
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.softslate.commerce.businessobjects.core.BusinessObject
initialize
Methods inherited from interface com.softslate.commerce.businessobjects.core.BusinessProcessor
getAppComponents, getAppSettings, getBusinessObjectFactory, getDaoFactory, getEventBus, getInjector, getSettings, getUser, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setEventBus, setInjector, setSettings, setUser, utils
-
Field Details
-
log
static org.apache.commons.logging.Log log
-
-
Constructor Details
-
BasicCustomerProcessor
public BasicCustomerProcessor()
-
-
Method Details
-
processRegister
Description copied from interface:CustomerProcessor
Processes a request to register or add a new customer account into the system. The incomingMap
should have at least two keys:userName
anddecryptedPassword
, which will be used for the new account. If successful, thecustomer
property of the currentUser
will be populated with the new account's information. If an account already exists with the sameuserName
, the returnedMap
will contain a key named "resultCode" whose value is "errors.userAlreadyLoggedIn". This code is used in the Struts layer to look up the error message.- Specified by:
processRegister
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the user name and password for the new customer account.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
processLogin
Description copied from interface:CustomerProcessor
Processes a login attempt given a user name and password. The incomingMap
must have two keys:userName
andpassword
. If the login attempt succeeds, theCustomer
property of the currentUser
will be populated with the database information for the customer account. If the user name and password don't match an account in the database, the returnedMap
will contain a key named "resultCode" whose value is "errors.invalidLogin". This code is used in the Struts layer to look up the error message.- Specified by:
processLogin
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the user name and password for the customer attempting to log in.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
resetNumberOfFailedLoginsIfLockOutExpired
-
incrementNumberOfFailedLogins
-
isCustomerLockedOut
-
lockOutIfTooManyFailedLogins
-
isPasswordExpired
-
isSameAsPreviousPassword
-
processChangePassword
public Map processChangePassword(String currentDecryptedPassword, String newDecryptedPassword) throws Exception - Specified by:
processChangePassword
in interfaceCustomerProcessor
- Throws:
Exception
-
processAutoLogin
Description copied from interface:CustomerProcessor
Processes an automatic login given a user's autoLoginToken. The incomingMap
must have the key:autoLoginToken
. If the login succeeds, theCustomer
property of the currentUser
will be populated with the database information for the customer account. If the autoLoginToken doesn't match an account in the database, the returnedMap
will contain a key named "resultCode" whose value is "errors.invalidLogin".- Specified by:
processAutoLogin
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the autoLoginToken for the customer.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
updateAddresses
Description copied from interface:CustomerProcessor
Updates a customer's address information. The incomingMap
should contain keys corresponding to the delivery address properties ofCustomerAddress
, and the billing address properties ofCustomer
. TheCustomer
property of the current user, and the firstCustomerAddress
in thecustomerAddressCollection
of theCustomer
are modified with the incoming address information. Then the database records for the customer and the customer address are updated insscCustomer
andsscCustomerAddress
.- Specified by:
updateAddresses
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the address information for the current user, which is to be used to update the account.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
updateCustomer
Description copied from interface:CustomerProcessor
Updates a customer's account information. The incomingMap
should contain keys corresponding to the properties ofCustomer
. TheCustomer
property of the current user is modified with the account information contained in the incomingMap
. Then the database record for the customer is updated. Used to process a changed user name and password.If the incoming user name is already used by a different customer, the returned
Map
will contain a key named "resultCode" whose value is "errors.userNameNotUnique". This code is used in the Struts layer to look up the error message.- Specified by:
updateCustomer
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the account information for the current user, which is to be used to update the account.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
loadCustomerLostPassword
Description copied from interface:CustomerProcessor
Loads theCustomer
property of thisCustomerProcesor
from the database given aMap
containing theuserName
. Used in the lost password form, when a customer must be retrieved from database without a password.If the application is set to use one-way encryption for customer passwords, this method will generate a random password and update the customer's record with it.
If the customer corresponding to the user name in the
Map
does not exist in the database, the returnedMap
will contain a key named "resultCode" whose value is "errors.userNameNotFound". This code is used in the Struts layer to look up the error message.- Specified by:
loadCustomerLostPassword
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing the user name of a given customer.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
loadOrderHistory
Description copied from interface:CustomerProcessor
Loads a customer's order history from the database. If successful, theCustomer
property of the currentUser
will have itsorderHistory
property populated with information from the database about all of the customer's previous orders in the store.- Specified by:
loadOrderHistory
in interfaceCustomerProcessor
- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
loadOrderDetails
Description copied from interface:CustomerProcessor
Loads all of the database information corresponding to a given order number for a given customer. Used to retrieve the order details for a customer viewing his or her order history.- Specified by:
loadOrderDetails
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing a key namedorderNumber
with the order number of a given order.- Returns:
- An
Order
populated with information from the database. - Throws:
Exception
-
loadDownloadFiles
Description copied from interface:CustomerProcessor
Loads the set of download files that the customer has purchased from the database. The set of files is determined by querying thesscProductSetting
table for download files associated with products that the customer has purchased previously.- Specified by:
loadDownloadFiles
in interfaceCustomerProcessor
- Returns:
- A
Collection
ofMap
s, one for each file available for download by the customer. - Throws:
Exception
-
saveCart
Description copied from interface:CustomerProcessor
Saves anOrder
in the database as a saved cart, with a status of "Saved", which a customer can pick up later.- Specified by:
saveCart
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing arguments, by default null.- Returns:
- A
Map
with a key named "resultCode", equal to "0" if the result is successful. - Throws:
Exception
-
loadSavedCarts
Description copied from interface:CustomerProcessor
Loads a customer's list of saved carts from the database. Saved carts are stored as incomplete orders in thesscOrder
database table with a status of "Saved".- Specified by:
loadSavedCarts
in interfaceCustomerProcessor
- Returns:
- A
Collection
ofOrder
objects representing the customer's saved carts. - Throws:
Exception
-
loadSavedCart
Description copied from interface:CustomerProcessor
Loads a saved cart for a customer from the database, assigning it as the customer's current cart. Saved carts are stored as incomplete orders in thesscOrder
database table with a status of "Saved".- Specified by:
loadSavedCart
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing a key namedorderID
with the order id of a given order.- Returns:
- A
Map
object containing the results of the reprocessing of the order, or null, if therefreshSaved Carts
setting is false. - Throws:
Exception
-
removeSavedCart
Description copied from interface:CustomerProcessor
Removes a saved cart for a customer from the database, changing the order record to a status of "Saved".- Specified by:
removeSavedCart
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing a key namedorderID
with the order id of a given order.- Returns:
- null in this implementation.
- Throws:
Exception
-
loadPreviousOrder
Description copied from interface:CustomerProcessor
Loads a previously placed order for a customer from the database, assigning it as the customer's current cart.- Specified by:
loadPreviousOrder
in interfaceCustomerProcessor
- Parameters:
parameters
- AMap
containing a key namedorderID
with the order id of a given order.- Returns:
- A
Map
object containing the results of the reprocessing of the order, or null, if therefreshReorders
setting is false - Throws:
Exception
-
loadCustomersAndCount
- Specified by:
loadCustomersAndCount
in interfaceCustomerProcessor
- Throws:
Exception
-
addCustomer
- Specified by:
addCustomer
in interfaceCustomerProcessor
- Throws:
Exception
-
validateCustomer
- Specified by:
validateCustomer
in interfaceCustomerProcessor
- Throws:
Exception
-
loadCustomerFromID
- Specified by:
loadCustomerFromID
in interfaceCustomerProcessor
- Throws:
Exception
-
editCustomer
- Specified by:
editCustomer
in interfaceCustomerProcessor
- Throws:
Exception
-
loadCustomerFromUserName
- Specified by:
loadCustomerFromUserName
in interfaceCustomerProcessor
- Throws:
Exception
-
editDeleteCustomers
- Specified by:
editDeleteCustomers
in interfaceCustomerProcessor
- Throws:
Exception
-
deleteCustomer
- Specified by:
deleteCustomer
in interfaceCustomerProcessor
- Throws:
Exception
-
loadMaxCustomerID
- Specified by:
loadMaxCustomerID
in interfaceCustomerProcessor
- Throws:
Exception
-
loadCustomerAdvancedLostPassword
- Specified by:
loadCustomerAdvancedLostPassword
in interfaceCustomerProcessor
- Throws:
Exception
-
loadCustomerFromResetToken
- Specified by:
loadCustomerFromResetToken
in interfaceCustomerProcessor
- Throws:
Exception
-
resetPassword
- Specified by:
resetPassword
in interfaceCustomerProcessor
- Throws:
Exception
-
customerChangePassword
- Specified by:
customerChangePassword
in interfaceCustomerProcessor
- Throws:
Exception
-
computeAndFormatPasswordExpiration
-
formatPreviousPasswords
-
sendAccountActivationEmail
- Throws:
Exception
-
sendLostPasswordAdvancedEmail
- Specified by:
sendLostPasswordAdvancedEmail
in interfaceCustomerProcessor
- Throws:
Exception
-
sendCompleteResetPasswordEmail
- Specified by:
sendCompleteResetPasswordEmail
in interfaceCustomerProcessor
- Throws:
Exception
-
refreshCustomerFromDatabase
- Throws:
Exception
-
refreshCustomerFromDatabase
- Specified by:
refreshCustomerFromDatabase
in interfaceCustomerProcessor
- Throws:
Exception
-