Hi
I am developing a Jira plugin and trying to set substitutes for team leaders for a particular time interval. I am providing team permission to substitute and need to check every midnight if the substitutes time interval is over or not . if yes then need to remove permission for the substitute,
I have already developed the code for setting and removing substitute but now i m searching how to add a timer to jira so that it will make a rest call every midnight to check whether current date reside in substitutes time interval if not then delete the permission.
Thnanks!!
Hey ..
actually in my authentication helper i'm appending http req.
Is it possible to create a jsession id for the user using name and password or if we can create a cookie to make a tempo rest api call ....
Thanks
I don't know exactly how your AuthenticationHelper and TempoRestClient are implemented but maybe you need to do something like:
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext();
authContext.setLoggedInUser(ComponentAccessor.getUserManager().getUserByKey("username"));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there some another way in which i can create a timer then and append my http req too ?because i ll need admin rights to make a rest call to get tempo teams
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Look at this tutorial to schedule a task: https://developer.atlassian.com/server/framework/atlassian-sdk/scheduling-events-via-sal-tutorial.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Aleksander ,
Thanks for the link .
As I described earlier,I am trying to develop a substitute functionality in JIRA in which team leaders can assign their substitutes and give them permission to approve the timesheet of his team members,
It will be valid for a specified interval for that interval i am giving tempo team permission to the substitute. After the time interval is over i want to remove the team permission for the substitute,
I already have the code to remove and set permission for substitute i need to create a timer which will run every mid night to check weather team's substitute reside in the time interval for team permission or not if not then remove it .
I tried to follow this link.
I used following steps to create a timer.
1. I added the maven dependency.
2. Imported the SAL scheduler as defined in link.
3. Wrote a Task in which I implemented PluginJob and also pass the task class name.I also injected the services here which I was using to delete the team permission here for substitute after checking the time interval.
// i m getting error in this step at the point where i tried to call my authentication helper to set the httprequest which i will need to get all the tempo teams and to get the substitute for them . I am getting following error.
2:15:49,422 Caesium-1-1 ERROR ServiceRunner [c.a.scheduler.core.JobLauncher] Scheduled job with ID 'JiraPluginScheduler:com.foxconn.dta.schedular.RemoveOldSubstituteTeamPermissionsimpl:job' failed
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.foxconn.dta.schedular.RemoveOldSubstitute.execute(RemoveOldSubstitute.java:31)
[INFO] [talledLocalContainer] at com.atlassian.sal.jira.scheduling.JiraPluginScheduler$JobDescriptor.runJob(JiraPluginScheduler.java:110)
[INFO] [talledLocalContainer] at com.atlassian.sal.jira.scheduling.JiraPluginScheduler.runJob(JiraPluginScheduler.java:80)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:153)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:118)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:97)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:443)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeLocalJob(CaesiumSchedulerService.java:410)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:388)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(CaesiumSchedulerService.java:285)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(CaesiumSchedulerService.java:282)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:65)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:59)
[INFO] [talledLocalContainer] at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:34)
[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:748)
Thanks !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you show your RemoveOldSubstitute.java?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public class RemoveOldSubstitute implements PluginJob {
@Inject
private SubstituteSettingsService substituteSettingService;
@Inject
private TempoRestClient tempoRestClient;
@Context
HttpServletRequest httpRequest;
@Inject
AuthenticationHelper authenticationHelper;
@Override
public void execute(Map<String, Object> jobDataMap) {
final RemoveOldSubstituteTeamPermissionsimpl monitor = (RemoveOldSubstituteTeamPermissionsimpl) jobDataMap
.get(RemoveOldSubstituteTeamPermissionsimpl.KEY);
assert monitor != null;
//here i m getting the error .. httprequest is null here how i can add request here .
authenticationHelper.setHttpRequest(httpRequest);
//getting all the teams info here
List<TempoTeam> teams = tempoRestClient.getTeamListForUser();
if (teams != null && !teams.isEmpty()) {
for (TempoTeam team : teams) {
substituteSettingService.deleteTeamLeadSubstitute(team.getId(), team.getLead());
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no httpRequest here because you run your method in scheduled mode, without user interaction. You have to think how to authenticate another way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.