Class DefaultCommentsPerIssueLimitValidator
java.lang.Object
com.atlassian.jira.bc.safeguards.issue.comment.DefaultCommentsPerIssueLimitValidator
- All Implemented Interfaces:
CommentsPerIssueLimitValidator
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
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCommentsPerIssueLimitValidator
(CommentSearchManager commentSearchManager, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext, RestrictedUsersComponent restrictedUsersComponent, SafeguardsManager safeguardsManager, CommentsPerIssueLimitNotifier notifier, ClusterManager clusterManager, 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.long
getLimit()
Returns the value of the limit as configured at the time of calling,boolean
isValid
(Issue issue, ApplicationUser author, String commentBody, ErrorCollection errorCollection) Checks if limit is not reached yet (eg.void
validate
(Issue issue, ApplicationUser author, String commentBody) Checks if limit is not reached yet (eg.
-
Constructor Details
-
DefaultCommentsPerIssueLimitValidator
public DefaultCommentsPerIssueLimitValidator(CommentSearchManager commentSearchManager, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext, RestrictedUsersComponent restrictedUsersComponent, SafeguardsManager safeguardsManager, CommentsPerIssueLimitNotifier notifier, ClusterManager clusterManager, com.atlassian.audit.core.spi.service.IpAddressProvider ipAddressProvider)
-
-
Method Details
-
isValid
public boolean isValid(@Nonnull Issue issue, @Nullable ApplicationUser author, @Nonnull String commentBody, @Nonnull ErrorCollection errorCollection) Description copied from interface:CommentsPerIssueLimitValidator
Checks if limit is not reached yet (eg. to determine if new entity can be created). If validation fails, an error with description is added to error collection.- Specified by:
isValid
in interfaceCommentsPerIssueLimitValidator
- Parameters:
issue
- entity analysed for comment numberauthor
- comment creatorcommentBody
- comment body- Returns:
- true if limit is not reached
-
getInvalidIssues
Description copied from interface:CommentsPerIssueLimitValidator
Validates 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:
getInvalidIssues
in interfaceCommentsPerIssueLimitValidator
- Parameters:
issues
- list of issues- Returns:
- list of issues for which validation failed
-
validate
public void validate(@Nonnull Issue issue, @Nullable ApplicationUser author, @Nonnull String commentBody) throws CommentsPerIssueLimitExceededException Description copied from interface:CommentsPerIssueLimitValidator
Checks if limit is not reached yet (eg. to determine if new entity can be created).- Specified by:
validate
in interfaceCommentsPerIssueLimitValidator
- Parameters:
issue
- entity analysed for comment numberauthor
- comment creatorcommentBody
- comment body- Throws:
CommentsPerIssueLimitExceededException
- if validation fails
-
getLimit
public long getLimit()Description copied from interface:CommentsPerIssueLimitValidator
Returns the value of the limit as configured at the time of calling,- Specified by:
getLimit
in interfaceCommentsPerIssueLimitValidator
- Returns:
- the configured limit
-