Coverage Report - org.kuali.rice.ksb.messaging.web.QuartzQueueAction
 
Classes in this File Line Coverage Branch Coverage Complexity
QuartzQueueAction
0%
0/24
0%
0/8
2.667
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.ksb.messaging.web;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.servlet.http.HttpServletRequest;
 22  
 import javax.servlet.http.HttpServletResponse;
 23  
 
 24  
 import org.apache.struts.action.ActionForm;
 25  
 import org.apache.struts.action.ActionForward;
 26  
 import org.apache.struts.action.ActionMapping;
 27  
 import org.apache.struts.action.ActionMessages;
 28  
 import org.kuali.rice.ksb.messaging.PersistedMessage;
 29  
 import org.kuali.rice.ksb.messaging.quartz.MessageServiceExecutorJob;
 30  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 31  
 import org.kuali.rice.ksb.util.KSBConstants;
 32  
 import org.quartz.JobDetail;
 33  
 import org.quartz.Trigger;
 34  
 
 35  
 
 36  
 /**
 37  
  * action to view messages in quartz and push them into the message queue. 
 38  
  * 
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  *
 41  
  */
 42  0
 public class QuartzQueueAction extends KSBAction {
 43  
     
 44  
     private static final String RENDER_LIST_OVERRIDE = "_renderlistoverride";
 45  
 
 46  
     @Override
 47  
     public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception {
 48  0
         if ("moveToRouteQueue".equals(request.getParameter("methodToCall")) && request.getAttribute(RENDER_LIST_OVERRIDE) == null) {
 49  0
             return null;
 50  
         }
 51  
         
 52  0
         List<QuartzQueueForm> jobs = new ArrayList<QuartzQueueForm>();
 53  0
         String[] jobGroups = KSBServiceLocator.getScheduler().getJobGroupNames(); 
 54  0
         for (int i = 0; i < jobGroups.length; i++) {
 55  0
             String jobGroup = KSBServiceLocator.getScheduler().getJobGroupNames()[i];
 56  0
             String[] jobNames = KSBServiceLocator.getScheduler().getJobNames(jobGroup);
 57  0
             for (int j = 0; j < jobNames.length; j++) {
 58  0
                 JobDetail job = KSBServiceLocator.getScheduler().getJobDetail(jobNames[j], jobGroup);
 59  0
                 Trigger trigger = KSBServiceLocator.getScheduler().getTriggersOfJob(job.getName(), job.getGroup())[0];
 60  0
                 jobs.add(new QuartzQueueForm(job, trigger));
 61  
             }
 62  
         }
 63  0
         request.setAttribute("jobs", jobs);
 64  0
         return null;
 65  
     }
 66  
 
 67  
     @Override
 68  
     public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request,
 69  
             HttpServletResponse response) throws Exception {
 70  0
         return mapping.findForward("joblisting");
 71  
     }
 72  
     
 73  
     public ActionForward moveToRouteQueue(ActionMapping mapping, ActionForm form, HttpServletRequest request,
 74  
             HttpServletResponse response) throws Exception {
 75  
         
 76  0
         QuartzQueueForm quartzForm = (QuartzQueueForm)form;
 77  
         
 78  0
         JobDetail job = KSBServiceLocator.getScheduler().getJobDetail(quartzForm.getJobName(), quartzForm.getJobGroup());
 79  0
         PersistedMessage message = (PersistedMessage)job.getJobDataMap().get(MessageServiceExecutorJob.MESSAGE_KEY);
 80  0
         message.setQueueStatus(KSBConstants.ROUTE_QUEUE_EXCEPTION);
 81  
         
 82  0
         KSBServiceLocator.getRouteQueueService().save(message);
 83  0
         KSBServiceLocator.getScheduler().deleteJob(quartzForm.getJobName(), quartzForm.getJobGroup());
 84  0
         request.setAttribute(RENDER_LIST_OVERRIDE, new Object());
 85  0
         establishRequiredState(request, form);
 86  0
         return mapping.findForward("joblisting");
 87  
     }
 88  
     
 89  
     
 90  
 }