Interface AdminUserService<P extends AdminUser>

All Known Implementing Classes:
DefaultAdminUserService

public interface AdminUserService<P extends AdminUser>
Provides services for interacting with AdminUsers and JpaAdminUsers

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 Type
    Method
    Description
    create(P user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Creates a new user in the data store.
    void
    delete(P user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    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
    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 with AdminUser.name containing name, ignoring case.
    findByEmail(String email, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Find a user by email address.
    findById(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    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 given id with user.
    save(P user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Saves the given user.
    updateUserPreferencesByName(String username, UserPreferences preferences, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
  • Method Details

    • findById

      Optional<P> findById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • existsById

      boolean existsById(String id)
      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 with AdminUser.name containing name, ignoring case.
      Parameters:
      name - The name to match
      page - The current page
      filters - Any filters to apply
      contextInfo - 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 the PersistenceProducer.TYPE channel.

      Parameters:
      user - the user to create
      Returns:
      the final user after creation
      Throws:
      com.broadleafcommerce.common.error.validation.ValidationException - if the given user 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 given id with user. Additional validation is also performed to prevent unauthorized addition/removal from an application.

      Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

      Parameters:
      id - the ID of the user to replace
      user - the replacement user
      Returns:
      the final user after replacement
      Throws:
      com.broadleafcommerce.common.error.validation.ValidationException - if the user failed validation for replacement
      com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if the user to replace was not found
    • save

      P save(P user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Saves the given user.

      Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

      Parameters:
      user - the user to save
      contextInfo - 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
      Note that, to avoid unauthorized removal of a user from an unrelated application, this always reads the user from the data store before performing a delete.

      Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

      Parameters:
      user - The user to delete
      contextInfo - 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 the PersistenceProducer.TYPE channel.

      Parameters:
      id - The ID of the user to delete
      contextInfo - 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 application
      applicationId - 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)