Class DefaultAccountInviteService<P extends AccountInvite>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.customer.service.DefaultAccountInviteService<P>
- 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>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultAccountInviteService
(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 Summary
Modifier and TypeMethodDescriptionacceptInvite
(String inviteId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Accepts an account invitation.void
acceptPendingInvitesForCustomer
(String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Accepts the pending invites for theCustomer
.protected P
buildAccountInvite
(String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
checkExpired
(P inviteToAccept) protected void
checkIfAlreadyAccountMember
(String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Instant
determineAccountExpirationTime
(String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected cz.jirutka.rsql.parser.ast.Node
enhanceWithAccountIdFilter
(@NonNull String accountId, cz.jirutka.rsql.parser.ast.Node filters) findExistingInvite
(String accountId, String email, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected AccountInviteProperties
protected AccountInviteRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected AccountMemberService<AccountMember>
protected AccountService<Account>
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
protected CustomerService<Customer>
getInviteDuration
(String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the duration for which account invites will be active.protected com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser
protected SendAccountInvitationService
protected com.broadleafcommerce.common.extension.TypeFactory
protected void
hydrateAccount
(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
hydrateAccountAndSendInvite
(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
hydrateCustomer
(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) inviteToAccount
(@NonNull String accountId, @NonNull AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Invite a new user to an account.protected boolean
org.springframework.data.domain.Page<P>
readAllByAccountId
(@NonNull String accountId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read a page of account invites by account ID.readByContextIdAndAccountId
(String id, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read an account invite by its ID and account ID.protected P
readByContextIdAndAccountIdOrThrow
(String id, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) readCurrentlyAuthenticatedCustomer
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.data.domain.Page<P>
readMyInvites
(org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read the currently authenticated user's account invites.resendInvite
(String inviteId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Re-send an account invitation.void
revokeInvite
(String inviteId, String accountId, String accountMemberId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Revoke an invite to an accountprotected void
sendAccountAcceptance
(Customer customer, Account account, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
sendAccountInvite
(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected P
updateExistingAccountInvite
(P existingInvite, String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
validateAccountIdMatchesContext
(String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
validateExistingFilter
(cz.jirutka.rsql.parser.ast.Node filters) Validates that an account ID filter isn't already present on the filter query.protected Customer
validateInviteMatchesCustomerEmail
(P inviteToAccept, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAll
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Field Details
-
CUSTOMER_REF
- See Also:
-
INVITE_ID
- See Also:
-
ACCOUNT_ID_FILTER
- See Also:
-
EMAIL_FILTER
- See Also:
-
INVITATION_EXPIRY_DATE_FILTER
- See Also:
-
BLACKLISTED_FILTERS
-
DEFAULT_INVITE_DURATION
-
-
Constructor Details
-
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 Details
-
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 suppliedfilters
object does not have an existing "accountId" filter.- Specified by:
readAllByAccountId
in interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
accountId
- The account IDfilters
- The filterspage
- The pagecontextInfo
- 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. IfAccountInviteProperties.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 interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
accountId
- The account ID.accountInviteRequest
- The account invite requestcontextInfo
- 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 interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
inviteId
- The invite IDaccountId
- The account IDcontextInfo
- 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 interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
inviteId
- The invite IDaccountId
- The account IDcontextInfo
- 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 newAccountMember
and deletes theAccountInvite
.- Specified by:
acceptInvite
in interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
inviteId
- The invite IDaccountId
- The account IDcontextInfo
- 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 interfaceAccountInviteService<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 theCustomer
.- Specified by:
acceptPendingInvitesForCustomer
in interfaceAccountInviteService<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 interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
id
- The invite IDaccountId
- The account IDcontextInfo
- 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 interfaceAccountInviteService<P extends AccountInvite>
- Parameters:
accountId
- The account IDcontextInfo
- 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
-
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
-
validateInviteMatchesCustomerEmail
-
readByContextIdAndAccountIdOrThrow
-
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
-
checkExpired
-
isActive
-
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
-
getAccountMemberService
-
getAccountService
-
getCustomerService
-
getSendAccountInvitationService
-
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() -
getAccountInviteProperties
-