001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.web.controller;
018
019import javax.servlet.http.HttpServletRequest;
020import javax.servlet.http.HttpServletResponse;
021import org.apache.activemq.broker.jmx.JobSchedulerViewMBean;
022import org.apache.activemq.web.BrokerFacade;
023import org.apache.activemq.web.DestinationFacade;
024import org.slf4j.Logger;
025import org.slf4j.LoggerFactory;
026import org.springframework.web.servlet.ModelAndView;
027import org.springframework.web.servlet.mvc.Controller;
028
029/**
030 * 
031 */
032public class DeleteJob extends DestinationFacade implements Controller {
033    private String jobId;
034    private static final Logger LOG = LoggerFactory.getLogger(DeleteJob.class);
035
036    public DeleteJob(BrokerFacade brokerFacade) {
037        super(brokerFacade);
038    }
039
040    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
041        if (jobId != null) {
042            JobSchedulerViewMBean jobScheduler = getBrokerFacade().getJobScheduler();
043            if (jobScheduler != null) {
044                jobScheduler.removeJob(jobId);
045                LOG.info("Removed scheduled Job " + jobId);
046            } else {
047                LOG.warn("Scheduler not configured");
048            }
049        }
050        return new ModelAndView("redirect:scheduled.jsp");
051    }
052
053    public String getJobId() {
054        return jobId;
055    }
056
057    public void setJobId(String id) {
058        this.jobId=id;
059    }
060
061}