// nadir evironment. from my point of coding, this needs an urgent
// fixxx.
// yeah, from my point too - tob.
- //actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");
+ //actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");
//actionRoot = docRoot + "/servlet/NadirAktuell";
-
+
actionRoot = docRoot + "/servlet/Mir";
+
openAction = MirConfig.getProp("Producer.OpenAction");
productionHost = MirConfig.getProp("Producer.ProductionHost");
videoHost = MirConfig.getProp("Producer.VideoHost");
/**
+ * This class provides the base functionality for the derived Module-Classes.
+ * These classes should provide methods to make more or less complex actions
+ * on Database and Entity classes. The modules are used by ServletModules.
+ * Future possibility could be access via Applications.
+ *
* Abstrakte Klasse, von denen die Modules die Basisfunktionalität erben.
* Die Moduleschicht dient dazu, Funktionalitaeten zur Verfügung zu stellen,
* die von mehreren ServletModulen verwendet werden.
+ *
*/
+
public class AbstractModule {
protected StorageObject theStorage;
public Entity getById (String id) throws ModuleException {
try {
if (theStorage == null)
- throw new ModuleException("Kein StorageObject gesetzt");
+ throw new ModuleException("No StorageObject set!");
Entity entity = (Entity)theStorage.selectById(id);
if (entity == null)
- throw new ModuleException("Objekt nicht vorhanden: ID=" + id);
+ throw new ModuleException("No object for id = " + id);
else return entity;
}
catch (StorageObjectException e){
/**
+ * Abstract class ServletModule provides the base functionality for servlets.
+ * Deriving a class from ServletModule enables class to insert/edit/update/delete
+ * and list Entity from a Database via mainModule.
+ *
+ *
* Abstrakte Klasse ServletModule stellt die Basisfunktionalitaet der
* abgeleiteten ServletModule zur Verfügung.
*
* TemplateModelRoot rtm gemischt wurde
*
* @param res Http-Response, die vom Dispatcher durchgereicht wird
+ * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den
+ * Daten, die ins Template gemerged werden sollen.
+ * @param tmpl Name des Templates
+ * @exception ServletModuleException
+ */
+ public void deliver_compressed(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm, String templateFilename)
+ throws ServletModuleException {
+ if (rtm == null) rtm = new SimpleHash();
+ try {
+ PrintWriter out = new LineFilterWriter(res.getWriter());
+ //PrintWriter out = res.getWriter();
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
+ out.close();
+ } catch (HTMLParseException e) {
+ throw new ServletModuleException(e.toString());
+ } catch (IOException e) {
+ throw new ServletModuleException(e.toString());
+ }
+ }
+ /**
+ * deliver liefert das Template mit dem Filenamen templateFilename
+ * an den HttpServletResponse res aus, nachdem es mit den Daten aus
+ * TemplateModelRoot rtm gemischt wurde
+ *
+ * @param res Http-Response, die vom Dispatcher durchgereicht wird
* @param entity Entity, aus der die Daten, die ins Template gemerged werden sollen.
* @param tmpl Name des Templates
* @exception ServletModuleException
import java.util.*;
import java.sql.*;
+import freemarker.template.*;
+
import mir.entity.*;
import mir.misc.*;
import mir.storage.*;
-public class EntityBreaking extends AbstractEntity implements Entity
+public class EntityBreaking extends AbstractEntity implements Entity, TemplateHashModel
{
- private static int instances;
+ private static int instances;
public EntityBreaking() { super(); instances++; }
public EntityBreaking(StorageObject theStorage) { this(); setStorage(theStorage); }
returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
return returnHash;
}
+
+ // Now implements freemarkers TemplateHashModel
+ // two methods have to be overridden:
+ // 1. public boolean isEmpty() throws TemplateModelException
+ // 2. public TemplateModel get(java.lang.String key) throws TemplateModelException
+
+ public boolean isEmpty() throws TemplateModelException
+ {
+ if (theValuesHash==null || theValuesHash.isEmpty())
+ return true;
+ return false;
+ }
+
+ public TemplateModel get(java.lang.String key) throws TemplateModelException
+ {
+ return new SimpleScalar(getValue("key"));
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////////
+
}
catch (IOException e) {throw new ServletModuleException(e.toString());}
catch (Exception e) {throw new ServletModuleException(e.toString());}
}
+
+
+
+ // test: deriving entity from freemarker.template.TemplateHashModel
+ //////////////////////////////////////////////////////////////////////////////
+
+ public void edit(HttpServletRequest req, HttpServletResponse res)
+ throws ServletModuleException {
+ try {
+ String idParam = req.getParameter("id");
+ deliver(req, res, (TemplateModelRoot)mainModule.getById(idParam), templateObjektString);
+ } catch(ModuleException e) {
+ throw new ServletModuleException(e.toString());
+ }
+ }
}
if (confirmParam!= null && !confirmParam.equals("")) {
try {
mainModule.deleteById(idParam);
+
+ /** @todo the following two should be imlied in
+ * DatabaseContent */
+
//delete rows in the content_x_topic-table
DatabaseContentToTopics.getInstance().deleteByContentId(idParam);
//delete rows in the comment-table
EntityUsers user = _getUser(req);
if (user==null) theLog.printDebugInfo("user null!");
String idParam = req.getParameter("id");
- if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben");
+ if (idParam == null) throw new ServletModuleException("Wrong call: (id) is missing");
HashMap withValues = getIntersectingValues(req, DatabaseContent.getInstance());
- //String topic_id = req.getParameter("to_topic");
String[] topic_id = req.getParameterValues("to_topic");
String content_id = req.getParameter("id");
// withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));