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
Fields Modifier and Type Field Description static String
ACCOUNT_ID_FILTER
protected static Set<String>
BLACKLISTED_FILTERS
static String
CUSTOMER_REF
static Duration
DEFAULT_INVITE_DURATION
static String
EMAIL_FILTER
static String
INVITATION_EXPIRY_DATE_FILTER
static String
INVITE_ID
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccountMember
acceptInvite(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)
protected Optional<P>
findExistingInvite(String accountId, String email, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected AccountInviteProperties
getAccountInviteProperties()
protected AccountInviteRepository<com.broadleafcommerce.data.tracking.core.Trackable>
getAccountInviteRepository()
protected AccountMemberService<AccountMember>
getAccountMemberService()
protected AccountService<Account>
getAccountService()
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getAuthenticationUtils()
protected CustomerService<Customer>
getCustomerService()
Duration
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
getRsqlFilterParser()
protected SendAccountInvitationService
getSendAccountInvitationService()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
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)
Optional<P>
inviteToAccount(@NonNull String accountId, @NonNull AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Invite a new user to an account.protected boolean
isActive(P invite)
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.Optional<P>
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)
protected Optional<Customer>
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.P
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
-
-
-
-
Field Detail
-
CUSTOMER_REF
public static final String CUSTOMER_REF
- See Also:
- Constant Field Values
-
INVITE_ID
public static final String INVITE_ID
- See Also:
- Constant Field Values
-
ACCOUNT_ID_FILTER
public static final String ACCOUNT_ID_FILTER
- See Also:
- Constant Field Values
-
EMAIL_FILTER
public static final String EMAIL_FILTER
- See Also:
- Constant Field Values
-
INVITATION_EXPIRY_DATE_FILTER
public static final String INVITATION_EXPIRY_DATE_FILTER
- See Also:
- Constant Field Values
-
DEFAULT_INVITE_DURATION
public static final Duration DEFAULT_INVITE_DURATION
-
-
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 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
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)
-
getAccountMemberService
protected AccountMemberService<AccountMember> getAccountMemberService()
-
getAccountService
protected AccountService<Account> getAccountService()
-
getCustomerService
protected CustomerService<Customer> getCustomerService()
-
getSendAccountInvitationService
protected SendAccountInvitationService 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
protected AccountInviteProperties getAccountInviteProperties()
-
-