Class DefaultCustomerAccountService<A extends Account,M extends AccountMember>

java.lang.Object
com.broadleafcommerce.customer.service.DefaultCustomerAccountService<A,M>
All Implemented Interfaces:
CustomerAccountService<A,M>

public class DefaultCustomerAccountService<A extends Account,M extends AccountMember> extends Object implements CustomerAccountService<A,M>
  • Constructor Details

    • DefaultCustomerAccountService

      public DefaultCustomerAccountService(AccountMemberService<M> accountMemberService, AccountService<A> accountService, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
  • Method Details

    • init

      @PostConstruct public void init()
    • readAccountMembers

      public org.springframework.data.domain.Page<M> readAccountMembers(String accountId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomerAccountService
      Read the AccountMembers for a specific Account by id.
      Specified by:
      readAccountMembers in interface CustomerAccountService<A extends Account,M extends AccountMember>
      Parameters:
      accountId - Id of the parent account
      filters - RSQL filters
      page - Pagination info
      contextInfo - Additional multitenant and sandbox info
      Returns:
      The AccountMembers for a specific Account by id.
    • readAccountMember

      public M readAccountMember(String accountId, String memberId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      readAccountMember in interface CustomerAccountService<A extends Account,M extends AccountMember>
    • updateAccountMember

      public M updateAccountMember(String accountId, String memberId, @NonNull @NonNull UpdateAccountMemberRequest accountMember, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      updateAccountMember in interface CustomerAccountService<A extends Account,M extends AccountMember>
    • createAccountUser

      @SuppressNotification(value="PERSISTENCE", compileChangeDetails=false) public CreateAccountUserResponse createAccountUser(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest createRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      The PERSISTENCE notification is suppressed so that one single AccountUserManuallyCreatedEvent can be used to create the user with given restrictions on the AuthenticationService side.
      Specified by:
      createAccountUser in interface CustomerAccountService<A extends Account,M extends AccountMember>
      Parameters:
      accountId - the id of the account to create the user in
      createRequest - the CreateAccountUserRequest containing the details
      contextInfo - additional multitenant and sandbox info
      Returns:
      the CreateAccountUserResponse representing the result of the creation
    • deleteAccountMember

      public void deleteAccountMember(String accountId, String memberId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      deleteAccountMember in interface CustomerAccountService<A extends Account,M extends AccountMember>
    • readMyAccounts

      public List<A> readMyAccounts(int childAccountDepth, boolean filterParents, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomerAccountService
      Reads the currently logged in user's Accounts. Set excludeAccountsWithInactiveParent to true to filter out accounts that have a disabled parent account.
      Specified by:
      readMyAccounts in interface CustomerAccountService<A extends Account,M extends AccountMember>
      Parameters:
      childAccountDepth - How many levels deep of the account hierarchy of the accounts matching ids to include in the results, e.g., how many levels of child accounts to include. -1 indicates no limit. 0 indicates no child accounts.

      Default is 0.

      filterParents - If true, the returned list will include only accounts with active parent accounts.
      filters - An RSQL filter used to narrow query results. May be EmptyNode if no filters should be applied.
      contextInfo - Additional multitenant and sandbox info
      Returns:
      The currently logged in user's Accounts.
    • validateUserNotModifyingThemselves

      protected void validateUserNotModifyingThemselves(@NonNull @NonNull AccountMember accountMember, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • validateAccountIdMatchesContext

      protected void validateAccountIdMatchesContext(String accountId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • validateCreateAccountUserRequest

      protected void validateCreateAccountUserRequest(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createCustomer

      protected Customer createCustomer(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildCustomerFromRequest

      protected Customer buildCustomerFromRequest(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest request)
    • createAccountMember

      protected M createAccountMember(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest request, @NonNull @NonNull Customer customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildAccountMemberFromRequest

      protected M buildAccountMemberFromRequest(@NonNull @NonNull String accountId, @NonNull @NonNull CreateAccountUserRequest request, @NonNull @NonNull Customer customer)
    • determineAccountMemberStatus

      protected String determineAccountMemberStatus(@NonNull @NonNull CreateAccountUserRequest request)
      Hook point to determine the status of the AccountMember being created.
      Parameters:
      request - the CreateAccountUserRequest that is being used to create the user
      Returns:
      the status of the AccountMember being created
    • buildAccountUserCreatedEvent

      protected AccountUserManuallyCreatedEvent buildAccountUserCreatedEvent(@NonNull @NonNull CreateAccountUserRequest request, @NonNull @NonNull String accountId, @NonNull @NonNull Customer createdCustomer, @NonNull M createdAccountMember)
      Builds an AccountUserManuallyCreatedEvent from the given request, account id, created Customer, and created AccountMember.
      Parameters:
      request - the original CreateAccountUserRequest
      accountId - the id of the account the user was created in
      createdCustomer - the Customer that was created
      createdAccountMember - the AccountMember that was created
      Returns:
      the built AccountUserManuallyCreatedEvent
    • getAccountMemberService

      protected AccountMemberService<M> getAccountMemberService()
    • getAccountService

      protected AccountService<A> getAccountService()
    • getAuthenticationUtils

      protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
    • getCustomerService

      protected CustomerService<Customer> getCustomerService()
    • setCustomerService

      @Autowired public void setCustomerService(CustomerService<Customer> customerService)
    • getCustomerProperties

      protected CustomerConfigurationProperties getCustomerProperties()
    • setCustomerProperties

      @Autowired public void setCustomerProperties(CustomerConfigurationProperties customerProperties)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getAccountUserCreatedProducer

      @Nullable protected AccountUserManuallyCreatedProducer getAccountUserCreatedProducer()
      The producer is not a required bean as a flexpackage (e.g. processing) may have CustomerService's messaging turned off so that another flexpackage (e.g. cart) is dedicated to handle it
    • setAccountUserCreatedProducer

      @Autowired(required=false) public void setAccountUserCreatedProducer(AccountUserManuallyCreatedProducer accountUserCreatedProducer)
      The producer is not a required bean as a flexpackage (e.g. processing) may have CustomerService's messaging turned off so that another flexpackage (e.g. cart) is dedicated to handle it
    • getDetachedDurableMessageSender

      @Nullable protected com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender getDetachedDurableMessageSender()
    • setDetachedDurableMessageSender

      @Autowired(required=false) public void setDetachedDurableMessageSender(com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender detachedDurableMessageSender)