public class DefaultFilterSubscriptionService extends Object implements FilterSubscriptionService
Constructor and Description |
---|
DefaultFilterSubscriptionService(JiraAuthenticationContext jiraAuthenticationContext,
SubscriptionManager subscriptionManager,
com.atlassian.scheduler.SchedulerService schedulerService,
FeatureManager featureManager,
GlobalPermissionManager globalPermissionManager) |
Modifier and Type | Method and Description |
---|---|
String |
getCronExpression(JiraServiceContext context,
FilterSubscription subscription)
Retrieve the cron expression associated with this subscription
|
Date |
getNextSendTime(FilterSubscription subscription)
Returns the next send time for this subscription.
|
String |
getPrettySchedule(JiraServiceContext context,
String cronExpression)
Renders a human readable description of the given cron expression.
|
Collection<FilterSubscription> |
getVisibleFilterSubscriptions(ApplicationUser user,
SearchRequest filter)
Retrieves subscriptions that a user can see for a filter.
|
void |
storeSubscription(JiraServiceContext context,
Long filterId,
String groupName,
String expr,
boolean emailOnEmpty)
Create and store a subscription that uses the given cron expression
|
void |
updateSubscription(JiraServiceContext context,
ApplicationUser owner,
Long subscriptionId,
String groupName,
String expr,
boolean emailOnEmpty)
Updates the subscription to the new given values and persists.
|
void |
updateSubscription(JiraServiceContext context,
Long subscriptionId,
String groupName,
String expr,
boolean emailOnEmpty)
Updates the subscription to the new given values and persists.
|
void |
validateCronExpression(JiraServiceContext context,
String expr)
Validates a given cron expression
|
public DefaultFilterSubscriptionService(JiraAuthenticationContext jiraAuthenticationContext, SubscriptionManager subscriptionManager, com.atlassian.scheduler.SchedulerService schedulerService, FeatureManager featureManager, GlobalPermissionManager globalPermissionManager)
public void validateCronExpression(JiraServiceContext context, String expr)
FilterSubscriptionService
Errors are passed back in the ErrorCollection
of the JiraServiceContext
validateCronExpression
in interface FilterSubscriptionService
context
- Jira service contextexpr
- expression to evaluatepublic void storeSubscription(JiraServiceContext context, Long filterId, String groupName, String expr, boolean emailOnEmpty)
FilterSubscriptionService
storeSubscription
in interface FilterSubscriptionService
context
- Jira service contextfilterId
- id of the filter subscribing togroupName
- sent to group (may be null if sent to self)expr
- cron expression to storeemailOnEmpty
- send email if filter returns no resultspublic void updateSubscription(JiraServiceContext context, Long subscriptionId, String groupName, String expr, boolean emailOnEmpty)
FilterSubscriptionService
Note: This method will always change the owner of the subscription to the logged in user. If you don't want
this behavior, use FilterSubscriptionService.updateSubscription(JiraServiceContext, ApplicationUser, Long, String, String, boolean)
.
updateSubscription
in interface FilterSubscriptionService
context
- Jira service contextsubscriptionId
- id of the subscription being updatedgroupName
- sent to group (may be null if sent to self)expr
- cron expression to storeemailOnEmpty
- send email if filter returns no resultspublic void updateSubscription(JiraServiceContext context, ApplicationUser owner, Long subscriptionId, String groupName, String expr, boolean emailOnEmpty)
FilterSubscriptionService
updateSubscription
in interface FilterSubscriptionService
context
- Jira service contextowner
- new owner for the subscriptionsubscriptionId
- id of the subscription being updatedgroupName
- sent to group (may be null if sent to self)expr
- cron expression to storeemailOnEmpty
- send email if filter returns no resultspublic String getPrettySchedule(JiraServiceContext context, String cronExpression)
FilterSubscriptionService
Returns the cron expression if it can't be parsed by the com.atlassian.core.cron.parser.CronExpressionParser
.
getPrettySchedule
in interface FilterSubscriptionService
context
- Jira service contextcronExpression
- a cron expression.public String getCronExpression(JiraServiceContext context, FilterSubscription subscription)
FilterSubscriptionService
getCronExpression
in interface FilterSubscriptionService
public Collection<FilterSubscription> getVisibleFilterSubscriptions(ApplicationUser user, SearchRequest filter)
FilterSubscriptionService
An admin can see all subscriptions, the filter owner can see all subscriptions for their filter, otherwise a user can only see their own subscriptions.
getVisibleFilterSubscriptions
in interface FilterSubscriptionService
user
- the user that can see the subscriptionsfilter
- the filter with the associated subscriptions@Nullable public Date getNextSendTime(@Nonnull FilterSubscription subscription)
FilterSubscriptionService
This may return null if the scheduler does not support the reporting of next send times.
getNextSendTime
in interface FilterSubscriptionService
subscription
- the subscriptionCopyright © 2002-2022 Atlassian. All Rights Reserved.