Coverage Report - org.apache.turbine.services.schedule.SchedulerTool
 
Classes in this File Line Coverage Branch Coverage Complexity
SchedulerTool
0%
0/14
0%
0/2
1,4
 
 1  
 package org.apache.turbine.services.schedule;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.commons.logging.Log;
 27  
 import org.apache.commons.logging.LogFactory;
 28  
 import org.apache.turbine.services.TurbineServices;
 29  
 import org.apache.turbine.services.pull.ApplicationTool;
 30  
 import org.apache.turbine.util.TurbineException;
 31  
 
 32  
 /**
 33  
  * This tool is used to retrieve information about the job scheduler.
 34  
  *
 35  
  * @author <a href="mailto:qmccombs@nequalsone.com">Quinton McCombs</a>
 36  
  * @version $Id: SchedulerTool.java 1706239 2015-10-01 13:18:35Z tv $
 37  
  */
 38  0
 public class SchedulerTool implements ApplicationTool
 39  
 {
 40  
     /** Used for logging */
 41  0
     private static Log log = LogFactory.getLog(ScheduleService.LOGGER_NAME);
 42  
 
 43  
     /**
 44  
      * Initialize the pull tool
 45  
      */
 46  
     @Override
 47  
     public void init(Object data)
 48  
     {
 49  0
         if (!TurbineServices.getInstance().isRegistered(
 50  
                 ScheduleService.SERVICE_NAME))
 51  
         {
 52  0
             log.error("You can not use the SchedulerTool unless you enable "
 53  
                     +"the Scheduler Service!!!!");
 54  
         }
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Does nothing
 59  
      */
 60  
     @Override
 61  
     public void refresh()
 62  
     {
 63  
         // empty
 64  0
     }
 65  
 
 66  
     /**
 67  
      * Gets the list of scheduled jobs.
 68  
      *
 69  
      * @return List of JobEntry objects.
 70  
      */
 71  
     public List<? extends JobEntry> getScheduledJobs()
 72  
     {
 73  0
         return TurbineScheduler.listJobs();
 74  
     }
 75  
 
 76  
     /**
 77  
      * Determines if the scheduler service is currently enabled.
 78  
      * @return true if the scheduler is enabled
 79  
      */
 80  
     public boolean isEnabled()
 81  
     {
 82  0
         return TurbineScheduler.isEnabled();
 83  
     }
 84  
 
 85  
     /**
 86  
      * Gets the job identified by the jobId.
 87  
      *
 88  
      * @param jobId Id of the job to retrieve.
 89  
      * @return The job.  Null if the jobId is not found.
 90  
      */
 91  
     public JobEntry getJob(String jobId)
 92  
     {
 93  0
         JobEntry je = null;
 94  
 
 95  
         try
 96  
         {
 97  0
             je = TurbineScheduler.getJob(Integer.parseInt(jobId));
 98  
         }
 99  0
         catch (TurbineException e)
 100  
         {
 101  0
             log.error("Could not retreive job id #" + jobId, e);
 102  0
         }
 103  
 
 104  0
         return je;
 105  
     }
 106  
 
 107  
 }