ServletModule exception cleanup + different error templates for admin + open postings...
authorzapata <zapata>
Thu, 6 Mar 2003 05:40:38 +0000 (05:40 +0000)
committerzapata <zapata>
Thu, 6 Mar 2003 05:40:38 +0000 (05:40 +0000)
38 files changed:
etc/open/error.template [new file with mode: 0755]
etc/open/usererror.template [new file with mode: 0755]
source/Mir.java
source/OpenMir.java
source/default.properties
source/mir/config/MirPropertiesConfiguration.java
source/mir/misc/XmlStyler.java [deleted file]
source/mir/servlet/AbstractServlet.java
source/mir/servlet/ServletModule.java
source/mir/servlet/ServletModuleDispatch.java
source/mir/servlet/ServletModuleExc.java [new file with mode: 0755]
source/mir/servlet/ServletModuleException.java [deleted file]
source/mir/servlet/ServletModuleFailure.java [new file with mode: 0755]
source/mir/servlet/ServletModuleShow.java
source/mir/servlet/ServletModuleUserExc.java [new file with mode: 0755]
source/mir/servlet/ServletModuleUserException.java [deleted file]
source/mir/util/ExceptionFunctions.java [new file with mode: 0755]
source/mircoders/media/MediaHandlerGeneric.java
source/mircoders/module/ModuleComment.java
source/mircoders/producer/IndexingProducerNode.java
source/mircoders/producer/PDFGeneratingProducerNode.java
source/mircoders/producer/UnIndexingProducerNode.java
source/mircoders/servlet/ServletHelper.java
source/mircoders/servlet/ServletModuleAdmin.java
source/mircoders/servlet/ServletModuleBreaking.java
source/mircoders/servlet/ServletModuleComment.java
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/servlet/ServletModuleFileEdit.java
source/mircoders/servlet/ServletModuleHidden.java
source/mircoders/servlet/ServletModuleLinksImcs.java
source/mircoders/servlet/ServletModuleLocalizer.java
source/mircoders/servlet/ServletModuleMediafolder.java
source/mircoders/servlet/ServletModuleMessage.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleProducer.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
source/mircoders/servlet/ServletModuleUsers.java
source/mircoders/storage/DatabaseContentToMedia.java

