#
# 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
#
#
<tr>
<td><b>${lang("posting.nr_of_media")}</b> <br>
${lang("posting.nr_of_media.info")}</td>
- <td colspan="2"><input type="text" name="medianum" value="${medianum}"> <input type="submit" value="${lang("posting.nr_of_media.submit")}">
+ <td colspan="2"><input type="text" name="medianum" value="${data.medianum}"> <input type="submit" value="${lang("posting.nr_of_media.submit")}">
</tr>
</form>
<td colspan="2">
<select name="to_topic" size="3" multiple>
<list extra.themenPopupData as t>
- <option value="${t.key}" <list to_topic as to><if (t.key == to)>selected</if></list>>${t.value}</option>
+ <option value="${t.key}" <list data.to_topic as to><if (t.key == to)>selected</if></list>>${t.value}</option>
</list>
</select>
<font size="-1">(<i>${lang("optional")}</i>)</font>
* 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;\r
+import java.io.PrintWriter;\r
+import java.lang.reflect.Method;\r
+import java.util.GregorianCalendar;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.UnavailableException;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.struts.util.MessageResources;\r
+import freemarker.template.SimpleHash;\r
+import freemarker.template.SimpleList;\r
+import freemarker.template.SimpleScalar;\r
+import freemarker.template.TemplateModel;\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.generator.FreemarkerGenerator;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.HTMLTemplateProcessor;\r
+import mir.misc.StringUtil;\r
+import mir.servlet.AbstractServlet;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleDispatch;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.util.ExceptionFunctions;\r
+import mir.util.StringRoutines;\r
+import mircoders.entity.EntityUsers;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleMessage;\r
+import mircoders.module.ModuleUsers;\r
+import mircoders.storage.DatabaseArticleType;\r
+import mircoders.storage.DatabaseMessages;\r
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;
-
* 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 {
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 {
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());
}
}
}
* 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;\r
+import java.io.PrintWriter;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import mir.servlet.AbstractServlet;\r
+import mir.servlet.ServletModuleDispatch;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.util.ExceptionFunctions;\r
+import mircoders.global.MirGlobal;\r
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);
handleUserError(aRequest, aResponse, aResponse.getWriter(), (ServletModuleUserExc) cause);
else
handleError(aRequest, aResponse, aResponse.getWriter(), cause);
-
}
sessionConnectTime = System.currentTimeMillis() - startTime;
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);
}
}
#
# 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
#
#
Adaptor.PostgreSQL.Driver=org.postgresql.Driver
#
-# should be explained .)
-#
-
-HTMLTemplateProcessor.Dir=
-
-#
# Servlet / Module configurations
#
#
# 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
logger = new LoggerWrapper("TemplateEngine");\r
\r
templateDir =\r
- configuration.getStringWithHome("HTMLTemplateProcessor.Dir");\r
+ configuration.getStringWithHome("Mir.TemplateDir");\r
templateCache = new FileTemplateCache(templateDir);\r
templateCache.setLoadingPolicy(FileTemplateCache.LOAD_ON_DEMAND);\r
// gone in freemarker 1.7.1: templateCache.startAutoUpdate();\r
// with freemarker templates\r
\r
/**\r
- * Wandelt <code>anEntity</code> in freemarker-Struktur um, mischt die Daten mit\r
+ * Wandelt <code>anEntity</code> in freemarker-Struktur um, mischt die Daten mit\r
* Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter\r
* <code>out</code>\r
*\r
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);
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 {
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);
-/*
- * 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;
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.servlet;\r
+\r
+import java.io.IOException;\r
+import java.util.Locale;\r
+import javax.servlet.ServletConfig;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.http.HttpServlet;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import com.codestudio.util.JDBCPool;\r
+import com.codestudio.util.JDBCPoolMetaData;\r
+import com.codestudio.util.SQLManager;\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration$PropertiesConfigExc;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.DatabaseAdaptor;\r
+\r
+/**\r
+ * Title: Mir\r
+ * Description: Abstract servlet-class\r
+ * Copyright: Copyright (c) 2001, 2002\r
+ * Company: Mir-coders group\r
+ * @author idfx, the Mir-coders group\r
+ * @version $Id: AbstractServlet.java,v 1.25 2003/03/17 20:47:03 zapata Exp $\r
+ */\r
+\r
+public abstract class AbstractServlet extends HttpServlet {\r
+ protected static String lang;\r
+ protected LoggerWrapper logger;\r
+ protected MirPropertiesConfiguration configuration;\r
+\r
+ /**\r
+ * Constructor for AbstractServlet.\r
+ */\r
+ public AbstractServlet() {\r
+ super();\r
+ logger = new LoggerWrapper("Servlet");\r
+ }\r
+\r
+ protected void setNoCaching(HttpServletResponse aResponse) {\r
+ //nothing in Mir can or should be cached as it's all dynamic...\r
+ //\r
+ //this needs to be done here and not per page (via meta tags) as some\r
+ //browsers have problems w/ it per-page -mh\r
+ aResponse.setHeader("Pragma", "no-cache");\r
+ aResponse.setDateHeader("Expires", 0);\r
+ aResponse.setHeader("Cache-Control", "no-cache");\r
+ }\r
+\r
+ /**\r
+ * Bind the language to the session\r
+ */\r
+ protected void setLanguage(HttpSession session, String language) {\r
+ logger.debug("setting language to " + language);\r
+\r
+ session.setAttribute("language", language);\r
+ session.setAttribute("locale", new Locale(language, ""));\r
+ }\r
+\r
+ /**\r
+ * Get the session-bound language\r
+ */\r
+ protected String getLanguage(HttpServletRequest aRequest, HttpSession session) {\r
+ String lang = (String) session.getAttribute("language");\r
+\r
+ if (lang == null || lang.length()==0) {\r
+ lang = getAcceptLanguage(aRequest);\r
+ }\r
+\r
+ return lang;\r
+ }\r
+\r
+ /**\r
+ * get the locale either from the session or the accept-language header ot the request\r
+ * this supersedes getLanguage for the new i18n\r
+ */\r
+ public Locale getLocale(HttpServletRequest aRequest) {\r
+ Locale loc = null;\r
+ HttpSession session = aRequest.getSession(false);\r
+ if (session != null) {\r
+ // session can be null in case of logout\r
+ loc = (Locale) session.getAttribute("locale");\r
+ }\r
+ // if there is nothing in the session get it fron the accept-language\r
+ if (loc == null) {\r
+ loc = aRequest.getLocale();\r
+ }\r
+\r
+ logger.debug("getting locale: " + loc.getLanguage());\r
+\r
+ return loc;\r
+ }\r
+\r
+ /**\r
+ * Checks the Accept-Language of the client browser.\r
+ * If this language is available it returns its country-code,\r
+ * else it returns the standard-language\r
+ */\r
+ protected String getAcceptLanguage(HttpServletRequest aRequest) {\r
+ Locale loc = aRequest.getLocale();\r
+ lang = loc.getLanguage();\r
+ return lang;\r
+ }\r
+\r
+ /**\r
+ * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)\r
+ */\r
+ public void init(ServletConfig config) throws ServletException {\r
+ super.init(config);\r
+\r
+ MirPropertiesConfiguration.setContext(config.getServletContext());\r
+ try {\r
+ configuration = MirPropertiesConfiguration.instance();\r
+ }\r
+ catch (PropertiesConfigExc e) {\r
+ throw new ServletException(e);\r
+ }\r
+\r
+ String dbUser = configuration.getString("Database.Username");\r
+ String dbPassword = configuration.getString("Database.Password");\r
+ String dbHost = configuration.getString("Database.Host");\r
+ String dbAdapName = configuration.getString("Database.Adaptor");\r
+ String dbName = configuration.getString("Database.Name");\r
+\r
+ DatabaseAdaptor adaptor;\r
+ try {\r
+ adaptor = (DatabaseAdaptor) Class.forName(dbAdapName).newInstance();\r
+ }\r
+ catch (Exception e) {\r
+ throw new ServletException("Could not load DB adapator: " +\r
+ e.toString());\r
+ }\r
+\r
+ String dbDriver;\r
+ String dbUrl;\r
+ try {\r
+ dbDriver = adaptor.getDriver();\r
+ dbUrl = adaptor.getURL(dbUser, dbPassword, dbHost);\r
+ }\r
+ catch (Exception e) {\r
+ throw new ServletException(e);\r
+ }\r
+\r
+ JDBCPoolMetaData meta = new JDBCPoolMetaData();\r
+ meta.setDbname(dbName);\r
+ meta.setDriver(dbDriver);\r
+ meta.setURL(dbUrl);\r
+ meta.setUserName(dbUser);\r
+ meta.setPassword(dbPassword);\r
+ meta.setJNDIName("mir");\r
+ meta.setMaximumSize(10);\r
+ meta.setMinimumSize(1);\r
+ meta.setPoolPreparedStatements(false);\r
+ meta.setCacheEnabled(false);\r
+ meta.setCacheSize(15);\r
+ meta.setDebugging(false);\r
+// meta.setLogFile(dblogfile+".pool");\r
+\r
+ SQLManager manager = SQLManager.getInstance();\r
+ JDBCPool pool = null;\r
+ if (manager != null) {\r
+ pool = manager.createPool(meta);\r
+ }\r
+ }\r
+\r
+\r
+ protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\r
+ doPost(request, response);\r
+ }\r
+\r
+ protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\r
+ if ( (configuration.getString("RootUri") == null) ||\r
+ configuration.getString("RootUri").equals("")) {\r
+ configuration.setProperty("RootUri", request.getContextPath());\r
+ }\r
+ process(request, response);\r
+ }\r
+\r
+ abstract public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;\r
+\r
+}\r
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;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import freemarker.template.SimpleHash;\r
+import freemarker.template.TemplateModelRoot;\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration$PropertiesConfigExc;\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.HTMLTemplateProcessor;\r
+import mir.misc.LineFilterWriter;\r
+import mir.module.AbstractModule;\r
+import mir.storage.StorageObject;\r
import mir.util.HTTPRequestParser;
-import freemarker.template.SimpleHash;
-import freemarker.template.TemplateModelRoot;
*/
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");
}
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) {
+++ /dev/null
-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; i<files.length; i++) {
- sourceFile = files[i];
- destinationFile=new File(aDestinationDirectory, sourceFile.getName());
- if (sourceFile.isDirectory()) {
- if (!destinationFile.exists())
- destinationFile.mkdir();
- copyDirectory(sourceFile, destinationFile);
- }
- else {
- copyFile(sourceFile, destinationFile);
- }
- }
- }
-
- public static void copy(File aSource, File aDestination) throws IOException {
- if (aSource.isDirectory()) {
- copyDirectory(aSource, aDestination);
- }
- else if (aDestination.isDirectory()) {
- copyFile(aSource, new File(aDestination, aSource.getName()));
- }
- else {
- copyFile(aSource, aDestination);
- }
- }
-
-}
\ No newline at end of file
--- /dev/null
+package mir.util;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.FilenameFilter;\r
+\r
+import gnu.regexp.RE;\r
+\r
+public class FileFunctions {\r
+ protected static final int FILE_COPY_BUFFER_SIZE = 65536;\r
+\r
+ private FileFunctions() {\r
+ }\r
+\r
+ public static void copyFile(File aSourceFile, File aDestinationFile) throws IOException {\r
+ FileInputStream inputStream;\r
+ FileOutputStream outputStream;\r
+ int nrBytesRead;\r
+ byte[] buffer = new byte[FILE_COPY_BUFFER_SIZE];\r
+\r
+ inputStream = new FileInputStream(aSourceFile);\r
+ try {\r
+ File directory = new File(aDestinationFile.getParent());\r
+ if (directory!=null && !directory.exists()){\r
+ directory.mkdirs();\r
+ }\r
+ outputStream = new FileOutputStream(aDestinationFile);\r
+ try {\r
+ do {\r
+ nrBytesRead = inputStream.read(buffer);\r
+ if (nrBytesRead>0)\r
+ outputStream.write(buffer, 0, nrBytesRead);\r
+ }\r
+ while (nrBytesRead>=0);\r
+ }\r
+ finally {\r
+ outputStream.close();\r
+ }\r
+ }\r
+ finally {\r
+ inputStream.close();\r
+ }\r
+ }\r
+\r
+ public static void copyDirectory(File aSourceDirectory, File aDestinationDirectory) throws IOException {\r
+ int i;\r
+ File sourceFile;\r
+ File destinationFile;\r
+ File[] files = aSourceDirectory.listFiles();\r
+\r
+ if (!aDestinationDirectory.exists())\r
+ aDestinationDirectory.mkdirs();\r
+\r
+ for (i=0; i<files.length; i++) {\r
+ sourceFile = files[i];\r
+ destinationFile=new File(aDestinationDirectory, sourceFile.getName());\r
+ if (sourceFile.isDirectory()) {\r
+ if (!destinationFile.exists())\r
+ destinationFile.mkdir();\r
+ copyDirectory(sourceFile, destinationFile);\r
+ }\r
+ else {\r
+ copyFile(sourceFile, destinationFile);\r
+ }\r
+ }\r
+ }\r
+\r
+ public static void copy(File aSource, File aDestination) throws IOException {\r
+ if (aSource.isDirectory()) {\r
+ copyDirectory(aSource, aDestination);\r
+ }\r
+ else if (aDestination.isDirectory()) {\r
+ copyFile(aSource, new File(aDestination, aSource.getName()));\r
+ }\r
+ else {\r
+ copyFile(aSource, aDestination);\r
+ }\r
+ }\r
+\r
+ public static class RegExpFileFilter implements FilenameFilter {\r
+ private RE expression;\r
+\r
+ public RegExpFileFilter(String anExpression) {\r
+ try {\r
+ expression = new RE(anExpression);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+\r
+ public boolean accept(File aDir, String aName) {\r
+ return expression.isMatch(aName) && !new File(aDir, aName).isDirectory();\r
+ }\r
+ }\r
+\r
+ public static class DirectoryFilter implements FilenameFilter {\r
+ public DirectoryFilter() {\r
+ }\r
+\r
+ public boolean accept(File aDir, String aName) {\r
+ return new File(aDir, aName).isDirectory();\r
+ }\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
}
static String replaceStringCharacters(String aText, char[] aCharactersToReplace, String[] aStringsToSubstitute) {
+ if (aText==null)
+ return null;
+
int position, nextPosition;
int i;
StringBuffer result = new StringBuffer();
position=0;
-
do {
nextPosition = StringRoutines.indexOfCharacters(aText, aCharactersToReplace, position);
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
+public class AudioSearchTerm extends SearchTerm{
-public class AudioSearchTerm extends SearchTerm{
-
-
- public static String matchField = "hasAudio";
- public static String paramName = "search_hasAudio";
+ public static String matchField = "hasAudio";
+ public static String paramName = "search_hasAudio";
public static String templateVariable = "hasAudio";
public void index(Document doc, Entity entity) throws StorageObjectFailure{
return null;
}
}
-
- public void returnMeta(SimpleHash result,Document doc){
- result.put(templateVariable,new SimpleScalar(doc.get(matchField)));
+
+ public void returnMeta(Map result,Document doc){
+ result.put(templateVariable,doc.get(matchField));
}
-
+
}
package mircoders.search;
import java.util.StringTokenizer;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-
public class ContentSearchTerm extends SearchTerm{
matchField = aMatchField;
dataField = aDataField;
templateVariable = aTemplateVariable;
-
+
}
-
+
public void index(Document doc, Entity entity){
doc.add(Field.UnStored(matchField,entity.getValue(partOfEntity)));
}
public String makeTerm(HttpServletRequest req){
String wanted = req.getParameter(paramName);
if (wanted != null && !(wanted.equals(""))){
- String searchBoolean = req.getParameter("search_boolean");
- if (searchBoolean != null && searchBoolean.equals("phrase")){
- return matchField + ":" + "\"" + wanted + "\"";
- }
- else {
- if (searchBoolean != null && searchBoolean.equals("and")){
- StringTokenizer st = new StringTokenizer(wanted);
- String composite = "(";
- while (st.hasMoreTokens()) {
- composite = composite + " +" + matchField + ":" + st.nextToken();
- }
- composite = composite + ")";
- return composite;
- }
- else {
- //default to or
- StringTokenizer st = new StringTokenizer(wanted);
- String composite = "(";
- while (st.hasMoreTokens()) {
- composite = composite + " " + matchField + ":" + st.nextToken();
- }
- composite = composite + ")";
- return composite;
- }
- }
+ String searchBoolean = req.getParameter("search_boolean");
+ if (searchBoolean != null && searchBoolean.equals("phrase")){
+ return matchField + ":" + "\"" + wanted + "\"";
+ }
+ else {
+ if (searchBoolean != null && searchBoolean.equals("and")){
+ StringTokenizer st = new StringTokenizer(wanted);
+ String composite = "(";
+ while (st.hasMoreTokens()) {
+ composite = composite + " +" + matchField + ":" + st.nextToken();
+ }
+ composite = composite + ")";
+ return composite;
+ }
+ else {
+ //default to or
+ StringTokenizer st = new StringTokenizer(wanted);
+ String composite = "(";
+ while (st.hasMoreTokens()) {
+ composite = composite + " " + matchField + ":" + st.nextToken();
+ }
+ composite = composite + ")";
+ return composite;
+ }
+ }
}
else {
- return null;
+ return null;
}
}
- public void returnMeta(SimpleHash result,Document doc){
+ public void returnMeta(Map result,Document doc){
return;
}
-
+
}
package mircoders.search;
import java.util.StringTokenizer;
+import java.util.Map;
+import java.util.Vector;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleScalar;
-
public class ImagesSearchTerm extends SearchTerm{
-
-
- public static String matchField = "hasImages";
- public static String paramName = "search_hasImages";
- public static String dataField = "images";
+
+
+ public static String matchField = "hasImages";
+ public static String paramName = "search_hasImages";
+ public static String dataField = "images";
public static String templateVariable = "images";
public void index(Document doc, Entity entity) throws StorageObjectFailure{
doc.add(Field.Keyword(matchField,"y"));
String imageURLString = "";
for(int k=0;k<images.size();k++){
- if (k != 0){
- imageURLString = imageURLString + ":";
- }
- imageURLString = imageURLString + (images.elementAt(k)).getValue("icon_path");
+ if (k != 0){
+ imageURLString = imageURLString + ":";
+ }
+ imageURLString = imageURLString + (images.elementAt(k)).getValue("icon_path");
}
doc.add(Field.UnIndexed("images",imageURLString));
}
return null;
}
}
-
- public void returnMeta(SimpleHash result,Document doc){
+
+ public void returnMeta(Map result,Document doc){
String imageURLString=doc.get(dataField);
if (imageURLString != null){
- SimpleList theImages = new SimpleList();
+ List theImages = new Vector();
StringTokenizer st = new StringTokenizer(imageURLString,":");
while (st.hasMoreTokens()) {
- String imageURL=st.nextToken();
- theImages.add(new SimpleScalar(imageURL));
+ String imageURL=st.nextToken();
+ theImages.add(imageURL);
}
result.put(templateVariable,theImages);
}
}
-
+
}
package mircoders.search;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
-import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
+import mir.entity.Entity;
+
public class KeywordSearchTerm extends SearchTerm{
-
+
public String templateVariable;
public String dataField;
public String matchField;
public String paramName;
public String partOfEntity;
-
-
+
+
public KeywordSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
paramName = aParamName;
dataField = aDataField;
templateVariable = aTemplateVariable;
}
-
+
public void index(Document doc, Entity entity){
doc.add(Field.Keyword(matchField,entity.getValue(partOfEntity)));
public String makeTerm(HttpServletRequest req){
String wanted = req.getParameter(paramName);
if (wanted != null && !(wanted.equals(""))){
- return matchField + ":" + "\"" + wanted + "\"";
+ return matchField + ":" + "\"" + wanted + "\"";
}
else {
- return null;
+ return null;
}
}
- public void returnMeta(SimpleHash result,Document doc){
- result.put(templateVariable,new SimpleScalar(doc.get(dataField)));
+ public void returnMeta(Map result,Document doc){
+ result.put(templateVariable,doc.get(dataField));
}
-
+
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
-import freemarker.template.SimpleHash;
-
abstract public class SearchTerm {
-
- public static String partOfEntity;
- public static String paramName;
- public static String matchField;
- public static String dataField;
- public static String templateVariable;
+
+ public static String partOfEntity;
+ public static String paramName;
+ public static String matchField;
+ public static String dataField;
+ public static String templateVariable;
public SearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
//for more reusable SearchTerm types
- partOfEntity = anEntityPart;
- paramName = aParamName;
- matchField = aMatchField;
- dataField = aDataField;
+ partOfEntity = anEntityPart;
+ paramName = aParamName;
+ matchField = aMatchField;
+ dataField = aDataField;
templateVariable = aTemplateVariable;
}
public SearchTerm(){
- //do nothing, we'll get the values from the extending class definition instead
+ //do nothing, we'll get the values from the extending class definition instead
}
abstract public void index(Document doc, Entity entity) throws Exception;
abstract public String makeTerm(HttpServletRequest req);
- abstract public void returnMeta(SimpleHash result,Document doc);
-
+ abstract public void returnMeta(Map result,Document doc);
+
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
-
public class TextSearchTerm extends SearchTerm{
matchField = aMatchField;
dataField = aDataField;
templateVariable = aTemplateVariable;
-
+
}
-
+
public void index(Document doc, Entity entity){
doc.add(Field.Text(matchField,entity.getValue(partOfEntity)));
}
public String makeTerm(HttpServletRequest req){
String wanted = req.getParameter(paramName);
if (wanted != null && !(wanted.equals(""))){
- return matchField + ":" + "\"" + wanted + "\"";
+ return matchField + ":" + "\"" + wanted + "\"";
}
else {
- return null;
+ return null;
}
}
- public void returnMeta(SimpleHash result,Document doc){
- result.put(templateVariable,new SimpleScalar(doc.get(dataField)));
+ public void returnMeta(Map result,Document doc){
+ result.put(templateVariable, doc.get(dataField));
}
-
+
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-
public class TopicSearchTerm extends SearchTerm{
-
-
- public static String matchField = "topic";
- public static String paramName = "search_topic";
+
+
+ public static String matchField = "topic";
+ public static String paramName = "search_topic";
public void index(Document doc, Entity entity) throws StorageObjectFailure{
EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity);
if (topics != null && topics.size()>0){
for(int k=0;k<topics.size();k++){
- doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getValue("title")));
+ doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getValue("title")));
}
}
}
return null;
}
}
-
- public void returnMeta(SimpleHash result,Document doc){
+
+ public void returnMeta(Map result,Document doc){
return;
}
-
+
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
public class UnIndexedSearchTerm extends SearchTerm{
-
+
public String templateVariable;
public String dataField;
public String matchField;
dataField = aDataField;
templateVariable = aTemplateVariable;
}
-
+
public void index(Document doc, Entity entity){
doc.add(Field.Text(dataField,entity.getValue(partOfEntity)));
public String makeTerm(HttpServletRequest req){
- // it isn't indexed!
+ // it isn't indexed!
return null;
}
- public void returnMeta(SimpleHash result,Document doc){
- result.put(templateVariable,new SimpleScalar(doc.get(dataField)));
+ public void returnMeta(Map result,Document doc){
+ result.put(templateVariable,doc.get(dataField));
}
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-
public class UnStoredSearchTerm extends SearchTerm{
public String paramName;
public String partOfEntity;
-
+
public UnStoredSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
paramName = aParamName;
dataField = aDataField;
templateVariable = aTemplateVariable;
}
-
-
+
+
public void index(Document doc, Entity entity){
doc.add(Field.UnStored(matchField,entity.getValue(partOfEntity)));
}
public void indexValue(Document doc, String value){
doc.add(Field.UnStored(matchField, value));
}
-
+
public String makeTerm(HttpServletRequest req){
String wanted = req.getParameter(paramName);
if (wanted != null && !(wanted.equals(""))){
- return matchField + ":" + "\"" + wanted + "\"";
+ return matchField + ":" + "\"" + wanted + "\"";
}
else {
- return null;
+ return null;
}
}
- public void returnMeta(SimpleHash result,Document doc){
+ public void returnMeta(Map result,Document doc){
return;
}
-
+
}
package mircoders.search;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import mir.entity.Entity;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
-
public class VideoSearchTerm extends SearchTerm{
-
-
- public static String matchField = "hasVideo";
- public static String paramName = "search_hasVideo";
+ public static String matchField = "hasVideo";
+ public static String paramName = "search_hasVideo";
public static String templateVariable = "hasVideo";
public void index(Document doc, Entity entity) throws StorageObjectFailure{
return null;
}
}
-
- public void returnMeta(SimpleHash result,Document doc){
- result.put(templateVariable,new SimpleScalar(doc.get(matchField)));
+
+ public void returnMeta(Map result,Document doc){
+ result.put(templateVariable, doc.get(matchField));
}
-
+
}
-package mircoders.servlet;
-
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import mir.entity.adapter.EntityIteratorAdapter;
-import mir.generator.Generator;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import mir.util.CachingRewindableIterator;
-import mir.util.NullWriter;
-import mir.util.ResourceBundleGeneratorFunction;
-import mircoders.global.MirGlobal;
-
-import org.apache.struts.util.MessageResources;
-
-
-
-public class ServletHelper {
-// ML: add logging!
-
- static Map makeGenerationData(Locale aLocale) throws ServletModuleExc {
- try {
- Map result = new HashMap();
-
- MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result);
-
- result.put("returnurl", null);
-
- Object languages =
- new CachingRewindableIterator(
- new EntityIteratorAdapter( "", "id", 30,
- MirGlobal.localizer().dataModel().adapterModel(), "language"));
- Object topics =
- new CachingRewindableIterator(
- new EntityIteratorAdapter("", "id", 30,
- MirGlobal.localizer().dataModel().adapterModel(), "topic"));
-
- Object articleTypes =
- new CachingRewindableIterator(
- new EntityIteratorAdapter( "", "id", 30,
- MirGlobal.localizer().dataModel().adapterModel(), "articleType"));
-
- Object commentStatuses =
- new CachingRewindableIterator(
- new EntityIteratorAdapter( "", "id", 30,
- MirGlobal.localizer().dataModel().adapterModel(), "commentStatus"));
-
- result.put("commentstatuses", commentStatuses);
- result.put("articletypes", articleTypes);
- result.put("languages", languages);
- result.put("topics", topics);
-
- result.put( "lang",
- new ResourceBundleGeneratorFunction( aLocale,
- MessageResources.getMessageResources("bundles.adminlocal"),
- MessageResources.getMessageResources("bundles.admin")));
-
- return result;
- }
- catch (Throwable t) {
- throw new ServletModuleFailure(t);
- }
- }
-
- static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {
-
- Generator generator;
-
- try {
- generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator);
-
- generator.generate(aWriter, aGenerationData, new PrintWriter(new NullWriter()));
- }
- catch (Throwable t) {
- throw new ServletModuleFailure(t);
- }
- }
-}
+package mircoders.servlet;\r
+\r
+import java.io.PrintWriter;\r
+import java.util.HashMap;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+\r
+import org.apache.struts.util.MessageResources;\r
+\r
+import mir.entity.adapter.EntityIteratorAdapter;\r
+import mir.generator.Generator;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.NullWriter;\r
+import mir.util.ResourceBundleGeneratorFunction;\r
+\r
+import mircoders.global.MirGlobal;\r
+\r
+\r
+\r
+public class ServletHelper {\r
+ static Map makeGenerationData(Locale aLocale) throws ServletModuleExc {\r
+ return makeGenerationData(aLocale, "bundles.adminlocal", "bundles.admin");\r
+ }\r
+\r
+ static Map makeGenerationData(Locale aLocale, String aBundle) throws ServletModuleExc {\r
+ return makeGenerationData(aLocale, aBundle, aBundle);\r
+ }\r
+\r
+ static Map makeGenerationData(Locale aLocale, String aBundle, String aDefaultBundle) throws ServletModuleExc {\r
+\r
+ try {\r
+ Map result = new HashMap();\r
+\r
+ MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result);\r
+\r
+ result.put("returnurl", null);\r
+\r
+ Object languages =\r
+ new CachingRewindableIterator(\r
+ new EntityIteratorAdapter( "", "id", 30,\r
+ MirGlobal.localizer().dataModel().adapterModel(), "language"));\r
+ Object topics =\r
+ new CachingRewindableIterator(\r
+ new EntityIteratorAdapter("", "id", 30,\r
+ MirGlobal.localizer().dataModel().adapterModel(), "topic"));\r
+\r
+ Object articleTypes =\r
+ new CachingRewindableIterator(\r
+ new EntityIteratorAdapter( "", "id", 30,\r
+ MirGlobal.localizer().dataModel().adapterModel(), "articleType"));\r
+\r
+ Object commentStatuses =\r
+ new CachingRewindableIterator(\r
+ new EntityIteratorAdapter( "", "id", 30,\r
+ MirGlobal.localizer().dataModel().adapterModel(), "commentStatus"));\r
+\r
+ result.put("commentstatuses", commentStatuses);\r
+ result.put("articletypes", articleTypes);\r
+ result.put("languages", languages);\r
+ result.put("topics", topics);\r
+\r
+ result.put( "lang",\r
+ new ResourceBundleGeneratorFunction( aLocale,\r
+ MessageResources.getMessageResources(aBundle),\r
+ MessageResources.getMessageResources(aDefaultBundle)));\r
+\r
+ return result;\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ServletModuleFailure(t);\r
+ }\r
+ }\r
+\r
+ static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {\r
+ Generator generator;\r
+\r
+ try {\r
+ generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator);\r
+\r
+ generator.generate(aWriter, aGenerationData, new PrintWriter(new NullWriter()));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ServletModuleFailure(t);\r
+ }\r
+ }\r
+\r
+ static void generateOpenPostingResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {\r
+ Generator generator;\r
+\r
+ try {\r
+ generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator);\r
+\r
+ generator.generate(aWriter, aGenerationData, new PrintWriter(new NullWriter()));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ServletModuleFailure(t);\r
+ }\r
+ }\r
+}\r
package mircoders.servlet;
-import mir.config.MirPropertiesConfiguration;
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModule;
-import mircoders.module.ModuleCommentStatus;
+import mir.config.MirPropertiesConfiguration;\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mircoders.module.ModuleCommentStatus;\r
import mircoders.storage.DatabaseCommentStatus;
public class ServletModuleCommentStatus extends ServletModule
-/*
- * 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 mircoders.servlet;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.log.LoggerWrapper;
-import mir.misc.FileExtFilter;
-import mir.misc.HTMLTemplateProcessor;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-/*
- * ServletModuleFileEdit -
- * Allows one to do a basic edit of a file in a directory specified
- * in the config file.
- *
- * @author $Author: idfx $
- * @version $Revision: 1.7 $ $Date: 2003/03/08 17:18:19 $
- *
- */
-
-public class ServletModuleFileEdit extends ServletModule
-{
-
-// Singelton / Kontruktor
-
- private static ServletModuleFileEdit instance =
- new ServletModuleFileEdit();
- public static ServletModule getInstance() { return instance; }
-
- private String _dirName;
- private String _extName;
-
- private ServletModuleFileEdit() {
- super();
-
- logger = new LoggerWrapper("ServletModule.FileEdit");
-
- _dirName = configuration.getString("ServletModule.FileEdit.FileDirectory");
- _extName = configuration.getString("ServletModule.FileEdit.ExtFilter");
-
- templateListString =configuration.getString("ServletModule.FileEdit.ListTemplate");
- templateObjektString =configuration.getString("ServletModule.FileEdit.ObjektTemplate");
- templateConfirmString =configuration.getString("ServletModule.FileEdit.ConfirmTemplate");
- }
-
- public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
-// fetch and deliver
- try {
- SimpleHash mergeData = new SimpleHash();
- String offset = req.getParameter("offset");
- if (offset==null || offset.equals("")) offset="0";
- mergeData.put("offset",offset);
- File dir = new File(_dirName);
-
- FileExtFilter extFilter = new FileExtFilter(_extName);
- String[] dirEntries = dir.list(extFilter);
- SimpleList theList = new SimpleList();
- for ( int i = 0; i < dirEntries.length; ++i ) {
- theList.add(dirEntries[i]);
- }
- mergeData.put("filelist",theList);
-
- HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String filename = req.getParameter("filename");
- if (filename == null) throw new ServletModuleExc("No filename specified");
- try {
-
- File f = new File(_dirName, filename);
- FileReader in = new FileReader(f);
- StringWriter out = new StringWriter();
-
- int c;
- while ((c = in.read()) != -1)
- out.write(c);
- in.close();
- out.close();
- SimpleHash withValues = new SimpleHash();
- withValues.put("text", out.toString());
- withValues.put("filename", filename);
-
-
- deliver(req, res, withValues, null, templateObjektString);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String filename = req.getParameter("filename");
-
- if (filename == null) throw new ServletModuleExc("No filename specified");
- try {
-
- File f = new File(_dirName, filename);
- StringReader in = new StringReader(req.getParameter("text"));
- FileWriter out = new FileWriter(f);
-
- int c;
- while ((c = in.read()) != -1)
- out.write(c);
- in.close();
- out.close();
-
- edit(req, res);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.servlet;\r
+\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.FileWriter;\r
+import java.io.FilenameFilter;\r
+import java.io.StringReader;\r
+import java.io.StringWriter;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.util.FileFunctions;\r
+import mir.util.HTTPRequestParser;\r
+import mir.util.URLBuilder;\r
+\r
+/*\r
+ * ServletModuleFileEdit -\r
+ * Allows one to do a basic edit of a file in a directory specified\r
+ * in the config file.\r
+ *\r
+ * @author $Author: zapata $\r
+ * @version $Revision: 1.8 $ $Date: 2003/03/17 20:47:04 $\r
+ *\r
+ */\r
+\r
+public class ServletModuleFileEdit extends ServletModule\r
+{\r
+ private static ServletModuleFileEdit instance = new ServletModuleFileEdit();\r
+ public static ServletModule getInstance() { return instance; }\r
+\r
+ private File rootDirectory;\r
+ private FilenameFilter filter;\r
+ private FilenameFilter dirFilter;\r
+ private boolean recurse;\r
+\r
+ private ServletModuleFileEdit() {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("ServletModule.FileEdit");\r
+\r
+ rootDirectory = new File(configuration.getString("ServletModule.FileEdit.FileDirectory"));\r
+ recurse = configuration.getString("ServletModule.FileEdit.Recursive", "").equals("1");\r
+\r
+ filter = new FileFunctions.RegExpFileFilter(configuration.getString("ServletModule.FileEdit.ExtFilter"));\r
+ dirFilter = new FileFunctions.DirectoryFilter();\r
+\r
+ templateListString =configuration.getString("ServletModule.FileEdit.ListTemplate");\r
+ templateObjektString =configuration.getString("ServletModule.FileEdit.ObjektTemplate");\r
+ templateConfirmString =configuration.getString("ServletModule.FileEdit.ConfirmTemplate");\r
+ }\r
+\r
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ listSubDirectory("/", aRequest, aResponse);\r
+ }\r
+\r
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ try {\r
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+ String filename = requestParser.getParameter("filename");\r
+ String subDirectory = requestParser.getParameterWithDefault("subdirectory", "");\r
+\r
+ if (filename == null)\r
+ throw new ServletModuleExc("No filename specified");\r
+\r
+ editFile(filename, subDirectory, aRequest, aResponse);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ public void enter(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ try {\r
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+ String directoryName = requestParser.getParameter("directory");\r
+ String subDirectoryName = requestParser.getParameter("subdirectory");\r
+\r
+ if (directoryName==null | subDirectoryName==null)\r
+ throw new ServletModuleExc("No directory/subDirectory specified");\r
+\r
+ listSubDirectory(subDirectoryName+File.separator+directoryName, aRequest, aResponse);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+ public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ String filename = aRequest.getParameter("filename");\r
+ String subDirectory = aRequest.getParameter("subdirectory");\r
+ String text = aRequest.getParameter("text");\r
+\r
+ try {\r
+ File f = new File(new File(rootDirectory, subDirectory), filename);\r
+\r
+ if (validateDirectory(f)) {\r
+ StringReader in = new StringReader(text);\r
+ FileWriter out = new FileWriter(f);\r
+\r
+ int c;\r
+ while ( (c = in.read()) != -1)\r
+ out.write(c);\r
+ in.close();\r
+ out.close();\r
+\r
+ editFile(filename, subDirectory, aRequest, aResponse);\r
+ }\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ public void listSubDirectory(String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ try {\r
+ Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest));\r
+ File dir = new File(rootDirectory, aSubDirectory);\r
+\r
+ if (!validateDirectory(dir) || !dir.isDirectory()) {\r
+ dir = rootDirectory;\r
+ aSubDirectory = "";\r
+ }\r
+\r
+ responseData.put("filelist", Arrays.asList(dir.list(filter)));\r
+\r
+ if (recurse) {\r
+ List dirs = new Vector();\r
+ if (!dir.getCanonicalPath().equals(rootDirectory.getCanonicalPath()))\r
+ responseData.put("updir", new File(aSubDirectory).getParent());\r
+\r
+ dirs.addAll(Arrays.asList(dir.list(dirFilter)));\r
+\r
+ responseData.put("dirlist", dirs);\r
+ }\r
+ else {\r
+ responseData.put("dirlist", null);\r
+ responseData.put("updir", null);\r
+ }\r
+\r
+ responseData.put("subdirectory", aSubDirectory);\r
+\r
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateListString);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ public void editFile(String aFileName, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+ {\r
+ try {\r
+ File f = new File(new File(rootDirectory, aSubDirectory), aFileName);\r
+\r
+ if (!validateDirectory(f) || f.isDirectory() || !validateFile(f)) {\r
+ listSubDirectory("", aRequest, aResponse);\r
+ }\r
+ else {\r
+ Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest));\r
+ URLBuilder urlBuilder = new URLBuilder();\r
+\r
+ urlBuilder.setValue("module", "FileEdit");\r
+ urlBuilder.setValue("do", "enter");\r
+ urlBuilder.setValue("directory", "");\r
+ urlBuilder.setValue("subdirectory", aSubDirectory);\r
+\r
+ FileReader in = new FileReader(f);\r
+ StringWriter out = new StringWriter();\r
+\r
+ int c;\r
+ while ( (c = in.read()) != -1)\r
+ out.write(c);\r
+ in.close();\r
+ out.close();\r
+\r
+ responseData.put("text", out.toString());\r
+ responseData.put("filename", aFileName);\r
+ responseData.put("subdirectory", aSubDirectory);\r
+ responseData.put("returnurl", urlBuilder.getQuery());\r
+\r
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateObjektString);\r
+ }\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ protected boolean validateDirectory(File aFile) {\r
+ try {\r
+ return (aFile.getCanonicalPath().startsWith(rootDirectory.getCanonicalPath()));\r
+ }\r
+ catch (Throwable t) {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ protected boolean validateFile(File aFile) {\r
+ try {\r
+ return filter.accept(aFile.getParentFile(), aFile.getName());\r
+ }\r
+ catch (Throwable t) {\r
+ return false;\r
+ }\r
+ }\r
+}\r
import java.util.GregorianCalendar;\r
import java.util.HashMap;\r
import java.util.Iterator;\r
+import java.util.List;\r
import java.util.ListIterator;\r
-import java.util.Locale;\r
import java.util.Map;\r
import java.util.Random;\r
import java.util.Set;\r
-\r
-\r
+import java.util.Vector;\r
import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
import javax.servlet.http.HttpSession;\r
\r
+import org.apache.commons.net.smtp.SMTPClient;\r
+import org.apache.commons.net.smtp.SMTPReply;\r
+import org.apache.fop.apps.Driver;\r
+import org.apache.fop.apps.XSLTInputHandler;\r
+import org.apache.log.Hierarchy;\r
+import org.apache.log.Priority;\r
+import org.apache.lucene.analysis.standard.StandardAnalyzer;\r
+import org.apache.lucene.document.Document;\r
+import org.apache.lucene.queryParser.QueryParser;\r
+import org.apache.lucene.search.Hits;\r
+import org.apache.lucene.search.IndexSearcher;\r
+import org.apache.lucene.search.Query;\r
+import org.apache.lucene.search.Searcher;\r
+import org.apache.struts.util.MessageResources;\r
+\r
import mir.entity.Entity;\r
import mir.entity.EntityList;\r
+import mir.generator.Generator;\r
import mir.log.LoggerWrapper;\r
import mir.misc.FileHandler;\r
-import mir.misc.HTMLTemplateProcessor;\r
import mir.misc.StringUtil;\r
import mir.misc.WebdbMultipartRequest;\r
import mir.servlet.ServletModule;\r
import mir.storage.StorageObjectFailure;\r
import mir.util.ExceptionFunctions;\r
import mir.util.StringRoutines;\r
-\r
import mircoders.entity.EntityComment;\r
import mircoders.entity.EntityContent;\r
import mircoders.global.MirGlobal;\r
-import mircoders.global.Abuse;\r
import mircoders.media.MediaRequest;\r
import mircoders.media.UnsupportedMediaFormatExc;\r
import mircoders.module.ModuleComment;\r
import mircoders.storage.DatabaseImages;\r
import mircoders.storage.DatabaseLanguage;\r
import mircoders.storage.DatabaseTopics;\r
-import mircoders.global.*;\r
-\r
-import org.apache.commons.net.smtp.SMTPClient;\r
-import org.apache.commons.net.smtp.SMTPReply;\r
-import org.apache.fop.apps.Driver;\r
-import org.apache.fop.apps.XSLTInputHandler;\r
-import org.apache.log.Hierarchy;\r
-import org.apache.log.Priority;\r
-import org.apache.lucene.analysis.standard.StandardAnalyzer;\r
-import org.apache.lucene.document.Document;\r
-import org.apache.lucene.queryParser.QueryParser;\r
-import org.apache.lucene.search.Hits;\r
-import org.apache.lucene.search.IndexSearcher;\r
-import org.apache.lucene.search.Query;\r
-import org.apache.lucene.search.Searcher;\r
-\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateModelRoot;\r
\r
/*\r
* ServletModuleOpenIndy -\r
* open-postings to the newswire\r
*\r
* @author mir-coders group\r
- * @version $Id: ServletModuleOpenIndy.java,v 1.68 2003/03/15 15:35:57 zapata Exp $\r
+ * @version $Id: ServletModuleOpenIndy.java,v 1.69 2003/03/17 20:47:04 zapata Exp $\r
*\r
*/\r
\r
* @throws ServletModuleFailure\r
*/\r
public void openPostingDisabled(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
- deliver(aRequest, aResponse, new SimpleHash(),\r
+ deliver(aRequest, aResponse, (Map) null, null,\r
configuration.getString("ServletModule.OpenIndy.PostingDisabledTemplate"));\r
}\r
\r
}\r
\r
String aid = req.getParameter("aid"); // the article id the comment will belong to\r
+/*\r
String language = req.getParameter("language");\r
+ */\r
\r
if (aid!=null && !aid.equals("")) {\r
try {\r
- SimpleHash mergeData = new SimpleHash();\r
+ Map mergeData = new HashMap();\r
\r
// onetimepasswd\r
if (MirGlobal.abuse().getOpenPostingPassword()) {\r
else {\r
mergeData.put("passwd", (String) null);\r
}\r
-\r
+/*\r
if (language != null) {\r
HttpSession session = req.getSession(false);\r
session.setAttribute("Locale", new Locale(language, ""));\r
session.setAttribute("language", language);\r
}\r
-\r
+*/\r
mergeData.put("aid", aid);\r
\r
- SimpleHash extraInfo = new SimpleHash();\r
+ Map extraInfo = new HashMap();\r
extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData());\r
\r
deliver(req, res, mergeData, extraInfo, commentFormTemplate);\r
String id = mainModule.add(withValues);\r
\r
if(id==null){\r
- deliver(req, res, new SimpleHash(), commentFormDupeTemplate);\r
+ deliver(req, res, (Map) null, null, commentFormDupeTemplate);\r
}\r
else {\r
MirGlobal.abuse().logComment(req.getRemoteAddr(), id, new Date(), (String) req.getHeader("User-Agent"));\r
\r
// redirecting to url\r
// should implement back to article\r
- SimpleHash mergeData = new SimpleHash();\r
- deliver(req, res, mergeData, commentFormDoneTemplate);\r
+ Map mergeData = new HashMap();\r
+ deliver(req, res, mergeData, null, commentFormDoneTemplate);\r
}\r
catch (Throwable e) {\r
throw new ServletModuleFailure(e);\r
public void addposting(HttpServletRequest req, HttpServletResponse res)\r
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
{\r
- if (MirGlobal.abuse().getOpenPostingDisabled()) {\r
- openPostingDisabled(req, res);\r
-\r
- return;\r
- }\r
-\r
- SimpleHash mergeData = new SimpleHash();\r
+ try {\r
+ if (MirGlobal.abuse().getOpenPostingDisabled()) {\r
+ openPostingDisabled(req, res);\r
\r
- // onetimepasswd\r
- if (MirGlobal.abuse().getOpenPostingPassword()) {\r
- String passwd = this.createOneTimePasswd();\r
- HttpSession session = req.getSession(false);\r
- session.setAttribute("passwd",passwd);\r
- mergeData.put("passwd", passwd);\r
- }\r
- else {\r
- mergeData.put("passwd", (String) null);\r
- }\r
+ return;\r
+ }\r
\r
+ Map mergeData = new HashMap();\r
\r
- String maxMedia = configuration.getString("ServletModule.OpenIndy.MaxMediaUploadItems");\r
- String defaultMedia = configuration.getString("ServletModule.OpenIndy.DefaultMediaUploadItems");\r
- String numOfMedia = req.getParameter("medianum");\r
+ // onetimepasswd\r
+ if (MirGlobal.abuse().getOpenPostingPassword()) {\r
+ String passwd = this.createOneTimePasswd();\r
+ HttpSession session = req.getSession(false);\r
+ session.setAttribute("passwd", passwd);\r
+ mergeData.put("passwd", passwd);\r
+ }\r
+ else {\r
+ mergeData.put("passwd", (String)null);\r
+ }\r
\r
- if(numOfMedia==null||numOfMedia.equals("")){\r
- numOfMedia=defaultMedia;\r
- }\r
- else if(Integer.parseInt(numOfMedia) > Integer.parseInt(maxMedia)) {\r
- numOfMedia = maxMedia;\r
- }\r
+ String maxMedia = configuration.getString("ServletModule.OpenIndy.MaxMediaUploadItems");\r
+ String defaultMedia = configuration.getString("ServletModule.OpenIndy.DefaultMediaUploadItems");\r
+ String numOfMedia = req.getParameter("medianum");\r
\r
- int mediaNum = Integer.parseInt(numOfMedia);\r
- SimpleList mediaFields = new SimpleList();\r
- for(int i =0; i<mediaNum;i++){\r
- Integer mNum = new Integer(i+1);\r
- mediaFields.add(mNum.toString());\r
- }\r
- mergeData.put("medianum",numOfMedia);\r
- mergeData.put("mediafields",mediaFields);\r
+ if (numOfMedia == null || numOfMedia.equals("")) {\r
+ numOfMedia = defaultMedia;\r
+ }\r
+ else if (Integer.parseInt(numOfMedia) > Integer.parseInt(maxMedia)) {\r
+ numOfMedia = maxMedia;\r
+ }\r
\r
+ int mediaNum = Integer.parseInt(numOfMedia);\r
+ List mediaFields = new Vector();\r
+ for (int i = 0; i < mediaNum; i++) {\r
+ Integer mNum = new Integer(i + 1);\r
+ mediaFields.add(mNum.toString());\r
+ }\r
+ mergeData.put("medianum", numOfMedia);\r
+ mergeData.put("mediafields", mediaFields);\r
+ mergeData.put("to_topic", null);\r
\r
- SimpleHash extraInfo = new SimpleHash();\r
- try{\r
- extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData() );\r
+ Map extraInfo = new HashMap();\r
+ extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData());\r
extraInfo.put("themenPopupData", topicsModule.getTopicsAsSimpleList());\r
\r
extraInfo.put("topics", topicsModule.getTopicsList());\r
-\r
+ deliver(req, res, mergeData, extraInfo, postingFormTemplate);\r
}\r
- catch (Exception e) {\r
- logger.error("languagePopUpData or getTopicslist failed "+e.toString());\r
-\r
- throw new ServletModuleFailure("OpenIndy -- failed getting language or topics: "+e.toString(), e);\r
+ catch (Throwable t) {\r
+ throw new ServletModuleFailure(t);\r
}\r
-\r
- deliver(req, res, mergeData, extraInfo, postingFormTemplate);\r
}\r
\r
/**\r
return;\r
}\r
\r
- SimpleHash mergeData = new SimpleHash();\r
+ Map mergeData = new HashMap();\r
boolean setMedia=false;\r
boolean setTopic = false;\r
\r
String sessionPasswd = (String) session.getAttribute("passwd");\r
if (sessionPasswd != null){\r
String passwd = (String) withValues.get("passwd");\r
+\r
+ logger.debug("session password = " + sessionPasswd + ", form password = " + passwd);\r
+\r
if ( passwd == null || passwd.length()==0) {\r
throw new ServletModuleUserExc("posting.error.missingpassword", new String[] {});\r
}\r
withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));\r
withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));\r
withValues.put("is_produced", "0");\r
- // by default stuff is published, they can be un-published through the\r
- // admin interface.\r
withValues.put("is_published","1");\r
- // if op direct article-type == newswire\r
- if (directOp.equals("yes")) withValues.put("to_article_type","1");\r
+ if (directOp.equals("yes"))\r
+ withValues.put("to_article_type","1");\r
\r
withValues.put("to_publisher","1");\r
\r
- // owner is openposting user\r
- // ML: this is not multi-language friendly and this can be done in a template\r
- // if (withValues.get("creator").toString().equals(""))\r
- // withValues.put("creator","Anonym");\r
-\r
// inserting content into database\r
String cid = contentModule.add(withValues);\r
logger.debug("id: "+cid);\r
//insert was not successfull\r
if(cid==null){\r
+\r
//How do we know that it was not succesful cause of a\r
//dupe, what if it failed cause of "No space left on device"?\r
//Or is there something I am missing? Wouldn't it be better\r
//to have an explicit dupe check and then insert? I have no\r
//idea what I am talking about. this comment is in case\r
//I forget to explicitely ask. -mh\r
- deliver(req, res, mergeData, postingFormDupeTemplate);\r
+ deliver(req, res, mergeData, null, postingFormDupeTemplate);\r
return;\r
}\r
\r
throw new ServletModuleFailure(e);\r
}\r
\r
- deliver(req, res, mergeData, postingFormDoneTemplate);\r
+ deliver(req, res, mergeData, null, postingFormDoneTemplate);\r
}\r
\r
- /*\r
+ /**\r
* Method for preparing and sending a content as an email message\r
*/\r
\r
String comment = req.getParameter("mail_comment");\r
String mail_language = req.getParameter("mail_language");\r
\r
- SimpleHash mergeData = new SimpleHash();\r
+ Map mergeData = new HashMap();\r
\r
if (to == null || from == null || from_name == null|| to.equals("") || from.equals("") || from_name.equals("") || mail_language == null || mail_language.equals("")){\r
\r
for (Enumeration theParams = req.getParameterNames(); theParams.hasMoreElements() ;) {\r
String pName=(String)theParams.nextElement();\r
if (pName.startsWith("mail_")){\r
- mergeData.put(pName,new SimpleScalar(req.getParameter(pName)));\r
+ mergeData.put( pName,req.getParameter(pName) );\r
}\r
}\r
- deliver(req,res,mergeData,prepareMailTemplate);\r
+\r
+ deliver(req, res, mergeData, null, prepareMailTemplate);\r
}\r
else {\r
//run checks on to and from and mail_language to make sure no monkey business occurring\r
\r
client.disconnect();\r
//mission accomplished\r
- deliver(req, res, mergeData, sentMailTemplate);\r
+ deliver(req, res, mergeData, null, sentMailTemplate);\r
}\r
catch(IOException e) {\r
if(client.isConnected()) {\r
}\r
}\r
\r
-\r
- /*\r
+ /**\r
* Method for querying a lucene index\r
+ *\r
+ * @param req\r
+ * @param res\r
+ * @throws ServletModuleExc\r
+ * @throws ServletModuleUserExc\r
+ * @throws ServletModuleFailure\r
*/\r
+\r
public void search(HttpServletRequest req, HttpServletResponse res)\r
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
try {\r
\r
String queryString="";\r
\r
- SimpleHash mergeData = new SimpleHash();\r
+ Map mergeData = new HashMap();\r
\r
KeywordSearchTerm dateTerm = new KeywordSearchTerm("date_formatted","search_date","webdb_create_formatted","webdb_create_formatted","webdb_create_formatted");\r
UnIndexedSearchTerm whereTerm = new UnIndexedSearchTerm("","","","where","where");\r
for (Enumeration theParams = req.getParameterNames(); theParams.hasMoreElements() ;) {\r
String pName=(String)theParams.nextElement();\r
if (pName.startsWith("search_")){\r
- mergeData.put(pName,new SimpleScalar(req.getParameter(pName)));\r
+ mergeData.put(pName, req.getParameter(pName) );\r
}\r
}\r
\r
if (theDocs != null){\r
\r
mergeData.put("numberOfHits", ((Integer)session.getAttribute("numberOfHits")).toString());\r
- SimpleList theHits = new SimpleList();\r
+ List theHits = new Vector();\r
int pIR=((Integer)session.getAttribute("positionInResults")).intValue();\r
int terminus;\r
int numHits=((Integer)session.getAttribute("numberOfHits")).intValue();\r
terminus=pIR+increment;\r
}\r
for(int i = pIR; i < terminus; i++) {\r
- SimpleHash h = new SimpleHash();\r
+ Map h = new HashMap();\r
Document theHit = (Document)theDocs.get(i);\r
whereTerm.returnMeta(h,theHit);\r
creatorTerm.returnMeta(h,theHit);\r
}\r
\r
mergeData.put("queryString",queryString);\r
- deliver(req,res,mergeData,searchResultsTemplate);\r
+\r
+ deliver(req, res, mergeData, null, searchResultsTemplate);\r
}\r
catch (NullPointerException n){\r
throw new ServletModuleFailure("Null Pointer: "+n.toString(), n);\r
throw new ServletModuleExc("Missing id.");\r
}\r
}\r
- catch (Exception ex) {\r
- logger.error(ex.toString());\r
- throw new ServletModuleFailure(ex);\r
+ catch (Throwable t) {\r
+ logger.error(t.toString());\r
+\r
+ throw new ServletModuleFailure(t);\r
}\r
- } else {\r
+ }\r
+ else {\r
throw new ServletModuleExc("Can't generate a PDF because the config tells me not to.");\r
}\r
}\r
l = (l*l*l*l)/random;\r
if(l<0) l = l * -1;\r
String returnString = ""+l;\r
+\r
return returnString.substring(5);\r
}\r
\r
\r
/* this is an overwritten method of ServletModule in order\r
to use different bundles for open and admin */\r
- public void deliver(HttpServletRequest req, HttpServletResponse res,\r
+/* public void deliver(HttpServletRequest req, HttpServletResponse res,\r
TemplateModelRoot rtm, TemplateModelRoot popups,\r
String templateFilename) throws ServletModuleFailure\r
{\r
- if (rtm == null) rtm = new SimpleHash();\r
+ }\r
+*/\r
+ public void deliver(HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator)\r
+ throws ServletModuleFailure {\r
+ try {\r
+ deliver(aResponse.getWriter(), aRequest, aResponse, aData, anExtra, aGenerator);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ServletModuleFailure(t);\r
+ }\r
+ }\r
+\r
+ public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator)\r
+ throws ServletModuleFailure {\r
+ try {\r
+ Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest), "bundles.open");\r
+ responseData.put("data", aData);\r
+ responseData.put("extra", anExtra);\r
+\r
+\r
+ Generator generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator);\r
+ generator.generate(anOutputWriter, responseData, logger.asPrintWriter(logger.INFO_MESSAGE));\r
+\r
+ anOutputWriter.close();\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("Error while generating " + aGenerator + ": " + e.getMessage());\r
+\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ public void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) {\r
+ try {\r
+ logger.error("error: " + anException);\r
+ Map data = new HashMap();\r
+\r
+ data.put("errorstring", anException.getMessage());\r
+ data.put("date", StringUtil.date2readableDateTime(new GregorianCalendar()));\r
+\r
+ deliver(out, aRequest, aResponse, data, null, configuration.getString("ServletModule.OpenIndy.ErrorTemplate"));\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ServletModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ public void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse,\r
+ PrintWriter out, ServletModuleUserExc anException) {\r
try {\r
- PrintWriter out = res.getWriter();\r
- HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out,\r
- getLocale(req), "bundles.open");\r
- out.close();\r
+ logger.warn("user error: " + anException.getMessage());\r
+ Map data = new HashMap();\r
+\r
+ MessageResources messages = MessageResources.getMessageResources("bundles.open");\r
+ data.put("errorstring",\r
+ messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters())\r
+ );\r
+ data.put("date", StringUtil.date2readableDateTime(new GregorianCalendar()));\r
+\r
+ deliver(out, aRequest, aResponse, data, null, configuration.getString("ServletModule.OpenIndy.UserErrorTemplate"));\r
}\r
catch (Throwable e) {\r
throw new ServletModuleFailure(e);\r
}\r
}\r
+\r
+\r
}\r
\r
\r
<head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="ArticleType">
</form>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<p>
<a class="majorcommand" href="${config.actionRoot}?module=ArticleType&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
</p>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.new>
<form action="${config.actionRoot}?module=Audio&do=add" method="post">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<tr><td align="center">${lang("no_matches_found")}</td></tr>
</if>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="Breaking">
<input type="hidden" name="id" value="${data.id}">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.contentlist>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="darkgrey">
<else>
<P align="center">${lang("no_matches_found")}</p>
</if>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<form method="post" action="${config.actionRoot}">
<input type="hidden" name="module" value="Comment">
</tr>
</table>
</form>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="CommentStatus">
</form>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<p>
<a class="majorcommand" href="${config.actionRoot}?module=CommentStatus&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
</p>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head_nonavi.template">
+ <include "head_nonavi.template">
<table width="100%" border="0" align="center">
<tr class="darkgrey">
<td colspan="2">
</td>
</tr>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<br>
-<b>${lang("fileedit.filename")} :</b> ${data.filename}
+<b>${lang("fileedit.filename")} :</b> ${filename}
<br>
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="FileEdit">
- <input type="hidden" name="filename" value="${data.filename}">
+ <input type="hidden" name="filename" value="${filename}">
+ <input type="hidden" name="subdirectory" value="${subdirectory}">
<input type="hidden" name="do" value="update">
- <textarea cols="120" rows="40" name="text" wrap=virtual>${data.text}</textarea>
+ <textarea cols="120" rows="40" name="text" wrap=virtual>${text}</textarea>
<br>
<hr size="2" width="90%" noshade>
-${data.text}
+${text}
<hr size="2" width="90%" noshade>
<br>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
+<if dirlist || updir>
-<if data.filelist>
+ <table border="0" cellpadding="2" cellspacing="1">
+
+ <tr class="dark">
+ <td><span class="witesmall"><b>${lang("fileeditlist.dirname")}</b></span></td>
+ <td> </td>
+ </tr>
+
+ <assign grey="0">
+
+ <if updir>
+ <tr class="list1">
+ <td>.. </td>
+ <td><span class="small"><a href="${config.actionRoot}?module=FileEdit&do=enter&subdirectory=${utility.encodeURI(updir)}&directory=">${lang("edit")}</a></span></td>
+ </tr>
+ </if>
+
+ <if dirlist>
+ <list dirlist as entry>
+ <if grey=="1">
+ <assign grey="0">
+ <tr class="list1">
+ <else>
+ <tr class="list2">
+ <assign grey="1">
+ </if>
+ <td>${entry} </td>
+ <td><span class="small"><a href="${config.actionRoot}?module=FileEdit&do=enter&subdirectory=${utility.encodeURI(subdirectory)}&directory=${utility.encodeURI(entry)}">${lang("edit")}</a></span></td>
+ </tr>
+ </list>
+ </if>
+
+ </table>
+</if>
+
+<if filelist || updir || dirlist>
+<p></p>
+</if>
+
+<if filelist>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="dark">
-
<td><span class="witesmall"><b>${lang("fileeditlist.filename")}</b></span></td>
<td> </td>
</tr>
+ <assign grey="0">
- <list data.filelist as entry>
- <tr
- <if grey=="1"><assign grey="0">class="list1"<else>class="list2"<assign grey="1"> </if>
- >
- <td>${entry} </td>
- <td><span class="small"><a href="${config.actionRoot}?module=FileEdit&do=edit&filename=${entry}">${lang("edit")}</a></span></td>
- </tr>
+ <list filelist as entry>
+ <if grey=="1">
+ <assign grey="0">
+ <tr class="list1">
+ <else>
+ <tr class="list2">
+ <assign grey="1">
+ </if>
+ <td>${entry} </td>
+ <td><span class="small"><a href="${config.actionRoot}?module=FileEdit&do=edit&subdirectory=${utility.encodeURI(subdirectory)}&filename=${utility.encodeURI(entry)}">${lang("edit")}</a></span></td>
+ </tr>
</list>
</table>
- <P>
+<P>
<else>
<P align="center">${lang("no_matches_found")}</p>
</if>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<table width="98%" class="pink">
<tr>
<td>
</if>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<if data.new>
<form action="${config.actionRoot}?module=Images&do=add" method="post">
</form>
</table>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<tr><td align="center">${lang("no_matches_found")}</td></tr>
</if>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="Language">
<input type="hidden" name="id" value="${data.id}">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<p>
<a class="majorcommand" href="${config.actionRoot}?module=Language&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
</p>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<form action="${config.actionRoot}" method="post">
<input type=hidden name=module value=LinksImcs>
<input type="hidden" name="id" value="${data.entity.id}">
</td>
</tr>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
\r
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">\r
\r
-<include "templates/admin/head.template">\r
+<include "head.template">\r
\r
<form method="post" action="${config.actionRoot}">\r
<input type="hidden" name="module" value="LinksImcs">\r
<else>\r
<P align="center">${lang("no_matches_found")}</p>\r
</if>\r
-<include "templates/admin/foot.template">\r
+<include "foot.template">\r
</body>\r
</html>
\ No newline at end of file
</script>
</head>
<body onLoad="placeFocus()" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head_nonavi.template">
+ <include "head_nonavi.template">
<center>
<p>
<span class="small">
</table>
</form>
</center>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.new>
<form action="${config.actionRoot}?module=OtherMedia&do=add" method="post">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<form method="post" action="${config.actionRoot}">
<input type=hidden name=module value=Mediafolder>
<input type="hidden" name="id" value="${data.id}">
</span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.contentlist>
<table border="0">
<tr class="darkgrey">
<else>
<P align="center">${lang("no_matches_found")}</p>
</if>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<tr><td align="center">${lang("no_matches_found")}</td></tr>
</if>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="Message">
<input type="hidden" name="id" value="${data.id}">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.contentlist>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="darkgrey">
<else>
<P align="center">${lang("no_matches_found")}</p>
</if>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<table border="0" width="100%">
<tr>
<td valign="top" width="40%" class="grey">
</tr>
</table>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<form action="${config.actionRoot}" method="post">
<input type=hidden name=module value=Topics>
</tr>
</table>
</form>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<a class="majorcommand" href="${config.actionRoot}?module=Topics&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
<a class="majorcommand" href="${config.actionRoot}?module=Topics&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="Users">
</table>
</form>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<title>${lang("usererror.htmltitle")}</title>
</head>
<body>
-<include "templates/admin/head_nonavi.template">
+<include "head_nonavi.template">
<table width="100%" border="0" align="center">
<tr bgcolor="#006600">
<td>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
- <include "templates/admin/head.template">
+ <include "head.template">
<p>
<a class="majorcommand" href="${config.actionRoot}?module=Users&do=add">${lang("add")}</a> |
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
<a class="majorcommand" href="${config.actionRoot}?module=Admin&do=superusermenu">${lang("back")}</a>
</p>
- <include "templates/admin/foot.template">
+ <include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<if data.new>
<form action="${config.actionRoot}?module=Video&do=add" method="post">
</if> </span></form></span>
</td>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "templates/admin/head.template">
+<include "head.template">
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<tr><td align="center">${lang("no_matches_found")}</td></tr>
</if>
</table>
-<include "templates/admin/foot.template">
+<include "foot.template">
</body>
</html>