From 0cfc7c748b6494ddbe21f5a66622d2d480a9a8fd Mon Sep 17 00:00:00 2001 From: zapata Date: Mon, 17 Mar 2003 20:47:03 +0000 Subject: [PATCH] Various fixes + Upgrades to the FileEdit module: - recurse option - regular expressions for the filename --- etc/config.properties-dist | 3 +- etc/open/posting.template | 4 +- source/Mir.java | 89 ++--- source/OpenMir.java | 130 +++---- source/default.properties | 137 ++++--- source/mir/misc/HTMLTemplateProcessor.java | 4 +- source/mir/misc/PDFUtil.java | 11 +- source/mir/producer/DirCopyingProducerNode.java | 4 +- source/mir/servlet/AbstractServlet.java | 431 ++++++++++----------- source/mir/servlet/ServletModule.java | 43 +- .../util/{FileCopier.java => FileFunctions.java} | 186 +++++---- source/mir/util/StringRoutines.java | 4 +- source/mircoders/search/AudioSearchTerm.java | 20 +- source/mircoders/search/ContentSearchTerm.java | 63 ++- source/mircoders/search/ImagesSearchTerm.java | 37 +- source/mircoders/search/KeywordSearchTerm.java | 24 +- source/mircoders/search/SearchTerm.java | 30 +- source/mircoders/search/TextSearchTerm.java | 19 +- source/mircoders/search/TopicSearchTerm.java | 20 +- source/mircoders/search/UnIndexedSearchTerm.java | 14 +- source/mircoders/search/UnStoredSearchTerm.java | 20 +- source/mircoders/search/VideoSearchTerm.java | 19 +- source/mircoders/servlet/ServletHelper.java | 182 +++++---- .../servlet/ServletModuleCommentStatus.java | 8 +- .../mircoders/servlet/ServletModuleFileEdit.java | 410 ++++++++++++-------- .../mircoders/servlet/ServletModuleOpenIndy.java | 279 +++++++------ templates/admin/articletype.template | 4 +- templates/admin/articletypelist.template | 4 +- templates/admin/audio.template | 4 +- templates/admin/audiolist.template | 4 +- templates/admin/breaking.template | 4 +- templates/admin/breakinglist.template | 4 +- templates/admin/comment.template | 4 +- templates/admin/commentstatus.template | 4 +- templates/admin/commentstatuslist.template | 4 +- templates/admin/confirm.template | 4 +- templates/admin/fileedit.template | 13 +- templates/admin/fileeditlist.template | 67 +++- templates/admin/hiddenlist.template | 4 +- templates/admin/image.template | 4 +- templates/admin/imagelist.template | 4 +- templates/admin/language.template | 4 +- templates/admin/languagelist.template | 4 +- templates/admin/linksimcs.template | 4 +- templates/admin/linksimcslist.template | 4 +- templates/admin/login.template | 4 +- templates/admin/media.template | 4 +- templates/admin/mediafolder.template | 4 +- templates/admin/mediafolderlist.template | 4 +- templates/admin/medialist.template | 4 +- templates/admin/message.template | 4 +- templates/admin/messagelist.template | 4 +- templates/admin/start_admin.template | 4 +- templates/admin/topic.template | 4 +- templates/admin/topiclist.template | 4 +- templates/admin/user.template | 4 +- templates/admin/usererror.template | 2 +- templates/admin/userlist.template | 4 +- templates/admin/video.template | 4 +- templates/admin/videolist.template | 4 +- 60 files changed, 1288 insertions(+), 1109 deletions(-) rename source/mir/util/{FileCopier.java => FileFunctions.java} (69%) diff --git a/etc/config.properties-dist b/etc/config.properties-dist index 4403526a..90f0e838 100755 --- a/etc/config.properties-dist +++ b/etc/config.properties-dist @@ -137,7 +137,8 @@ Producer.StorageRoot=/pub/Dokumente/Indymedia/de-tech/Mir/produced # # where do we find the files? absolute path ServletModule.FileEdit.FileDirectory=/pub/Dokumente/Indymedia/de-tech/Mir/produced -ServletModule.FileEdit.ExtFilter=inc +ServletModule.FileEdit.ExtFilter=.*\.inc$ +ServletModule.FileEdit.Recursive=1 # # diff --git a/etc/open/posting.template b/etc/open/posting.template index 67e2f476..f98ed27d 100755 --- a/etc/open/posting.template +++ b/etc/open/posting.template @@ -44,7 +44,7 @@ ${lang("posting.nr_of_media")}
${lang("posting.nr_of_media.info")} -   +   @@ -78,7 +78,7 @@   (${lang("optional")}) diff --git a/source/Mir.java b/source/Mir.java index ce3de041..b4a880b2 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -29,50 +29,47 @@ * not wish to do so, delete this exception statement from your version. */ -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.Method; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Vector; - -import javax.servlet.ServletException; -import javax.servlet.UnavailableException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import mir.config.MirPropertiesConfiguration; -import mir.generator.FreemarkerGenerator; -import mir.log.LoggerWrapper; -import mir.misc.HTMLTemplateProcessor; -import mir.misc.StringUtil; -import mir.servlet.AbstractServlet; -import mir.servlet.ServletModule; -import mir.servlet.ServletModuleDispatch; -import mir.servlet.ServletModuleExc; -import mir.servlet.ServletModuleUserExc; -import mir.util.ExceptionFunctions; -import mir.util.StringRoutines; -import mircoders.entity.EntityUsers; -import mircoders.global.MirGlobal; -import mircoders.module.ModuleMessage; -import mircoders.module.ModuleUsers; -import mircoders.storage.DatabaseArticleType; -import mircoders.storage.DatabaseMessages; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.util.MessageResources; +import freemarker.template.SimpleHash; +import freemarker.template.SimpleList; +import freemarker.template.SimpleScalar; +import freemarker.template.TemplateModel; +import mir.config.MirPropertiesConfiguration; +import mir.generator.FreemarkerGenerator; +import mir.log.LoggerWrapper; +import mir.misc.HTMLTemplateProcessor; +import mir.misc.StringUtil; +import mir.servlet.AbstractServlet; +import mir.servlet.ServletModule; +import mir.servlet.ServletModuleDispatch; +import mir.servlet.ServletModuleExc; +import mir.servlet.ServletModuleUserExc; +import mir.util.ExceptionFunctions; +import mir.util.StringRoutines; +import mircoders.entity.EntityUsers; +import mircoders.global.MirGlobal; +import mircoders.module.ModuleMessage; +import mircoders.module.ModuleUsers; +import mircoders.storage.DatabaseArticleType; +import mircoders.storage.DatabaseMessages; import mircoders.storage.DatabaseUsers; -import org.apache.struts.util.MessageResources; - -import freemarker.template.SimpleHash; -import freemarker.template.SimpleList; -import freemarker.template.SimpleScalar; -import freemarker.template.TemplateModel; - @@ -80,7 +77,7 @@ import freemarker.template.TemplateModel; * Mir.java - main servlet, that dispatches to servletmodules * * @author $Author: zapata $ - * @version $Id: Mir.java,v 1.40 2003/03/15 15:35:56 zapata Exp $ + * @version $Id: Mir.java,v 1.41 2003/03/17 20:47:03 zapata Exp $ * */ public class Mir extends AbstractServlet { @@ -433,7 +430,7 @@ public class Mir extends AbstractServlet { private void _sendStartPage(HttpServletResponse aResponse, HttpServletRequest aRequest, PrintWriter out, EntityUsers userEntity) { - String startTemplate = "templates/admin/start_admin.template"; + String startTemplate = "start_admin.template"; String sessionUrl = aResponse.encodeURL(""); try { @@ -472,13 +469,11 @@ public class Mir extends AbstractServlet { if (lang != null) { logger.info("selected language " + lang + " overrides accept-language"); setLanguage(session, lang); - setLocale(session, new Locale(lang, "")); } // otherwise store language from accept header in session - else if (session.getAttribute("Language") == null) { + else if (session.getAttribute("language") == null) { logger.info("accept-language is " + aRequest.getLocale().getLanguage()); setLanguage(session, aRequest.getLocale().getLanguage()); - setLocale(session, aRequest.getLocale()); } } } diff --git a/source/OpenMir.java b/source/OpenMir.java index 56002889..77807af0 100755 --- a/source/OpenMir.java +++ b/source/OpenMir.java @@ -29,56 +29,41 @@ * not wish to do so, delete this exception statement from your version. */ -import java.io.IOException; -import java.io.PrintWriter; -import java.util.GregorianCalendar; -import java.util.Locale; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import mir.config.MirPropertiesConfiguration; -import mir.misc.HTMLTemplateProcessor; -import mir.misc.StringUtil; -import mir.servlet.AbstractServlet; -import mir.servlet.ServletModuleDispatch; -import mir.servlet.ServletModuleUserExc; -import mir.util.ExceptionFunctions; +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import mir.servlet.AbstractServlet; +import mir.servlet.ServletModuleDispatch; +import mir.servlet.ServletModuleUserExc; +import mir.util.ExceptionFunctions; +import mircoders.global.MirGlobal; import mircoders.servlet.ServletModuleOpenIndy; -import org.apache.struts.util.MessageResources; - -import freemarker.template.SimpleHash; -import freemarker.template.SimpleScalar; - /** * OpenMir.java - main servlet for open posting and comment feature to articles * * @author RK 1999-2001, the mir-coders group - * @version $Id: OpenMir.java,v 1.29 2003/03/16 13:10:45 zapata Exp $ + * @version $Id: OpenMir.java,v 1.30 2003/03/17 20:47:03 zapata Exp $ * */ public class OpenMir extends AbstractServlet { - private static String lang; - public HttpSession session; - - - - public void process(HttpServletRequest aRequest, HttpServletResponse aResponse) - throws ServletException, IOException { - if ((configuration.getString("RootUri") == null) || - configuration.getString("RootUri").equals("")) { - configuration.setProperty("RootUri", aRequest.getContextPath()); - } + public void process(HttpServletRequest aRequest, HttpServletResponse aResponse) + throws ServletException, IOException { + if ((configuration.getString("RootUri") == null) || + configuration.getString("RootUri").equals("")) { + configuration.setProperty("RootUri", aRequest.getContextPath()); + } long startTime = System.currentTimeMillis(); long sessionConnectTime=0; - session = aRequest.getSession(); + HttpSession session = aRequest.getSession(); checkLanguage(session, aRequest); @@ -98,7 +83,6 @@ public class OpenMir extends AbstractServlet { handleUserError(aRequest, aResponse, aResponse.getWriter(), (ServletModuleUserExc) cause); else handleError(aRequest, aResponse, aResponse.getWriter(), cause); - } sessionConnectTime = System.currentTimeMillis() - startTime; @@ -107,61 +91,45 @@ public class OpenMir extends AbstractServlet { private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, PrintWriter out, ServletModuleUserExc anException) { - try { - logger.info("user error: " + anException.getMessage()); - SimpleHash modelRoot = new SimpleHash(); - MessageResources messages = MessageResources.getMessageResources("bundles.open"); - modelRoot.put("errorstring", - new SimpleScalar( - messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters()) - )); - modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); - HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.UserErrorTemplate"), - modelRoot, out, getLocale(aRequest)); - out.close(); - } - catch (Exception e) { - logger.error("Error in UserErrorTemplate"); - } + ((ServletModuleOpenIndy) ServletModuleOpenIndy.getInstance()).handleUserError(aRequest, aResponse, out, anException); } private void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) { - try { - logger.error("error: " + anException); - SimpleHash modelRoot = new SimpleHash(); - - modelRoot.put("errorstring", new SimpleScalar(anException.getMessage())); - modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime( - new GregorianCalendar()))); - HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.ErrorTemplate"), - modelRoot,out, getLocale(aRequest)); - out.close(); - } - catch (Exception e) { - logger.error("Error in ErrorTemplate"); - } - + ((ServletModuleOpenIndy) ServletModuleOpenIndy.getInstance()).handleError(aRequest, aResponse, out, anException); } public String getServletInfo(){ return "OpenMir "+configuration.getString("Mir.Version"); } - private void checkLanguage(HttpSession session, HttpServletRequest aRequest) { - // a lang parameter always sets the language - String lang = aRequest.getParameter("language"); - if (lang != null) { - logger.info("selected language " + lang + " overrides accept-language"); - setLanguage(session, lang); - setLocale(session, new Locale(lang, "")); - } - // otherwise store language from accept header in session - else if (session.getAttribute("Language") == null) { - logger.info("accept-language is " + aRequest.getLocale().getLanguage()); - setLanguage(session, aRequest.getLocale().getLanguage()); - setLocale(session, aRequest.getLocale()); - } + /** + * Selects the language for the response. + * + * @param session + * @param aRequest + */ + private void checkLanguage(HttpSession aSession, HttpServletRequest aRequest) { + String requestLanguage = aRequest.getParameter("language"); + String sessionLanguage = (String) aSession.getAttribute("language"); + String acceptLanguage = aRequest.getLocale().getLanguage(); + String defaultLanguage = MirGlobal.config().getString("Mir.Login.DefaultLanguage", "en"); + + logger.debug(" requestlanguage = " + requestLanguage + ", sessionLanugage = " + sessionLanguage + + ", acceptLanguage = " + acceptLanguage + ", defaultLanguage = " + defaultLanguage); + + String language = requestLanguage; + + if (language==null) + language = sessionLanguage; + + if (language==null) + language = acceptLanguage; + + if (language==null) + language = defaultLanguage; + + setLanguage(aSession, language); } } diff --git a/source/default.properties b/source/default.properties index 03a3af9e..39aa89f3 100755 --- a/source/default.properties +++ b/source/default.properties @@ -143,7 +143,8 @@ Producer.StorageRoot=/pub/Dokumente/Indymedia/de-tech/Mir/produced # # where do we find the files? absolute path ServletModule.FileEdit.FileDirectory=/pub/Dokumente/Indymedia/de-tech/Mir/produced -ServletModule.FileEdit.ExtFilter=inc +ServletModule.FileEdit.ExtFilter=.*\.inc$ +ServletModule.FileEdit.Recursive=0 # # @@ -256,12 +257,6 @@ Adaptor.PostgreSQL.URL=jdbc:postgresql://localhost:5432/Mir Adaptor.PostgreSQL.Driver=org.postgresql.Driver # -# should be explained .) -# - -HTMLTemplateProcessor.Dir= - -# # Servlet / Module configurations # @@ -275,109 +270,113 @@ Mir.DefaultEncoding=UTF8 # # config used for OpenIndy -ServletModule.OpenIndy.CommentTemplate=etc/open/comment.template -ServletModule.OpenIndy.CommentDoneTemplate=etc/open/comment_done.template -ServletModule.OpenIndy.CommentDupeTemplate=etc/open/comment_dupe.template -ServletModule.OpenIndy.PostingTemplate=etc/open/posting.template -ServletModule.OpenIndy.PostingDoneTemplate=etc/open/posting_done.template -ServletModule.OpenIndy.PostingDupeTemplate=etc/open/posting_dupe.template -ServletModule.OpenIndy.PostingDisabledTemplate=etc/open/posting_disabled.template -ServletModule.OpenIndy.SearchResultsTemplate=etc/open/search_results.template -ServletModule.OpenIndy.PrepareMailTemplate=etc/open/prepare_mail.template -ServletModule.OpenIndy.SentMailTemplate=etc/open/sent_mail.template + +OpenMir.TemplateDir=etc/open/ +ServletModule.OpenIndy.CommentTemplate=comment.template +ServletModule.OpenIndy.CommentDoneTemplate=comment_done.template +ServletModule.OpenIndy.CommentDupeTemplate=comment_dupe.template +ServletModule.OpenIndy.PostingTemplate=posting.template +ServletModule.OpenIndy.PostingDoneTemplate=posting_done.template +ServletModule.OpenIndy.PostingDupeTemplate=posting_dupe.template +ServletModule.OpenIndy.PostingDisabledTemplate=posting_disabled.template +ServletModule.OpenIndy.SearchResultsTemplate=search_results.template +ServletModule.OpenIndy.PrepareMailTemplate=prepare_mail.template +ServletModule.OpenIndy.SentMailTemplate=sent_mail.template ServletModule.OpenIndy.EmailIsFrom=mailer@somewhere.org ServletModule.OpenIndy.SMTPServer=localhost -ServletModule.OpenIndy.ErrorTemplate=etc/open/error.template -ServletModule.OpenIndy.UserErrorTemplate=etc/open/usererror.template +ServletModule.OpenIndy.ErrorTemplate=error.template +ServletModule.OpenIndy.UserErrorTemplate=usererror.template + +Mir.TemplateDir=templates/admin/ -Mir.LoginTemplate=templates/admin/login.template +Mir.LoginTemplate=login.template -Mir.ErrorTemplate=templates/error.template -Mir.UserErrorTemplate=templates/usererror.template +Mir.ErrorTemplate=error.template +Mir.UserErrorTemplate=usererror.template -ServletModule.Themen.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Themen.ObjektTemplate=templates/admin/topic.template -ServletModule.Themen.ListTemplate=templates/admin/topiclist.template +ServletModule.Themen.ConfirmTemplate=confirm.template +ServletModule.Themen.ObjektTemplate=topic.template +ServletModule.Themen.ListTemplate=topiclist.template -ServletModule.LinksImcs.ConfirmTemplate=templates/admin/confirm.template -ServletModule.LinksImcs.ObjektTemplate=templates/admin/linksimcs.template -ServletModule.LinksImcs.ListTemplate=templates/admin/linksimcslist.template +ServletModule.LinksImcs.ConfirmTemplate=confirm.template +ServletModule.LinksImcs.ObjektTemplate=linksimcs.template +ServletModule.LinksImcs.ListTemplate=linksimcslist.template -ServletModule.Users.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Users.ObjektTemplate=templates/admin/user.template -ServletModule.Users.ListTemplate=templates/admin/userlist.template +ServletModule.Users.ConfirmTemplate=confirm.template +ServletModule.Users.ObjektTemplate=user.template +ServletModule.Users.ListTemplate=userlist.template -ServletModule.Images.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Images.ObjektTemplate=templates/admin/image.template -ServletModule.Images.ListTemplate=templates/admin/imagelist.template +ServletModule.Images.ConfirmTemplate=confirm.template +ServletModule.Images.ObjektTemplate=image.template +ServletModule.Images.ListTemplate=imagelist.template -ServletModule.Audio.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Audio.ObjektTemplate=templates/admin/audio.template -ServletModule.Audio.ListTemplate=templates/admin/audiolist.template +ServletModule.Audio.ConfirmTemplate=confirm.template +ServletModule.Audio.ObjektTemplate=audio.template +ServletModule.Audio.ListTemplate=audiolist.template -ServletModule.Video.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Video.ObjektTemplate=templates/admin/video.template -ServletModule.Video.ListTemplate=templates/admin/videolist.template +ServletModule.Video.ConfirmTemplate=confirm.template +ServletModule.Video.ObjektTemplate=video.template +ServletModule.Video.ListTemplate=videolist.template -ServletModule.OtherMedia.ConfirmTemplate=templates/admin/confirm.template -ServletModule.OtherMedia.ObjektTemplate=templates/admin/media.template -ServletModule.OtherMedia.ListTemplate=templates/admin/medialist.template +ServletModule.OtherMedia.ConfirmTemplate=confirm.template +ServletModule.OtherMedia.ObjektTemplate=media.template +ServletModule.OtherMedia.ListTemplate=medialist.template -ServletModule.Content.ConfirmTemplate=templates/admin/confirm.template +ServletModule.Content.ConfirmTemplate=confirm.template ServletModule.Content.ObjektTemplate=content.template ServletModule.Content.ListTemplate=contentlist.template -ServletModule.Mediafolder.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Mediafolder.ObjektTemplate=templates/admin/mediafolder.template -ServletModule.Mediafolder.ListTemplate=templates/admin/mediafolderlist.template +ServletModule.Mediafolder.ConfirmTemplate=confirm.template +ServletModule.Mediafolder.ObjektTemplate=mediafolder.template +ServletModule.Mediafolder.ListTemplate=mediafolderlist.template # # config for ServletModuleComment - browsing/editing/deleting comments -ServletModule.Comment.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Comment.ObjektTemplate=templates/admin/comment.template -ServletModule.Comment.ListTemplate=templates/admin/commentlist.template +ServletModule.Comment.ConfirmTemplate=confirm.template +ServletModule.Comment.ObjektTemplate=comment.template +ServletModule.Comment.ListTemplate=commentlist.template # # config for ServletModuleHidden - lists all hidden articles of one month -ServletModule.Hidden.ListTemplate=templates/admin/hiddenlist.template +ServletModule.Hidden.ListTemplate=hiddenlist.template # # config for Breaking - browsing/editing/deleting breaking news -ServletModule.Breaking.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Breaking.ObjektTemplate=templates/admin/breaking.template -ServletModule.Breaking.ListTemplate=templates/admin/breakinglist.template +ServletModule.Breaking.ConfirmTemplate=confirm.template +ServletModule.Breaking.ObjektTemplate=breaking.template +ServletModule.Breaking.ListTemplate=breakinglist.template # # config for Breaking - editing text files -ServletModule.FileEdit.ConfirmTemplate=templates/admin/confirm.template -ServletModule.FileEdit.ObjektTemplate=templates/admin/fileedit.template -ServletModule.FileEdit.ListTemplate=templates/admin/fileeditlist.template +ServletModule.FileEdit.ConfirmTemplate=confirm.template +ServletModule.FileEdit.ObjektTemplate=fileedit.template +ServletModule.FileEdit.ListTemplate=fileeditlist.template # # config for messages - browsing/editing/deleting internal messages -ServletModule.Messages.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Messages.ObjektTemplate=templates/admin/message.template -ServletModule.Messages.ListTemplate=templates/admin/messagelist.template +ServletModule.Messages.ConfirmTemplate=confirm.template +ServletModule.Messages.ObjektTemplate=message.template +ServletModule.Messages.ListTemplate=messagelist.template # # config for languages - browsing/editing/deleting languages -ServletModule.Language.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Language.ObjektTemplate=templates/admin/language.template -ServletModule.Language.ListTemplate=templates/admin/languagelist.template +ServletModule.Language.ConfirmTemplate=confirm.template +ServletModule.Language.ObjektTemplate=language.template +ServletModule.Language.ListTemplate=languagelist.template # # config for article type -ServletModule.ArticleType.ConfirmTemplate=templates/admin/confirm.template -ServletModule.ArticleType.EditTemplate=templates/admin/articletype.template -ServletModule.ArticleType.ListTemplate=templates/admin/articletypelist.template +ServletModule.ArticleType.ConfirmTemplate=confirm.template +ServletModule.ArticleType.EditTemplate=articletype.template +ServletModule.ArticleType.ListTemplate=articletypelist.template # # config for comment status -ServletModule.CommentStatus.ConfirmTemplate=templates/admin/confirm.template -ServletModule.CommentStatus.EditTemplate=templates/admin/commentstatus.template -ServletModule.CommentStatus.ListTemplate=templates/admin/commentstatuslist.template +ServletModule.CommentStatus.ConfirmTemplate=confirm.template +ServletModule.CommentStatus.EditTemplate=commentstatus.template +ServletModule.CommentStatus.ListTemplate=commentstatuslist.template # # producer-related configs below diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java index 04d9d406..f23a66d8 100755 --- a/source/mir/misc/HTMLTemplateProcessor.java +++ b/source/mir/misc/HTMLTemplateProcessor.java @@ -86,7 +86,7 @@ public final class HTMLTemplateProcessor { logger = new LoggerWrapper("TemplateEngine"); templateDir = - configuration.getStringWithHome("HTMLTemplateProcessor.Dir"); + configuration.getStringWithHome("Mir.TemplateDir"); templateCache = new FileTemplateCache(templateDir); templateCache.setLoadingPolicy(FileTemplateCache.LOAD_ON_DEMAND); // gone in freemarker 1.7.1: templateCache.startAutoUpdate(); @@ -112,7 +112,7 @@ public final class HTMLTemplateProcessor { // with freemarker templates /** - * Wandelt anEntity in freemarker-Struktur um, mischt die Daten mit + * Wandelt anEntity in freemarker-Struktur um, mischt die Daten mit * Template templateFilename und gibt das Ergebnis an den PrintWriter * out * diff --git a/source/mir/misc/PDFUtil.java b/source/mir/misc/PDFUtil.java index 7279f728..76640c50 100755 --- a/source/mir/misc/PDFUtil.java +++ b/source/mir/misc/PDFUtil.java @@ -66,15 +66,8 @@ public class PDFUtil { File foFile=new File(foFilePath); String html2foStyleSheetPath; - if (stylesheetPath == "FROMCONFIG"){ - html2foStyleSheetPath=MirGlobal.config().getString("Home") - + MirGlobal.config().getString("HTMLTemplateProcessor.Dir") - + File.separator - + MirGlobal.config().getString("Producer.PrintableContent.html2foStyleSheetName"); - } - else { - html2foStyleSheetPath=stylesheetPath; - } + html2foStyleSheetPath=stylesheetPath; + File html2foStyleSheet=new File(html2foStyleSheetPath); InputHandler inputHandler = new XSLTInputHandler(foFile, html2foStyleSheet); diff --git a/source/mir/producer/DirCopyingProducerNode.java b/source/mir/producer/DirCopyingProducerNode.java index 6ac3de64..0960a516 100755 --- a/source/mir/producer/DirCopyingProducerNode.java +++ b/source/mir/producer/DirCopyingProducerNode.java @@ -35,7 +35,7 @@ import java.io.File; import java.util.Map; import mir.log.LoggerWrapper; -import mir.util.FileCopier; +import mir.util.FileFunctions; import mir.util.ParameterExpander; public class DirCopyingProducerNode implements ProducerNode { @@ -60,7 +60,7 @@ public class DirCopyingProducerNode implements ProducerNode { try { source = ParameterExpander.expandExpression( aValueMap, sourceExpression ); destination = ParameterExpander.expandExpression( aValueMap, destinationExpression ); - FileCopier.copy( + FileFunctions.copy( new File(sourceBasePath, source), new File(destinationBasePath, destination)); aLogger.info(source + " copied into " + destination); diff --git a/source/mir/servlet/AbstractServlet.java b/source/mir/servlet/AbstractServlet.java index 91bfa876..7a1de3d4 100755 --- a/source/mir/servlet/AbstractServlet.java +++ b/source/mir/servlet/AbstractServlet.java @@ -1,217 +1,214 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * 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. - */ - -package mir.servlet; - -import java.io.IOException; -import java.util.Locale; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import mir.config.MirPropertiesConfiguration; -import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; -import mir.log.LoggerWrapper; -import mir.storage.DatabaseAdaptor; - -import com.codestudio.util.JDBCPool; -import com.codestudio.util.JDBCPoolMetaData; -import com.codestudio.util.SQLManager; - -/** - * Title: Mir - * Description: Abstract servlet-class - * Copyright: Copyright (c) 2001, 2002 - * Company: Mir-coders group - * @author idfx, the Mir-coders group - * @version $Id: AbstractServlet.java,v 1.24 2003/03/15 02:07:36 idfx Exp $ - */ - -public abstract class AbstractServlet extends HttpServlet { - protected static String lang; - protected LoggerWrapper logger; - protected MirPropertiesConfiguration configuration; - - /** - * Constructor for AbstractServlet. - */ - public AbstractServlet() { - super(); - logger = new LoggerWrapper("Servlet"); - } - - protected void setNoCaching(HttpServletResponse aResponse) { - //nothing in Mir can or should be cached as it's all dynamic... - // - //this needs to be done here and not per page (via meta tags) as some - //browsers have problems w/ it per-page -mh - aResponse.setHeader("Pragma", "no-cache"); - aResponse.setDateHeader("Expires", 0); - aResponse.setHeader("Cache-Control", "no-cache"); - } - - /** - * Bind the language to the session - */ - protected void setLanguage(HttpSession session, String language) { - session.setAttribute("Language", language); - } - - protected void setLocale(HttpSession session, Locale loc) { - session.setAttribute("Locale", loc); - } - - /** - * Get the session-bound language - */ - protected String getLanguage(HttpServletRequest aRequest, HttpSession session) { - String lang = (String) session.getAttribute("Language"); - - if (lang == null || lang.length()==0) { - lang = getAcceptLanguage(aRequest); - } - - return lang; - } - - /** - * get the locale either from the session or the accept-language header ot the request - * this supersedes getLanguage for the new i18n - */ - public Locale getLocale(HttpServletRequest aRequest) { - Locale loc = null; - HttpSession session = aRequest.getSession(false); - if (session != null) { - // session can be null in case of logout - loc = (Locale) session.getAttribute("Locale"); - } - // if there is nothing in the session get it fron the accept-language - if (loc == null) { - loc = aRequest.getLocale(); - } - return loc; - } - - /** - * Checks the Accept-Language of the client browser. - * If this language is available it returns its country-code, - * else it returns the standard-language - */ - protected String getAcceptLanguage(HttpServletRequest aRequest) { - Locale loc = aRequest.getLocale(); - lang = loc.getLanguage(); - return lang; - } - - /** - * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) - */ - public void init(ServletConfig config) throws ServletException { - super.init(config); - - MirPropertiesConfiguration.setContext(config.getServletContext()); - try { - configuration = MirPropertiesConfiguration.instance(); - } - catch (PropertiesConfigExc e) { - throw new ServletException(e); - } - - String dbUser = configuration.getString("Database.Username"); - String dbPassword = configuration.getString("Database.Password"); - String dbHost = configuration.getString("Database.Host"); - String dbAdapName = configuration.getString("Database.Adaptor"); - String dbName = configuration.getString("Database.Name"); - - DatabaseAdaptor adaptor; - try { - adaptor = (DatabaseAdaptor) Class.forName(dbAdapName).newInstance(); - } - catch (Exception e) { - throw new ServletException("Could not load DB adapator: " + - e.toString()); - } - - String dbDriver; - String dbUrl; - try { - dbDriver = adaptor.getDriver(); - dbUrl = adaptor.getURL(dbUser, dbPassword, dbHost); - } - catch (Exception e) { - throw new ServletException(e); - } - - JDBCPoolMetaData meta = new JDBCPoolMetaData(); - meta.setDbname(dbName); - meta.setDriver(dbDriver); - meta.setURL(dbUrl); - meta.setUserName(dbUser); - meta.setPassword(dbPassword); - meta.setJNDIName("mir"); - meta.setMaximumSize(10); - meta.setMinimumSize(1); - meta.setPoolPreparedStatements(false); - meta.setCacheEnabled(false); - meta.setCacheSize(15); - meta.setDebugging(false); -// meta.setLogFile(dblogfile+".pool"); - - SQLManager manager = SQLManager.getInstance(); - JDBCPool pool = null; - if (manager != null) { - pool = manager.createPool(meta); - } - } - - - protected final void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - protected final void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - if ((configuration.getString("RootUri") == null) || - configuration.getString("RootUri").equals("")) { - configuration.setProperty("RootUri", request.getContextPath()); - } - process(request, response); - } - - abstract public void process(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException; - -} +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * 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. + */ + +package mir.servlet; + +import java.io.IOException; +import java.util.Locale; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import com.codestudio.util.JDBCPool; +import com.codestudio.util.JDBCPoolMetaData; +import com.codestudio.util.SQLManager; +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration$PropertiesConfigExc; +import mir.log.LoggerWrapper; +import mir.storage.DatabaseAdaptor; + +/** + * Title: Mir + * Description: Abstract servlet-class + * Copyright: Copyright (c) 2001, 2002 + * Company: Mir-coders group + * @author idfx, the Mir-coders group + * @version $Id: AbstractServlet.java,v 1.25 2003/03/17 20:47:03 zapata Exp $ + */ + +public abstract class AbstractServlet extends HttpServlet { + protected static String lang; + protected LoggerWrapper logger; + protected MirPropertiesConfiguration configuration; + + /** + * Constructor for AbstractServlet. + */ + public AbstractServlet() { + super(); + logger = new LoggerWrapper("Servlet"); + } + + protected void setNoCaching(HttpServletResponse aResponse) { + //nothing in Mir can or should be cached as it's all dynamic... + // + //this needs to be done here and not per page (via meta tags) as some + //browsers have problems w/ it per-page -mh + aResponse.setHeader("Pragma", "no-cache"); + aResponse.setDateHeader("Expires", 0); + aResponse.setHeader("Cache-Control", "no-cache"); + } + + /** + * Bind the language to the session + */ + protected void setLanguage(HttpSession session, String language) { + logger.debug("setting language to " + language); + + session.setAttribute("language", language); + session.setAttribute("locale", new Locale(language, "")); + } + + /** + * Get the session-bound language + */ + protected String getLanguage(HttpServletRequest aRequest, HttpSession session) { + String lang = (String) session.getAttribute("language"); + + if (lang == null || lang.length()==0) { + lang = getAcceptLanguage(aRequest); + } + + return lang; + } + + /** + * get the locale either from the session or the accept-language header ot the request + * this supersedes getLanguage for the new i18n + */ + public Locale getLocale(HttpServletRequest aRequest) { + Locale loc = null; + HttpSession session = aRequest.getSession(false); + if (session != null) { + // session can be null in case of logout + loc = (Locale) session.getAttribute("locale"); + } + // if there is nothing in the session get it fron the accept-language + if (loc == null) { + loc = aRequest.getLocale(); + } + + logger.debug("getting locale: " + loc.getLanguage()); + + return loc; + } + + /** + * Checks the Accept-Language of the client browser. + * If this language is available it returns its country-code, + * else it returns the standard-language + */ + protected String getAcceptLanguage(HttpServletRequest aRequest) { + Locale loc = aRequest.getLocale(); + lang = loc.getLanguage(); + return lang; + } + + /** + * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) + */ + public void init(ServletConfig config) throws ServletException { + super.init(config); + + MirPropertiesConfiguration.setContext(config.getServletContext()); + try { + configuration = MirPropertiesConfiguration.instance(); + } + catch (PropertiesConfigExc e) { + throw new ServletException(e); + } + + String dbUser = configuration.getString("Database.Username"); + String dbPassword = configuration.getString("Database.Password"); + String dbHost = configuration.getString("Database.Host"); + String dbAdapName = configuration.getString("Database.Adaptor"); + String dbName = configuration.getString("Database.Name"); + + DatabaseAdaptor adaptor; + try { + adaptor = (DatabaseAdaptor) Class.forName(dbAdapName).newInstance(); + } + catch (Exception e) { + throw new ServletException("Could not load DB adapator: " + + e.toString()); + } + + String dbDriver; + String dbUrl; + try { + dbDriver = adaptor.getDriver(); + dbUrl = adaptor.getURL(dbUser, dbPassword, dbHost); + } + catch (Exception e) { + throw new ServletException(e); + } + + JDBCPoolMetaData meta = new JDBCPoolMetaData(); + meta.setDbname(dbName); + meta.setDriver(dbDriver); + meta.setURL(dbUrl); + meta.setUserName(dbUser); + meta.setPassword(dbPassword); + meta.setJNDIName("mir"); + meta.setMaximumSize(10); + meta.setMinimumSize(1); + meta.setPoolPreparedStatements(false); + meta.setCacheEnabled(false); + meta.setCacheSize(15); + meta.setDebugging(false); +// meta.setLogFile(dblogfile+".pool"); + + SQLManager manager = SQLManager.getInstance(); + JDBCPool pool = null; + if (manager != null) { + pool = manager.createPool(meta); + } + } + + + protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request, response); + } + + protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if ( (configuration.getString("RootUri") == null) || + configuration.getString("RootUri").equals("")) { + configuration.setProperty("RootUri", request.getContextPath()); + } + process(request, response); + } + + abstract public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; + +} diff --git a/source/mir/servlet/ServletModule.java b/source/mir/servlet/ServletModule.java index a9dfd625..4895a2d0 100755 --- a/source/mir/servlet/ServletModule.java +++ b/source/mir/servlet/ServletModule.java @@ -31,27 +31,26 @@ package mir.servlet; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import mir.config.MirPropertiesConfiguration; -import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; -import mir.entity.EntityList; -import mir.log.LoggerWrapper; -import mir.misc.HTMLTemplateProcessor; -import mir.misc.LineFilterWriter; -import mir.module.AbstractModule; -import mir.storage.StorageObject; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import freemarker.template.SimpleHash; +import freemarker.template.TemplateModelRoot; +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration$PropertiesConfigExc; +import mir.entity.EntityList; +import mir.log.LoggerWrapper; +import mir.misc.HTMLTemplateProcessor; +import mir.misc.LineFilterWriter; +import mir.module.AbstractModule; +import mir.storage.StorageObject; import mir.util.HTTPRequestParser; -import freemarker.template.SimpleHash; -import freemarker.template.TemplateModelRoot; @@ -110,7 +109,7 @@ public abstract class ServletModule { */ public String getLanguage(HttpServletRequest req) { HttpSession session = req.getSession(false); - String language = (String) session.getAttribute("Language"); + String language = (String) session.getAttribute("language"); if (language == null) { language = configuration.getString("StandardLanguage"); } @@ -126,7 +125,7 @@ public abstract class ServletModule { HttpSession session = req.getSession(false); if (session != null) { // session can be null in case of logout - loc = (Locale) session.getAttribute("Locale"); + loc = (Locale) session.getAttribute("locale"); } // if there is nothing in the session get it fron the accept-language if (loc == null) { diff --git a/source/mir/util/FileCopier.java b/source/mir/util/FileFunctions.java similarity index 69% rename from source/mir/util/FileCopier.java rename to source/mir/util/FileFunctions.java index 6a040da5..bdca26ac 100755 --- a/source/mir/util/FileCopier.java +++ b/source/mir/util/FileFunctions.java @@ -1,79 +1,109 @@ -package mir.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -public class FileCopier { - protected static final int FILE_COPY_BUFFER_SIZE = 65536; - - protected FileCopier() { - } - - public static void copyFile(File aSourceFile, File aDestinationFile) throws IOException { - FileInputStream inputStream; - FileOutputStream outputStream; - int nrBytesRead; - byte[] buffer = new byte[FILE_COPY_BUFFER_SIZE]; - - inputStream = new FileInputStream(aSourceFile); - try { - File directory = new File(aDestinationFile.getParent()); - if (directory!=null && !directory.exists()){ - directory.mkdirs(); - } - outputStream = new FileOutputStream(aDestinationFile); - try { - do { - nrBytesRead = inputStream.read(buffer); - if (nrBytesRead>0) - outputStream.write(buffer, 0, nrBytesRead); - } - while (nrBytesRead>=0); - } - finally { - outputStream.close(); - } - } - finally { - inputStream.close(); - } - } - - public static void copyDirectory(File aSourceDirectory, File aDestinationDirectory) throws IOException { - int i; - File sourceFile; - File destinationFile; - File[] files = aSourceDirectory.listFiles(); - - if (!aDestinationDirectory.exists()) - aDestinationDirectory.mkdirs(); - - for (i=0; i0) + outputStream.write(buffer, 0, nrBytesRead); + } + while (nrBytesRead>=0); + } + finally { + outputStream.close(); + } + } + finally { + inputStream.close(); + } + } + + public static void copyDirectory(File aSourceDirectory, File aDestinationDirectory) throws IOException { + int i; + File sourceFile; + File destinationFile; + File[] files = aSourceDirectory.listFiles(); + + if (!aDestinationDirectory.exists()) + aDestinationDirectory.mkdirs(); + + for (i=0; i0){ for(int k=0;k Integer.parseInt(maxMedia)) { - numOfMedia = maxMedia; - } + String maxMedia = configuration.getString("ServletModule.OpenIndy.MaxMediaUploadItems"); + String defaultMedia = configuration.getString("ServletModule.OpenIndy.DefaultMediaUploadItems"); + String numOfMedia = req.getParameter("medianum"); - int mediaNum = Integer.parseInt(numOfMedia); - SimpleList mediaFields = new SimpleList(); - for(int i =0; i Integer.parseInt(maxMedia)) { + numOfMedia = maxMedia; + } + int mediaNum = Integer.parseInt(numOfMedia); + List mediaFields = new Vector(); + for (int i = 0; i < mediaNum; i++) { + Integer mNum = new Integer(i + 1); + mediaFields.add(mNum.toString()); + } + mergeData.put("medianum", numOfMedia); + mergeData.put("mediafields", mediaFields); + mergeData.put("to_topic", null); - SimpleHash extraInfo = new SimpleHash(); - try{ - extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData() ); + Map extraInfo = new HashMap(); + extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData()); extraInfo.put("themenPopupData", topicsModule.getTopicsAsSimpleList()); extraInfo.put("topics", topicsModule.getTopicsList()); - + deliver(req, res, mergeData, extraInfo, postingFormTemplate); } - catch (Exception e) { - logger.error("languagePopUpData or getTopicslist failed "+e.toString()); - - throw new ServletModuleFailure("OpenIndy -- failed getting language or topics: "+e.toString(), e); + catch (Throwable t) { + throw new ServletModuleFailure(t); } - - deliver(req, res, mergeData, extraInfo, postingFormTemplate); } /** @@ -391,7 +380,7 @@ public class ServletModuleOpenIndy extends ServletModule return; } - SimpleHash mergeData = new SimpleHash(); + Map mergeData = new HashMap(); boolean setMedia=false; boolean setTopic = false; @@ -416,6 +405,9 @@ public class ServletModuleOpenIndy extends ServletModule String sessionPasswd = (String) session.getAttribute("passwd"); if (sessionPasswd != null){ String passwd = (String) withValues.get("passwd"); + + logger.debug("session password = " + sessionPasswd + ", form password = " + passwd); + if ( passwd == null || passwd.length()==0) { throw new ServletModuleUserExc("posting.error.missingpassword", new String[] {}); } @@ -454,31 +446,25 @@ public class ServletModuleOpenIndy extends ServletModule withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar())); withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date"))); withValues.put("is_produced", "0"); - // by default stuff is published, they can be un-published through the - // admin interface. withValues.put("is_published","1"); - // if op direct article-type == newswire - if (directOp.equals("yes")) withValues.put("to_article_type","1"); + if (directOp.equals("yes")) + withValues.put("to_article_type","1"); withValues.put("to_publisher","1"); - // owner is openposting user - // ML: this is not multi-language friendly and this can be done in a template - // if (withValues.get("creator").toString().equals("")) - // withValues.put("creator","Anonym"); - // inserting content into database String cid = contentModule.add(withValues); logger.debug("id: "+cid); //insert was not successfull if(cid==null){ + //How do we know that it was not succesful cause of a //dupe, what if it failed cause of "No space left on device"? //Or is there something I am missing? Wouldn't it be better //to have an explicit dupe check and then insert? I have no //idea what I am talking about. this comment is in case //I forget to explicitely ask. -mh - deliver(req, res, mergeData, postingFormDupeTemplate); + deliver(req, res, mergeData, null, postingFormDupeTemplate); return; } @@ -523,10 +509,10 @@ public class ServletModuleOpenIndy extends ServletModule throw new ServletModuleFailure(e); } - deliver(req, res, mergeData, postingFormDoneTemplate); + deliver(req, res, mergeData, null, postingFormDoneTemplate); } - /* + /** * Method for preparing and sending a content as an email message */ @@ -544,17 +530,18 @@ public class ServletModuleOpenIndy extends ServletModule String comment = req.getParameter("mail_comment"); String mail_language = req.getParameter("mail_language"); - SimpleHash mergeData = new SimpleHash(); + Map mergeData = new HashMap(); if (to == null || from == null || from_name == null|| to.equals("") || from.equals("") || from_name.equals("") || mail_language == null || mail_language.equals("")){ for (Enumeration theParams = req.getParameterNames(); theParams.hasMoreElements() ;) { String pName=(String)theParams.nextElement(); if (pName.startsWith("mail_")){ - mergeData.put(pName,new SimpleScalar(req.getParameter(pName))); + mergeData.put( pName,req.getParameter(pName) ); } } - deliver(req,res,mergeData,prepareMailTemplate); + + deliver(req, res, mergeData, null, prepareMailTemplate); } else { //run checks on to and from and mail_language to make sure no monkey business occurring @@ -640,7 +627,7 @@ public class ServletModuleOpenIndy extends ServletModule client.disconnect(); //mission accomplished - deliver(req, res, mergeData, sentMailTemplate); + deliver(req, res, mergeData, null, sentMailTemplate); } catch(IOException e) { if(client.isConnected()) { @@ -655,10 +642,16 @@ public class ServletModuleOpenIndy extends ServletModule } } - - /* + /** * Method for querying a lucene index + * + * @param req + * @param res + * @throws ServletModuleExc + * @throws ServletModuleUserExc + * @throws ServletModuleFailure */ + public void search(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure { try { @@ -668,7 +661,7 @@ public class ServletModuleOpenIndy extends ServletModule String queryString=""; - SimpleHash mergeData = new SimpleHash(); + Map mergeData = new HashMap(); KeywordSearchTerm dateTerm = new KeywordSearchTerm("date_formatted","search_date","webdb_create_formatted","webdb_create_formatted","webdb_create_formatted"); UnIndexedSearchTerm whereTerm = new UnIndexedSearchTerm("","","","where","where"); @@ -686,7 +679,7 @@ public class ServletModuleOpenIndy extends ServletModule for (Enumeration theParams = req.getParameterNames(); theParams.hasMoreElements() ;) { String pName=(String)theParams.nextElement(); if (pName.startsWith("search_")){ - mergeData.put(pName,new SimpleScalar(req.getParameter(pName))); + mergeData.put(pName, req.getParameter(pName) ); } } @@ -874,7 +867,7 @@ public class ServletModuleOpenIndy extends ServletModule if (theDocs != null){ mergeData.put("numberOfHits", ((Integer)session.getAttribute("numberOfHits")).toString()); - SimpleList theHits = new SimpleList(); + List theHits = new Vector(); int pIR=((Integer)session.getAttribute("positionInResults")).intValue(); int terminus; int numHits=((Integer)session.getAttribute("numberOfHits")).intValue(); @@ -893,7 +886,7 @@ public class ServletModuleOpenIndy extends ServletModule terminus=pIR+increment; } for(int i = pIR; i < terminus; i++) { - SimpleHash h = new SimpleHash(); + Map h = new HashMap(); Document theHit = (Document)theDocs.get(i); whereTerm.returnMeta(h,theHit); creatorTerm.returnMeta(h,theHit); @@ -915,7 +908,8 @@ public class ServletModuleOpenIndy extends ServletModule } mergeData.put("queryString",queryString); - deliver(req,res,mergeData,searchResultsTemplate); + + deliver(req, res, mergeData, null, searchResultsTemplate); } catch (NullPointerException n){ throw new ServletModuleFailure("Null Pointer: "+n.toString(), n); @@ -984,11 +978,13 @@ public class ServletModuleOpenIndy extends ServletModule throw new ServletModuleExc("Missing id."); } } - catch (Exception ex) { - logger.error(ex.toString()); - throw new ServletModuleFailure(ex); + catch (Throwable t) { + logger.error(t.toString()); + + throw new ServletModuleFailure(t); } - } else { + } + else { throw new ServletModuleExc("Can't generate a PDF because the config tells me not to."); } } @@ -1000,27 +996,84 @@ public class ServletModuleOpenIndy extends ServletModule l = (l*l*l*l)/random; if(l<0) l = l * -1; String returnString = ""+l; + return returnString.substring(5); } /* this is an overwritten method of ServletModule in order to use different bundles for open and admin */ - public void deliver(HttpServletRequest req, HttpServletResponse res, +/* public void deliver(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm, TemplateModelRoot popups, String templateFilename) throws ServletModuleFailure { - if (rtm == null) rtm = new SimpleHash(); + } +*/ + public void deliver(HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator) + throws ServletModuleFailure { + try { + deliver(aResponse.getWriter(), aRequest, aResponse, aData, anExtra, aGenerator); + } + catch (Throwable t) { + throw new ServletModuleFailure(t); + } + } + + public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator) + throws ServletModuleFailure { + try { + Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest), "bundles.open"); + responseData.put("data", aData); + responseData.put("extra", anExtra); + + + Generator generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator); + generator.generate(anOutputWriter, responseData, logger.asPrintWriter(logger.INFO_MESSAGE)); + + anOutputWriter.close(); + } + catch (Throwable e) { + logger.error("Error while generating " + aGenerator + ": " + e.getMessage()); + + throw new ServletModuleFailure(e); + } + } + + public void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) { + try { + logger.error("error: " + anException); + Map data = new HashMap(); + + data.put("errorstring", anException.getMessage()); + data.put("date", StringUtil.date2readableDateTime(new GregorianCalendar())); + + deliver(out, aRequest, aResponse, data, null, configuration.getString("ServletModule.OpenIndy.ErrorTemplate")); + } + catch (Throwable e) { + throw new ServletModuleFailure(e); + } + } + + public void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, + PrintWriter out, ServletModuleUserExc anException) { try { - PrintWriter out = res.getWriter(); - HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out, - getLocale(req), "bundles.open"); - out.close(); + logger.warn("user error: " + anException.getMessage()); + Map data = new HashMap(); + + MessageResources messages = MessageResources.getMessageResources("bundles.open"); + data.put("errorstring", + messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters()) + ); + data.put("date", StringUtil.date2readableDateTime(new GregorianCalendar())); + + deliver(out, aRequest, aResponse, data, null, configuration.getString("ServletModule.OpenIndy.UserErrorTemplate")); } catch (Throwable e) { throw new ServletModuleFailure(e); } } + + } diff --git a/templates/admin/articletype.template b/templates/admin/articletype.template index abfe3a45..62af13e2 100755 --- a/templates/admin/articletype.template +++ b/templates/admin/articletype.template @@ -5,7 +5,7 @@ - +
@@ -46,6 +46,6 @@
- + diff --git a/templates/admin/articletypelist.template b/templates/admin/articletypelist.template index 55b7d15a..a07d8b14 100755 --- a/templates/admin/articletypelist.template +++ b/templates/admin/articletypelist.template @@ -5,7 +5,7 @@ - +

${lang("add")} | @@ -82,7 +82,7 @@ ${lang("back")}

- + diff --git a/templates/admin/audio.template b/templates/admin/audio.template index d8198ef9..5e431003 100755 --- a/templates/admin/audio.template +++ b/templates/admin/audio.template @@ -11,7 +11,7 @@ function openWin(url) { - +
@@ -160,6 +160,6 @@ function openWin(url) {
- + diff --git a/templates/admin/audiolist.template b/templates/admin/audiolist.template index 22322c6d..c01f4013 100755 --- a/templates/admin/audiolist.template +++ b/templates/admin/audiolist.template @@ -6,7 +6,7 @@ - + @@ -108,6 +108,6 @@
${lang("no_matches_found")}
- + diff --git a/templates/admin/breaking.template b/templates/admin/breaking.template index d0ed0204..8c5e3702 100755 --- a/templates/admin/breaking.template +++ b/templates/admin/breaking.template @@ -6,7 +6,7 @@ - +
@@ -37,6 +37,6 @@
- + diff --git a/templates/admin/breakinglist.template b/templates/admin/breakinglist.template index d9b5bfb1..34b75cc8 100755 --- a/templates/admin/breakinglist.template +++ b/templates/admin/breakinglist.template @@ -6,7 +6,7 @@ - + @@ -42,7 +42,7 @@

${lang("no_matches_found")}

- + diff --git a/templates/admin/comment.template b/templates/admin/comment.template index a9c22133..408e365c 100755 --- a/templates/admin/comment.template +++ b/templates/admin/comment.template @@ -6,7 +6,7 @@ - +
@@ -132,6 +132,6 @@
- + diff --git a/templates/admin/commentstatus.template b/templates/admin/commentstatus.template index 0a6d67dd..4b4dd64a 100755 --- a/templates/admin/commentstatus.template +++ b/templates/admin/commentstatus.template @@ -5,7 +5,7 @@ - +
@@ -46,6 +46,6 @@
- + diff --git a/templates/admin/commentstatuslist.template b/templates/admin/commentstatuslist.template index 2ca6b94f..be06706e 100755 --- a/templates/admin/commentstatuslist.template +++ b/templates/admin/commentstatuslist.template @@ -5,7 +5,7 @@ - +

${lang("add")} | @@ -82,7 +82,7 @@ ${lang("back")}

- + diff --git a/templates/admin/confirm.template b/templates/admin/confirm.template index 69363227..ccb7e138 100755 --- a/templates/admin/confirm.template +++ b/templates/admin/confirm.template @@ -6,7 +6,7 @@ - +
@@ -34,6 +34,6 @@
- + diff --git a/templates/admin/fileedit.template b/templates/admin/fileedit.template index e0775ae8..601c83dc 100755 --- a/templates/admin/fileedit.template +++ b/templates/admin/fileedit.template @@ -6,21 +6,22 @@ - +
-${lang("fileedit.filename")} : ${data.filename} +${lang("fileedit.filename")} : ${filename}
- + + - +
@@ -38,12 +39,12 @@ ${lang("preview")}
-${data.text} +${text}

- + diff --git a/templates/admin/fileeditlist.template b/templates/admin/fileeditlist.template index 3ea5a3b0..680fe46c 100755 --- a/templates/admin/fileeditlist.template +++ b/templates/admin/fileeditlist.template @@ -5,37 +5,80 @@ - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
${lang("fileeditlist.dirname")} 
.. ${lang("edit")}
${entry} ${lang("edit")}
+
+ + +

+
+ + - + - - class="list1"class="list2" - > - - - + + + + + + + + + + +
${lang("fileeditlist.filename")}  
${entry} ${lang("edit")}
${entry} ${lang("edit")}
-

+

${lang("no_matches_found")}

- + diff --git a/templates/admin/hiddenlist.template b/templates/admin/hiddenlist.template index 0e7e9ccb..26357a46 100755 --- a/templates/admin/hiddenlist.template +++ b/templates/admin/hiddenlist.template @@ -7,7 +7,7 @@ - +
@@ -100,7 +100,7 @@ ${i.content_data_parsed} - + diff --git a/templates/admin/image.template b/templates/admin/image.template index 7562b5b8..4d34c23c 100755 --- a/templates/admin/image.template +++ b/templates/admin/image.template @@ -12,7 +12,7 @@ - + @@ -168,6 +168,6 @@
- + diff --git a/templates/admin/imagelist.template b/templates/admin/imagelist.template index b3d306c1..2ba619b4 100755 --- a/templates/admin/imagelist.template +++ b/templates/admin/imagelist.template @@ -6,7 +6,7 @@ - + @@ -110,6 +110,6 @@
${lang("no_matches_found")}
- + diff --git a/templates/admin/language.template b/templates/admin/language.template index 6a0c4017..1581f888 100755 --- a/templates/admin/language.template +++ b/templates/admin/language.template @@ -6,7 +6,7 @@ - +
@@ -39,6 +39,6 @@
- + diff --git a/templates/admin/languagelist.template b/templates/admin/languagelist.template index d22c92ad..4a4f0ea7 100755 --- a/templates/admin/languagelist.template +++ b/templates/admin/languagelist.template @@ -4,7 +4,7 @@ - +

${lang("add")} | @@ -54,7 +54,7 @@ ${lang("back")}

- + diff --git a/templates/admin/linksimcs.template b/templates/admin/linksimcs.template index adbc65b3..dd74867d 100755 --- a/templates/admin/linksimcs.template +++ b/templates/admin/linksimcs.template @@ -6,7 +6,7 @@ - +
@@ -69,6 +69,6 @@ - + diff --git a/templates/admin/linksimcslist.template b/templates/admin/linksimcslist.template index 9f442527..bdde488b 100755 --- a/templates/admin/linksimcslist.template +++ b/templates/admin/linksimcslist.template @@ -6,7 +6,7 @@ - + @@ -103,6 +103,6 @@

${lang("no_matches_found")}

- + \ No newline at end of file diff --git a/templates/admin/login.template b/templates/admin/login.template index d56c24d4..86f84463 100755 --- a/templates/admin/login.template +++ b/templates/admin/login.template @@ -11,7 +11,7 @@ - +

@@ -73,7 +73,7 @@

- + diff --git a/templates/admin/media.template b/templates/admin/media.template index d6ecab9f..434bfd52 100755 --- a/templates/admin/media.template +++ b/templates/admin/media.template @@ -11,7 +11,7 @@ function openWin(url) { - +
@@ -160,6 +160,6 @@ function openWin(url) {
- + diff --git a/templates/admin/mediafolder.template b/templates/admin/mediafolder.template index b19878e1..6d4060fa 100755 --- a/templates/admin/mediafolder.template +++ b/templates/admin/mediafolder.template @@ -6,7 +6,7 @@ - +
@@ -47,6 +47,6 @@
- + diff --git a/templates/admin/mediafolderlist.template b/templates/admin/mediafolderlist.template index e13c0e44..b0361c90 100755 --- a/templates/admin/mediafolderlist.template +++ b/templates/admin/mediafolderlist.template @@ -6,7 +6,7 @@ - + @@ -44,7 +44,7 @@

${lang("no_matches_found")}

- + diff --git a/templates/admin/medialist.template b/templates/admin/medialist.template index fa2a3c2e..c23eb0a9 100755 --- a/templates/admin/medialist.template +++ b/templates/admin/medialist.template @@ -6,7 +6,7 @@ - +
@@ -108,6 +108,6 @@
${lang("no_matches_found")}
- + diff --git a/templates/admin/message.template b/templates/admin/message.template index de72ef91..d2bd155a 100755 --- a/templates/admin/message.template +++ b/templates/admin/message.template @@ -6,7 +6,7 @@ - +
@@ -53,6 +53,6 @@
- + diff --git a/templates/admin/messagelist.template b/templates/admin/messagelist.template index 719358b2..887ed750 100755 --- a/templates/admin/messagelist.template +++ b/templates/admin/messagelist.template @@ -6,7 +6,7 @@ - + @@ -47,6 +47,6 @@

${lang("no_matches_found")}

- + diff --git a/templates/admin/start_admin.template b/templates/admin/start_admin.template index e3bd3378..05401af8 100755 --- a/templates/admin/start_admin.template +++ b/templates/admin/start_admin.template @@ -7,7 +7,7 @@ - +
@@ -215,7 +215,7 @@
- + diff --git a/templates/admin/topic.template b/templates/admin/topic.template index f70c2185..760091c9 100755 --- a/templates/admin/topic.template +++ b/templates/admin/topic.template @@ -5,7 +5,7 @@ - +
@@ -65,6 +65,6 @@
- + diff --git a/templates/admin/topiclist.template b/templates/admin/topiclist.template index 3028554e..4a0a44e0 100755 --- a/templates/admin/topiclist.template +++ b/templates/admin/topiclist.template @@ -6,7 +6,7 @@ - + ${lang("add")} | ${lang("back")} @@ -62,7 +62,7 @@ ${lang("add")} | ${lang("back")} - + diff --git a/templates/admin/user.template b/templates/admin/user.template index 1ddfaf3e..74e048c9 100755 --- a/templates/admin/user.template +++ b/templates/admin/user.template @@ -6,7 +6,7 @@ - +
@@ -72,7 +72,7 @@
- + diff --git a/templates/admin/usererror.template b/templates/admin/usererror.template index fc61c25c..594e4dc5 100755 --- a/templates/admin/usererror.template +++ b/templates/admin/usererror.template @@ -3,7 +3,7 @@ ${lang("usererror.htmltitle")} - +
diff --git a/templates/admin/userlist.template b/templates/admin/userlist.template index 8ee984d6..0298fc88 100755 --- a/templates/admin/userlist.template +++ b/templates/admin/userlist.template @@ -5,7 +5,7 @@ - +

${lang("add")} | ${lang("back")} @@ -53,7 +53,7 @@ ${lang("back")}

- + diff --git a/templates/admin/video.template b/templates/admin/video.template index 45f12d56..d7ff1b27 100755 --- a/templates/admin/video.template +++ b/templates/admin/video.template @@ -11,7 +11,7 @@ function openWin(url) { - +
@@ -160,6 +160,6 @@ function openWin(url) {
- + diff --git a/templates/admin/videolist.template b/templates/admin/videolist.template index 1e066bb7..0b1a74c1 100755 --- a/templates/admin/videolist.template +++ b/templates/admin/videolist.template @@ -6,7 +6,7 @@ - + @@ -108,6 +108,6 @@
${lang("no_matches_found")}
- + -- 2.11.0