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 StringACCOUNT_ID_FILTERprotected static Set<String>BLACKLISTED_FILTERSstatic StringCUSTOMER_REFstatic DurationDEFAULT_INVITE_DURATIONstatic StringEMAIL_FILTERstatic StringINVITATION_EXPIRY_DATE_FILTERstatic StringINVITE_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 AccountMemberacceptInvite(String inviteId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Accepts an account invitation.voidacceptPendingInvitesForCustomer(String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Accepts the pending invites for theCustomer.protected PbuildAccountInvite(String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidcheckExpired(P inviteToAccept)protected voidcheckIfAlreadyAccountMember(String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected InstantdetermineAccountExpirationTime(String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected cz.jirutka.rsql.parser.ast.NodeenhanceWithAccountIdFilter(@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 AccountInvitePropertiesgetAccountInviteProperties()protected AccountInviteRepository<com.broadleafcommerce.data.tracking.core.Trackable>getAccountInviteRepository()protected AccountMemberService<AccountMember>getAccountMemberService()protected AccountService<Account>getAccountService()protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsgetAuthenticationUtils()protected CustomerService<Customer>getCustomerService()DurationgetInviteDuration(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.RSQLFilterParsergetRsqlFilterParser()protected SendAccountInvitationServicegetSendAccountInvitationService()protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected voidhydrateAccount(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidhydrateAccountAndSendInvite(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidhydrateCustomer(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 booleanisActive(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 PreadByContextIdAndAccountIdOrThrow(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.PresendInvite(String inviteId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Re-send an account invitation.voidrevokeInvite(String inviteId, String accountId, String accountMemberId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Revoke an invite to an accountprotected voidsendAccountAcceptance(Customer customer, Account account, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidsendAccountInvite(P accountInvite, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected PupdateExistingAccountInvite(P existingInvite, String accountId, AccountInviteRequest accountInviteRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidvalidateAccountIdMatchesContext(String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected voidvalidateExistingFilter(cz.jirutka.rsql.parser.ast.Node filters)Validates that an account ID filter isn't already present on the filter query.protected CustomervalidateInviteMatchesCustomerEmail(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:AccountInviteServiceRead a page of account invites by account ID. Additional includes validation that the suppliedfiltersobject does not have an existing "accountId" filter.- Specified by:
readAllByAccountIdin 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:AccountInviteServiceInvite 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:
inviteToAccountin 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:AccountInviteServiceRevoke an invite to an account- Specified by:
revokeInvitein 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:AccountInviteServiceRe-send an account invitation. When an invite is re-sent, its expiration time is also reset.- Specified by:
resendInvitein 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:AccountInviteServiceAccepts an account invitation. If successful, creates and returns the newAccountMemberand deletes theAccountInvite.- Specified by:
acceptInvitein 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:AccountInviteServiceRead the currently authenticated user's account invites.- Specified by:
readMyInvitesin 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:AccountInviteServiceAccepts the pending invites for theCustomer.- Specified by:
acceptPendingInvitesForCustomerin 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:AccountInviteServiceRead an account invite by its ID and account ID.- Specified by:
readByContextIdAndAccountIdin 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:AccountInviteServiceReturn the duration for which account invites will be active.- Specified by:
getInviteDurationin 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()
-
-