1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.messaging.web; |
17 | |
|
18 | |
import org.apache.struts.action.ActionForm; |
19 | |
import org.apache.struts.action.ActionForward; |
20 | |
import org.apache.struts.action.ActionMapping; |
21 | |
import org.apache.struts.action.ActionMessages; |
22 | |
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
23 | |
import org.kuali.rice.ksb.messaging.quartz.MessageServiceExecutorJob; |
24 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
25 | |
import org.kuali.rice.ksb.util.KSBConstants; |
26 | |
import org.quartz.JobDetail; |
27 | |
import org.quartz.Trigger; |
28 | |
|
29 | |
import javax.servlet.http.HttpServletRequest; |
30 | |
import javax.servlet.http.HttpServletResponse; |
31 | |
import java.util.ArrayList; |
32 | |
import java.util.List; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class QuartzQueueAction extends KSBAction { |
42 | |
|
43 | |
private static final String RENDER_LIST_OVERRIDE = "_renderlistoverride"; |
44 | |
|
45 | |
@Override |
46 | |
public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception { |
47 | 0 | if ("moveToRouteQueue".equals(request.getParameter("methodToCall")) && request.getAttribute(RENDER_LIST_OVERRIDE) == null) { |
48 | 0 | return null; |
49 | |
} |
50 | |
|
51 | 0 | List<QuartzQueueForm> jobs = new ArrayList<QuartzQueueForm>(); |
52 | 0 | String[] jobGroups = KSBServiceLocator.getScheduler().getJobGroupNames(); |
53 | 0 | for (int i = 0; i < jobGroups.length; i++) { |
54 | 0 | String jobGroup = KSBServiceLocator.getScheduler().getJobGroupNames()[i]; |
55 | 0 | String[] jobNames = KSBServiceLocator.getScheduler().getJobNames(jobGroup); |
56 | 0 | for (int j = 0; j < jobNames.length; j++) { |
57 | 0 | JobDetail job = KSBServiceLocator.getScheduler().getJobDetail(jobNames[j], jobGroup); |
58 | 0 | Trigger trigger = KSBServiceLocator.getScheduler().getTriggersOfJob(job.getName(), job.getGroup())[0]; |
59 | 0 | jobs.add(new QuartzQueueForm(job, trigger)); |
60 | |
} |
61 | |
} |
62 | 0 | request.setAttribute("jobs", jobs); |
63 | 0 | return null; |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
68 | |
HttpServletResponse response) throws Exception { |
69 | 0 | return mapping.findForward("joblisting"); |
70 | |
} |
71 | |
|
72 | |
public ActionForward moveToRouteQueue(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
73 | |
HttpServletResponse response) throws Exception { |
74 | |
|
75 | 0 | QuartzQueueForm quartzForm = (QuartzQueueForm)form; |
76 | |
|
77 | 0 | JobDetail job = KSBServiceLocator.getScheduler().getJobDetail(quartzForm.getJobName(), quartzForm.getJobGroup()); |
78 | 0 | PersistedMessageBO message = (PersistedMessageBO)job.getJobDataMap().get(MessageServiceExecutorJob.MESSAGE_KEY); |
79 | 0 | message.setQueueStatus(KSBConstants.ROUTE_QUEUE_EXCEPTION); |
80 | |
|
81 | 0 | KSBServiceLocator.getMessageQueueService().save(message); |
82 | 0 | KSBServiceLocator.getScheduler().deleteJob(quartzForm.getJobName(), quartzForm.getJobGroup()); |
83 | 0 | request.setAttribute(RENDER_LIST_OVERRIDE, new Object()); |
84 | 0 | establishRequiredState(request, form); |
85 | 0 | return mapping.findForward("joblisting"); |
86 | |
} |
87 | |
|
88 | |
|
89 | |
} |