Class BasicCustomerProcessor

All Implemented Interfaces:
BusinessObject, BusinessProcessor, CustomerProcessor

public class BasicCustomerProcessor extends BaseBusinessProcessor implements CustomerProcessor
Processes business logic having to do with a customer's account and related objects. Created in the Struts layer in response to requests for information about an exisiting customer account, or to create new accounts.

BasicCustomerProcessor is the default implementation of the CustomerProcessor interface for the application.

Author:
David Tobey
See Also:
  • Field Details

    • log

      static org.apache.commons.logging.Log log
  • Constructor Details

    • BasicCustomerProcessor

      public BasicCustomerProcessor()
  • Method Details

    • processRegister

      public Map processRegister(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Processes a request to register or add a new customer account into the system. The incoming Map should have at least two keys: userName and decryptedPassword, which will be used for the new account. If successful, the customer property of the current User will be populated with the new account's information. If an account already exists with the same userName, the returned Map 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 interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      public Map processLogin(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Processes a login attempt given a user name and password. The incoming Map must have two keys: userName and password. If the login attempt succeeds, the Customer property of the current User 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 returned Map 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 interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      protected void resetNumberOfFailedLoginsIfLockOutExpired(Customer customer)
    • incrementNumberOfFailedLogins

      protected void incrementNumberOfFailedLogins(Customer customer)
    • isCustomerLockedOut

      protected boolean isCustomerLockedOut(Customer customer)
    • lockOutIfTooManyFailedLogins

      protected void lockOutIfTooManyFailedLogins(Customer customer)
    • isPasswordExpired

      protected boolean isPasswordExpired(Customer customer)
    • isSameAsPreviousPassword

      protected boolean isSameAsPreviousPassword(Customer customer, String newPasswordEncrypted, int numberOfPreviousPasswordsToCheck)
    • processChangePassword

      public Map processChangePassword(String currentDecryptedPassword, String newDecryptedPassword) throws Exception
      Specified by:
      processChangePassword in interface CustomerProcessor
      Throws:
      Exception
    • processAutoLogin

      public Map processAutoLogin(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Processes an automatic login given a user's autoLoginToken. The incoming Map must have the key: autoLoginToken. If the login succeeds, the Customer property of the current User will be populated with the database information for the customer account. If the autoLoginToken doesn't match an account in the database, the returned Map will contain a key named "resultCode" whose value is "errors.invalidLogin".
      Specified by:
      processAutoLogin in interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      public Map updateAddresses(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Updates a customer's address information. The incoming Map should contain keys corresponding to the delivery address properties of CustomerAddress, and the billing address properties of Customer. The Customer property of the current user, and the first CustomerAddress in the customerAddressCollection of the Customer are modified with the incoming address information. Then the database records for the customer and the customer address are updated in sscCustomer and sscCustomerAddress.
      Specified by:
      updateAddresses in interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      public Map updateCustomer(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Updates a customer's account information. The incoming Map should contain keys corresponding to the properties of Customer. The Customer property of the current user is modified with the account information contained in the incoming Map. 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 interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      public Map loadCustomerLostPassword(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Loads the Customer property of this CustomerProcesor from the database given a Map containing the userName. 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 returned Map 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 interface CustomerProcessor
      Parameters:
      parameters - A Map 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

      public Map loadOrderHistory() throws Exception
      Description copied from interface: CustomerProcessor
      Loads a customer's order history from the database. If successful, the Customer property of the current User will have its orderHistory property populated with information from the database about all of the customer's previous orders in the store.
      Specified by:
      loadOrderHistory in interface CustomerProcessor
      Returns:
      A Map with a key named "resultCode", equal to "0" if the result is successful.
      Throws:
      Exception
    • loadOrderDetails

      public Order loadOrderDetails(Map parameters) throws Exception
      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 interface CustomerProcessor
      Parameters:
      parameters - A Map containing a key named orderNumber with the order number of a given order.
      Returns:
      An Order populated with information from the database.
      Throws:
      Exception
    • loadDownloadFiles

      public Collection loadDownloadFiles() throws Exception
      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 the sscProductSetting table for download files associated with products that the customer has purchased previously.
      Specified by:
      loadDownloadFiles in interface CustomerProcessor
      Returns:
      A Collection of Maps, one for each file available for download by the customer.
      Throws:
      Exception
    • saveCart

      public Map saveCart(Map parameters) throws Exception
      Description copied from interface: CustomerProcessor
      Saves an Order in the database as a saved cart, with a status of "Saved", which a customer can pick up later.
      Specified by:
      saveCart in interface CustomerProcessor
      Parameters:
      parameters - A Map containing arguments, by default null.
      Returns:
      A Map with a key named "resultCode", equal to "0" if the result is successful.
      Throws:
      Exception
    • loadSavedCarts

      public Collection loadSavedCarts() throws Exception
      Description copied from interface: CustomerProcessor
      Loads a customer's list of saved carts from the database. Saved carts are stored as incomplete orders in the sscOrder database table with a status of "Saved".
      Specified by:
      loadSavedCarts in interface CustomerProcessor
      Returns:
      A Collection of Order objects representing the customer's saved carts.
      Throws:
      Exception
    • loadSavedCart

      public Map loadSavedCart(Map parameters) throws Exception
      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 the sscOrder database table with a status of "Saved".
      Specified by:
      loadSavedCart in interface CustomerProcessor
      Parameters:
      parameters - A Map containing a key named orderID with the order id of a given order.
      Returns:
      A Map object containing the results of the reprocessing of the order, or null, if the refreshSaved Carts setting is false.
      Throws:
      Exception
    • removeSavedCart

      public Map removeSavedCart(Map parameters) throws Exception
      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 interface CustomerProcessor
      Parameters:
      parameters - A Map containing a key named orderID with the order id of a given order.
      Returns:
      null in this implementation.
      Throws:
      Exception
    • loadPreviousOrder

      public Map loadPreviousOrder(Map parameters) throws Exception
      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 interface CustomerProcessor
      Parameters:
      parameters - A Map containing a key named orderID with the order id of a given order.
      Returns:
      A Map object containing the results of the reprocessing of the order, or null, if the refreshReorders setting is false
      Throws:
      Exception
    • loadCustomersAndCount

      public Map loadCustomersAndCount(Map parameters) throws Exception
      Specified by:
      loadCustomersAndCount in interface CustomerProcessor
      Throws:
      Exception
    • addCustomer

      public Map addCustomer(Map parameters) throws Exception
      Specified by:
      addCustomer in interface CustomerProcessor
      Throws:
      Exception
    • validateCustomer

      public Map validateCustomer(Customer customer) throws Exception
      Specified by:
      validateCustomer in interface CustomerProcessor
      Throws:
      Exception
    • loadCustomerFromID

      public Customer loadCustomerFromID(Map parameters) throws Exception
      Specified by:
      loadCustomerFromID in interface CustomerProcessor
      Throws:
      Exception
    • editCustomer

      public Map editCustomer(Map parameters) throws Exception
      Specified by:
      editCustomer in interface CustomerProcessor
      Throws:
      Exception
    • loadCustomerFromUserName

      public Customer loadCustomerFromUserName(Map parameters) throws Exception
      Specified by:
      loadCustomerFromUserName in interface CustomerProcessor
      Throws:
      Exception
    • editDeleteCustomers

      public Map editDeleteCustomers(Map parameters) throws Exception
      Specified by:
      editDeleteCustomers in interface CustomerProcessor
      Throws:
      Exception
    • deleteCustomer

      public void deleteCustomer(Map parameters) throws Exception
      Specified by:
      deleteCustomer in interface CustomerProcessor
      Throws:
      Exception
    • loadMaxCustomerID

      public int loadMaxCustomerID() throws Exception
      Specified by:
      loadMaxCustomerID in interface CustomerProcessor
      Throws:
      Exception
    • loadCustomerAdvancedLostPassword

      public Map loadCustomerAdvancedLostPassword(Map parameters) throws Exception
      Specified by:
      loadCustomerAdvancedLostPassword in interface CustomerProcessor
      Throws:
      Exception
    • loadCustomerFromResetToken

      public Map loadCustomerFromResetToken(Map parameters) throws Exception
      Specified by:
      loadCustomerFromResetToken in interface CustomerProcessor
      Throws:
      Exception
    • resetPassword

      public Map resetPassword(String token, String newPassword) throws Exception
      Specified by:
      resetPassword in interface CustomerProcessor
      Throws:
      Exception
    • customerChangePassword

      public void customerChangePassword(String newDecryptedPassword, Customer customer) throws Exception
      Specified by:
      customerChangePassword in interface CustomerProcessor
      Throws:
      Exception
    • computeAndFormatPasswordExpiration

      protected String computeAndFormatPasswordExpiration()
    • formatPreviousPasswords

      protected String formatPreviousPasswords(Customer customer, String newPasswordEncrypted)
    • sendAccountActivationEmail

      protected boolean sendAccountActivationEmail(Customer customer) throws Exception
      Throws:
      Exception
    • sendLostPasswordAdvancedEmail

      public boolean sendLostPasswordAdvancedEmail(Customer customer) throws Exception
      Specified by:
      sendLostPasswordAdvancedEmail in interface CustomerProcessor
      Throws:
      Exception
    • sendCompleteResetPasswordEmail

      public boolean sendCompleteResetPasswordEmail(Customer customer) throws Exception
      Specified by:
      sendCompleteResetPasswordEmail in interface CustomerProcessor
      Throws:
      Exception
    • refreshCustomerFromDatabase

      public Map refreshCustomerFromDatabase() throws Exception
      Throws:
      Exception
    • refreshCustomerFromDatabase

      public Map refreshCustomerFromDatabase(User user) throws Exception
      Specified by:
      refreshCustomerFromDatabase in interface CustomerProcessor
      Throws:
      Exception