Class DefaultAccountInviteService<P extends AccountInvite>

  • All Implemented Interfaces:
    AccountInviteService<P>, com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>

    public class DefaultAccountInviteService<P extends AccountInvite>
    extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
    implements AccountInviteService<P>
    • Constructor Detail

      • DefaultAccountInviteService

        public DefaultAccountInviteService​(AccountService<Account> accountService,
                                           AccountMemberService<AccountMember> accountMemberService,
                                           CustomerService<Customer> customerService,
                                           SendAccountInvitationService sendAccountInvitationService,
                                           com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils,
                                           com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                           com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser rsqlFilterParser,
                                           AccountInviteRepository<com.broadleafcommerce.data.tracking.core.Trackable> accountInviteRepository,
                                           com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper,
                                           AccountInviteProperties accountInviteProperties)
    • Method Detail

      • readAllByAccountId

        public org.springframework.data.domain.Page<P> readAllByAccountId​(@NonNull
                                                                          @NonNull 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: AccountInviteService
        Read a page of account invites by account ID. Additional includes validation that the supplied filters object does not have an existing "accountId" filter.
        Specified by:
        readAllByAccountId in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        accountId - The account ID
        filters - The filters
        page - The page
        contextInfo - context surrounding customer and multitenant state
        Returns:
        A page of account invites
      • inviteToAccount

        public Optional<P> inviteToAccount​(@NonNull
                                           @NonNull String accountId,
                                           @NonNull
                                           @NonNull AccountInviteRequest accountInviteRequest,
                                           @Nullable
                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Invite a new user to an account. If an invite already exists for the supplied account/email address, the existing invite's expiration time is reset. If AccountInviteProperties.isAutoAcceptPendingInvitesOnRegistration() is true and the invited user already exists (has registered), then no invite is created since it's auto- accepted.
        Specified by:
        inviteToAccount in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        accountId - The account ID.
        accountInviteRequest - The account invite request
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The newly created account invite.
      • hydrateAccountAndSendInvite

        protected void hydrateAccountAndSendInvite​(P accountInvite,
                                                   @Nullable
                                                   com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • revokeInvite

        public void revokeInvite​(String inviteId,
                                 String accountId,
                                 String accountMemberId,
                                 @Nullable
                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Revoke an invite to an account
        Specified by:
        revokeInvite in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        inviteId - The invite ID
        accountId - The account ID
        contextInfo - context surrounding customer and multitenant state
      • resendInvite

        public P resendInvite​(String inviteId,
                              String accountId,
                              @Nullable
                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Re-send an account invitation. When an invite is re-sent, its expiration time is also reset.
        Specified by:
        resendInvite in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        inviteId - The invite ID
        accountId - The account ID
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The re-sent account invitation.
      • acceptInvite

        public AccountMember acceptInvite​(String inviteId,
                                          String accountId,
                                          @Nullable
                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Accepts an account invitation. If successful, creates and returns the new AccountMember and deletes the AccountInvite.
        Specified by:
        acceptInvite in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        inviteId - The invite ID
        accountId - The account ID
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The newly created account member.
      • readMyInvites

        public org.springframework.data.domain.Page<P> readMyInvites​(@Nullable
                                                                     org.springframework.data.domain.Pageable page,
                                                                     @Nullable
                                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Read the currently authenticated user's account invites.
        Specified by:
        readMyInvites in interface AccountInviteService<P extends AccountInvite>
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The currently logged in user's account invites.
      • acceptPendingInvitesForCustomer

        public void acceptPendingInvitesForCustomer​(String customerId,
                                                    @Nullable
                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Accepts the pending invites for the Customer.
        Specified by:
        acceptPendingInvitesForCustomer in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        customerId - The id of the customer whose invites to read.
        contextInfo - context surrounding customer and multitenant state
      • readByContextIdAndAccountId

        public Optional<P> readByContextIdAndAccountId​(String id,
                                                       String accountId,
                                                       @Nullable
                                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Read an account invite by its ID and account ID.
        Specified by:
        readByContextIdAndAccountId in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        id - The invite ID
        accountId - The account ID
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The account invite, if found.
      • getInviteDuration

        public Duration getInviteDuration​(@Nullable
                                          String accountId,
                                          @Nullable
                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountInviteService
        Return the duration for which account invites will be active.
        Specified by:
        getInviteDuration in interface AccountInviteService<P extends AccountInvite>
        Parameters:
        accountId - The account ID
        contextInfo - context surrounding customer and multitenant state
        Returns:
        The duration for which account invites should be active.
      • validateAccountIdMatchesContext

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

        protected void sendAccountInvite​(P accountInvite,
                                         @Nullable
                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • sendAccountAcceptance

        protected void sendAccountAcceptance​(Customer customer,
                                             Account account,
                                             @Nullable
                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • hydrateAccount

        protected void hydrateAccount​(@NonNull
                                      P accountInvite,
                                      @Nullable
                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • hydrateCustomer

        protected void hydrateCustomer​(@NonNull
                                       P accountInvite,
                                       @Nullable
                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • findExistingInvite

        protected Optional<P> findExistingInvite​(String accountId,
                                                 String email,
                                                 @Nullable
                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • validateInviteMatchesCustomerEmail

        protected Customer validateInviteMatchesCustomerEmail​(P inviteToAccept,
                                                              @Nullable
                                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • readByContextIdAndAccountIdOrThrow

        protected P readByContextIdAndAccountIdOrThrow​(String id,
                                                       String accountId,
                                                       @Nullable
                                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • checkIfAlreadyAccountMember

        protected void checkIfAlreadyAccountMember​(String accountId,
                                                   AccountInviteRequest accountInviteRequest,
                                                   @Nullable
                                                   com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • buildAccountInvite

        protected P buildAccountInvite​(String accountId,
                                       AccountInviteRequest accountInviteRequest,
                                       @Nullable
                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • updateExistingAccountInvite

        protected P updateExistingAccountInvite​(P existingInvite,
                                                String accountId,
                                                AccountInviteRequest accountInviteRequest,
                                                @Nullable
                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • determineAccountExpirationTime

        @Nullable
        protected Instant determineAccountExpirationTime​(String accountId,
                                                         @Nullable
                                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • checkExpired

        protected void checkExpired​(P inviteToAccept)
      • isActive

        protected boolean isActive​(P invite)
      • enhanceWithAccountIdFilter

        protected cz.jirutka.rsql.parser.ast.Node enhanceWithAccountIdFilter​(@NonNull
                                                                             @NonNull String accountId,
                                                                             @Nullable
                                                                             cz.jirutka.rsql.parser.ast.Node filters)
      • validateExistingFilter

        protected void validateExistingFilter​(cz.jirutka.rsql.parser.ast.Node filters)
        Validates that an account ID filter isn't already present on the filter query.
        Parameters:
        filters - The filters to validate
      • readCurrentlyAuthenticatedCustomer

        protected Optional<Customer> readCurrentlyAuthenticatedCustomer​(@Nullable
                                                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getTypeFactory

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

        protected com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser getRsqlFilterParser()
      • getAuthenticationUtils

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

        protected AccountInviteRepository<com.broadleafcommerce.data.tracking.core.Trackable> getAccountInviteRepository()