Interface AccountRoleService<P extends AccountRole>

  • All Superinterfaces:
    com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
    All Known Implementing Classes:
    DefaultAccountRoleService

    public interface AccountRoleService<P extends AccountRole>
    extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
    Service API for management of AccountRole.

    Supported by AccountRoleRepository.

    Declares different versions of CRUD operations beyond just those provided by MappableCrudEntityService - these operations declare a ContextInfo argument to enable access control based upon context. In most scenarios, these operations should be preferred to those without ContextInfo arguments to prevent unwanted mutation/assignment in invalid contexts.

    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:
    Samarth Dhruva (samarthd)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      P create​(P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Creates the role.
      void delete​(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Deletes the given role.
      boolean existsById​(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reports whether there exists a role in the data store whose AccountRole.getId() ()} is equal to the given id.
      boolean existsByNameAndIdNot​(String name, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reports whether there exists a role in the data store whose AccountRole.getName() is equal to the given name and whose AccountRole.getId() is not equal to the given id.
      org.springframework.data.domain.Page<P> readAllByName​(String name, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reads roles in the data store, filtering to those whose name contains the given value.
      Optional<P> readByIdOptional​(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Read a single role by id.
      P replace​(String id, P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Replaces the given role.
      • Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

        createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
      • Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

        readAll, readAll, readAll, readAll
    • Method Detail

      • readByIdOptional

        Optional<P> readByIdOptional​(String id,
                                     @Nullable
                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Read a single role by id.

        Similar to CrudEntityService.readByContextId(String, ContextInfo), but does not throw an exception if the entity is not found.

        Parameters:
        id - the id of the role to find
        context -
        Returns:
        an Optional containing the role if found, otherwise Optional.empty()
      • readAllByName

        org.springframework.data.domain.Page<P> readAllByName​(String name,
                                                              @Nullable
                                                              org.springframework.data.domain.Pageable pageable,
                                                              @Nullable
                                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Reads roles in the data store, filtering to those whose name contains the given value. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.
        Parameters:
        name - the value that role names must contain in order to match
        pageable - describes the page of results to return
        context - context information about multitenant state
        Returns:
        roles accessible in the current context that match the given name
      • existsById

        boolean existsById​(String id,
                           @Nullable
                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Reports whether there exists a role in the data store whose AccountRole.getId() ()} is equal to the given id. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.
        Parameters:
        id - the value that the role's id must not equal in order to match
        context - context information about multitenant state
        Returns:
        true if there exists a role accessible from the given context matching the given name and not matching the given id, false otherwise
      • existsByNameAndIdNot

        boolean existsByNameAndIdNot​(String name,
                                     @Nullable
                                     String id,
                                     @Nullable
                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Reports whether there exists a role in the data store whose AccountRole.getName() is equal to the given name and whose AccountRole.getId() is not equal to the given id. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.
        Parameters:
        name - the value that role name must equal in order to match
        id - (optional) the value that the role's id must not equal in order to match. If this value is null, then results will not be filtered by their id.
        context - context information about multitenant state
        Returns:
        true if there exists a role accessible from the given context matching the given name and not matching the given id, false otherwise
      • create

        P create​(P role,
                 @Nullable
                 com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Creates the role.

        Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

        Specified by:
        create in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
        Parameters:
        role - the role to create
        context - context information about multitenant state
        Returns:
        the role after it has been created in the data store
        Throws:
        com.broadleafcommerce.common.error.validation.ValidationException - if there were any validation errors
      • replace

        P replace​(String id,
                  P role,
                  @Nullable
                  com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Replaces the given role.

        Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

        Specified by:
        replace in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
        Parameters:
        id - the id of the role to replace
        role - the replacement role
        context - context information about multitenant state
        Returns:
        the role after it has been replaced in the data store
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if the role was not found or accessible from the given context
        com.broadleafcommerce.common.error.validation.ValidationException - if there were validation errors
      • delete

        void delete​(String id,
                    @Nullable
                    com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Deletes the given role.

        Emits an OperationAwarePersistenceMessage to the PersistenceProducer.TYPE channel.

        Specified by:
        delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
        Parameters:
        id - the ID of the role to delete
        context - context information about multitenant state
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if the role was not found or accessible from the given context
        com.broadleafcommerce.common.error.validation.ValidationException - if there were validation errors
        InvalidAccountRoleDeleteException - if the role has children