Interface CustomerService

All Known Implementing Classes:
CustomerServiceImpl

public interface CustomerService
  • Method Details

    • saveCustomer

      Customer saveCustomer(Customer customer)
    • saveCustomer

      Customer saveCustomer(Customer customer, boolean register)
    • registerCustomer

      Customer registerCustomer(Customer customer, String password, String passwordConfirm)
    • readCustomerByUsername

      Customer readCustomerByUsername(String customerName)
    • readCustomerByUsername

      Customer readCustomerByUsername(String username, Boolean cacheable)
    • readCustomerByEmail

      Customer readCustomerByEmail(String emailAddress)
    • changePassword

      Customer changePassword(PasswordChange passwordChange)
    • readCustomerById

      Customer readCustomerById(Long userId)
    • readCustomerByExternalId

      Customer readCustomerByExternalId(String userExternalId)
    • createCustomer

      Customer createCustomer()
    • createCustomerWithNullId

      Customer createCustomerWithNullId()
      Returns a non-persisted Customer with a null id. Typically used with registering a new customer or creating a new anonymous customer. Creating a customer with null id so that we don't need to query the database for the next id everytime an anonymous customer browses the site.
    • deleteCustomer

      void deleteCustomer(Customer customer)
      Delete the customer entity from the persistent store
      Parameters:
      customer - the customer entity to remove
    • detachCustomer

      void detachCustomer(Customer customer)
      Detaches the given Customer instance from the entity manager.
      Parameters:
      customer -
    • createCustomerFromId

      Customer createCustomerFromId(Long customerId)
      Returns a Customer by first looking in the database, otherwise creating a new non-persisted Customer
      Parameters:
      customerId - the id of the customer to lookup
    • createNewCustomer

      @Deprecated Customer createNewCustomer()
      Deprecated.
      Returns a non-persisted Customer.
    • createRegisteredCustomerRoles

      void createRegisteredCustomerRoles(Customer customer)
      Subclassed implementations can assign unique roles for various customer types
      Parameters:
      customer - Customer to create roles for
    • addPostRegisterListener

      void addPostRegisterListener(PostRegistrationObserver postRegisterListeners)
    • removePostRegisterListener

      void removePostRegisterListener(PostRegistrationObserver postRegisterListeners)
    • resetPassword

      Customer resetPassword(PasswordReset passwordReset)
    • getPasswordResetHandlers

      List<PasswordUpdatedHandler> getPasswordResetHandlers()
    • setPasswordResetHandlers

      void setPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers)
    • getPasswordChangedHandlers

      List<PasswordUpdatedHandler> getPasswordChangedHandlers()
    • setPasswordChangedHandlers

      void setPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers)
    • sendForgotUsernameNotification

      GenericResponse sendForgotUsernameNotification(String emailAddress)
      Looks up the corresponding Customer and emails the address on file with the associated username.
      Parameters:
      emailAddress - user's email address
      Returns:
      Response can contain errors including (notFound)
    • sendForgotPasswordNotification

      GenericResponse sendForgotPasswordNotification(String userName, String forgotPasswordUrl)
      Generates an access token and then emails the user.
      Parameters:
      userName - - the user to send a reset password email to.
      forgotPasswordUrl - - Base url to include in the email.
      Returns:
      Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
    • sendForcedPasswordChangeNotification

      GenericResponse sendForcedPasswordChangeNotification(String userName, String forgotPasswordUrl)
      Generates an access token and then emails the user.
      Parameters:
      userName - - the user to send a reset password email to.
      forgotPasswordUrl - - Base url to include in the email.
      Returns:
      Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
    • resetPasswordUsingToken

      GenericResponse resetPasswordUsingToken(String username, String token, String password, String confirmPassword)
      Updates the password for the passed in customer only if the passed in token is valid for that customer.
      Parameters:
      username - Username of the customer
      token - Valid reset token
      password - new password
      Returns:
      Response can contain errors including (invalidUsername, inactiveUser, invalidToken, invalidPassword, tokenExpired)
    • checkPasswordResetToken

      GenericResponse checkPasswordResetToken(String token, Customer customer)
      Verifies that a customer has a valid token.
      Parameters:
      token - password reset token
      customer - Customer who owns the token
      Returns:
      Response can contain errors including (invalidToken, tokenUsed, and tokenExpired)
    • findNextCustomerId

      Long findNextCustomerId()
      Allow customers to call from subclassed service.
      Returns:
      the next customerId to be used
    • encodePassword

      String encodePassword(String rawPassword)
      Encodes the clear text parameter, using the salt provided by PasswordEncoder. Does not change the customer properties. This method only encodes the password and returns the encoded result.

      This method can only be called once per password. The salt is randomly generated internally in the PasswordEncoder and appended to the hash to provide the resulting encoded password. Once this has been called on a password, going forward all checks for authenticity must be done by isPasswordValid(String, String) as encoding the same password twice will result in different encoded passwords.

      Parameters:
      rawPassword - the unencoded password
      Returns:
      the encoded password
    • isPasswordValid

      boolean isPasswordValid(String rawPassword, String encodedPassword)
      Determines if a password is valid by comparing it to the encoded string, salting is handled internally to the PasswordEncoder.

      This method must always be called to verify if a password is valid after the original encoded password is generated due to PasswordEncoder randomly generating salts internally and appending them to the resulting hash.

      Parameters:
      rawPassword - the unencoded password
      encodedPassword - the encoded password to compare against
      Returns:
      true if the unencoded password matches the encoded password, false otherwise
    • customerPassesCustomerRule

      boolean customerPassesCustomerRule(Customer customer, CustomerRuleHolder customerRuleHolder)
      Determines if the given customer passes the MVEL customer rule
      Parameters:
      customer -
      customerRuleHolder - an MVEL rule targeting Customers
      Returns:
      true if the customer passes the rule, false otherwise
    • readBatchCustomers

      List<Customer> readBatchCustomers(int start, int pageSize)
    • readNumberOfCustomers

      Long readNumberOfCustomers()