Interface AdminUserService<P extends AdminUser>
- All Known Implementing Classes:
DefaultAdminUserService
AdminUser
s and JpaAdminUser
s
Certain operations will emit an OperationAwarePersistenceMessage
to the
PersistenceProducer.TYPE
channel, which is expected to be consumed by the authentication
service and synchronized there.
- Author:
- Nathan Moore (nathanmoore).
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new user in the data store.void
Deletes an admin user or removes an admin user from an application, depending on the scenario.void
deleteById
(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deletes an admin user or removes an admin user from an application, depending on the scenario.boolean
existsById
(String id) Performs an existence check to determine if there is a user in the data store matching the given id.org.springframework.data.domain.Page<P>
findAll
(org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.data.domain.Page<P>
findAllByName
(String name, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find all users withAdminUser.name
containingname
, ignoring case.findByEmail
(String email, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a user by email address.findByUsername
(String username, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a user by username.void
removeUserFromApplication
(P user, String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Removes a user from an application.replace
(String id, P user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces the user in the data store with the givenid
withuser
.Saves the given user.updateUserPreferencesByName
(String username, UserPreferences preferences, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Method Details
-
findById
-
existsById
Performs an existence check to determine if there is a user in the data store matching the given id.- Parameters:
id
- the id of the user to find- Returns:
- true if the user exists, false otherwise
-
findAll
org.springframework.data.domain.Page<P> findAll(org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
findAllByName
org.springframework.data.domain.Page<P> findAllByName(String name, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find all users withAdminUser.name
containingname
, ignoring case.- Parameters:
name
- The name to matchpage
- The current pagefilters
- Any filters to applycontextInfo
- The current context.- Returns:
- A page of users matching the supplied
name
.ß
-
create
P create(P user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates a new user in the data store. Validation is performed to ensure the user is not assigned to an unauthorized tenant or application.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
user
- the user to create- Returns:
- the final user after creation
- Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if the givenuser
failed validation for creation
-
replace
P replace(String id, P user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces the user in the data store with the givenid
withuser
. Additional validation is also performed to prevent unauthorized addition/removal from an application.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
id
- the ID of the user to replaceuser
- the replacement user- Returns:
- the final user after replacement
- Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if theuser
failed validation for replacementcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the user to replace was not found
-
save
Saves the given user.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
user
- the user to savecontextInfo
- context information surrounding multitenant state- Returns:
- the saved user
-
delete
void delete(P user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deletes an admin user or removes an admin user from an application, depending on the scenario.For an admin user assigned to 1 application, they are always deleted. For an admin user assigned to 2 or more applications, the operation depends on the context in which the delete is requested:
- In a tenant or global context: Delete the user
- In an application context: Remove the user from the application
Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
user
- The user to deletecontextInfo
- The context
-
deleteById
void deleteById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deletes an admin user or removes an admin user from an application, depending on the scenario.For an admin user assigned to 1 application, they are always deleted. For an admin user assigned to 2 or more applications, the operation depends on the context in which the delete is requested:
- In a tenant or global context: Delete the user
- In an application context: Remove the user from the application
Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
id
- The ID of the user to deletecontextInfo
- The context- See Also:
-
findByEmail
Optional<P> findByEmail(String email, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a user by email address.- Parameters:
email
- The email address.contextInfo
- The current context.- Returns:
- The user found, or
Optional.empty()
-
findByUsername
Optional<P> findByUsername(String username, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a user by username.- Parameters:
username
- The username.contextInfo
- The current context.- Returns:
- The user found, or
Optional.empty()
-
removeUserFromApplication
void removeUserFromApplication(P user, String applicationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Removes a user from an application. Intended for use in delete operations. When a user belongs to more than one application and a delete operation is performed in an application context, that user should be removed from that application instead of deleted.- Parameters:
user
- The user to remove from an applicationapplicationId
- The ID of the application to remove the user from.contextInfo
- The current context.
-
updateUserPreferencesByName
P updateUserPreferencesByName(String username, UserPreferences preferences, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-