package mir.servlet;
-import freemarker.template.SimpleHash;
-import freemarker.template.TemplateModelRoot;
-import freemarker.template.TemplateModel;
-
-import mir.entity.EntityList;
-import mir.log.*;
-import mir.misc.*;
-import mir.module.AbstractModule;
-import mir.module.ModuleException;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.entity.EntityList;
+import mir.log.LoggerWrapper;
+import mir.misc.HTMLParseException;
+import mir.misc.HTMLTemplateProcessor;
+import mir.misc.LineFilterWriter;
+import mir.module.AbstractModule;
+import mir.module.ModuleException;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+import freemarker.template.SimpleHash;
+import freemarker.template.TemplateModelRoot;
+
/**
* Abstract class ServletModule provides the base functionality for servlets.
*
*
* Abstrakte Klasse ServletModule stellt die Basisfunktionalitaet der
- * abgeleiteten ServletModule zur VerfΓΌgung.
+ * abgeleiteten ServletModule zur Verf?gung.
*
* @version 28.6.1999
* @author RK
public String defaultAction;
protected LoggerWrapper logger;
-
+ protected MirPropertiesConfiguration configuration;
protected AbstractModule mainModule;
protected String templateListString;
protected String templateObjektString;
protected String templateConfirmString;
+
+
+ public ServletModule(){
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ } catch (PropertiesConfigExc e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
/**
* Singelton - Methode muss in den abgeleiteten Klassen ueberschrieben werden.
* get the module name to be used for generic operations like delete.
*/
protected String getOperationModuleName() {
- return getClass().getName().substring((new String("mircoders.servler.ServletModule")).length());
+ return getClass().getName().substring((new String("mircoders.servlet.ServletModule")).length());
}
/**
HttpSession session = req.getSession(false);
String language = (String) session.getAttribute("Language");
if (language == null) {
- language = MirConfig.getProp("StandardLanguage");
+ language = configuration.getString("StandardLanguage");
}
return language;
}
public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleException {
try {
- aResponse.sendRedirect(MirConfig.getProp("RootUri") + "/Mir?"+aQuery);
+ aResponse.sendRedirect(MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?"+aQuery);
}
catch (Throwable t) {
throw new ServletModuleException(t.getMessage());
}
}
theList = mainModule.getByWhereClause(null, offset);
- //theList = mainModule.getByWhereClause((String)null, offset);
- if (theList == null || theList.getCount() == 0 || theList.getCount() > 1) {
- HTMLTemplateProcessor.process(res, templateListString, theList, out, getLocale(req));
- }
- else {
- deliver(req, res, theList.elementAt(0), templateObjektString);
- }
+
+ HTMLTemplateProcessor.process(res, templateListString, theList, out, getLocale(req));
}
catch (Exception e) {
throw new ServletModuleException(e.getMessage());
mergeData.put("where", req.getParameter("where"));
mergeData.put("order", req.getParameter("order"));
mergeData.put("offset", req.getParameter("offset"));
+ // this stuff is to be compatible with the other more advanced
+ // search method used for media and comments
+ mergeData.put("query_media_folder", req.getParameter("query_media_folder"));
+ mergeData.put("query_is_published", req.getParameter("query_is_published"));
+ mergeData.put("query_text", req.getParameter("query_text"));
+ mergeData.put("query_field", req.getParameter("query_field"));
+
deliver(req, res, mergeData, templateConfirmString);
}
else {
try {
String idParam = req.getParameter("id");
HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject());
+
String id = mainModule.set(withValues);
- //theLog.printInfo("Showing Entity with id: " + id);
- //edit(req,res);
String whereParam = req.getParameter("where");
String orderParam = req.getParameter("order");
+
if ((whereParam != null && !whereParam.equals("")) || (orderParam != null && !orderParam.equals(""))) {
- //theLog.printDebugInfo("update to list");
list(req, res);
}
else {
edit(req, res);
}
- //list(req,res);
}
catch (Exception e) {
throw new ServletModuleException(e.getMessage());
if (rtm == null) rtm = new SimpleHash();
try {
PrintWriter out = res.getWriter();
- HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out,
- getLocale(req), "bundles.admin");
+ HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out, getLocale(req));
+
// we default to admin bundles here, which is not exactly beautiful...
// but this whole producer stuff is going to be rewritten soon.
// ServletModuleOpenIndy overwrites deliver() to use open bundles
try {
theFieldList = theStorage.getFields();
}
- catch (StorageObjectException e) {
+ catch (StorageObjectFailure e) {
throw new ServletModuleException("ServletModule.getIntersectingValues: " + e.getMessage());
}
return withValues;
}
-}
\ No newline at end of file
+}