diff --git a/etc/open/error.template b/etc/open/error.template
new file mode 100755 (executable)
index 0000000..2a0395d
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+    <title>${config["Mir.Name"]} | ${lang("error.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+</head>
+<body>
+<include "head.template">
+<table width="100%" border="0" align="center">
+       <tr class="grey">
+               <td>
+                       <div align="center"><h2><font class="specialtext">${lang("error.title")}</font></h2>
+                       </div>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>
+                       <p align="center"><font color="red">${data.date} -- ${data.errorstring}</font>
+                       <p>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p align="center">
+            ${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+                       <p>
+               </td>
+       </tr>
+</table>
+<include "foot.template">
+</body>
+</html>
diff --git a/etc/open/usererror.template b/etc/open/usererror.template
new file mode 100755 (executable)
index 0000000..fc61c25
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+<title>${lang("usererror.htmltitle")}</title>
+</head>
+<body>
+<include "templates/admin/head_nonavi.template">
+<table width="100%" border="0" align="center">
+       <tr bgcolor="#006600">
+               <td>
+                       <div align="center"><h2><font color="Pink">${lang("usererror.title")}</font></h2>
+                       </div>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>${lang("usererror.text")}
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>
+                       <p align="center"><font size="5" color="Red"><b> ${data.errorstring}</b></font>
+            <p>
+                       <p> 
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">${lang("usererror.what_to_do")}
+                       </a></font>
+                       <p>
+               </td>
+       </tr>
+</table>
+<include "foot.template">
+</body>
+</html>
index dc7cca0..e69de29 100755 (executable)
@@ -1,490 +0,0 @@
-/*\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
-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
-\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 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.ServletModuleException;\r
-import mir.servlet.ServletModuleUserException;\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;\r
-\r
-import org.apache.struts.util.MessageResources;\r
-\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateModel;\r
-\r
-\r
-\r
-/**\r
- * Mir.java - main servlet, that dispatches to servletmodules\r
- *\r
- * @author $Author: idfx $\r
- * @version $Id: Mir.java,v 1.32 2003/03/05 19:23:14 idfx Exp $\r
- *\r
- */\r
-public class Mir extends AbstractServlet {\r
-  private static ModuleUsers usersModule = null;\r
-  private static ModuleMessage messageModule = null;\r
-  private final static Map servletModuleInstanceHash = new HashMap();\r
-\r
-  //I don't know about making this static cause it removes the\r
-  //possibility to change the config on the fly.. -mh\r
-  private static List loginLanguages = null;\r
-  public HttpSession session;\r
-\r
-  public void doGet(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletException, IOException {\r
-    doPost(req, res);\r
-  }\r
-\r
-  protected TemplateModel getLoginLanguages() throws ServletException {\r
-    synchronized (Mir.class) {\r
-      try {\r
-        if (loginLanguages == null) {\r
-          MessageResources messageResources2 =\r
-            MessageResources.getMessageResources("bundles.admin");\r
-          MessageResources messageResources =\r
-            MessageResources.getMessageResources("bundles.adminlocal");\r
-          List languages =\r
-            StringRoutines.splitString(MirGlobal.getConfigPropertyWithDefault(\r
-                "Mir.Login.Languages", "en"), ";");\r
-\r
-          loginLanguages = new Vector();\r
-\r
-          Iterator i = languages.iterator();\r
-\r
-          while (i.hasNext()) {\r
-            String code = (String) i.next();\r
-            Locale locale = new Locale(code, "");\r
-            String name = messageResources.getMessage(locale, "languagename");\r
-\r
-            if (name == null) {\r
-              name = messageResources2.getMessage(locale, "languagename");\r
-            }\r
-\r
-            if (name == null) {\r
-              name = code;\r
-            }\r
-\r
-            Map record = new HashMap();\r
-            record.put("name", name);\r
-            record.put("code", code);\r
-            loginLanguages.add(record);\r
-          }\r
-        }\r
-\r
-        return FreemarkerGenerator.makeAdapter(loginLanguages);\r
-      } catch (Throwable t) {\r
-        throw new ServletException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
-  // FIXME: this should probalby go into AbstractServlet so it can be used in\r
-  // OpenMir as well -mh\r
-  protected String getDefaultLanguage(HttpServletRequest req) {\r
-    String defaultlanguage =\r
-      MirGlobal.getConfigPropertyWithDefault("Mir.Login.DefaultLanguage", "");\r
-\r
-    if (defaultlanguage.length() == 0) {\r
-      Locale locale = req.getLocale();\r
-      defaultlanguage = locale.getLanguage();\r
-    }\r
-\r
-    return defaultlanguage;\r
-  }\r
-\r
-  public void doPost(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletException, IOException, UnavailableException {\r
-    long startTime = System.currentTimeMillis();\r
-    long sessionConnectTime = 0;\r
-    EntityUsers userEntity;\r
-    String http = "";\r
-\r
-    if ((configuration.getString("RootUri") == null) ||\r
-        configuration.getString("RootUri").equals("")) {\r
-      configuration.setProperty("RootUri", req.getContextPath());\r
-    }\r
-\r
-    configuration.addProperty("ServletName", getServletName());\r
-\r
-    //*** test\r
-    // Log.info(this, "blalalala");\r
-    session = req.getSession(true);\r
-    userEntity = (EntityUsers) session.getAttribute("login.uid");\r
-\r
-    if (req.getServerPort() == 443) {\r
-      http = "https";\r
-    } else {\r
-      http = "http";\r
-    }\r
-\r
-    //make sure client browsers don't cache anything\r
-    setNoCaching(res);\r
-\r
-    //FIXME: this seems kind of hackish and only here because we can have\r
-    // default other than the one that the browser is set to.\r
-    Locale locale = new Locale(getDefaultLanguage(req), "");\r
-    MessageResources messageResources =\r
-      MessageResources.getMessageResources("bundles.admin");\r
-    String htmlcharset = messageResources.getMessage(locale, "htmlcharset");\r
-\r
-    res.setContentType("text/html; charset=" + htmlcharset);\r
-\r
-    String moduleName = req.getParameter("module");\r
-    checkLanguage(session, req);\r
-\r
-    /** @todo for cleanup and readability this should be moved to\r
-     *  method loginIfNecessary() */\r
-    if ((moduleName != null) && moduleName.equals("direct")) {\r
-      //...\r
-    }\r
-\r
-    // Authentication\r
-    if (((moduleName != null) && moduleName.equals("login")) ||\r
-        (userEntity == null)) {\r
-      String user = req.getParameter("login");\r
-      String passwd = req.getParameter("password");\r
-      logger.debug("--login: evaluating for user: " + user);\r
-      userEntity = allowedUser(user, passwd);\r
-\r
-      if (userEntity == null) {\r
-        // login failed: redirecting to login\r
-        logger.warn("--login: failed!");\r
-        _sendLoginPage(res, req, res.getWriter());\r
-\r
-        return;\r
-      } else if ((moduleName != null) && moduleName.equals("login")) {\r
-        // login successful\r
-        logger.info("--login: successful! setting uid: " + userEntity.getId());\r
-        session.setAttribute("login.uid", userEntity);\r
-        logger.debug("--login: trying to retrieve login.target");\r
-\r
-        String target = (String) session.getAttribute("login.target");\r
-\r
-        if (target != null) {\r
-          logger.debug("Redirect: " + target);\r
-\r
-          int serverPort = req.getServerPort();\r
-          String redirect = "";\r
-          String redirectString = "";\r
-\r
-          if (serverPort == 80) {\r
-            redirect =\r
-              res.encodeURL(http + "://" + req.getServerName() + target);\r
-            redirectString =\r
-              "<html><head><meta http-equiv=refresh content=\"1;URL=" +\r
-              redirect + "\"></head><body>going <a href=\"" + redirect +\r
-              "\">Mir</a></body></html>";\r
-          } else {\r
-            redirect =\r
-              res.encodeURL(http + "://" + req.getServerName() + ":" +\r
-                req.getServerPort() + target);\r
-            redirectString =\r
-              "<html><head><meta http-equiv=refresh content=\"1;URL=" +\r
-              redirect + "\"></head><body>going <a href=\"" + redirect +\r
-              "\">Mir</a></body></html>";\r
-          }\r
-\r
-          res.getWriter().println(redirectString);\r
-\r
-          //res.sendRedirect(redirect);\r
-        } else {\r
-          // redirecting to default target\r
-          logger.debug("--login: no target - redirecting to default");\r
-          _sendStartPage(res, req, res.getWriter(), userEntity);\r
-        }\r
-\r
-        return;\r
-      }\r
-       // if login succesful\r
-    }\r
-     // if login\r
-\r
-    if ((moduleName != null) && moduleName.equals("logout")) {\r
-      logger.info("--logout");\r
-      session.invalidate();\r
-\r
-      //session = req.getSession(true);\r
-      //checkLanguage(session, req);\r
-      _sendLoginPage(res, req, res.getWriter());\r
-\r
-      return;\r
-    }\r
-\r
-    // Check if authed!\r
-    if (userEntity == null) {\r
-      // redirect to loginpage\r
-      String redirectString = req.getRequestURI();\r
-      String queryString = req.getQueryString();\r
-\r
-      if ((queryString != null) && !queryString.equals("")) {\r
-        redirectString += ("?" + req.getQueryString());\r
-        logger.debug("STORING: " + redirectString);\r
-        session.setAttribute("login.target", redirectString);\r
-      }\r
-\r
-      _sendLoginPage(res, req, res.getWriter());\r
-\r
-      return;\r
-    }\r
-\r
-    // If no module is specified goto standard startpage\r
-    if ((moduleName == null) || moduleName.equals("")) {\r
-      logger.debug("no module: redirect to standardpage");\r
-      _sendStartPage(res, req, res.getWriter(), userEntity);\r
-\r
-      return;\r
-    }\r
-\r
-    // end of auth\r
-    // From now on regular dispatching...\r
-    try {\r
-      // get servletmodule by parameter and continue with dispacher\r
-      ServletModule smod = getServletModuleForName(moduleName);\r
-      ServletModuleDispatch.dispatch(smod, req, res);\r
-    } catch (ServletModuleException e) {\r
-      handleError(req, res, res.getWriter(),\r
-        "ServletException in Module " + moduleName + " -- " + e.getMessage());\r
-    } catch (ServletModuleUserException e) {\r
-      handleUserError(req, res, res.getWriter(), e.getMessage());\r
-    }\r
-\r
-    // timing...\r
-    sessionConnectTime = System.currentTimeMillis() - startTime;\r
-    logger.info("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms");\r
-  }\r
-\r
-  /**\r
-   *  Private method getServletModuleForName returns ServletModule\r
-   *  from Cache\r
-   *\r
-   * @param moduleName\r
-   * @return ServletModule\r
-   *\r
-   */\r
-  private static ServletModule getServletModuleForName(String moduleName)\r
-    throws ServletModuleException {\r
-    // Instance in Map ?\r
-    if (!servletModuleInstanceHash.containsKey(moduleName)) {\r
-      // was not found in hash...\r
-      try {\r
-        Class theServletModuleClass = null;\r
-\r
-        try {\r
-          // first we try to get ServletModule from stern.che3.servlet\r
-          theServletModuleClass =\r
-            Class.forName("mircoders.servlet.ServletModule" + moduleName);\r
-        } catch (ClassNotFoundException e) {\r
-          // on failure, we try to get it from lib-layer\r
-          theServletModuleClass =\r
-            Class.forName("mir.servlet.ServletModule" + moduleName);\r
-        }\r
-\r
-        Method m = theServletModuleClass.getMethod("getInstance", null);\r
-        ServletModule smod = (ServletModule) m.invoke(null, null);\r
-\r
-        // we put it into map for further reference\r
-        servletModuleInstanceHash.put(moduleName, smod);\r
-\r
-        return smod;\r
-      } catch (Exception e) {\r
-        throw new ServletModuleException("*** error resolving classname for " +\r
-          moduleName + " -- " + e.getMessage());\r
-      }\r
-    } else {\r
-      return (ServletModule) servletModuleInstanceHash.get(moduleName);\r
-    }\r
-  }\r
-\r
-  private void handleError(HttpServletRequest req, HttpServletResponse res,\r
-    PrintWriter out, String errorString) {\r
-    try {\r
-      logger.error(errorString);\r
-\r
-      SimpleHash modelRoot = new SimpleHash();\r
-      modelRoot.put("errorstring", new SimpleScalar(errorString));\r
-      modelRoot.put("date",\r
-        new SimpleScalar(StringUtil.date2readableDateTime(\r
-            new GregorianCalendar())));\r
-      HTMLTemplateProcessor.process(res,\r
-        MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"),\r
-        modelRoot, out, getLocale(req));\r
-      out.close();\r
-    }\r
-    catch (Exception e) {\r
-      logger.error("Error in ErrorTemplate: " + e.getMessage());\r
-      e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
-    }\r
-  }\r
-\r
-  private void handleUserError(HttpServletRequest req, HttpServletResponse res,\r
-    PrintWriter out, String errorString) {\r
-    try {\r
-      logger.error(errorString);\r
-\r
-      SimpleHash modelRoot = new SimpleHash();\r
-      modelRoot.put("errorstring", new SimpleScalar(errorString));\r
-      modelRoot.put("date",\r
-        new SimpleScalar(StringUtil.date2readableDateTime(\r
-            new GregorianCalendar())));\r
-      HTMLTemplateProcessor.process(res,\r
-        MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"),\r
-        modelRoot, out, getLocale(req));\r
-      out.close();\r
-    }\r
-    catch (Exception e) {\r
-      logger.error("Error in UserErrorTemplate");\r
-    }\r
-  }\r
-\r
-  /**\r
-   *  evaluate login for user / password\r
-   */\r
-  protected EntityUsers allowedUser(String user, String password) {\r
-    try {\r
-      if (usersModule == null) {\r
-        usersModule = new ModuleUsers(DatabaseUsers.getInstance());\r
-      }\r
-\r
-      return usersModule.getUserForLogin(user, password);\r
-    } catch (Exception e) {\r
-      logger.debug(e.getMessage());\r
-      e.printStackTrace();\r
-\r
-      return null;\r
-    }\r
-  }\r
-\r
-  // Redirect-methods\r
-  private void _sendLoginPage(HttpServletResponse res, HttpServletRequest req,\r
-    PrintWriter out) {\r
-    String loginTemplate = configuration.getString("Mir.LoginTemplate");\r
-    String sessionUrl = res.encodeURL("");\r
-\r
-    try {\r
-      SimpleHash mergeData = new SimpleHash();\r
-      SimpleList languages = new SimpleList();\r
-\r
-      mergeData.put("session", sessionUrl);\r
-\r
-      mergeData.put("defaultlanguage", getDefaultLanguage(req));\r
-      mergeData.put("languages", getLoginLanguages());\r
-\r
-      HTMLTemplateProcessor.process(res, loginTemplate, mergeData, out,\r
-        getLocale(req));\r
-    } catch (Throwable e) {\r
-      handleError(req, res, out, "Error sending login page: " + e.getMessage());\r
-    }\r
-  }\r
-\r
-  private void _sendStartPage(HttpServletResponse res, HttpServletRequest req,\r
-    PrintWriter out, EntityUsers userEntity) {\r
-    String startTemplate = "templates/admin/start_admin.template";\r
-    String sessionUrl = res.encodeURL("");\r
-\r
-    try {\r
-      // merge with logged in user and messages\r
-      SimpleHash mergeData = new SimpleHash();\r
-      mergeData.put("session", sessionUrl);\r
-      mergeData.put("login_user", userEntity);\r
-\r
-      if (messageModule == null) {\r
-        messageModule = new ModuleMessage(DatabaseMessages.getInstance());\r
-      }\r
-\r
-      mergeData.put("messages",\r
-        messageModule.getByWhereClause(null, "webdb_create desc", 0, 10));\r
-\r
-      mergeData.put("articletypes",\r
-        DatabaseArticleType.getInstance().selectByWhereClause("", "id", 0, 20));\r
-\r
-      HTMLTemplateProcessor.process(res, startTemplate, mergeData, out,\r
-        getLocale(req));\r
-    }\r
-    catch (Exception e) {\r
-      e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
-      handleError(req, res, out, "error while trying to send startpage. " + e.getMessage());\r
-    }\r
-  }\r
-\r
-  public String getServletInfo() {\r
-    return "Mir " + configuration.getString("Mir.Version");\r
-  }\r
-\r
-  private void checkLanguage(HttpSession session, HttpServletRequest req) {\r
-    // a lang parameter always sets the language\r
-    String lang = req.getParameter("language");\r
-\r
-    if (lang != null) {\r
-      logger.info("selected language " + lang + " overrides accept-language");\r
-      setLanguage(session, lang);\r
-      setLocale(session, new Locale(lang, ""));\r
-    }\r
-    // otherwise store language from accept header in session\r
-    else if (session.getAttribute("Language") == null) {\r
-      logger.info("accept-language is " + req.getLocale().getLanguage());\r
-      setLanguage(session, req.getLocale().getLanguage());\r
-      setLocale(session, req.getLocale());\r
-    }\r
-  }\r
-}\r
index 8235d74..ca0377c 100755 (executable)
@@ -44,8 +44,11 @@ import mir.misc.HTMLTemplateProcessor;
 import mir.misc.StringUtil;
 import mir.servlet.AbstractServlet;
 import mir.servlet.ServletModuleDispatch;
-import mir.servlet.ServletModuleException;
-import mir.servlet.ServletModuleUserException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleUserExc;
+import mir.servlet.ServletModuleFailure;
+import mir.util.ExceptionFunctions;
+
 import mircoders.servlet.ServletModuleOpenIndy;
 import freemarker.template.SimpleHash;
 import freemarker.template.SimpleScalar;
@@ -54,71 +57,69 @@ 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.21 2003/03/05 19:23:14 idfx Exp $
+ *  @version $Id: OpenMir.java,v 1.22 2003/03/06 05:40:38 zapata Exp $
  *
  */
 
 
 public class OpenMir extends AbstractServlet {
-
-  //private static boolean                confed=false;
   private static String lang;
   public HttpSession session;
 
-  public void doGet(HttpServletRequest req, HttpServletResponse res)
-    throws ServletException, IOException {
-    doPost(req,res);
+  public void doGet(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletException, IOException {
+    doPost(aRequest,aResponse);
   }
 
-  public void doPost(HttpServletRequest req, HttpServletResponse res)
-    throws ServletException, IOException {
-
+  public void doPost(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletException, IOException {
     long startTime = System.currentTimeMillis();
     long sessionConnectTime=0;
 
-    session = req.getSession();
+    session = aRequest.getSession();
 
     if(session.getAttribute("Language")==null){
-      if (req.getParameter("language")!=null) {
-        setLanguage(session, req.getParameter("language"));
+      if (aRequest.getParameter("language")!=null) {
+        setLanguage(session, aRequest.getParameter("language"));
       }
       else {
-        setLanguage(session, getAcceptLanguage(req));
+        setLanguage(session, getAcceptLanguage(aRequest));
       }
     }
 
-    if (req.getParameter("language")!=null)
-      setLocale(session, new Locale(req.getParameter("language"), "") );
+    if (session.getAttribute("language")!=null)
+      setLocale(session, new Locale((String) session.getAttribute("language"), "") );
 
     //make sure client browsers don't cache anything
-    setNoCaching(res);
+    setNoCaching(aResponse);
+
+    aResponse.setContentType("text/html");
+    //aResponse.setContentType("text/html; charset="+MirPropertiesConfiguration.instance().getString("Mir.DefaultHTMLCharset"));
 
-    res.setContentType("text/html");
-    //res.setContentType("text/html; charset="+MirPropertiesConfiguration.instance().getString("Mir.DefaultHTMLCharset"));
     try {
-      ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
+      ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(), aRequest, aResponse);
     }
-    catch (ServletModuleUserException e) {
-      handleUserError(req,res,res.getWriter(), e.getMessage());
-    }
-    catch (ServletModuleException e){
-      e.printStackTrace();
-      handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.getMessage());
+    catch (Throwable e) {
+      Throwable cause = ExceptionFunctions.traceCauseException(e);
+
+      if (cause instanceof ServletModuleUserExc)
+        handleUserError(aRequest, aResponse, aResponse.getWriter(), (ServletModuleUserExc) cause);
+      else
+        handleError(aRequest, aResponse, aResponse.getWriter(), cause);
+
     }
-    // timing...
+
     sessionConnectTime = System.currentTimeMillis() - startTime;
     logger.debug("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
   }
 
-  private void handleUserError(HttpServletRequest req, HttpServletResponse res,
-                               PrintWriter out, String errorString) {
+  private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse,
+                               PrintWriter out, Throwable anException) {
     try {
-      logger.error(errorString);
+      logger.info("user error: " + anException.getMessage());
       SimpleHash modelRoot = new SimpleHash();
-      modelRoot.put("errorstring", new SimpleScalar(errorString));
+      modelRoot.put("errorstring", new SimpleScalar(anException.getMessage()));
       modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
-      HTMLTemplateProcessor.process(res,MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"),
-                                    modelRoot, out, req.getLocale() );
+      HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"),
+                                    modelRoot, out, aRequest.getLocale() );
       out.close();
     }
     catch (Exception e) {
@@ -127,16 +128,16 @@ public class OpenMir extends AbstractServlet {
 
   }
 
-  private void handleError(HttpServletRequest req, HttpServletResponse res,PrintWriter out, String errorString) {
+  private void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) {
 
     try {
-      logger.error(errorString);
+      logger.error("error: " + anException);
       SimpleHash modelRoot = new SimpleHash();
-      modelRoot.put("errorstring", new SimpleScalar(errorString));
+      modelRoot.put("errorstring", new SimpleScalar(anException.getMessage()));
       modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(
                                                new GregorianCalendar())));
-      HTMLTemplateProcessor.process(res,MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"),
-                                    modelRoot,out, req.getLocale());
+      HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"),
+                                    modelRoot,out, aRequest.getLocale());
       out.close();
     }
     catch (Exception e) {
index 62cabf0..0b5d417 100755 (executable)
@@ -253,9 +253,30 @@ HTMLTemplateProcessor.Dir=
 # also used for the HTML charset meta tag.
 Mir.DefaultEncoding=UTF8
 
+
+
+#
+# config used for OpenIndy
+ServletModule.OpenIndy.CommentTemplate=etc/open/comment.template
+ServletModule.OpenIndy.CommentDoneTemplate=etc/open/comment_done.template
+ServletModule.OpenIndy.CommentDupeTemplate=etc/open/comment_dupe.template
+ServletModule.OpenIndy.PostingTemplate=etc/open/posting.template
+ServletModule.OpenIndy.PostingDoneTemplate=etc/open/posting_done.template
+ServletModule.OpenIndy.PostingDupeTemplate=etc/open/posting_dupe.template
+ServletModule.OpenIndy.SearchResultsTemplate=etc/open/search_results.template
+ServletModule.OpenIndy.PrepareMailTemplate=etc/open/prepare_mail.template
+ServletModule.OpenIndy.SentMailTemplate=etc/open/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
+
+
+
+Mir.LoginTemplate=templates/admin/login.template
+
 Mir.ErrorTemplate=templates/error.template
 Mir.UserErrorTemplate=templates/usererror.template
-Mir.LoginTemplate=templates/admin/login.template
 
 ServletModule.Schwerpunkt.ConfirmTemplate=templates/admin/confirm.template
 ServletModule.Schwerpunkt.ObjektTemplate=templates/admin/feature.template
@@ -302,20 +323,6 @@ ServletModule.Mediafolder.ObjektTemplate=templates/admin/mediafolder.template
 ServletModule.Mediafolder.ListTemplate=templates/admin/mediafolderlist.template
 
 #
-# 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.SearchResultsTemplate=etc/open/search_results.template
-ServletModule.OpenIndy.PrepareMailTemplate=etc/open/prepare_mail.template
-ServletModule.OpenIndy.SentMailTemplate=etc/open/sent_mail.template
-ServletModule.OpenIndy.EmailIsFrom=mailer@somewhere.org
-ServletModule.OpenIndy.SMTPServer=localhost
-
-#
 # config for ServletModuleComment - browsing/editing/deleting comments
 ServletModule.Comment.ConfirmTemplate=templates/admin/confirm.template
 ServletModule.Comment.ObjektTemplate=templates/admin/comment.template
index 4d2775b..2e39bfb 100755 (executable)
@@ -53,16 +53,16 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
   private static ServletContext context;
   private static String contextPath;
 
-  //if one of these properties is not present a new 
+  //if one of these properties is not present a new
   //property is added with its default value;
   private  static NeededProperty[] neededWithValue =
   {
-       new NeededProperty("Producer.DocRoot",""),
-               new NeededProperty("Producer.ImageRoot",""),
-               new NeededProperty("Producer.Image.Path",""),
-               new NeededProperty("Producer.Media.Path",""),
-               new NeededProperty("Producer.RealMedia.Path",""),
-               new NeededProperty("Producer.Image.IconPath","")
+        new NeededProperty("Producer.DocRoot",""),
+                new NeededProperty("Producer.ImageRoot",""),
+                new NeededProperty("Producer.Image.Path",""),
+                new NeededProperty("Producer.Media.Path",""),
+                new NeededProperty("Producer.RealMedia.Path",""),
+                new NeededProperty("Producer.Image.IconPath","")
   };
 
   /**
@@ -110,10 +110,10 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     return context;
   }
 
-       /**
-        * Returns all properties in a Map
-        * @return Map
-        */
+        /**
+         * Returns all properties in a Map
+         * @return Map
+         */
   public Map allSettings() {
     Iterator iterator = this.getKeys();
     Map returnMap = new HashMap();
@@ -153,11 +153,11 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
    * Checks if one property is missing and adds a default value
    */
   private void checkMissing() {
-               for (int i = 0; i < neededWithValue.length; i++) {
-                       if (super.getProperty(neededWithValue[i].getKey()) == null) {
-                               addProperty(neededWithValue[i].getKey(), neededWithValue[i].getValue());
-                       }
-               }
+                for (int i = 0; i < neededWithValue.length; i++) {
+                        if (super.getProperty(neededWithValue[i].getKey()) == null) {
+                                addProperty(neededWithValue[i].getKey(), neededWithValue[i].getValue());
+                        }
+                }
   }
 
   public File getFile(String key) throws FileNotFoundException {
@@ -217,28 +217,28 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     public PropertiesConfigFailure(String msg, Throwable cause) {
       super(msg, cause);
     }
-    
+
   }
-  
-       /**
-        * A Class for properties to be checked
-        * @author idefix
-        */
-       private static class NeededProperty {
-               private String _key;
-               private String _value;
-       
-               public NeededProperty(String key, String value) {
-                       _key = key;
-                       _value = value;
-               }
-               
-               public String getKey() {
-                       return _key;
-               }
-               
-               public String getValue() {
-                       return _value;
-               }
-       }
+
+        /**
+         * A Class for properties to be checked
+         * @author idefix
+         */
+        private static class NeededProperty {
+                private String _key;
+                private String _value;
+
+                public NeededProperty(String key, String value) {
+                        _key = key;
+                        _value = value;
+                }
+
+                public String getKey() {
+                        return _key;
+                }
+
+                public String getValue() {
+                        return _value;
+                }
+        }
 }
diff --git a/source/mir/misc/XmlStyler.java b/source/mir/misc/XmlStyler.java
deleted file mode 100755 (executable)
index ff5f000..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.misc;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.xml.sax.SAXException;
-
-/**
- * Title:        XmLStyler
- * Description:
- * Copyright:    Copyright (c) 2001
- * Company:      Indymedia
- * @author       idfx
- * @version 1.0
- */
-
-public interface XmlStyler {
-
-  void style( String styleKey, InputStream is, OutputStream os )
-    throws SAXException;
-
-}
\ No newline at end of file
index 4435521..281118d 100755 (executable)
-/*
- * 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.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.22 2003/02/20 16:05:33 zapata Exp $
- */
-
-public abstract class AbstractServlet extends HttpServlet {
-    protected static String lang;
-    protected LoggerWrapper logger;
-    protected MirPropertiesConfiguration configuration;
-
-  /**
-   * Constructor for AbstractServlet.
-   */
-  public AbstractServlet() {
-    super();
-    logger = new LoggerWrapper("Servlet");
-  }
-
-    protected void setNoCaching(HttpServletResponse res) {
-      //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
-      res.setHeader("Pragma", "no-cache");
-      res.setDateHeader("Expires", 0);
-      res.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 req, HttpSession session) {
-        String lang = (String) session.getAttribute("Language");
-        if (lang == null || lang.equals("")) {
-            return getAcceptLanguage(req);
-        }
-        else {
-            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 req) {
-        Locale loc=null;
-        HttpSession session = req.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 = req.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 req) {
-        Locale loc = req.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);
-    }
-  }
-
-}
+/*\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.util.Locale;\r
+\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 mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.DatabaseAdaptor;\r
+\r
+import com.codestudio.util.JDBCPool;\r
+import com.codestudio.util.JDBCPoolMetaData;\r
+import com.codestudio.util.SQLManager;\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.23 2003/03/06 05:40:39 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
+    session.setAttribute("Language", language);\r
+  }\r
+\r
+  protected void setLocale(HttpSession session, Locale loc) {\r
+    session.setAttribute("Locale", loc);\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
+    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
+    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
index 1e9185d..76bb151 100755 (executable)
@@ -76,7 +76,7 @@ public abstract class ServletModule {
 \r
   public String defaultAction;\r
   protected LoggerWrapper logger;\r
-        protected MirPropertiesConfiguration configuration;\r
+  protected MirPropertiesConfiguration configuration;\r
   protected AbstractModule mainModule;\r
   protected String templateListString;\r
   protected String templateObjektString;\r
@@ -138,12 +138,12 @@ public abstract class ServletModule {
     return loc;\r
   }\r
 \r
-  public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleException {\r
+  public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {\r
     try {\r
       aResponse.sendRedirect(MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?"+aQuery);\r
     }\r
     catch (Throwable t) {\r
-      throw new ServletModuleException(t.getMessage());\r
+      throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);\r
     }\r
   }\r
 \r
@@ -156,7 +156,7 @@ public abstract class ServletModule {
    * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
    */\r
   public void list(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
     try {\r
       EntityList theList;\r
       String offsetParam = req.getParameter("offset");\r
@@ -179,8 +179,8 @@ public abstract class ServletModule {
 \r
       HTMLTemplateProcessor.process(res, templateListString, theList, out, getLocale(req));\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -192,15 +192,15 @@ public abstract class ServletModule {
    * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
    */\r
   public void add(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
 \r
     try {\r
       SimpleHash mergeData = new SimpleHash();\r
       mergeData.put("new", "1");\r
       deliver(req, res, mergeData, templateObjektString);\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -214,7 +214,7 @@ public abstract class ServletModule {
    * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
    */\r
   public void insert(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
       Map withValues = getIntersectingValues(req, mainModule.getStorageObject());\r
       logger.debug("--trying to add...");\r
@@ -222,8 +222,8 @@ public abstract class ServletModule {
       logger.debug("--trying to deliver..." + id);\r
       list(req, res);\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -232,12 +232,13 @@ public abstract class ServletModule {
    *\r
    */\r
 \r
-  public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException, ServletModuleUserException {\r
+  public void delete(HttpServletRequest req, HttpServletResponse res)\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
       String idParam = req.getParameter("id");\r
 \r
       if (idParam == null)\r
-        throw new ServletModuleException("Invalid call to delete: no id supplied");\r
+        throw new ServletModuleExc("Invalid call to delete: no id supplied");\r
 \r
       String confirmParam = req.getParameter("confirm");\r
       String cancelParam = req.getParameter("cancel");\r
@@ -273,8 +274,8 @@ public abstract class ServletModule {
         }\r
       }\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -287,7 +288,7 @@ public abstract class ServletModule {
    * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
    */\r
   public void edit(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     edit(req, res, req.getParameter("id"));\r
   }\r
 \r
@@ -300,12 +301,12 @@ public abstract class ServletModule {
    * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
    */\r
   public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse, String anIdentifier)\r
-      throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
       deliver(aRequest, aResponse, mainModule.getById(anIdentifier), templateObjektString);\r
     }\r
-    catch (ModuleException e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -319,7 +320,7 @@ public abstract class ServletModule {
    */\r
 \r
   public void update(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
       String idParam = req.getParameter("id");\r
       Map withValues = getIntersectingValues(req, mainModule.getStorageObject());\r
@@ -335,8 +336,8 @@ public abstract class ServletModule {
         edit(req, res);\r
       }\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -351,11 +352,11 @@ public abstract class ServletModule {
    * @param tmpl Name des Templates\r
    * @exception ServletModuleException\r
    */\r
-  public void deliver(HttpServletRequest req, HttpServletResponse res,\r
-                      TemplateModelRoot rtm, TemplateModelRoot popups,\r
-                      String templateFilename)\r
-      throws ServletModuleException {\r
-    if (rtm == null) rtm = new SimpleHash();\r
+  public void deliver(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm,\r
+         TemplateModelRoot popups, String templateFilename) throws ServletModuleFailure  {\r
+    if (rtm == null)\r
+      rtm = new SimpleHash();\r
+\r
     try {\r
       PrintWriter out = res.getWriter();\r
       HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out, getLocale(req));\r
@@ -366,10 +367,8 @@ public abstract class ServletModule {
       // (br1)\r
       out.close();\r
     }\r
-    catch (HTMLParseException e) {\r
-      throw new ServletModuleException(e.getMessage());\r
-    } catch (IOException e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -386,8 +385,7 @@ public abstract class ServletModule {
    * @exception ServletModuleException\r
    */\r
   public void deliver(HttpServletRequest req, HttpServletResponse res,\r
-                      TemplateModelRoot rtm, String templateFilename)\r
-      throws ServletModuleException {\r
+        TemplateModelRoot rtm, String templateFilename) throws ServletModuleFailure {\r
     deliver(req, res, rtm, null, templateFilename);\r
   }\r
 \r
@@ -404,7 +402,7 @@ public abstract class ServletModule {
    */\r
   public void deliver_compressed(HttpServletRequest req, HttpServletResponse res,\r
                                  TemplateModelRoot rtm, String templateFilename)\r
-      throws ServletModuleException {\r
+      throws ServletModuleFailure {\r
     if (rtm == null) rtm = new SimpleHash();\r
     try {\r
       PrintWriter out = new LineFilterWriter(res.getWriter());\r
@@ -412,11 +410,8 @@ public abstract class ServletModule {
       HTMLTemplateProcessor.process(res, templateFilename, rtm, out, getLocale(req));\r
       out.close();\r
     }\r
-    catch (HTMLParseException e) {\r
-      throw new ServletModuleException(e.getMessage());\r
-    }\r
-    catch (IOException e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -433,8 +428,14 @@ public abstract class ServletModule {
    */\r
   private void deliver(HttpServletResponse res, HttpServletRequest req, PrintWriter out,\r
                        TemplateModelRoot rtm, String templateFilename)\r
-      throws HTMLParseException {\r
-    HTMLTemplateProcessor.process(res, templateFilename, rtm, out, getLocale(req));\r
+      throws ServletModuleFailure {\r
+    try {\r
+      HTMLTemplateProcessor.process(res, templateFilename, rtm, out,\r
+                                    getLocale(req));\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
   }\r
 \r
   /**\r
@@ -449,22 +450,13 @@ public abstract class ServletModule {
   }\r
 \r
   /**\r
-   *  Hier kann vor der Datenaufbereitung schon mal ein response geschickt\r
-   *  werden (um das subjektive Antwortverhalten bei langsamen Verbindungen\r
-   *  zu verbessern).\r
-   */\r
-  public void predeliver(HttpServletRequest req, HttpServletResponse res) {\r
-    ;\r
-  }\r
-\r
-  /**\r
    * Gets the fields from a httprequest and matches them with the metadata from\r
    * the storage object. Returns the keys that match, with their values.\r
    *\r
    * @return Map with the values\r
    */\r
   public Map getIntersectingValues(HttpServletRequest req, StorageObject theStorage)\r
-      throws ServletModuleException {\r
+      throws ServletModuleExc, ServletModuleFailure {\r
 \r
     try {\r
       HTTPRequestParser parser;\r
@@ -499,8 +491,8 @@ public abstract class ServletModule {
     }\r
     catch (Throwable e) {\r
       e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
-      throw new ServletModuleException(\r
-          "ServletModule.getIntersectingValues: " + e.getMessage());\r
+\r
+      throw new ServletModuleFailure( "ServletModule.getIntersectingValues: " + e.getMessage(), e);\r
     }\r
   }\r
 \r
index 0c9d2c8..1c58dd9 100755 (executable)
@@ -44,7 +44,7 @@ import mir.log.LoggerWrapper;
  * Dispatcher, calls the method passed to ServletModule Class, through the "do"
  * Parameter (via POST or GET)
  *
- * @version $Id: ServletModuleDispatch.java,v 1.12 2003/01/25 17:45:19 idfx Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.13 2003/03/06 05:40:39 zapata Exp $
  *
  * @Author rk
  *
@@ -76,7 +76,7 @@ public final class ServletModuleDispatch {
          */
 
   public static void dispatch(ServletModule sMod, HttpServletRequest req,
-                              HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+          HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
   {
     //sMod.predeliver(req,res);
 
@@ -86,7 +86,7 @@ public final class ServletModuleDispatch {
       if (sMod.defaultAction() != null)
         doParam = sMod.defaultAction();
       else
-        throw new ServletModuleException("no parameter do supplied!");
+        throw new ServletModuleExc("no parameter do supplied!");
     }
 
     try {
@@ -98,26 +98,21 @@ public final class ServletModuleDispatch {
       else logger.debug("method lookup unsuccesful");
     }
     catch ( NoSuchMethodException e) {
-      throw new ServletModuleException("no such method '"+doParam+"' (" + e.getMessage() + ")");
+      throw new ServletModuleFailure("no such method '"+doParam+"' (" + e.getMessage() + ")", e);
     }
     catch ( SecurityException e) {
-      throw new ServletModuleException("method not allowed!" + e.getMessage());
+      throw new ServletModuleFailure("method not allowed!" + e.getMessage(), e);
     }
     catch ( InvocationTargetException e) {
       logger.debug( "invocation target exception: " + e.getMessage());
-      if (e.getTargetException() instanceof ServletModuleUserException) {
-        throw new ServletModuleUserException(e.getTargetException().getMessage());
-      }
-      else {
-        e.printStackTrace();
-        throw new ServletModuleException(e.getTargetException().getMessage());
-      }
+
+      throw new ServletModuleFailure(e.getTargetException().getMessage(), e.getTargetException());
     }
     catch ( IllegalAccessException e) {
-      throw new ServletModuleException("illegal method not allowed!" + e.getMessage());
+      throw new ServletModuleFailure("illegal method not allowed!" + e.getMessage(), e);
+    }
+    catch (Throwable t) {
+      throw new ServletModuleFailure(t);
     }
-
-//hopefully we don't get here ...
-    throw new ServletModuleException("delivery failed! -- ");
   }
 }
diff --git a/source/mir/servlet/ServletModuleExc.java b/source/mir/servlet/ServletModuleExc.java
new file mode 100755 (executable)
index 0000000..3a4fe89
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 multex.Exc;
+
+public class ServletModuleExc extends Exc {
+  public ServletModuleExc(String aMessage) {
+    super(aMessage);
+  }
+}
diff --git a/source/mir/servlet/ServletModuleException.java b/source/mir/servlet/ServletModuleException.java
deleted file mode 100755 (executable)
index e82d6ba..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*\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
-\r
-/*\r
- *  ServletModuleException -\r
- *  wird vom ServletModule geschmissen</b>\r
- *\r
- *\r
- * @version 28.6.199\r
- * @author RK\r
- */\r
-\r
-public final class ServletModuleException extends Exception\r
-{\r
-  public ServletModuleException(String msg) {\r
-    super(msg);\r
-  }\r
-}\r
-\r
diff --git a/source/mir/servlet/ServletModuleFailure.java b/source/mir/servlet/ServletModuleFailure.java
new file mode 100755 (executable)
index 0000000..c83d391
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 multex.Failure;
+
+public class ServletModuleFailure extends Failure {
+
+  public ServletModuleFailure(String aMessage,Throwable aCause) {
+    super(aMessage, aCause);
+  }
+
+  public ServletModuleFailure(Throwable aCause) {
+    this (aCause.getMessage(), aCause);
+  }
+}
index f001f11..d3d376d 100755 (executable)
-/*
- * 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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import freemarker.template.TemplateModelRoot;
-
-
-/**
- *  Standard ServletModule, dass eine Template anzeigt, und nicht
- *  mit Daten mischt. Damit ist es moeglich, einfache HTML-Seiten
- *  als templates zu benutzen. Damit kann auf einfache Weise die
- *  Funktionalitaet der Freemarker-Bibliothek (beispielsweise Navigationen
- *  per <code>include</code> einzubauen) benutzt werden. Die Templates
- *  werden aus dem per Konfiguration angegebenem template-Verzeichnis
- *  im Ordner "/html" genommen.
- *
- * @author RK
- */
-public class ServletModuleShow extends ServletModule {
-       private static ServletModuleShow instance = new ServletModuleShow();
-
-       /**
-        * Ein ServletModuleShow-Objekt wird ?ber getInstance geliefert. Es gibt zur
-        * Laufzeit nur ein Objekt (Singleton)
-        * @return ServletModuleShow
-        */
-       public static ServletModule getInstance () {
-               return  instance;
-       }
-
-       /**
-        * Initialisierung leer.
-        */
-       private ServletModuleShow () {
-       }
-
-       /**
-        * defaultAction (s.a ServletModule)
-        * @return "show"
-        */
-       public String defaultAction () {
-               return  "show";
-       }
-
-       /**
-        * Standardmethode, die die Funktionalitaet des ServletModules implementiert.
-        *
-        * @param req Http-Request, das vom Dispatcher durchgereicht wird
-        * @param res Http-Response, die vom Dispatcher durchgereicht wird
-        * @return String fuer Logfile
-        * @exception ServletModuleException
-        */
-  public void show(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
-    try {
-      String idParam = req.getParameter("tmpl");
-      if (!(idParam==null || idParam.equals(""))) {
-           deliver(req, res, (TemplateModelRoot)null, "html/"+idParam+".template");
-      }
-      else {
-        throw new ServletModuleException("Falsches template: " + idParam);
-      }
-    }
-    catch (Exception e) {
-      throw new ServletModuleException(e.toString());
-    }
-  }
-
-}
-
-
-
-
+/*\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 javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import freemarker.template.TemplateModelRoot;\r
+\r
+\r
+/**\r
+ *  Standard ServletModule, dass eine Template anzeigt, und nicht\r
+ *  mit Daten mischt. Damit ist es moeglich, einfache HTML-Seiten\r
+ *  als templates zu benutzen. Damit kann auf einfache Weise die\r
+ *  Funktionalitaet der Freemarker-Bibliothek (beispielsweise Navigationen\r
+ *  per <code>include</code> einzubauen) benutzt werden. Die Templates\r
+ *  werden aus dem per Konfiguration angegebenem template-Verzeichnis\r
+ *  im Ordner "/html" genommen.\r
+ *\r
+ * @author RK\r
+ */\r
+public class ServletModuleShow extends ServletModule {\r
+  private static ServletModuleShow instance = new ServletModuleShow();\r
+\r
+  /**\r
+   * Ein ServletModuleShow-Objekt wird ?ber getInstance geliefert. Es gibt zur\r
+   * Laufzeit nur ein Objekt (Singleton)\r
+   * @return ServletModuleShow\r
+   */\r
+  public static ServletModule getInstance() {\r
+    return instance;\r
+  }\r
+\r
+  /**\r
+   * Initialisierung leer.\r
+   */\r
+  private ServletModuleShow() {\r
+  }\r
+\r
+  /**\r
+   * defaultAction (s.a ServletModule)\r
+   * @return "show"\r
+   */\r
+  public String defaultAction() {\r
+    return "show";\r
+  }\r
+\r
+  /**\r
+   * Standardmethode, die die Funktionalitaet des ServletModules implementiert.\r
+   *\r
+   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
+   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
+   * @return String fuer Logfile\r
+   * @exception ServletModuleException\r
+   */\r
+  public void show(HttpServletRequest req, HttpServletResponse res) throws\r
+      ServletModuleExc {\r
+    try {\r
+      String idParam = req.getParameter("tmpl");\r
+      if (! (idParam == null || idParam.equals(""))) {\r
+        deliver(req, res, (TemplateModelRoot)null,\r
+                "html/" + idParam + ".template");\r
+      }\r
+      else {\r
+        throw new ServletModuleExc("Invalid template: " + idParam);\r
+      }\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+}\r
+\r
+\r
+\r
+\r
diff --git a/source/mir/servlet/ServletModuleUserExc.java b/source/mir/servlet/ServletModuleUserExc.java
new file mode 100755 (executable)
index 0000000..5d42ff3
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 multex.Exc;
+
+public class ServletModuleUserExc extends Exc {
+  public ServletModuleUserExc(String aMessage) {
+    super(aMessage);
+  }
+}
diff --git a/source/mir/servlet/ServletModuleUserException.java b/source/mir/servlet/ServletModuleUserException.java
deleted file mode 100755 (executable)
index 5150788..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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;
-
-
-/*
- *  ServletModuleUserException -
- *  Return an Exception with a simple String Message Method
- *  Differentiates user errors from System bugs/errors.
- *
- *
- * @version 02.2002
- * @author mh
- */
-
-public final class ServletModuleUserException extends Exception
-{
-  public ServletModuleUserException(String msg) {
-    super(msg);
-  }
-}
-
diff --git a/source/mir/util/ExceptionFunctions.java b/source/mir/util/ExceptionFunctions.java
new file mode 100755 (executable)
index 0000000..5c06501
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.util;
+
+import multex.Failure;
+import org.xml.sax.SAXException;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ *
+ * <p>Title: ExceptionFunctions </p>
+ * <p>Description: Functions to assist handling and throwing exceptions</p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: Mir coders</p>
+ * @author Zapata
+ * @version 1.0
+ */
+
+public class ExceptionFunctions {
+  private ExceptionFunctions() {
+  }
+
+  /**
+   * Traces an exception to it's root cause, using all known exception types that support
+   *   cause exceptions.
+   *
+   * @param anException
+   * @return the cause (if found)
+   */
+
+  public static Throwable traceCauseException(Throwable anException) {
+    Throwable result = anException;
+
+    while (true) {
+      if ((result instanceof Failure) && (((Failure) result).getCause()!=null)) {
+        result = ((Failure) result).getCause();
+      }
+      else if ((result instanceof SAXException) && (((SAXException) result).getException()!=null)) {
+        result = ((SAXException) result).getException();
+      }
+      else if ((result instanceof InvocationTargetException) && (((InvocationTargetException) result).getTargetException()!=null)) {
+        result = ((InvocationTargetException) result).getTargetException();
+      }
+      else
+        break;
+    }
+
+    return result;
+  }
+}
index 6518e61..66b11cf 100755 (executable)
@@ -64,7 +64,7 @@ import freemarker.template.SimpleList;
  *\r
  * @see mir.media.MirMedia\r
  * @author mh <mh@nadir.org>\r
- * @version $Id: MediaHandlerGeneric.java,v 1.15 2003/03/05 19:23:16 idfx Exp $\r
+ * @version $Id: MediaHandlerGeneric.java,v 1.16 2003/03/06 05:40:39 zapata Exp $\r
  */\r
 \r
 public class MediaHandlerGeneric implements MirMedia\r
@@ -78,8 +78,8 @@ public class MediaHandlerGeneric implements MirMedia
     static {\r
       try {\r
         configuration = MirPropertiesConfiguration.instance();\r
-      } catch (PropertiesConfigExc e) {\r
-        e.printStackTrace();\r
+      }\r
+      catch (PropertiesConfigExc e) {\r
       }\r
       imageHost = configuration.getString("Producer.Image.Host");\r
       imageRoot = configuration.getString("Producer.ImageRoot");\r
index c57a920..3579184 100755 (executable)
@@ -104,7 +104,7 @@ public class ModuleComment extends AbstractModule
     }
     catch (StorageObjectFailure e){
       logger.error("ModuleComment.set: " + e.getMessage());
-      e.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, LoggerWrapper.DEBUG_MESSAGE)));
+      e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));
 
       throw new ModuleException(e.toString());
     } catch (StorageObjectExc e) {
index f647533..74e20ab 100755 (executable)
@@ -165,11 +165,12 @@ public class IndexingProducerNode implements ProducerNode {
       //}
       //theDoc.add(Field.UnStored("comments",commentsAggregate));
       indexWriter.addDocument(theDoc);
-    } catch (Throwable t) {
+    }
+    catch (Throwable t) {
       aLogger.error("Error while indexing content: " + t.getMessage());
-      t.printStackTrace(new PrintWriter(
-          new LoggerToWriterAdapter(aLogger, LoggerWrapper.DEBUG_MESSAGE)));
-    finally {
+      t.printStackTrace(aLogger.asPrintWriter(aLogger.DEBUG_MESSAGE));
+    }
+    finally {
       if (indexWriter != null) {
         try {
           indexWriter.close();
index 6a2b063..82327ee 100755 (executable)
@@ -71,7 +71,7 @@ public class PDFGeneratingProducerNode implements ProducerNode {
 
     }
     catch (Throwable t) {
-      t.printStackTrace();
+      t.printStackTrace(aLogger.asPrintWriter(aLogger.DEBUG_MESSAGE));
       aLogger.error("  error while generating: " + t.getMessage() + t.toString());
     }
     endTime = System.currentTimeMillis();
index 4ceaf84..05ec425 100755 (executable)
@@ -80,13 +80,13 @@ public class UnIndexingProducerNode implements ProducerNode {
       aLogger.info("UnIndexing " + (String) entity.getValue("id") + " out of " + index);
 
       IndexUtil.unindexEntity((EntityContent) entity,index);
-      
+
     }
     catch (Throwable t) {
       aLogger.error("Error while unindexing content: " + t.getMessage());
-      t.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(aLogger, LoggerWrapper.DEBUG_MESSAGE)));
+      t.printStackTrace(aLogger.asPrintWriter(aLogger.DEBUG_MESSAGE));
     }
-    
+
     endTime = System.currentTimeMillis();
 
     aLogger.info("  UnIndexTime: " + (endTime-startTime) + " ms<br>");
index fc9d76c..a294cce 100755 (executable)
@@ -7,10 +7,11 @@ import java.util.Map;
 
 import mir.entity.adapter.EntityIteratorAdapter;
 import mir.generator.Generator;
-import mir.servlet.ServletModuleException;
-import mir.util.CachingRewindableIterator;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.util.NullWriter;
 import mir.util.ResourceBundleGeneratorFunction;
+import mir.util.CachingRewindableIterator;
 import mircoders.global.MirGlobal;
 
 import org.apache.struts.util.MessageResources;
@@ -20,7 +21,7 @@ import org.apache.struts.util.MessageResources;
 public class ServletHelper {
 // ML: add logging!
 
-  static Map makeGenerationData(Locale aLocale) throws ServletModuleException {
+  static Map makeGenerationData(Locale aLocale) throws ServletModuleExc {
     try {
       Map result = new HashMap();
 
@@ -58,11 +59,11 @@ public class ServletHelper {
       return result;
     }
     catch (Throwable t) {
-      throw new ServletModuleException(t.getMessage());
+      throw new ServletModuleFailure(t);
     }
   }
 
-  static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleException {
+  static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {
 
     Generator generator;
 
@@ -72,7 +73,7 @@ public class ServletHelper {
       generator.generate(aWriter, aGenerationData, new PrintWriter(new NullWriter()));
     }
     catch (Throwable t) {
-      throw new ServletModuleException(t.getMessage());
+      throw new ServletModuleFailure(t);
     }
   }
-}
\ No newline at end of file
+}
index 6782909..88b119d 100755 (executable)
@@ -40,7 +40,7 @@ import javax.servlet.http.HttpServletResponse;
 import mir.log.LoggerToWriterAdapter;
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleFailure;
 import mir.util.URLBuilder;
 
 public class ServletModuleAdmin extends ServletModule
@@ -53,10 +53,7 @@ public class ServletModuleAdmin extends ServletModule
     defaultAction = "showSuperUserMenu";
   }
 
-  public void superusermenu(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
-    // ML: experiment in using the producer's generation system instead of the
-    //     old one...
-
+  public void superusermenu(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     URLBuilder urlBuilder = new URLBuilder();
     int count;
 
@@ -70,9 +67,7 @@ public class ServletModuleAdmin extends ServletModule
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, "superusermenu.template");
     }
     catch (Throwable e) {
-      e.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, LoggerWrapper.ERROR_MESSAGE)));
-
-      throw new ServletModuleException(e.getMessage());
+      throw new ServletModuleFailure(e);
     }
   }
 }
index 0ca07cb..0b057a9 100755 (executable)
@@ -43,7 +43,7 @@ import mir.log.LoggerWrapper;
 import mir.misc.HTMLTemplateProcessor;
 import mir.module.ModuleException;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleFailure;
 import mircoders.module.ModuleBreaking;
 import mircoders.storage.DatabaseBreaking;
 import freemarker.template.SimpleHash;
@@ -66,7 +66,7 @@ public class ServletModuleBreaking extends ServletModule
   private ServletModuleBreaking() {
     logger = new LoggerWrapper("ServletModule.Breaking");
     try {
-                       configuration = MirPropertiesConfiguration.instance();
+                        configuration = MirPropertiesConfiguration.instance();
 
       templateListString = configuration.getString("ServletModule.Breaking.ListTemplate");
       templateObjektString = configuration.getString("ServletModule.Breaking.ObjektTemplate");
@@ -81,7 +81,6 @@ public class ServletModuleBreaking extends ServletModule
   }
 
   public void list(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
   {
     logger.debug("-- breaking: list");
 // fetch and deliver
@@ -107,8 +106,8 @@ public class ServletModuleBreaking extends ServletModule
 // raus damit
       HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
     }
-    catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-    catch (IOException e) {throw new ServletModuleException(e.toString());}
-    catch (Exception e) {throw new ServletModuleException(e.toString());}
+    catch (Exception e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 }
index 416a1c6..1e1c652 100755 (executable)
@@ -43,7 +43,8 @@ import mir.entity.adapter.EntityIteratorAdapter;
 import mir.log.LoggerToWriterAdapter;
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.util.CachingRewindableIterator;
 import mir.util.HTTPRequestParser;
 import mir.util.JDBCStringRoutines;
@@ -93,17 +94,17 @@ public class ServletModuleComment extends ServletModule
     }
   }
 
-  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
     String idParam = req.getParameter("id");
 
     if (idParam == null)
-      throw new ServletModuleException("Invalid call: id not supplied ");
+      throw new ServletModuleExc("Invalid call: id not supplied ");
 
     showComment(idParam, req, res);
   }
 
-  public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+  public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
     try {
       SimpleHash extraInfo = new SimpleHash();
       TemplateModelRoot data;
@@ -115,13 +116,13 @@ public class ServletModuleComment extends ServletModule
 
       deliver(aRequest, aResponse, data, extraInfo, templateObjektString);
     }
-    catch (Exception e) {
-      throw new ServletModuleException(e.toString());
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 
 
-  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
   {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
 
@@ -132,7 +133,7 @@ public class ServletModuleComment extends ServletModule
     returnCommentList(aRequest, aResponse, where, order, offset);
   }
 
-  public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException
+  public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
   {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
     SQLQueryBuilder queryBuilder = new SQLQueryBuilder();
@@ -175,7 +176,7 @@ public class ServletModuleComment extends ServletModule
     returnCommentList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);
   }
 
-  public void articlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  public void articlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
     String articleIdString = req.getParameter("articleid");
     int articleId;
@@ -185,16 +186,13 @@ public class ServletModuleComment extends ServletModule
 
       returnCommentList( req, res, "to_media="+articleId, "webdb_create desc", 0);
     }
-    catch (ServletModuleException e) {
-      throw e;
-    }
     catch (Throwable e) {
-      throw new ServletModuleException(e.getMessage());
+      throw new ServletModuleFailure(e);
     }
   }
 
   public void returnCommentList(HttpServletRequest aRequest, HttpServletResponse aResponse,
-     String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleException {
+     String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {
     // ML: experiment in using the producer's generation system instead of the
     //     old one...
 
@@ -258,9 +256,7 @@ public class ServletModuleComment extends ServletModule
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, "commentlist.template");
     }
     catch (Throwable e) {
-      e.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, LoggerWrapper.ERROR_MESSAGE)));
-
-      throw new ServletModuleException(e.getMessage());
+      throw new ServletModuleFailure(e);
     }
   }
 }
index f22923f..0300a58 100755 (executable)
@@ -48,7 +48,9 @@ import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;\r
 import mir.module.ModuleException;\r
 import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleException;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.servlet.ServletModuleFailure;\r
 import mir.storage.StorageObjectFailure;\r
 import mir.util.CachingRewindableIterator;\r
 import mir.util.HTTPRequestParser;\r
@@ -72,7 +74,7 @@ import freemarker.template.SimpleHash;
  *  ServletModuleContent -\r
  *  deliver html for the article admin form.\r
  *\r
- * @version $Id: ServletModuleContent.java,v 1.39 2003/03/05 19:23:16 idfx Exp $\r
+ * @version $Id: ServletModuleContent.java,v 1.40 2003/03/06 05:40:40 zapata Exp $\r
  * @author rk, mir-coders\r
  *\r
  */\r
@@ -101,7 +103,7 @@ public class ServletModuleContent extends ServletModule
     }\r
   }\r
 \r
-  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
 \r
@@ -113,7 +115,7 @@ public class ServletModuleContent extends ServletModule
     returnArticleList(aRequest, aResponse, where, order, offset, selectArticleUrl);\r
   }\r
 \r
-  public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
+  public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleFailure {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
       SQLQueryBuilder queryBuilder = new SQLQueryBuilder();\r
@@ -160,16 +162,16 @@ public class ServletModuleContent extends ServletModule
       returnArticleList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0, selectArticleUrl);\r
     }\r
     catch (Throwable e) {\r
-      throw new ServletModuleException(e.toString());\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {\r
+  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
     _showObject(null, req, res);\r
   }\r
 \r
 \r
-  public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
 //theLog.printDebugInfo(":: content :: trying to insert");\r
     try {\r
@@ -191,20 +193,17 @@ public class ServletModuleContent extends ServletModule
 \r
       _showObject(id, req, res);\r
     }\r
-    catch (StorageObjectFailure e) {\r
-      throw new ServletModuleException(e.toString());\r
-    }\r
-    catch (ModuleException e) {\r
-      throw new ServletModuleException(e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     EntityUsers   user = _getUser(req);\r
 \r
     String idParam = req.getParameter("id");\r
-    if (idParam == null) throw new ServletModuleException("Invalid call: id missing");\r
+    if (idParam == null) throw new ServletModuleExc("Invalid call: id missing");\r
 \r
     String confirmParam = req.getParameter("confirm");\r
     String cancelParam = req.getParameter("cancel");\r
@@ -241,14 +240,8 @@ public class ServletModuleContent extends ServletModule
           }\r
 \r
         }\r
-        catch (ModuleException e) {\r
-          throw new ServletModuleException(e.toString());\r
-        }\r
-        catch (StorageObjectFailure e) {\r
-          throw new ServletModuleException(e.toString());\r
-        }\r
-        catch (IOException e) {\r
-          throw new ServletModuleException(e.toString());\r
+        catch (Throwable e) {\r
+          throw new ServletModuleFailure(e);\r
         }\r
         list(req,res);\r
       }\r
@@ -259,20 +252,20 @@ public class ServletModuleContent extends ServletModule
     }\r
   }\r
 \r
-  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String idParam = req.getParameter("id");\r
     if (idParam == null)\r
-      throw new ServletModuleException("Invalid call: id not supplied ");\r
+      throw new ServletModuleExc("Invalid call: id not supplied ");\r
     _showObject(idParam, req, res);\r
   }\r
 \r
 // methods for attaching media file\r
-  public void attach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void attach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String  mediaIdParam = req.getParameter("mid");\r
     String  idParam = req.getParameter("cid");\r
-    if (idParam == null||mediaIdParam==null) throw new ServletModuleException("smod content :: attach :: cid/mid missing");\r
+    if (idParam == null||mediaIdParam==null) throw new ServletModuleExc("smod content :: attach :: cid/mid missing");\r
 \r
     try {\r
       EntityContent entContent = (EntityContent)mainModule.getById(idParam);\r
@@ -288,12 +281,14 @@ public class ServletModuleContent extends ServletModule
     _showObject(idParam, req, res);\r
   }\r
 \r
-  public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String  cidParam = req.getParameter("cid");\r
     String  midParam = req.getParameter("mid");\r
-    if (cidParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");\r
-    if (midParam == null) throw new ServletModuleException("smod content :: dettach :: mid missing");\r
+    if (cidParam == null)\r
+      throw new ServletModuleExc("smod content :: dettach :: cid missing");\r
+    if (midParam == null)\r
+      throw new ServletModuleExc("smod content :: dettach :: mid missing");\r
 \r
     try {\r
       EntityContent entContent = (EntityContent)mainModule.getById(cidParam);\r
@@ -309,8 +304,7 @@ public class ServletModuleContent extends ServletModule
     _showObject(cidParam, req, res);\r
   }\r
 \r
-  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
-      throws ServletModuleException\r
+  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
@@ -318,7 +312,8 @@ public class ServletModuleContent extends ServletModule
       String returnUrl = requestParser.getParameter("returnurl");\r
 \r
       String idParam = aRequest.getParameter("id");\r
-      if (idParam == null) throw new ServletModuleException("Wrong call: (id) is missing");\r
+      if (idParam == null)\r
+        throw new ServletModuleExc("Wrong call: (id) is missing");\r
 \r
       Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());\r
       String[] topic_id = aRequest.getParameterValues("to_topic");\r
@@ -343,7 +338,7 @@ public class ServletModuleContent extends ServletModule
         _showObject(idParam, aRequest, aResponse);\r
     }\r
     catch (Throwable e) {\r
-      throw new ServletModuleException(e.toString());\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -354,8 +349,7 @@ public class ServletModuleContent extends ServletModule
   * article.\r
 */\r
   public void _showObject(String id, HttpServletRequest aRequest, HttpServletResponse aResponse)\r
-      throws ServletModuleException {\r
-\r
+      throws ServletModuleExc {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
       Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest));\r
@@ -392,8 +386,8 @@ public class ServletModuleContent extends ServletModule
 \r
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
@@ -403,7 +397,7 @@ public class ServletModuleContent extends ServletModule
        String aWhereClause,\r
        String anOrderByClause,\r
        int anOffset,\r
-       String aSelectArticleUrl) throws ServletModuleException {\r
+       String aSelectArticleUrl) throws ServletModuleExc {\r
 \r
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
     URLBuilder urlBuilder = new URLBuilder();\r
@@ -472,11 +466,11 @@ public class ServletModuleContent extends ServletModule
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);\r
     }\r
     catch (Throwable e) {\r
-      throw new ServletModuleException(e.toString());\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
+  public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
@@ -490,27 +484,27 @@ public class ServletModuleContent extends ServletModule
       returnArticleList(aRequest, aResponse, "", "", 0, urlBuilder.getQuery());\r
     }\r
     catch (Throwable e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void listchildren(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
+  public void listchildren(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
       String articleId = requestParser.getParameter("article_id");\r
 \r
       if (articleId == null)\r
-        throw new ServletModuleException("ServletModuleContent.listchildren: article_id not set!");\r
+        throw new ServletModuleExc("ServletModuleContent.listchildren: article_id not set!");\r
 \r
       returnArticleList(aRequest, aResponse, "to_content = " + articleId, "", 0, null);\r
     }\r
     catch (Throwable e) {\r
-      throw new ServletModuleException(e.getMessage());\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void setparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
+  public void setparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
     String articleId = aRequest.getParameter("childid");\r
@@ -525,13 +519,13 @@ public class ServletModuleContent extends ServletModule
     }\r
     catch(Throwable e) {\r
       logger.error("ServletModuleContent.setparent: " + e.getMessage());\r
-      throw new ServletModuleException("ServletModuleContent.setparent: " + e.getMessage());\r
+      throw new ServletModuleFailure(e);\r
     }\r
 \r
     redirect(aResponse, returnUrl);\r
   }\r
 \r
-  public void clearparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
+  public void clearparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
   {\r
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
     String articleId = requestParser.getParameter("id");\r
@@ -547,7 +541,7 @@ public class ServletModuleContent extends ServletModule
       e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
       logger.error("ServletModuleContent.clearparent: " + e.getMessage());\r
 \r
-      throw new ServletModuleException("ServletModuleContent.clearparent: " + e.getMessage());\r
+      throw new ServletModuleFailure("ServletModuleContent.clearparent: " + e.getMessage(), e);\r
     }\r
 \r
     redirect(aResponse, returnUrl);\r
index 97ba55f..c93712e 100755 (executable)
@@ -45,7 +45,8 @@ import mir.log.LoggerWrapper;
 import mir.misc.FileExtFilter;
 import mir.misc.HTMLTemplateProcessor;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import freemarker.template.SimpleHash;
 import freemarker.template.SimpleList;
 
@@ -55,7 +56,7 @@ import freemarker.template.SimpleList;
  *  in the config file.
  *
  * @author $Author: zapata $
- * @version $Revision: 1.5 $ $Date: 2003/02/23 05:00:15 $
+ * @version $Revision: 1.6 $ $Date: 2003/03/06 05:40:40 $
  *
  */
 
@@ -84,8 +85,7 @@ public class ServletModuleFileEdit extends ServletModule
     templateConfirmString =configuration.getString("ServletModule.FileEdit.ConfirmTemplate");
   }
 
-  public void list(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
 // fetch and deliver
     try {
@@ -105,15 +105,15 @@ public class ServletModuleFileEdit extends ServletModule
 
       HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
     }
-    catch (IOException e) {throw new ServletModuleException(e.toString());}
-    catch (Exception e) {throw new ServletModuleException(e.toString());}
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 
-  public void edit(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
     String filename = req.getParameter("filename");
-    if (filename == null) throw new ServletModuleException("No filename specified");
+    if (filename == null) throw new ServletModuleExc("No filename specified");
     try {
 
       File f = new File(_dirName, filename);
@@ -131,16 +131,17 @@ public class ServletModuleFileEdit extends ServletModule
 
 
       deliver(req, res, withValues, null, templateObjektString);
-    } catch (Exception e) {
-      throw new ServletModuleException(e.toString());
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 
-  public void update(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
+  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
     String filename = req.getParameter("filename");
-    if (filename == null) throw new ServletModuleException("No filename specified");
+
+    if (filename == null) throw new ServletModuleExc("No filename specified");
     try {
 
       File f = new File(_dirName, filename);
@@ -154,8 +155,9 @@ public class ServletModuleFileEdit extends ServletModule
       out.close();
 
       edit(req, res);
-    } catch (Exception e) {
-      throw new ServletModuleException(e.toString());
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 }
index 9182107..bae412b 100755 (executable)
@@ -41,7 +41,8 @@ import mir.log.LoggerWrapper;
 import mir.misc.HTMLTemplateProcessor;
 import mir.module.ModuleException;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleContent;
 import mircoders.storage.DatabaseContent;
@@ -74,8 +75,7 @@ public class ServletModuleHidden extends ServletModule
   }
 
 
-  public void list(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
 // determine parameter
     SimpleHash mergeData = new SimpleHash();
@@ -120,8 +120,8 @@ public class ServletModuleHidden extends ServletModule
 // raus damit
       HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
     }
-    catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-    catch (IOException e) {throw new ServletModuleException(e.toString());}
-    catch (Exception e) {throw new ServletModuleException(e.toString());}
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 }
index efb4313..dc740ea 100755 (executable)
@@ -44,7 +44,8 @@ import mir.misc.HTMLParseException;
 import mir.misc.HTMLTemplateProcessor;
 import mir.module.ModuleException;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleLanguage;
 import mircoders.module.ModuleLinksImcs;
@@ -87,8 +88,7 @@ public class ServletModuleLinksImcs extends ServletModule {
     }
   }
 
-  public void add(HttpServletRequest req, HttpServletResponse res)
-          throws ServletModuleException {
+  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
     try {
       SimpleHash modelRoot = new SimpleHash();
       EntityList theParentList;
@@ -110,19 +110,12 @@ public class ServletModuleLinksImcs extends ServletModule {
       }
 
     }
-    catch (ModuleException e) {
-      throw new ServletModuleException(e.toString());
-    }
-    catch (HTMLParseException e) {
-      throw new ServletModuleException(e.toString());
-    }
-    catch (IOException e) {
-      throw new ServletModuleException(e.toString());
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 
-  public void list(HttpServletRequest req, HttpServletResponse res)
-          throws ServletModuleException {
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
     try {
 
       SimpleHash modelRoot = new SimpleHash();
@@ -197,13 +190,13 @@ public class ServletModuleLinksImcs extends ServletModule {
       HTMLTemplateProcessor.process(res, templateListString, modelRoot, res.getWriter(), getLocale(req));
 
     }
-    catch (Exception e) {
-      throw new ServletModuleException(e.toString());
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 
   public void edit(HttpServletRequest req, HttpServletResponse res)
-          throws ServletModuleException {
+          throws ServletModuleExc {
     try {
 
       SimpleHash modelRoot = new SimpleHash();
@@ -223,8 +216,8 @@ public class ServletModuleLinksImcs extends ServletModule {
       deliver(req, res, modelRoot, templateObjektString);
 
     }
-    catch (ModuleException e) {
-      throw new ServletModuleException(e.toString());
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
     }
   }
 
index ce39a6a..6f122b2 100755 (executable)
@@ -40,7 +40,8 @@ import javax.servlet.http.HttpSession;
 import mir.entity.adapter.EntityAdapter;\r
 import mir.log.LoggerWrapper;\r
 import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleException;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
 import mir.util.StringRoutines;\r
 import mircoders.entity.EntityComment;\r
 import mircoders.entity.EntityContent;\r
@@ -71,14 +72,14 @@ public class ServletModuleLocalizer extends ServletModule {
     }\r
   }\r
 \r
-  private EntityAdapter getActiveUser(HttpServletRequest aRequest) throws ServletModuleException {\r
+  private EntityAdapter getActiveUser(HttpServletRequest aRequest) throws ServletModuleExc {\r
     try {\r
       HttpSession session = aRequest.getSession(false);\r
       return MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter\r
           ("user", (EntityUsers) session.getAttribute("login.uid"));\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException("ServletModuleLocalizer.getActiveUser: " + e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure("ServletModuleLocalizer.getActiveUser: " + e.getMessage(), e);\r
     }\r
   }\r
 \r
@@ -103,7 +104,7 @@ public class ServletModuleLocalizer extends ServletModule {
     }\r
   }\r
 \r
-  public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
+  public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
     String commentIdString = aRequest.getParameter("id");\r
     String operationString = aRequest.getParameter("operation");\r
     String returnUrlString = aRequest.getParameter("returnurl");\r
@@ -113,7 +114,7 @@ public class ServletModuleLocalizer extends ServletModule {
     redirect(aResponse, returnUrlString);\r
   }\r
 \r
-  public void commentoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
+  public void commentoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
     String returnUrlString = aRequest.getParameter("returnurl");\r
 \r
     String[] operations = aRequest.getParameterValues("operation");\r
@@ -161,7 +162,7 @@ public class ServletModuleLocalizer extends ServletModule {
     }\r
   }\r
 \r
-  public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
+  public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
     String articleIdString = aRequest.getParameter("articleid");\r
     String operationString = aRequest.getParameter("operation");\r
     String returnUrlString = aRequest.getParameter("returnurl");\r
@@ -170,7 +171,7 @@ public class ServletModuleLocalizer extends ServletModule {
     redirect(aResponse, returnUrlString);\r
   }\r
 \r
-  public void articleoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
+  public void articleoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
     String returnUrlString = aRequest.getParameter("returnurl");\r
 \r
     String[] operations = aRequest.getParameterValues("operation");\r
index 9f7a1f8..022e6be 100755 (executable)
@@ -46,7 +46,6 @@ import javax.servlet.http.HttpServletResponse;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleMediafolder;
 import mircoders.storage.DatabaseMediafolder;
@@ -75,7 +74,7 @@ public class ServletModuleMediafolder extends ServletModule
     }
   }
 
-  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  public void add(HttpServletRequest req, HttpServletResponse res)
   {
     SimpleHash mergeData = new SimpleHash();
     mergeData.put("new", "1");
index 16950c9..fbe12e9 100755 (executable)
@@ -42,7 +42,8 @@ import mir.log.LoggerWrapper;
 import mir.misc.HTMLTemplateProcessor;
 import mir.module.ModuleException;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleMessage;
 import mircoders.storage.DatabaseMessages;
@@ -79,11 +80,12 @@ public class ServletModuleMessage extends ServletModule
     }
     catch (StorageObjectFailure e) {
       logger.error("initialization of ServletModuleMessage failed!: " + e.getMessage());
+
+      throw new ServletModuleFailure(e);
     }
   }
 
-  public void list(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
   {
 // fetch and deliver
     try {
@@ -108,9 +110,9 @@ public class ServletModuleMessage extends ServletModule
       HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
 
     }
-    catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-    catch (IOException e) {throw new ServletModuleException(e.toString());}
-    catch (Exception e) {throw new ServletModuleException(e.toString());}
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 
 
index 55def12..beb854b 100755 (executable)
@@ -67,8 +67,9 @@ import mir.misc.StringUtil;
 import mir.misc.WebdbMultipartRequest;\r
 import mir.module.ModuleException;\r
 import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleException;\r
-import mir.servlet.ServletModuleUserException;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.servlet.ServletModuleFailure;\r
 import mir.storage.StorageObjectFailure;\r
 import mir.util.StringRoutines;\r
 import mircoders.entity.EntityComment;\r
@@ -121,7 +122,7 @@ import freemarker.template.TemplateModelRoot;
  *    open-postings to the newswire\r
  *\r
  * @author mir-coders group\r
- * @version $Id: ServletModuleOpenIndy.java,v 1.62 2003/03/05 19:23:16 idfx Exp $\r
+ * @version $Id: ServletModuleOpenIndy.java,v 1.63 2003/03/06 05:40:40 zapata Exp $\r
  *\r
  */\r
 \r
@@ -177,7 +178,8 @@ public class ServletModuleOpenIndy extends ServletModule
    *  Method for making a comment\r
    */\r
 \r
-  public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void addcomment(HttpServletRequest req, HttpServletResponse res)\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     String aid = req.getParameter("aid"); // the article id the comment will belong to\r
     String language = req.getParameter("language");\r
@@ -208,10 +210,10 @@ public class ServletModuleOpenIndy extends ServletModule
         deliver(req, res, mergeData, extraInfo, commentFormTemplate);\r
       }\r
       catch (Throwable t) {\r
-        throw new ServletModuleException("ServletModuleOpenIndy.addcomment: " + t.getMessage());\r
+        throw new ServletModuleFailure("ServletModuleOpenIndy.addcomment: " + t.getMessage(), t);\r
       }\r
     }\r
-    else throw new ServletModuleException("aid not set!");\r
+    else throw new ServletModuleExc("aid not set!");\r
   }\r
 \r
   /**\r
@@ -220,7 +222,7 @@ public class ServletModuleOpenIndy extends ServletModule
    */\r
 \r
   public void inscomment(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException,ServletModuleUserException\r
+    throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     String aid = req.getParameter("to_media"); // the article id the comment will belong to\r
     if (aid!=null && !aid.equals(""))\r
@@ -244,11 +246,11 @@ public class ServletModuleOpenIndy extends ServletModule
             HttpSession session = req.getSession(false);\r
             String sessionPasswd = (String)session.getAttribute("passwd");\r
             if ( sessionPasswd == null){\r
-              throw new ServletModuleUserException("Lost password");\r
+              throw new ServletModuleUserExc("Lost password");\r
             }\r
             String passwd = req.getParameter("passwd");\r
             if ( passwd == null || (!sessionPasswd.equals(passwd))) {\r
-              throw new ServletModuleUserException("Missing password");\r
+              throw new ServletModuleUserExc("Missing password");\r
             }\r
             session.invalidate();\r
           }\r
@@ -267,7 +269,7 @@ public class ServletModuleOpenIndy extends ServletModule
               MirGlobal.localizer().openPostings().afterCommentPosting(comment);\r
             }\r
             catch (Throwable t) {\r
-              throw new ServletModuleException(t.getMessage());\r
+              throw new ServletModuleExc(t.getMessage());\r
             }\r
           }\r
 \r
@@ -276,11 +278,11 @@ public class ServletModuleOpenIndy extends ServletModule
           SimpleHash mergeData = new SimpleHash();\r
           deliver(req, res, mergeData, commentFormDoneTemplate);\r
         }\r
-        catch (StorageObjectFailure e) { throw new ServletModuleException(e.toString());}\r
-        catch (ModuleException e) { throw new ServletModuleException(e.toString());}\r
-\r
+        catch (Throwable e) {\r
+          throw new ServletModuleFailure(e);\r
+        }\r
       }\r
-    else throw new ServletModuleException("aid not set!");\r
+    else throw new ServletModuleExc("aid not set!");\r
 \r
   }\r
 \r
@@ -289,7 +291,8 @@ public class ServletModuleOpenIndy extends ServletModule
    */\r
 \r
   public void addposting(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
     SimpleHash mergeData = new SimpleHash();\r
 \r
     // onetimepasswd\r
@@ -331,7 +334,8 @@ public class ServletModuleOpenIndy extends ServletModule
     }\r
     catch (Exception e) {\r
       logger.error("languagePopUpData or getTopicslist failed "+e.toString());\r
-      throw new ServletModuleException("OpenIndy -- failed getting language or topics: "+e.toString());\r
+\r
+      throw new ServletModuleFailure("OpenIndy -- failed getting language or topics: "+e.toString(), e);\r
     }\r
 \r
 \r
@@ -345,7 +349,7 @@ public class ServletModuleOpenIndy extends ServletModule
    */\r
 \r
   public void insposting(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException, ServletModuleUserException\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     SimpleHash mergeData = new SimpleHash();\r
     boolean setMedia=false;\r
@@ -362,9 +366,7 @@ public class ServletModuleOpenIndy extends ServletModule
         mediaList = mediaReq.getEntityList();\r
       }\r
       catch (FileHandlerUserException e) {\r
-        throw new ServletModuleUserException(e.getMessage());\r
-      } catch (PropertiesConfigExc e) {\r
-        throw new ServletModuleUserException(e.getMessage());\r
+        throw new ServletModuleFailure(e);\r
       }\r
 \r
       Map withValues = mp.getParameters();\r
@@ -374,11 +376,11 @@ public class ServletModuleOpenIndy extends ServletModule
         HttpSession session = req.getSession(false);\r
         String sessionPasswd = (String)session.getAttribute("passwd");\r
         if ( sessionPasswd == null){\r
-          throw new ServletModuleUserException("Lost password");\r
+          throw new ServletModuleUserExc("Lost password");\r
         }\r
         String passwd = (String)withValues.get("passwd");\r
         if ( passwd == null || (!sessionPasswd.equals(passwd))) {\r
-          throw new ServletModuleUserException("Missing password");\r
+          throw new ServletModuleUserExc("Missing password");\r
         }\r
         session.invalidate();\r
       }\r
@@ -386,7 +388,7 @@ public class ServletModuleOpenIndy extends ServletModule
       if ((((String)withValues.get("title")).length() == 0) ||\r
           (((String)withValues.get("description")).length() == 0) ||\r
           (((String)withValues.get("content_data")).length() == 0))\r
-        throw new ServletModuleUserException("Missing field");\r
+        throw new ServletModuleUserExc("Missing field");\r
 \r
       // call the routines that escape html\r
 \r
@@ -447,7 +449,7 @@ public class ServletModuleOpenIndy extends ServletModule
         catch (Exception e) {\r
           logger.error("setting content_x_topic failed");\r
           contentModule.deleteById(cid);\r
-          throw new ServletModuleException("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString());\r
+          throw new ServletModuleExc("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString());\r
         } //end try\r
       } //end if\r
 \r
@@ -462,16 +464,12 @@ public class ServletModuleOpenIndy extends ServletModule
                                                                  (EntityContent)contentModule.getById(cid));\r
       }\r
       catch (Throwable t) {\r
-        throw new ServletModuleException(t.getMessage());\r
+        throw new ServletModuleFailure(t);\r
       }\r
     }\r
-    catch (FileHandlerException e) {\r
-      e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
-      throw new ServletModuleException("MediaException: "+ e.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
-    catch (IOException e) { throw new ServletModuleException("IOException: "+ e.getMessage());}\r
-    catch (StorageObjectFailure e) { throw new ServletModuleException("StorageObjectException" + e.getMessage());}\r
-    catch (ModuleException e) { throw new ServletModuleException("ModuleException"+e.getMessage());}\r
 \r
     deliver(req, res, mergeData, postingFormDoneTemplate);\r
   }\r
@@ -481,10 +479,11 @@ public class ServletModuleOpenIndy extends ServletModule
    */\r
 \r
   public void mail(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
     String aid = req.getParameter("mail_aid");\r
     if (aid == null){\r
-      throw new ServletModuleUserException("An article id must be specified in requests to email an article.  Something therefore went badly wrong....");\r
+      throw new ServletModuleUserExc("An article id must be specified in requests to email an article.  Something therefore went badly wrong....");\r
     }\r
 \r
     String to = req.getParameter("mail_to");\r
@@ -508,7 +507,7 @@ public class ServletModuleOpenIndy extends ServletModule
     else {\r
       //run checks on to and from and mail_language to make sure no monkey business occurring\r
       if (mail_language.indexOf('.') != -1 || mail_language.indexOf('/') != -1 ){\r
-        throw new ServletModuleUserException("Sorry, you've entered an illegal character into the language field.  Go back and try again, asshole.");\r
+        throw new ServletModuleUserExc("Sorry, you've entered an illegal character into the language field.  Go back and try again, asshole.");\r
       }\r
       if (to.indexOf('\n') != -1\r
           || to.indexOf('\r') != -1\r
@@ -516,14 +515,14 @@ public class ServletModuleOpenIndy extends ServletModule
           || from.indexOf('\n') != -1\r
           || from.indexOf('\r') != -1\r
           || from.indexOf(',') != -1 ){\r
-        throw new ServletModuleUserException("Sorry, you've entered an illegal character into the from or to field.  Go back and try again.");\r
+        throw new ServletModuleUserExc("Sorry, you've entered an illegal character into the from or to field.  Go back and try again.");\r
       }\r
       EntityContent contentEnt;\r
       try{\r
         contentEnt = (EntityContent)contentModule.getById(aid);\r
       }\r
-      catch (ModuleException e){\r
-        throw new ServletModuleUserException("Couldn't get content for article "+aid);\r
+      catch (Throwable e){\r
+        throw new ServletModuleFailure("Couldn't get content for article "+aid + ": " + e.getMessage(), e);\r
       }\r
       String producerStorageRoot=configuration.getString("Producer.StorageRoot");\r
       String producerDocRoot=configuration.getString("Producer.DocRoot");\r
@@ -545,10 +544,10 @@ public class ServletModuleOpenIndy extends ServletModule
         content= out.toString();\r
       }\r
       catch (FileNotFoundException e){\r
-        throw new ServletModuleUserException("No text file found in " + txtFilePath);\r
+        throw new ServletModuleFailure("No text file found in " + txtFilePath, e);\r
       }\r
       catch (IOException e){\r
-        throw new ServletModuleUserException("Problem reading file in " + txtFilePath);\r
+        throw new ServletModuleFailure("Problem reading file in " + txtFilePath, e);\r
       }\r
       // add some headers\r
       content = "To: " + to + "\nReply-To: "+ from + "\n" + content;\r
@@ -558,16 +557,16 @@ public class ServletModuleOpenIndy extends ServletModule
         try {\r
           content=StringRoutines.performRegularExpressionReplacement(content,"!COMMENT!",commentTextToInsert);\r
         }\r
-        catch (Exception e){\r
-          throw new ServletModuleUserException("Problem doing regular expression replacement " + e.toString());\r
+        catch (Throwable e){\r
+          throw new ServletModuleFailure("Problem doing regular expression replacement " + e.toString(), e);\r
         }\r
       }\r
       else{\r
         try {\r
           content=StringRoutines.performRegularExpressionReplacement(content,"!COMMENT!","");\r
         }\r
-        catch (Exception e){\r
-          throw new ServletModuleUserException("Problem doing regular expression replacement " + e.toString());\r
+        catch (Throwable e){\r
+          throw new ServletModuleFailure("Problem doing regular expression replacement " + e.toString(), e);\r
         }\r
       }\r
 \r
@@ -580,7 +579,7 @@ public class ServletModuleOpenIndy extends ServletModule
 \r
         if (!SMTPReply.isPositiveCompletion(reply)) {\r
           client.disconnect();\r
-          throw new ServletModuleUserException("SMTP server refused connection.");\r
+          throw new ServletModuleExc("SMTP server refused connection.");\r
         }\r
 \r
         client.sendSimpleMessage(configuration.getString("ServletModule.OpenIndy.EmailIsFrom"), to, content);\r
@@ -597,7 +596,7 @@ public class ServletModuleOpenIndy extends ServletModule
             // do nothing\r
           }\r
         }\r
-        throw new ServletModuleUserException(e.toString());\r
+        throw new ServletModuleFailure(e);\r
       }\r
     }\r
   }\r
@@ -607,7 +606,7 @@ public class ServletModuleOpenIndy extends ServletModule
    * Method for querying a lucene index\r
    */\r
   public void search(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
     try {\r
       int increment=10;\r
 \r
@@ -715,7 +714,7 @@ public class ServletModuleOpenIndy extends ServletModule
               }\r
               catch(IOException e) {\r
                 logger.debug("Can't open indexPath: " + indexPath);\r
-                throw new ServletModuleUserException("Problem with Search Index! : "+ e.toString());\r
+                throw new ServletModuleExc("Problem with Search Index! : "+ e.toString());\r
               }\r
 \r
               Query query = null;\r
@@ -725,7 +724,7 @@ public class ServletModuleOpenIndy extends ServletModule
               catch(Exception e) {\r
                 searcher.close();\r
                 logger.debug("Query don't parse: " + queryString);\r
-                throw new ServletModuleUserException("Problem with Query String! (was '"+queryString+"')");\r
+                throw new ServletModuleExc("Problem with Query String! (was '"+queryString+"')");\r
               }\r
 \r
               Hits hits = null;\r
@@ -735,7 +734,7 @@ public class ServletModuleOpenIndy extends ServletModule
               catch(IOException e) {\r
                 searcher.close();\r
                 logger.debug("Can't get hits: " + e.toString());\r
-                throw new ServletModuleUserException("Problem getting hits!");\r
+                throw new ServletModuleExc("Problem getting hits!");\r
               }\r
 \r
               int start = 0;\r
@@ -743,7 +742,7 @@ public class ServletModuleOpenIndy extends ServletModule
 \r
               String sortBy=req.getParameter("search_sort");\r
               if (sortBy == null || sortBy.equals("")){\r
-                throw new ServletModuleUserException("Please let me sort by something!(missing search_sort)");\r
+                throw new ServletModuleExc("Please let me sort by something!(missing search_sort)");\r
               }\r
 \r
               // here is where the documents will go for storage across sessions\r
@@ -777,7 +776,7 @@ public class ServletModuleOpenIndy extends ServletModule
                 }\r
                 else{\r
                   if (!sortBy.equals("date_asc")){\r
-                    throw new ServletModuleUserException("don't know how to sort by: "+ sortBy);\r
+                    throw new ServletModuleExc("don't know how to sort by: "+ sortBy);\r
                   }\r
                 }\r
                 ListIterator keyTraverser = keyList.listIterator();\r
@@ -795,7 +794,7 @@ public class ServletModuleOpenIndy extends ServletModule
               }\r
               catch (IOException e){\r
                 logger.debug("Can't close searcher: " + e.toString());\r
-                throw new ServletModuleUserException("Problem closing searcher(normal)!");\r
+                throw new ServletModuleFailure("Problem closing searcher(normal):" + e.getMessage(), e);\r
               }\r
 \r
 \r
@@ -810,7 +809,7 @@ public class ServletModuleOpenIndy extends ServletModule
             }\r
             catch (IOException e){\r
               logger.debug("Can't close searcher: " + e.toString());\r
-              throw new ServletModuleUserException("Problem closing searcher!");\r
+              throw new ServletModuleFailure("Problem closing searcher: " + e.getMessage(), e);\r
             }\r
           }\r
         }\r
@@ -855,17 +854,17 @@ public class ServletModuleOpenIndy extends ServletModule
           mergeData.put("hits",theHits);\r
         }\r
       }\r
-      catch (Exception e) {\r
-        logger.debug("Can't iterate over hits: " + e.toString());\r
-        throw new ServletModuleUserException("Problem getting hits!");\r
+      catch (Throwable e) {\r
+        logger.error("Can't iterate over hits: " + e.toString());\r
+\r
+        throw new ServletModuleFailure("Problem getting hits: " + e.getMessage(), e);\r
       }\r
 \r
       mergeData.put("queryString",queryString);\r
       deliver(req,res,mergeData,searchResultsTemplate);\r
     }\r
     catch (NullPointerException n){\r
-      n.printStackTrace();\r
-      throw new ServletModuleUserException("Null Pointer"+n.toString());\r
+      throw new ServletModuleFailure("Null Pointer: "+n.toString(), n);\r
     }\r
   }\r
 \r
@@ -873,7 +872,7 @@ public class ServletModuleOpenIndy extends ServletModule
    * Method for dynamically generating a pdf from a fo file\r
    */\r
   public void getpdf(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException, ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
     String ID_REQUEST_PARAM = "id";\r
     String language = req.getParameter("language");\r
     String generateFO=configuration.getString("GenerateFO");\r
@@ -926,24 +925,26 @@ public class ServletModuleOpenIndy extends ServletModule
           res.setContentLength(content.length);\r
           res.getOutputStream().write(content);\r
           res.getOutputStream().flush();\r
-        } else {\r
-          throw new ServletModuleUserException("Missing id parameter.");\r
         }\r
-      } catch (Exception ex) {\r
+        else {\r
+          throw new ServletModuleUserExc("Missing id parameter.");\r
+        }\r
+      }\r
+      catch (Exception ex) {\r
         logger.error(ex.toString());\r
-        throw new ServletModuleException(ex.toString());\r
+        throw new ServletModuleFailure(ex);\r
       }\r
     } else {\r
-      throw new ServletModuleUserException("Can't generate a PDF because the config tells me not to.");\r
+      throw new ServletModuleExc("Can't generate a PDF because the config tells me not to.");\r
     }\r
   }\r
 \r
   private void _throwBadContentType (String fileName, String contentType)\r
-    throws ServletModuleUserException {\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
 \r
     logger.error("Wrong file type uploaded!: " + fileName+" "\r
                           +contentType);\r
-    throw new ServletModuleUserException("The file you uploaded is of the "\r
+    throw new ServletModuleUserExc("The file you uploaded is of the "\r
                                          +"following mime-type: "+contentType\r
                                          +", we do not support this mime-type. "\r
                                          +"Error One or more files of unrecognized type. Sorry");\r
@@ -964,18 +965,17 @@ public class ServletModuleOpenIndy extends ServletModule
      to use different bundles for open and admin */\r
   public void deliver(HttpServletRequest req, HttpServletResponse res,\r
                       TemplateModelRoot rtm, TemplateModelRoot popups,\r
-                      String templateFilename)\r
-    throws ServletModuleException {\r
+                      String templateFilename) throws ServletModuleFailure\r
+  {\r
     if (rtm == null) rtm = new SimpleHash();\r
     try {\r
       PrintWriter out = res.getWriter();\r
       HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out,\r
                                     getLocale(req), "bundles.open");\r
       out.close();\r
-    }  catch (HTMLParseException e) {\r
-      throw new ServletModuleException(e.toString());\r
-    } catch (IOException e) {\r
-      throw new ServletModuleException(e.toString());\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 }\r
index cdebe68..0fe5755 100755 (executable)
@@ -46,7 +46,8 @@ import mir.generator.Generator;
 import mir.log.LoggerWrapper;
 import mir.producer.ProducerFactory;
 import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleException;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
 import mir.util.NullWriter;
 import mir.util.ResourceBundleGeneratorFunction;
 import mircoders.global.MirGlobal;
@@ -64,7 +65,7 @@ public class ServletModuleProducer extends ServletModule
   int totalNrComments;
   List producersData;
 
-  void generateResponse(String aGeneratorIdentifier, PrintWriter aWriter, Map aResponseData, Locale aLocale) throws ServletModuleException {
+  void generateResponse(String aGeneratorIdentifier, PrintWriter aWriter, Map aResponseData, Locale aLocale) {
     try {
       generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGeneratorIdentifier);
       MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(aResponseData);
@@ -72,7 +73,7 @@ public class ServletModuleProducer extends ServletModule
       generator.generate(aWriter, aResponseData, new PrintWriter(new NullWriter()));
     }
     catch (Throwable t) {
-      throw new ServletModuleException(t.getMessage());
+      throw new ServletModuleFailure(t);
     }
   }
 
@@ -82,7 +83,7 @@ public class ServletModuleProducer extends ServletModule
     defaultAction="showProducerQueueStatus";
   }
 
-  public void showMessage(PrintWriter aWriter, Locale aLocale, String aMessage, String anArgument1, String anArgument2) throws ServletModuleException {
+  public void showMessage(PrintWriter aWriter, Locale aLocale, String aMessage, String anArgument1, String anArgument2) {
     Map responseData;
     try {
       responseData = new HashMap();
@@ -92,12 +93,12 @@ public class ServletModuleProducer extends ServletModule
       generateResponse("infomessage.template", aWriter, responseData, aLocale);
     }
     catch (Throwable t) {
-      throw new ServletModuleException(t.getMessage());
+      throw new ServletModuleFailure(t);
     }
   }
 
 
-  public void showProducerQueueStatus(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+  public void showProducerQueueStatus(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     Object comments;
     Map generationData;
     Generator generator;
@@ -138,12 +139,11 @@ public class ServletModuleProducer extends ServletModule
       generator.generate(aResponse.getWriter(), generationData, new PrintWriter(new NullWriter()));
     }
     catch (Throwable t) {
-      t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-      throw new ServletModuleException(t.getMessage());
+      throw new ServletModuleFailure(t);
     }
   }
 
-  public void produce(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
+  public void produce(HttpServletRequest req, HttpServletResponse res) {
     /*
      * This method will only be called by external scripts (e.g. from cron jobs).
      * The output therefore is very simple.
@@ -161,22 +161,22 @@ public class ServletModuleProducer extends ServletModule
         out.println("job added");
       }
     }
-    catch (Exception e) {
-      throw new ServletModuleException(e.getMessage());
+    catch (Throwable t) {
+      throw new ServletModuleFailure(t);
     }
   }
 
-  public void produceAllNew(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+  public void produceAllNew(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     try {
       MirGlobal.localizer().producers().produceAllNew();
       showMessage(aResponse.getWriter(), getLocale(aRequest), "produceAllNewAddedToQueue", "", "");
     }
-    catch (Exception e) {
-      throw new ServletModuleException(e.getMessage());
+    catch (Throwable t) {
+      throw new ServletModuleFailure(t);
     }
   }
 
-  public void enqueue(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+  public void enqueue(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     try {
       if (aRequest.getParameter("producer")!=null) {
         String producerParam = aRequest.getParameter("producer");
@@ -187,12 +187,12 @@ public class ServletModuleProducer extends ServletModule
         showProducerQueueStatus(aRequest, aResponse);
       }
     }
-    catch (Exception e) {
-      throw new ServletModuleException(e.getMessage());
+    catch (Throwable t) {
+      throw new ServletModuleFailure(t);
     }
   }
 
-  public void cancelAbortJob(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+  public void cancelAbortJob(HttpServletRequest aRequest, HttpServletResponse aResponse)  {
     // ML: to be coded
   }
 }
index 6e0275b..2ba8613 100755 (executable)
@@ -55,8 +55,9 @@ import mir.misc.FileHandlerUserException;
 import mir.misc.WebdbMultipartRequest;\r
 import mir.module.ModuleException;\r
 import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleException;\r
-import mir.servlet.ServletModuleUserException;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.servlet.ServletModuleFailure;\r
 import mir.storage.StorageObjectFailure;\r
 import mircoders.entity.EntityContent;\r
 import mircoders.entity.EntityUploadedMedia;\r
@@ -71,7 +72,7 @@ import freemarker.template.SimpleList;
  *  ServletModuleBilder -\r
  *  liefert HTML fuer Bilder\r
  *\r
- * @version $Id: ServletModuleUploadedMedia.java,v 1.18 2003/03/05 19:23:17 idfx Exp $\r
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.19 2003/03/06 05:40:40 zapata Exp $\r
  * @author RK, the mir-coders group\r
  */\r
 \r
@@ -90,7 +91,7 @@ public abstract class ServletModuleUploadedMedia
   }\r
 \r
   public void insert(HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleException, ServletModuleUserException {\r
+          throws ServletModuleExc, ServletModuleUserExc {\r
     try {\r
       EntityUsers user = _getUser(req);\r
       MediaRequest mediaReq =  new MediaRequest(user.getId(), false);\r
@@ -134,28 +135,26 @@ public abstract class ServletModuleUploadedMedia
     }\r
     catch (FileHandlerUserException e) {\r
       logger.error("ServletModuleUploadedMedia.insert: " + e.getMessage());\r
-      throw new ServletModuleUserException(e.getMessage());\r
+      throw new ServletModuleUserExc(e.getMessage());\r
     }\r
     catch (FileHandlerException e) {\r
-      throw new ServletModuleException(\r
-              "upload -- media handling exception " + e.toString());\r
+      throw new ServletModuleFailure("upload -- media handling exception " + e.toString(), e);\r
     }\r
     catch (StorageObjectFailure e) {\r
-      throw new ServletModuleException("upload -- storageobjectexception "\r
-                                      + e.toString());\r
+      throw new ServletModuleFailure("upload -- storageobjectexception " + e.toString(), e);\r
     }\r
     catch (IOException e) {\r
-      throw new ServletModuleException("upload -- ioexception " + e.toString());\r
+      throw new ServletModuleFailure("upload -- ioexception " + e.toString(), e);\r
     }\r
     catch (PropertiesConfigExc e) {\r
-      throw new ServletModuleException("upload -- configexception " + e.toString());\r
+      throw new ServletModuleFailure("upload -- configexception " + e.toString(), e);\r
     }\r
     catch (Throwable t) {\r
-      throw new ServletModuleException("upload -- exception " + t.toString());\r
+      throw new ServletModuleFailure("upload -- exception " + t.toString(), t);\r
     }\r
   }\r
 \r
-  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {\r
+  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
 \r
     try {\r
       EntityUsers user = _getUser(req);\r
@@ -171,21 +170,14 @@ public abstract class ServletModuleUploadedMedia
       logger.debug("update: media ID = " + id);\r
       _edit(id, req, res);\r
     }\r
-    catch (IOException e) {\r
-      throw new ServletModuleException("upload -- ioexception " + e.toString());\r
-    }\r
-    catch (ModuleException e) {\r
-      throw new ServletModuleException("upload -- moduleexception " + e.toString());\r
-    }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException("upload -- exception " + e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure("upload -- exception " + e.toString(), e);\r
     }\r
 \r
   }\r
 \r
 \r
-  public void list(HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleException {\r
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
     // Parameter auswerten\r
     SimpleHash mergeData = new SimpleHash();\r
     SimpleHash popups = new SimpleHash();\r
@@ -252,17 +244,13 @@ public abstract class ServletModuleUploadedMedia
 \r
       deliver(req, res, mergeData, popups, templateListString);\r
     }\r
-    catch (ModuleException e) {\r
-      throw new ServletModuleException(e.toString());\r
-    }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
 \r
-  public void add(HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleException {\r
+  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
     try {\r
       SimpleHash mergeData = new SimpleHash();\r
       SimpleHash popups = new SimpleHash();\r
@@ -290,19 +278,18 @@ public abstract class ServletModuleUploadedMedia
       mergeData.put("medianum",numOfMedia);\r
       mergeData.put("mediafields",mediaFields);\r
       deliver(req, res, mergeData, popups, templateObjektString);\r
-    } catch (Exception e) {\r
-      throw new ServletModuleException(e.toString());\r
+    }\r
+    catch (Exception e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void edit(HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleException {\r
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
     String idParam = req.getParameter("id");\r
     _edit(idParam, req, res);\r
   }\r
 \r
-  private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleException {\r
+  private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
     if (idParam != null && !idParam.equals("")) {\r
       try {\r
         SimpleHash popups = new SimpleHash();\r
@@ -310,15 +297,12 @@ public abstract class ServletModuleUploadedMedia
         deliver(req, res, mainModule.getById(idParam), popups,\r
                 templateObjektString);\r
       }\r
-      catch (ModuleException e) {\r
-        throw new ServletModuleException(e.toString());\r
-      }\r
-      catch (StorageObjectFailure e) {\r
-        throw new ServletModuleException(e.toString());\r
+      catch (Throwable e) {\r
+        throw new ServletModuleFailure(e);\r
       }\r
     }\r
     else {\r
-      throw new ServletModuleException("ServletmoduleUploadedMedia :: _edit without id");\r
+      throw new ServletModuleExc("ServletmoduleUploadedMedia :: _edit without id");\r
     }\r
   }\r
 \r
@@ -329,8 +313,7 @@ public abstract class ServletModuleUploadedMedia
     return (EntityUsers) session.getAttribute("login.uid");\r
   }\r
 \r
-  public void getMedia(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException\r
+  public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String idParam = req.getParameter("id");\r
     if (idParam!=null && !idParam.equals("")) {\r
@@ -358,22 +341,15 @@ public abstract class ServletModuleUploadedMedia
         out.close();\r
       }\r
 \r
-      catch (IOException e) {\r
-        throw new ServletModuleException(e.toString());\r
-      }\r
-      catch (ModuleException e) {\r
-        throw new ServletModuleException(e.toString());\r
-      }\r
-      catch (Exception e) {\r
-        throw new ServletModuleException(e.toString());\r
+      catch (Throwable e) {\r
+        throw new ServletModuleFailure(e);\r
       }\r
     }\r
     else logger.error("id not specified.");\r
     // no exception allowed\r
   }\r
 \r
-  public void getIcon(HttpServletRequest req, HttpServletResponse res)\r
-    throws ServletModuleException\r
+  public void getIcon(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String idParam = req.getParameter("id");\r
     if (idParam!=null && !idParam.equals("")) {\r
@@ -401,14 +377,8 @@ public abstract class ServletModuleUploadedMedia
         out.close();\r
       }\r
 \r
-      catch (IOException e) {\r
-        throw new ServletModuleException(e.toString());\r
-      }\r
-      catch (ModuleException e) {\r
-        throw new ServletModuleException(e.toString());\r
-      }\r
-      catch (Exception e) {\r
-        throw new ServletModuleException(e.toString());\r
+      catch (Throwable e) {\r
+        throw new ServletModuleFailure(e);\r
       }\r
     }\r
     else logger.error("getIcon: id not specified.");\r
index 5955b05..09b3ebc 100755 (executable)
@@ -38,9 +38,7 @@ import javax.servlet.http.HttpServletResponse;
 \r
 import mir.log.LoggerWrapper;\r
 import mir.module.ModuleException;\r
-import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleException;\r
-import mir.servlet.ServletModuleUserException;\r
+import mir.servlet.*;\r
 import mir.storage.StorageObjectFailure;\r
 import mir.util.HTTPRequestParser;\r
 import mircoders.module.ModuleUsers;\r
@@ -76,33 +74,35 @@ public class ServletModuleUsers extends ServletModule
     }\r
   }\r
 \r
-  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
   {\r
     String idParam = req.getParameter("id");\r
 \r
     if (idParam == null)\r
-      throw new ServletModuleException("ServletModuleUser.edit: invalid call: (id) not specified");\r
+      throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");\r
 \r
     try {\r
       deliver(req, res, mainModule.getById(idParam), templateObjektString);\r
     }\r
-    catch (ModuleException e) {\r
-      throw new ServletModuleException(e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
   public void add(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleException\r
+      throws ServletModuleExc\r
   {\r
     try {\r
       SimpleHash mergeData = new SimpleHash();\r
       mergeData.put("new", "1");\r
       deliver(req, res, mergeData, templateObjektString);\r
     }\r
-    catch (Exception e) { throw new ServletModuleException(e.toString());}\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
   }\r
 \r
-  public String checkPassword(HTTPRequestParser aRequestParser) throws ServletModuleException, ServletModuleUserException\r
+  public String checkPassword(HTTPRequestParser aRequestParser) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     if ( (aRequestParser.getParameter("newpassword") != null &&\r
           aRequestParser.getParameter("newpassword").length() > 0) ||\r
@@ -113,13 +113,11 @@ public class ServletModuleUsers extends ServletModule
       String newPassword2 = aRequestParser.getParameterWithDefault("newpassword2", "");\r
 \r
       if (newPassword.length() == 0 || newPassword2.length() == 0) {\r
-        throw new ServletModuleUserException(\r
-            "The new password must be entered twice!");\r
+        throw new ServletModuleUserExc("The new password must be entered twice!");\r
       }\r
 \r
       if (!newPassword.equals(newPassword2)) {\r
-        throw new ServletModuleUserException(\r
-            "New password differes from confirmation");\r
+        throw new ServletModuleUserExc("New password differes from confirmation");\r
       }\r
 \r
       return newPassword;\r
@@ -129,7 +127,7 @@ public class ServletModuleUsers extends ServletModule
   }\r
 \r
   public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
-      throws ServletModuleException\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
@@ -139,7 +137,7 @@ public class ServletModuleUsers extends ServletModule
       if (newPassword!=null)\r
         withValues.put("password", newPassword);\r
       else\r
-        throw new ServletModuleUserException("Password is empty");\r
+        throw new ServletModuleUserExc("Password is empty");\r
 \r
       String id = mainModule.add(withValues);\r
       if (requestParser.hasParameter("returnurl"))\r
@@ -147,12 +145,12 @@ public class ServletModuleUsers extends ServletModule
       else\r
         list(aRequest, aResponse);\r
     }\r
-    catch (Exception e) {\r
-      throw new ServletModuleException(e.toString());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException, ServletModuleUserException\r
+  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
   {\r
     try {\r
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
@@ -170,10 +168,9 @@ public class ServletModuleUsers extends ServletModule
       else\r
         list(aRequest, aResponse);\r
     }\r
-    catch (Throwable t) {\r
-      throw new ServletModuleException("ServletModuleUsers: " + t.getMessage());\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
-\r
   }\r
 \r
 \r
index 5c32f72..5f98ad6 100755 (executable)
@@ -48,7 +48,7 @@ import mircoders.entity.EntityUploadedMedia;
  * <b>implements abstract DB connection to the content_x_media SQL table\r
  *\r
  * @author RK, mir-coders group\r
- * @version $Id: DatabaseContentToMedia.java,v 1.14 2003/03/05 19:23:17 idfx Exp $\r
+ * @version $Id: DatabaseContentToMedia.java,v 1.15 2003/03/06 05:40:40 zapata Exp $\r
  *\r
  */\r
 \r
@@ -239,10 +239,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
             "id");\r
       }\r
       catch (Exception e) {\r
-        e.printStackTrace();\r
         logger.error("DatabaseContentToMedia.getOther: " + e.toString());\r
-        throw new StorageObjectFailure("DatabaseContentToMedia.getOther: " +\r
-                                       e.toString(), e);\r
+        throw new StorageObjectFailure("DatabaseContentToMedia.getOther: " + e.toString(), e);\r
       }\r
     }\r
     return returnList;\r
@@ -270,7 +268,6 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
             "id");\r
       }\r
       catch (Exception e) {\r
-        e.printStackTrace();\r
         logger.error("DatabaseContentToMedia.getUploadedMedia: " + e.toString());\r
         throw new StorageObjectFailure(\r
             "DatabaseContentToMedia.getUploadedMedia: " + e.toString(), e);\r