/*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
*
* This file is part of Mir.
*
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two. You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries. If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so. If you do
- * not wish to do so, delete this exception statement from your version.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
*/
-
package mircoders.servlet;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Map;
import java.util.Vector;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.struts.util.MessageResources;
+
import mir.generator.Generator;
import mir.log.LoggerWrapper;
import mir.producer.ProducerFactory;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleFailure;
-import mir.util.NullWriter;
+import mir.util.HTTPRequestParser;
import mir.util.ResourceBundleGeneratorFunction;
import mircoders.global.MirGlobal;
-import org.apache.struts.util.MessageResources;
-
public class ServletModuleProducer extends ServletModule
{
private static ServletModuleProducer instance = new ServletModuleProducer();
defaultAction="showProducerQueueStatus";
}
- public void showMessage(PrintWriter aWriter, Locale aLocale, String aMessage, String anArgument1, String anArgument2) {
+ public void showMessage(HttpServletRequest aRequest, HttpServletResponse aResponse, String aMessage, String anArgument1, String anArgument2) {
Map responseData;
try {
- responseData = new HashMap();
+ responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
responseData.put("message", aMessage);
responseData.put("argument1", anArgument1);
responseData.put("argument2", anArgument2);
- generateResponse("infomessage.template", aWriter, responseData, aLocale);
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, "infomessage.template");
}
catch (Throwable t) {
throw new ServletModuleFailure(t);
try {
generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator("producerqueue.template");
- generationData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ generationData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
generationData.put( "thisurl", "module=Producer&do=showProducerQueueStatus");
producersData = new Vector();
}
}
- public void produce(HttpServletRequest req, HttpServletResponse res) {
+ public void produce(HttpServletRequest aRequest, HttpServletResponse aResponse) {
/*
* This method will only be called by external scripts (e.g. from cron jobs).
* The output therefore is very simple.
*/
try {
- PrintWriter out = res.getWriter();
+ PrintWriter out = aResponse.getWriter();
- if (req.getParameter("producer")!=null) {
- String producerParam = req.getParameter("producer");
- String verbParam = req.getParameter("verb");
+ if (aRequest.getParameter("producer")!=null) {
+ String producerParam = aRequest.getParameter("producer");
+ String verbParam = aRequest.getParameter("verb");
MirGlobal.producerEngine().addJob(producerParam, verbParam);
out.println("job added");
public void produceAllNew(HttpServletRequest aRequest, HttpServletResponse aResponse) {
try {
MirGlobal.localizer().producers().produceAllNew();
- showMessage(aResponse.getWriter(), getLocale(aRequest), "produceAllNewAddedToQueue", "", "");
+ showMessage(aRequest, aResponse, "produceAllNewAddedToQueue", "", "");
}
catch (Throwable t) {
throw new ServletModuleFailure(t);
MirGlobal.producerEngine().addJob(producerParam, verbParam);
- showProducerQueueStatus(aRequest, aResponse);
+ ServletHelper.redirect(aResponse, "Producer", "showProducerQueueStatus");
}
}
catch (Throwable t) {
}
}
- public void cancelAbortJob(HttpServletRequest aRequest, HttpServletResponse aResponse) {
- // ML: to be coded
+ public void cancel(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ List jobs = new Vector(requestParser.getParameterList("jobid"));
+
+ MirGlobal.producerEngine().cancelJobs(jobs);
+ ServletHelper.redirect(aResponse, "Producer", "showProducerQueueStatus");
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
}
}