--- /dev/null
+<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>
--- /dev/null
+<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>
-/*\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
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;
* 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) {
}
- 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) {
# 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
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
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","")
};
/**
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();
* 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 {
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;
+ }
+ }
}
+++ /dev/null
-/*
- * 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
-/*
- * 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
\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
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
* @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
\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
* @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
* @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
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
*\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
}\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
* @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
* @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
*/\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
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
* @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
// (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
* @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
*/\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
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
*/\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
}\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
}\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
* 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
*
*/
public static void dispatch(ServletModule sMod, HttpServletRequest req,
- HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+ HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
//sMod.predeliver(req,res);
if (sMod.defaultAction() != null)
doParam = sMod.defaultAction();
else
- throw new ServletModuleException("no parameter do supplied!");
+ throw new ServletModuleExc("no parameter do supplied!");
}
try {
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! -- ");
}
}
--- /dev/null
+/*
+ * 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);
+ }
+}
+++ /dev/null
-/*\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
--- /dev/null
+/*
+ * 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);
+ }
+}
-/*
- * 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
--- /dev/null
+/*
+ * 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);
+ }
+}
+++ /dev/null
-/*
- * 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);
- }
-}
-
--- /dev/null
+/*
+ * 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;
+ }
+}
*\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
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
}
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) {
//}
//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();
}
catch (Throwable t) {
- t.printStackTrace();
+ t.printStackTrace(aLogger.asPrintWriter(aLogger.DEBUG_MESSAGE));
aLogger.error(" error while generating: " + t.getMessage() + t.toString());
}
endTime = System.currentTimeMillis();
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>");
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;
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();
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;
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
+}
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
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;
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);
}
}
}
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;
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");
}
public void list(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException
{
logger.debug("-- breaking: list");
// fetch and deliver
// 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);
+ }
}
}
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;
}
}
- 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;
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);
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();
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;
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...
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);
}
}
}
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
* 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
}\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
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
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
\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
}\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
}\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
_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
_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
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
_showObject(idParam, aRequest, aResponse);\r
}\r
catch (Throwable e) {\r
- throw new ServletModuleException(e.toString());\r
+ throw new ServletModuleFailure(e);\r
}\r
}\r
\r
* 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
\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
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
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
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
}\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
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
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;
* 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 $
*
*/
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 {
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);
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);
out.close();
edit(req, res);
- } catch (Exception e) {
- throw new ServletModuleException(e.toString());
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
}
}
}
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;
}
- public void list(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException
+ public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
{
// determine parameter
SimpleHash mergeData = new SimpleHash();
// 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);
+ }
}
}
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;
}
}
- 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;
}
}
- 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();
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();
deliver(req, res, modelRoot, templateObjektString);
}
- catch (ModuleException e) {
- throw new ServletModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
}
}
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
}\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
}\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
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
}\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
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
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;
}
}
- public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+ public void add(HttpServletRequest req, HttpServletResponse res)
{
SimpleHash mergeData = new SimpleHash();
mergeData.put("new", "1");
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;
}
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 {
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);
+ }
}
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
* 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
* 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
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
*/\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
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
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
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
*/\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
}\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
*/\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
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
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
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
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
(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
*/\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
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
|| 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
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
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
\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
// do nothing\r
}\r
}\r
- throw new ServletModuleUserException(e.toString());\r
+ throw new ServletModuleFailure(e);\r
}\r
}\r
}\r
* 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
}\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
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
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
\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
}\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
}\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
}\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
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
* 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
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
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
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;
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);
generator.generate(aWriter, aResponseData, new PrintWriter(new NullWriter()));
}
catch (Throwable t) {
- throw new ServletModuleException(t.getMessage());
+ throw new ServletModuleFailure(t);
}
}
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();
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;
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.
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");
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
}
}
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
* 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
}\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
}\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
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
\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
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
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
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
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
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
\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
}\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
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
}\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
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
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
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
* <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
"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
"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