Class ComponentRestrictionFeatureService

java.lang.Object
com.codebarrel.jira.plugin.automation.web.admin.ComponentRestrictionFeatureService

@Named public class ComponentRestrictionFeatureService extends Object
Service that determines whether component restriction processing should be performed.

This service provides a centralized check that short-circuits restriction processing when the feature is not in use, optimizing performance and avoiding unnecessary database/cache lookups.

The following conditions will cause restriction processing to be skipped:

  • Feature flag a4j.automation.component.restrictions is disabled
  • The user is a global administrator (exempt from component restrictions)
  • No restriction configurations exist (feature not being used)

  • Constructor Details

  • Method Details

    • shouldProcessRestrictions

      public boolean shouldProcessRestrictions(TenantContext context, ApplicationUser user)
      Determines whether component restrictions should be processed for the given context and user.

      This method performs a series of short-circuit checks to determine if restriction processing is necessary. Returns false if any short-circuit condition is met, allowing callers to skip expensive restriction lookups.

      Global administrators are always exempt from component restrictions: they can use any component regardless of configured restrictions.

      Parameters:
      context - the tenant context
      user - the user performing the operation, or null for anonymous access
      Returns:
      true if restrictions should be processed, false to skip
    • isFeatureFlagEnabled

      public boolean isFeatureFlagEnabled()
      Checks if the component restrictions feature flag is enabled.
      Returns:
      true if the feature flag is enabled
    • hasAnyRestrictionConfigs

      public boolean hasAnyRestrictionConfigs(TenantContext context)
      Checks if any restriction configurations exist for the given context.
      Parameters:
      context - the tenant context
      Returns:
      true if at least one restriction config exists
    • areProjectAdminsAllowedToEditRules

      public boolean areProjectAdminsAllowedToEditRules(TenantContext context)
      Checks if project admins are allowed to edit automation rules based on global settings.

      When project admins cannot edit rules, only global admins can modify automation rules. Since global admins are always exempt from component restrictions, restriction processing becomes unnecessary.

      Parameters:
      context - the tenant context
      Returns:
      true if project admins are allowed to edit rules