Interface CustomizedRoleRepository<D>

  • All Superinterfaces:
    com.broadleafcommerce.common.extension.DomainTypeAware
    All Known Subinterfaces:
    JpaRoleRepository<D>, RoleRepository<D>
    All Known Implementing Classes:
    JpaCustomizedRoleRepository

    public interface CustomizedRoleRepository<D>
    extends com.broadleafcommerce.common.extension.DomainTypeAware
    Additional functionality necessary for RoleRepository.
    Author:
    Samarth Dhruva (samarthd)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      D createOnlyIfDoesNotExist​(D role, Instant lastUpdated)
      A specialized create operation for creating an entity with a pre-defined id with the minimum guarantee that concurrent requests to this method for the same entity ID will fail.
      D replaceOnlyIfLastUpdatedBefore​(String entityId, D role, Instant lastUpdated)
      A specialized replace operation that does not invoke the "save" create-or-update behavior.
      • Methods inherited from interface com.broadleafcommerce.common.extension.DomainTypeAware

        getDomainType
    • Method Detail

      • createOnlyIfDoesNotExist

        @Nullable
        D createOnlyIfDoesNotExist​(D role,
                                   Instant lastUpdated)
        A specialized create operation for creating an entity with a pre-defined id with the minimum guarantee that concurrent requests to this method for the same entity ID will fail.

        This is intended to be used in concurrent scenarios where only one operation should succeed.

        Note that this method should create the record with the provided UserRole.archived value, even if it is true.

        Parameters:
        role - the role to create. Must have a non-null id present.
        lastUpdated - the UserRole.lastUpdated to set on the role
        Returns:
        the role if successfully created, null otherwise
      • replaceOnlyIfLastUpdatedBefore

        @Nullable
        D replaceOnlyIfLastUpdatedBefore​(String entityId,
                                         D role,
                                         Instant lastUpdated)
        A specialized replace operation that does not invoke the "save" create-or-update behavior. This operation should directly attempt an atomic update that the data store will reject if the entity is not found or has a lastUpdated ahead of the current change.

        This is intended to be used in concurrent scenarios where only one operation should succeed.

        Note that this update should succeed even if the existing record is UserRole.archived.

        Note that this method should also set the provided UserRole.archived value, even if it is true.

        Parameters:
        entityId - the id of the entity to replace
        role - the replacement entity
        lastUpdated - the timestamp of the current change. This will be compared to the lastUpdated on the existing entity for determination of whether the replacement should occur. Furthermore, the replacement will have its UserRole.lastUpdated set to this value.
        Returns:
        the role after replacement if successfully replaced, or null if the entity was not found or could not be updated due to its lastUpdated value.