Interface RuleComponentRestrictionStore

All Known Implementing Classes:
JiraRuleComponentRestrictionStore

public interface RuleComponentRestrictionStore
Store interface for managing rule component restrictions. Provides CRUD operations for instance-wide restrictions on automation rule components (triggers, conditions, actions) based on Jira group allow-lists. Restriction Semantics: - No entry for a component key: component is UNRESTRICTED (all users can use it) - Entry with non-empty group set: component is restricted to users in those groups - Entry with empty group set: component is FULLY RESTRICTED (no users can use it) Thread-safe and DC-safe persistence layer.
  • Method Details

    • getAllRestrictions

      @Nonnull Map<String,Set<String>> getAllRestrictions(@Nonnull TenantContext context)
      Retrieves all rule component restrictions for the instance. Semantics: - Empty map: no restrictions configured - Entry with non-empty set: component is restricted to those groups - Entry with empty set: component is fully restricted (no one can use it)
      Parameters:
      context - the tenant context
      Returns:
      map of rule component key to set of allowed group names
    • getRestrictions

      @Nonnull Optional<Set<String>> getRestrictions(@Nonnull TenantContext context, @Nonnull String ruleComponentKey)
      Retrieves restrictions for a specific rule component.
      Parameters:
      context - the tenant context
      ruleComponentKey - the rule component key (e.g., "jira.issue.created")
      Returns:
      optional set of allowed group names, empty if no restrictions exist
    • setRestrictions

      void setRestrictions(@Nonnull TenantContext context, @Nonnull String ruleComponentKey, @Nonnull Set<String> groupNames, @Nonnull String updatedBy)
      Sets restrictions for a specific rule component. Creates a new restriction or updates an existing one. The restriction entry is always preserved. To remove restrictions entirely (making the component unrestricted), use deleteRestrictions(com.codebarrel.tenant.api.TenantContext, java.lang.String).
      Parameters:
      context - the tenant context
      ruleComponentKey - the rule component key
      groupNames - the set of allowed group names (empty means fully restricted - no one can use)
      updatedBy - the user key of the user making the change
    • deleteRestrictions

      void deleteRestrictions(@Nonnull TenantContext context, @Nonnull String ruleComponentKey)
      Removes restrictions for a specific rule component. After removal, the component becomes unrestricted.
      Parameters:
      context - the tenant context
      ruleComponentKey - the rule component key
    • getRestrictionConfig

      @Nonnull Optional<RuleComponentRestrictionConfig> getRestrictionConfig(@Nonnull TenantContext context, @Nonnull String ruleComponentKey)
      Retrieves detailed configuration for a specific rule component restriction, including metadata like creation/update timestamps.
      Parameters:
      context - the tenant context
      ruleComponentKey - the rule component key
      Returns:
      optional detailed configuration, empty if no restrictions exist
    • getAllRestrictionConfigs

      @Nonnull Map<String,RuleComponentRestrictionConfig> getAllRestrictionConfigs(@Nonnull TenantContext context)
      Retrieves all restriction configurations with metadata.
      Parameters:
      context - the tenant context
      Returns:
      map of rule component key to detailed configuration
    • replaceAllRestrictions

      void replaceAllRestrictions(@Nonnull TenantContext context, @Nonnull Map<String,Set<String>> restrictions, @Nonnull String updatedBy)
      Replaces all restrictions with a new set of restrictions atomically. This is a bulk operation that:
      1. Deletes all existing restrictions
      2. Creates new restrictions for all provided component keys

      This operation is transactional - either all restrictions are replaced or none are (rollback on failure).

      Parameters:
      context - the tenant context
      restrictions - map of rule component key to set of allowed group names (empty map = remove all restrictions, empty set = fully restricted)
      updatedBy - the user key of the user making the change
    • removeGroupFromAllRestrictions

      int removeGroupFromAllRestrictions(@Nonnull TenantContext context, @Nonnull String groupName)
      Removes a group from all rule component restrictions. This is used when a group is deleted to ensure stale group references are cleaned up from the restriction database.

      If a restriction's only allowed group is removed, the restriction entry remains with an empty group set (meaning fully restricted).

      This operation is typically called asynchronously in response to a group deletion event.

      Parameters:
      context - the tenant context
      groupName - the name of the group to remove from all restrictions
      Returns:
      the number of restrictions that were modified