From 4529b3926a3353fde9046d7dfc7373f6680404c0 Mon Sep 17 00:00:00 2001 From: zapata Date: Thu, 8 May 2003 02:43:41 +0000 Subject: [PATCH] no more cookie requirement for admin --- source/Mir.java | 4 +- source/mir/misc/HTMLTemplateProcessor.java | 22 ++- source/mircoders/servlet/ServletHelper.java | 36 +++-- source/mircoders/servlet/ServletModuleAbuse.java | 20 +-- source/mircoders/servlet/ServletModuleAdmin.java | 16 +- source/mircoders/servlet/ServletModuleComment.java | 4 +- source/mircoders/servlet/ServletModuleContent.java | 6 +- .../mircoders/servlet/ServletModuleFileEdit.java | 6 +- .../mircoders/servlet/ServletModuleOpenIndy.java | 178 ++++++++++----------- .../mircoders/servlet/ServletModuleProducer.java | 16 +- 10 files changed, 153 insertions(+), 155 deletions(-) diff --git a/source/Mir.java b/source/Mir.java index c67ecfcb..55235f77 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -80,7 +80,7 @@ import mircoders.storage.DatabaseUsers; * Mir.java - main servlet, that dispatches to servletmodules * * @author $Author: zapata $ - * @version $Id: Mir.java,v 1.48 2003/05/01 01:42:11 zapata Exp $ + * @version $Id: Mir.java,v 1.49 2003/05/08 02:43:41 zapata Exp $ * */ public class Mir extends AbstractServlet { @@ -442,7 +442,7 @@ public class Mir extends AbstractServlet { String sessionUrl = aResponse.encodeURL(""); try { - Map mergeData = ServletHelper.makeGenerationData(new Locale[] {getLocale(aRequest), getFallbackLocale()}, "bundles.admin", "bundles.adminlocal"); + Map mergeData = ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()}, "bundles.admin", "bundles.adminlocal"); mergeData.put("messages", new CachingRewindableIterator( new EntityIteratorAdapter( "", "webdb_create desc", 10, diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java index 6ea623c3..57281688 100755 --- a/source/mir/misc/HTMLTemplateProcessor.java +++ b/source/mir/misc/HTMLTemplateProcessor.java @@ -18,13 +18,13 @@ * 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 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. + * 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 mir.misc; @@ -203,11 +203,6 @@ public final class HTMLTemplateProcessor { tmr = new SimpleHash(); /** @todo what is this for? (rk) */ - String session = ""; - if (res != null) { - session = res.encodeURL(""); - } - SimpleHash configHash = new SimpleHash(); // pass the whole config hash to the templates @@ -222,7 +217,8 @@ public final class HTMLTemplateProcessor { // this does not come directly from the config file configHash.put("docRoot", new SimpleScalar(docRoot)); - configHash.put("actionRoot", new SimpleScalar(actionRoot + session)); + + configHash.put("actionRoot", new SimpleScalar(res.encodeURL(actionRoot))); configHash.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); diff --git a/source/mircoders/servlet/ServletHelper.java b/source/mircoders/servlet/ServletHelper.java index 63e8f8be..7836c124 100755 --- a/source/mircoders/servlet/ServletHelper.java +++ b/source/mircoders/servlet/ServletHelper.java @@ -18,13 +18,13 @@ * 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 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. + * 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; @@ -34,6 +34,11 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.util.MessageResources; + + import mir.entity.adapter.EntityIteratorAdapter; import mir.generator.Generator; import mir.log.LoggerWrapper; @@ -43,29 +48,30 @@ import mir.util.CachingRewindableIterator; import mir.util.ResourceBundleGeneratorFunction; import mircoders.global.MirGlobal; -import org.apache.struts.util.MessageResources; - - public class ServletHelper { static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper"); - public static Map makeGenerationData(Locale[] aLocales) throws ServletModuleExc { - return makeGenerationData(aLocales, "bundles.adminlocal", "bundles.admin"); + public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc { + return makeGenerationData(aResponse, aLocales, "bundles.adminlocal", "bundles.admin"); } - public static Map makeGenerationData(Locale[] aLocales, String aBundle) throws ServletModuleExc { - return makeGenerationData(aLocales, aBundle, aBundle); + public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc { + return makeGenerationData(aResponse, aLocales, aBundle, aBundle); } - public static Map makeGenerationData(Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc { + public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc { try { Map result = new HashMap(); MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result); + // ML: hackish + ((Map) result.get("config")).put("actionRoot", + aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir")); + result.put("returnurl", null); Object languages = diff --git a/source/mircoders/servlet/ServletModuleAbuse.java b/source/mircoders/servlet/ServletModuleAbuse.java index 00a101b8..af691d6e 100755 --- a/source/mircoders/servlet/ServletModuleAbuse.java +++ b/source/mircoders/servlet/ServletModuleAbuse.java @@ -18,13 +18,13 @@ * 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 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. + * 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. */ @@ -86,7 +86,7 @@ public class ServletModuleAbuse extends ServletModule { URLBuilder urlBuilder = new URLBuilder(); try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); urlBuilder.setValue("module", "Abuse"); urlBuilder.setValue("do", "showfilters"); @@ -107,7 +107,7 @@ public class ServletModuleAbuse extends ServletModule { URLBuilder urlBuilder = new URLBuilder(); try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); urlBuilder.setValue("module", "Abuse"); urlBuilder.setValue("do", "showsettings"); @@ -165,7 +165,7 @@ public class ServletModuleAbuse extends ServletModule { int count; try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); urlBuilder.setValue("module", "Abuse"); urlBuilder.setValue("do", "showlog"); responseData.put("thisurl", urlBuilder.getQuery()); diff --git a/source/mircoders/servlet/ServletModuleAdmin.java b/source/mircoders/servlet/ServletModuleAdmin.java index eb35ba8e..4b591e9b 100755 --- a/source/mircoders/servlet/ServletModuleAdmin.java +++ b/source/mircoders/servlet/ServletModuleAdmin.java @@ -18,13 +18,13 @@ * 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 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. + * 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; @@ -55,7 +55,7 @@ public class ServletModuleAdmin extends ServletModule int count; try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); urlBuilder.setValue("module", "Admin"); urlBuilder.setValue("do", "superusermenu"); diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java index c9c288f7..27043434 100755 --- a/source/mircoders/servlet/ServletModuleComment.java +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -108,7 +108,7 @@ public class ServletModuleComment extends ServletModule public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { try { HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); - Map responseData = ServletHelper.makeGenerationData(new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}); EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel(); Map comment; URLBuilder urlBuilder = new URLBuilder(); @@ -263,7 +263,7 @@ public class ServletModuleComment extends ServletModule int count; try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); model = MirGlobal.localizer().dataModel().adapterModel(); Object commentList = diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index 01e6abea..27309723 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -71,7 +71,7 @@ import freemarker.template.SimpleHash; * ServletModuleContent - * deliver html for the article admin form. * - * @version $Id: ServletModuleContent.java,v 1.51 2003/04/28 00:44:06 zapata Exp $ + * @version $Id: ServletModuleContent.java,v 1.52 2003/05/08 02:43:42 zapata Exp $ * @author rk, mir-coders * */ @@ -359,7 +359,7 @@ public class ServletModuleContent extends ServletModule throws ServletModuleExc { try { HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel(); Map article; URLBuilder urlBuilder = new URLBuilder(); @@ -419,7 +419,7 @@ public class ServletModuleContent extends ServletModule int count; try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); model = MirGlobal.localizer().dataModel().adapterModel(); Object articleList = diff --git a/source/mircoders/servlet/ServletModuleFileEdit.java b/source/mircoders/servlet/ServletModuleFileEdit.java index c9257821..3b4ca3bf 100755 --- a/source/mircoders/servlet/ServletModuleFileEdit.java +++ b/source/mircoders/servlet/ServletModuleFileEdit.java @@ -59,7 +59,7 @@ import mir.util.URLBuilder; * in the config file. * * @author $Author: zapata $ - * @version $Revision: 1.12 $ $Date: 2003/04/28 01:57:14 $ + * @version $Revision: 1.13 $ $Date: 2003/05/08 02:43:42 $ * */ @@ -228,7 +228,7 @@ public class ServletModuleFileEdit extends ServletModule public void listSubDirectory(FileEditDirectory aDirectory, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); File dir = new File(aDirectory.getRootDirectory(), aSubDirectory); if (!validateDirectory(aDirectory, dir) || !dir.isDirectory()) { @@ -271,7 +271,7 @@ public class ServletModuleFileEdit extends ServletModule listSubDirectory(aDirectory, "", aRequest, aResponse); } else { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); URLBuilder urlBuilder = new URLBuilder(); urlBuilder.setValue("module", "FileEdit"); diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index f7d0bf9f..eef87c9f 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -31,16 +31,12 @@ package mircoders.servlet; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Enumeration; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; @@ -123,7 +119,7 @@ import mircoders.storage.DatabaseTopics; * open-postings to the newswire * * @author mir-coders group - * @version $Id: ServletModuleOpenIndy.java,v 1.88 2003/05/06 12:22:07 john Exp $ + * @version $Id: ServletModuleOpenIndy.java,v 1.89 2003/05/08 02:43:42 zapata Exp $ * */ @@ -554,7 +550,7 @@ public class ServletModuleOpenIndy extends ServletModule Session session = new HTTPAdapters.HTTPSessionAdapter(aRequest.getSession()); SimpleResponse response = new SimpleResponse( - ServletHelper.makeGenerationData(new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}, + ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}, "bundles.open")); response.setResponseValue("actionURL", aResponse.encodeURL(HttpUtils.getRequestURL(aRequest).toString())+"?"+SESSION_REQUEST_KEY+"="+aRequest.getSession().getId()); @@ -597,8 +593,8 @@ public class ServletModuleOpenIndy extends ServletModule mergeData.put("mail_comment",comment); mergeData.put("mail_aid",aid); mergeData.put("mail_language",mail_language); - - + + if (to == null || from == null || from_name == null|| to.equals("") || from.equals("") || from_name.equals("") || mail_language == null || mail_language.equals("")){ deliver(req, res, mergeData, null, prepareMailTemplate); } @@ -615,32 +611,32 @@ public class ServletModuleOpenIndy extends ServletModule if (from.indexOf('\n') != -1 || from.indexOf('\r') != -1 || from.indexOf(',') != -1 ) { throw new ServletModuleUserExc("email.error.invalidfromaddress", new String[] {from}); } - + CacheKey theCacheKey=new CacheKey("email",aid+mail_language); String theEmailText; - + if (MirGlobal.mruCache().hasObject(theCacheKey)){ - logger.info("fetching email text for article "+aid+" from cache"); - theEmailText = (String) MirGlobal.mruCache().getObject(theCacheKey); + logger.info("fetching email text for article "+aid+" from cache"); + theEmailText = (String) MirGlobal.mruCache().getObject(theCacheKey); } else { - EntityContent contentEnt; - try{ - contentEnt = (EntityContent)contentModule.getById(aid); - StringWriter theEMailTextWriter=new StringWriter(); - PrintWriter dest = new PrintWriter(theEMailTextWriter); - Map articleData = new HashMap(); - articleData.put("article",MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", contentEnt)); - articleData.put("languagecode",mail_language); - deliver(dest,req, res, articleData, null, emailAnArticleTemplate,mail_language); - theEmailText=theEMailTextWriter.toString(); - MirGlobal.mruCache().storeObject(theCacheKey,theEmailText); - } - catch (Throwable e){ - throw new ServletModuleFailure("Couldn't get content for article "+aid + mail_language + ": " + e.getMessage(), e); - } + EntityContent contentEnt; + try { + contentEnt = (EntityContent) contentModule.getById(aid); + StringWriter theEMailTextWriter = new StringWriter(); + PrintWriter dest = new PrintWriter(theEMailTextWriter); + Map articleData = new HashMap(); + articleData.put("article", MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", contentEnt)); + articleData.put("languagecode", mail_language); + deliver(dest, req, res, articleData, null, emailAnArticleTemplate, mail_language); + theEmailText = theEMailTextWriter.toString(); + MirGlobal.mruCache().storeObject(theCacheKey, theEmailText); + } + catch (Throwable e) { + throw new ServletModuleFailure("Couldn't get content for article " + aid + mail_language + ": " + e.getMessage(), e); + } } - + String content = theEmailText; @@ -993,69 +989,69 @@ public class ServletModuleOpenIndy extends ServletModule try { String idParam = req.getParameter(ID_REQUEST_PARAM); if (idParam != null) { - - - RE re = new RE("[0-9]+"); - - - REMatch[] idMatches=re.getAllMatches(idParam); - - String cacheSelector=""; - - for (int i = 0; i < idMatches.length; i++){ - cacheSelector= cacheSelector + "," + idMatches[i].toString(); - } - - String cacheType="pdf"; - - CacheKey theCacheKey = new CacheKey(cacheType,cacheSelector); - - byte[] thePDF; - - if (MirGlobal.mruCache().hasObject(theCacheKey)){ - logger.info("fetching pdf from cache"); - thePDF = (byte[]) MirGlobal.mruCache().getObject(theCacheKey); - } - else { - logger.info("generating pdf and caching it"); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PDFGenerator pdfMaker = new PDFGenerator(out); - - if (idMatches.length > 1){ - pdfMaker.addLine(); - for (int i = 0; i < idMatches.length && i < maxArticlesInNewsleter; i++){ - REMatch aMatch = idMatches[i]; - String id=aMatch.toString(); - EntityContent contentEnt = (EntityContent)contentModule.getById(id); - pdfMaker.addIndexItem(contentEnt); - } - } - - for (int i = 0; i < idMatches.length; i++){ - REMatch aMatch = idMatches[i]; - String id=aMatch.toString(); - EntityContent contentEnt = (EntityContent)contentModule.getById(id); - - pdfMaker.add(contentEnt); - } - - pdfMaker.stop(); - thePDF = out.toByteArray(); - - //and save all our hard work! - MirGlobal.mruCache().storeObject(theCacheKey,thePDF); - } - - res.setContentType("application/pdf"); - res.setContentLength(thePDF.length); - res.getOutputStream().write(thePDF); - res.getOutputStream().flush(); - String elapsedtime=(new Long(System.currentTimeMillis()-starttime)).toString(); - logger.info("pdf retireval took "+elapsedtime + " milliseconds" ); + + + RE re = new RE("[0-9]+"); + + + REMatch[] idMatches=re.getAllMatches(idParam); + + String cacheSelector=""; + + for (int i = 0; i < idMatches.length; i++){ + cacheSelector= cacheSelector + "," + idMatches[i].toString(); + } + + String cacheType="pdf"; + + CacheKey theCacheKey = new CacheKey(cacheType,cacheSelector); + + byte[] thePDF; + + if (MirGlobal.mruCache().hasObject(theCacheKey)){ + logger.info("fetching pdf from cache"); + thePDF = (byte[]) MirGlobal.mruCache().getObject(theCacheKey); + } + else { + logger.info("generating pdf and caching it"); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PDFGenerator pdfMaker = new PDFGenerator(out); + + if (idMatches.length > 1){ + pdfMaker.addLine(); + for (int i = 0; i < idMatches.length && i < maxArticlesInNewsleter; i++){ + REMatch aMatch = idMatches[i]; + String id=aMatch.toString(); + EntityContent contentEnt = (EntityContent)contentModule.getById(id); + pdfMaker.addIndexItem(contentEnt); + } + } + + for (int i = 0; i < idMatches.length; i++){ + REMatch aMatch = idMatches[i]; + String id=aMatch.toString(); + EntityContent contentEnt = (EntityContent)contentModule.getById(id); + + pdfMaker.add(contentEnt); + } + + pdfMaker.stop(); + thePDF = out.toByteArray(); + + //and save all our hard work! + MirGlobal.mruCache().storeObject(theCacheKey,thePDF); + } + + res.setContentType("application/pdf"); + res.setContentLength(thePDF.length); + res.getOutputStream().write(thePDF); + res.getOutputStream().flush(); + String elapsedtime=(new Long(System.currentTimeMillis()-starttime)).toString(); + logger.info("pdf retireval took "+elapsedtime + " milliseconds" ); } else { - throw new ServletModuleExc("Missing id."); + throw new ServletModuleExc("Missing id."); } } catch (Throwable t) { @@ -1064,7 +1060,7 @@ public class ServletModuleOpenIndy extends ServletModule } } - + public String generateOnetimePassword() { Random r = new Random(); @@ -1093,7 +1089,7 @@ public class ServletModuleOpenIndy extends ServletModule public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator) throws ServletModuleFailure { try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}, "bundles.open"); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}, "bundles.open"); responseData.put("data", aData); responseData.put("extra", anExtra); @@ -1113,7 +1109,7 @@ public class ServletModuleOpenIndy extends ServletModule public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator,String aLocaleString) throws ServletModuleFailure { try { - Map responseData = ServletHelper.makeGenerationData(new Locale[] { new Locale(aLocaleString,""), getFallbackLocale(aRequest)}, "bundles.open"); + Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { new Locale(aLocaleString,""), getFallbackLocale(aRequest)}, "bundles.open"); responseData.put("data", aData); responseData.put("extra", anExtra); diff --git a/source/mircoders/servlet/ServletModuleProducer.java b/source/mircoders/servlet/ServletModuleProducer.java index b6216603..69be3b59 100755 --- a/source/mircoders/servlet/ServletModuleProducer.java +++ b/source/mircoders/servlet/ServletModuleProducer.java @@ -18,13 +18,13 @@ * 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 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. + * 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; @@ -104,7 +104,7 @@ public class ServletModuleProducer extends ServletModule try { generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator("producerqueue.template"); - generationData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); + generationData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); generationData.put( "thisurl", "module=Producer&do=showProducerQueueStatus"); producersData = new Vector(); -- 2.11.0