Class DefaultCommentsPerIssueLimitValidator
java.lang.Object
com.atlassian.jira.bc.safeguards.issue.comment.DefaultCommentsPerIssueLimitValidator
- All Implemented Interfaces:
CommentsPerIssueLimitValidator,SafeguardValidator<CommentsPerIssueValidationRequest>
public class DefaultCommentsPerIssueLimitValidator
extends Object
implements CommentsPerIssueLimitValidator
Default implementation of CommentsPerIssueLimitValidator.
Checks that the target issue contains less comments than configured limit.
Enabled/Disabled by using the feature flag 'com.atlassian.jira.safeguards'
The limit on allowed comments per issue is configured by the Application Property 'jira.safeguards.issue.comments'
- Since:
- 9.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCommentsPerIssueLimitValidator(CommentSearchManager commentSearchManager, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext, RestrictedUsersComponent restrictedUsersComponent, SafeguardsManager safeguardsManager, LegacyCommentsPerIssueLimitNotifier legacyNotifier, SafeguardEventHelper notificationHelper, com.atlassian.audit.core.spi.service.IpAddressProvider ipAddressProvider) -
Method Summary
Modifier and TypeMethodDescriptiongetInvalidIssues(List<Issue> issues) Validates comment limits for all provided issues and returns issues that failed.longgetLimit()Returns the configured limit value for this safeguard (or a sentinel value when undefined).booleanIndicates whether the safeguard feature (and specific safeguard) is enabled.booleanisValid(CommentsPerIssueValidationRequest request) Performs validation for the provided request.voidValidates the request and throws an exception if invalid.
-
Field Details
-
NOT_SPECIFIED_USER
- See Also:
-
-
Constructor Details
-
DefaultCommentsPerIssueLimitValidator
public DefaultCommentsPerIssueLimitValidator(CommentSearchManager commentSearchManager, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext, RestrictedUsersComponent restrictedUsersComponent, SafeguardsManager safeguardsManager, LegacyCommentsPerIssueLimitNotifier legacyNotifier, SafeguardEventHelper notificationHelper, com.atlassian.audit.core.spi.service.IpAddressProvider ipAddressProvider)
-
-
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<CommentsPerIssueValidationRequest>- Returns:
- true if valid (i.e., operation should be allowed)
-
validate
public void validate(@Nonnull CommentsPerIssueValidationRequest request) throws CommentsPerIssueLimitExceededException Description copied from interface:CommentsPerIssueLimitValidatorValidates the request and throws an exception if invalid.- Specified by:
validatein interfaceCommentsPerIssueLimitValidator- Throws:
CommentsPerIssueLimitExceededException
-
getLimit
public long getLimit()Description copied from interface:CommentsPerIssueLimitValidatorReturns the configured limit value for this safeguard (or a sentinel value when undefined).- Specified by:
getLimitin interfaceCommentsPerIssueLimitValidator
-
isEnabled
public boolean isEnabled()Description copied from interface:SafeguardValidatorIndicates whether the safeguard feature (and specific safeguard) is enabled.- Specified by:
isEnabledin interfaceSafeguardValidator<CommentsPerIssueValidationRequest>
-
getInvalidIssues
Description copied from interface:CommentsPerIssueLimitValidatorValidates comment limits for all provided issues and returns issues that failed. This method is a recommended way to validate a collection of issues due to performance optimizations. This method doesn't trigger any notification or logging.- Specified by:
getInvalidIssuesin interfaceCommentsPerIssueLimitValidator- Parameters:
issues- list of issues- Returns:
- list of issues for which validation failed
-