Package com.atlassian.jira.bc.safeguards
Class AbstractSafeguardValidator<T>
java.lang.Object
com.atlassian.jira.bc.safeguards.AbstractSafeguardValidator<T>
- Type Parameters:
T- the type of input to validate
- All Implemented Interfaces:
SafeguardValidator<T>
- Direct Known Subclasses:
DefaultCustomFieldLimitValidator,DefaultIssueSafeguardValidator,DefaultIssueTypeSafeguardValidator,DefaultProjectLimitValidator
Abstract base class for safeguard validators providing common functionality.
This class contains the common validation logic, limit checking, and breach notification mechanisms shared across different types of safeguard validators.
- Since:
- 11.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FeatureManagerprotected final JiraAuthenticationContextprotected final org.slf4j.Loggerprotected final SafeguardEventHelperprotected final SafeguardsManagerprotected static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSafeguardValidator(FeatureManager featureManager, SafeguardsManager safeguardsManager, JiraAuthenticationContext jiraAuthenticationContext, SafeguardEventHelper safeguardEventHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract longGets the current count of entities being validated.protected abstract StringGets the property key for the enabled flag.protected abstract StringgetEntityName(T input) Gets the entity name from the input for breach notifications.protected abstract SafeguardEntityTypeGets the SafeguardEntityType for this validator.protected abstract StringGets the name of the entity being validated for use in log messages.protected abstract StringGets the property key for the limit value.booleanIndicates whether the safeguard feature (and specific safeguard) is enabled.booleanPerforms validation for the provided request.protected voidnotifyBreach(T input, long limit, long currentCount)
-
Field Details
-
UNDEFINED_LIMIT
protected static final long UNDEFINED_LIMIT- See Also:
-
log
protected final org.slf4j.Logger log -
featureManager
-
safeguardsManager
-
jiraAuthenticationContext
-
safeguardEventHelper
-
-
Constructor Details
-
AbstractSafeguardValidator
protected AbstractSafeguardValidator(FeatureManager featureManager, SafeguardsManager safeguardsManager, JiraAuthenticationContext jiraAuthenticationContext, SafeguardEventHelper safeguardEventHelper)
-
-
Method Details
-
isValid
Description copied from interface:SafeguardValidatorPerforms validation for the provided request. Implementations may also perform side effects like logging/notification when appropriate.- Specified by:
isValidin interfaceSafeguardValidator<T>- Returns:
- true if valid (i.e., operation should be allowed)
-
isEnabled
public boolean isEnabled()Description copied from interface:SafeguardValidatorIndicates whether the safeguard feature (and specific safeguard) is enabled.- Specified by:
isEnabledin interfaceSafeguardValidator<T>
-
notifyBreach
-
getCurrentCount
protected abstract long getCurrentCount()Gets the current count of entities being validated.- Returns:
- the current count
-
getEntityType
Gets the SafeguardEntityType for this validator.- Returns:
- the entity type
-
getEnabledPropertyKey
Gets the property key for the enabled flag.- Returns:
- the enabled property key
-
getLimitPropertyKey
Gets the property key for the limit value.- Returns:
- the limit property key
-
getEntityTypeName
Gets the name of the entity being validated for use in log messages.- Returns:
- the entity type name
-
getEntityName
Gets the entity name from the input for breach notifications.- Parameters:
input- the input being validated- Returns:
- the entity name
-