Entity now freemarker compliant, freemarker lib update, deprecation of HTMLTemplatePr...
authorrk <rk>
Mon, 4 Feb 2002 19:22:44 +0000 (19:22 +0000)
committerrk <rk>
Mon, 4 Feb 2002 19:22:44 +0000 (19:22 +0000)
21 files changed:
lib/freemarker-utility.jar
lib/freemarker.jar
source/mir/entity/AbstractEntity.java [deleted file]
source/mir/entity/Entity.java
source/mir/entity/GenericEntity.java
source/mir/misc/HTMLTemplateProcessor.java
source/mir/module/AbstractModule.java
source/mir/servlet/ServletModule.java
source/mir/servlet/ServletModuleMonitor.java
source/mir/storage/Database.java
source/mircoders/entity/EntityBreaking.java
source/mircoders/entity/EntityComment.java
source/mircoders/entity/EntityContent.java
source/mircoders/entity/EntityFeature.java
source/mircoders/entity/EntityImages.java
source/mircoders/entity/EntityLinksImcs.java
source/mircoders/entity/EntityMedia.java
source/mircoders/entity/EntityTopics.java
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/entity/EntityUsers.java
source/mircoders/entity/EntityVideo.java

index aef43da..6887389 100755 (executable)
Binary files a/lib/freemarker-utility.jar and b/lib/freemarker-utility.jar differ
index f0b895a..3962afb 100755 (executable)
Binary files a/lib/freemarker.jar and b/lib/freemarker.jar differ
diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java
deleted file mode 100755 (executable)
index dddb33f..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * <b>abstrakte Basisklasse der Entity-Klassen</b><p>
- */
-
-
-package  mir.entity;
-
-import java.lang.*;
-import java.io.*;
-import java.util.*;
-import java.sql.*;
-
-import mir.storage.*;
-import mir.misc.*;
-
-/**
- * abstrakte Basisklasse der Entity-Klassen
- *
- * @author RK
- * @version 29.6.1999
- *
- */
-
-public class AbstractEntity implements Entity
-{
-  private boolean             changed;
-  protected HashMap           theValuesHash;   // tablekey / value
-  protected StorageObject     theStorageObject;
-  protected static Logfile    theLog;
-  protected ArrayList         streamedInput=null;
-  private static int instances = 0;
-    static {
-      theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Entity.Logfile"));
-    }
-
-    public AbstractEntity() {
-      this.changed = false;
-      instances++;
-    }
-
-  /**
-   * Konstruktor
-   */
-  public AbstractEntity (StorageObject StorageObject) {
-    this();
-    setStorage(StorageObject);
-  }
-
-  /*
-   * Setzt das StorageObject der Entity.
-   */
-  public void setStorage (StorageObject storage) {
-    this.theStorageObject = storage;
-  }
-
-  /**
-   * Setzt die Werte der Entity
-   * @param theStringValues
-   */
-
-  public void setValues(HashMap theStringValues)
-  {
-    /** @todo should be synchronized */
-    theValuesHash = new HashMap();
-    String aKey;
-    Set set = theStringValues.keySet();
-    Iterator it = set.iterator();
-    int size = set.size();
-    for (int i = 0; i < size; i++) {
-      aKey = (String)it.next();
-      theValuesHash.put(aKey, (String)theStringValues.get(aKey));
-    }
- }
-
-  /**
-   * Liefert boolschen Wert, ob sich der Inhalt der Entity geändert hat.
-   * @return true wenn ja, sonst false
-   */
-  public boolean changed () {
-    return  changed;
-  }
-
-  /**
-   * Liefert den Primärschluessel der Entity zurueck
-   * @return String Id
-   */
-  public String getId () {
-    return  (String)getValue(theStorageObject.getIdName());
-  }
-
-  /**
-   * Setzt den Primaerschluessel der Entity
-   * @param id
-   */
-  public void setId (String id) {
-    theValuesHash.put(theStorageObject.getIdName(), id);
-      }
-
-  /**
-   * Liefert den Wert für einen Feldnamen zurueck
-   * @param theFieldString
-   * @return Wert für Feld
-   */
-  public String getValue (String theFieldString) {
-    return  (String)theValuesHash.get(theFieldString);
-    }
-
-  /**
-   * Fügt Entity via StorageObject in Datenbank ein.
-   * @return Primary Key der Entity
-   * @exception StorageObjectException
-   */
-  public String insert () throws StorageObjectException {
-    theLog.printDebugInfo("Entity: trying to insert ...");
-    if (theStorageObject != null) {
-      return theStorageObject.insert((Entity)this);
-    }
-    else
-      throw  new StorageObjectException("Kein StorageObject gesetzt!");
-  }
-
-  /**
-   * Aktualisiert Aenderungen an der Entity in der Datenbank
-   * @exception StorageObjectException
-   */
-  public void update () throws StorageObjectException {
-    theStorageObject.update((Entity)this);
-  }
-
-  /**
-   * Setzt den Wert fuer ein Feld
-   * @param theProp
-   * @param theValue
-   * @exception StorageObjectException
-   */
-  public void setValueForProperty (String theProp, String theValue) throws StorageObjectException {
-    this.changed = true;
-    if (isField(theProp))
-      theValuesHash.put(theProp, theValue);
-    else
-      theLog.printWarning("Property not found: " + theProp+theValue);
-
-  }
-
-  /**
-   * Gibt die Feldnamen der Entity als ArrayList zurueck
-   * @return ArrayList mit Feldnamen
-   * @exception StorageObjectException wird geworfen, wenn kein Zugriff auf die Datenbank
-   *    möglich.
-   */
-  public ArrayList getFields () throws StorageObjectException {
-    return  theStorageObject.getFields();
-    }
-
-  /**
-   * Liefert ein int[] mit den Typen der Felder zurueck
-   * @return int[] mit den Feldtypen
-   * @exception StorageObjectException
-   */
-  public int[] getTypes () throws StorageObjectException {
-    return  theStorageObject.getTypes();
-    }
-
-  /**
-   * Liefert ArrayListe mit Feldnamen zurueck.
-   * @return Liste mit Feldnamen
-   * @exception StorageObjectException
-   */
-  public ArrayList getLabels () throws StorageObjectException {
-    return  theStorageObject.getLabels();
-    }
-
-  /**
-   * Liefert eine Hashmap mit allen Werten der Entity zurueck
-   * @return HashMap mit Feldname/Wert
-   */
-    public HashMap getValues() {
-      return theValuesHash;
-    }
-
-    /**
-     *  Liefert einen ArrayList mit allen Datenbankfeldern, die
-     *  als streamedInput ausgelesen werden muessen.
-     *  Waere automatisierbar ueber die types (blob, etc.)
-     *  Bisher manuell anzulegen in der erbenden Klasse
-     */
-
-  public ArrayList streamedInput() {
-    return streamedInput;
-  }
-
-   /* Fragt ab, ob fieldName einem Feld entspricht
-   * @param fieldName
-   * @return true, wennn ja, sonst false
-   * @exception StorageObjectException
-   */
-  public boolean isField (String fieldName) throws StorageObjectException {
-    return  theStorageObject.getFields().contains(fieldName);
-  }
-
-   /** Liefert Anzahl der Instanzen zurück
-   * @return int
-   */
-  public int getInstances() {
-     return instances;
-  }
-
-  protected void throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
-    theLog.printError( e.toString() + " Funktion: "+ wo);
-    throw  new StorageObjectException("Storage Object Exception in entity" +e.toString());
-  }
-
-  /**
-   * Gibt eine Instanz frei
-   */
-  public void finalize () {
-    instances--;
-    try {
-      super.finalize();
-    } catch (Throwable t) {
-      System.err.println(t.toString());
-    }
-  }
-}
-
index bff5eb2..d10fb93 100755 (executable)
-/*
- * put your module comment here
+/**
+ * Base class the entities are derived from. Provides base functionality of
+ * an entity<p>
  */
 
 
-package mir.entity;
+package  mir.entity;
 
 import java.lang.*;
+import java.io.*;
 import java.util.*;
+import java.sql.*;
+
+import freemarker.template.*;
+
 import mir.storage.*;
+import mir.misc.*;
 
 /**
- * Interface-Definition für Entities
+ * Base Class of Entities
+ * Interfacing TemplateHashModel and TemplateModelRoot to be freemarker compliant
+ *
+ * @author rk
+ * @version 29.6.1999
+ *
  */
 
-public interface Entity {
-
-       /**
-        * Eine Entity muss setStorage implementieren, mit der eine Entity mit einem
-        * StorageObject assoziiert wird.
-        *
-        * @param st
-        */
-       public abstract void setStorage (StorageObject st);
-
-
-
-       /**
-        * Eine Entity muss setValues implementieren, mit der die Werte der Entity gesetzt werden
-        * können.
-        *
-        * @param ht
-        */
-               public abstract void setValues(HashMap ht);
-
-
-
-       /**
-        * Eine Entity muss getValues implementieren, mit der die Werte der Entity
-        * als HashMap zurueckgeliefert werden
-        * @return Werte der Entity
-        */
-               public abstract HashMap getValues();
-
-
-
-       /**
-        * Eine Entity muss getFields implementieren, mit der die Feldnamen der
-        * Entity zurueckgegeben werden.
-        * @return ArrayList der Feldnamen
-        * @exception StorageObjectException
-        */
-       public abstract ArrayList getFields () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getTypes implementieren, mit der die Feldtype der
-        * Entity zurueckgegeben werden.
-        * @return int[] der Feldtypen
-        * @exception StorageObjectException
-        */
-       public abstract int[] getTypes () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getLabels implementieren, mit der die Feldnamen der
-        * Entity zurueckgegeben werden.
-        * @return ArrayList der Feldnamen
-        * @exception StorageObjectException
-        */
-       public abstract ArrayList getLabels () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getId implementieren, um den Primaerschuessel der
-        * Entity zurueckgeliefert zu bekommen.
-        *
-        * @return Primary-Key der Entity
-        */
-               public abstract String getId();
-
-
-
-       /**
-        * Eine Entity muss setId implementieren, um den Primaerschuessel der
-        * Entity zu setzen
-        *
-        * @param str
-        */
-               public abstract void setId(String str);
-
-
-       /**
-        * Eine Entity muss getValue implementieren, um den Wert eines
-        * Feldes zurueckzugeben
-        *
-        * @param field
-        * @return Wert von Feld field
-        */
-       public abstract String getValue (String field);
-
-
-
-       /**
-        * Einfügen der Entity in StorageObject
-        *
-        * @return Primary-Key der eingefügten Entity
-        * @exception StorageObjectException
-        */
-       public abstract String insert () throws StorageObjectException;
-
-
-
-       /**
-        * Aktualisieren der Entity via StorageObject
-        * @exception StorageObjectException
-        */
-       public abstract void update () throws StorageObjectException;
-
-
-
-       /**
-        * ArrayListe mit Feldern, die einer Sonderbehandlung bedürfen (blobs)
-        * @return Liste der Feldnamen
-        */
-       public abstract ArrayList streamedInput ();
-
-
-       public abstract void setValueForProperty (String theProp, String theValue) throws StorageObjectException;
+public class Entity implements TemplateHashModel, TemplateModelRoot
+{
+  private boolean             changed;
+  protected HashMap           theValuesHash;   // tablekey / value
+  protected StorageObject     theStorageObject;
+  protected static Logfile    theLog;
+  protected ArrayList         streamedInput=null;
+  private static int instances = 0;
+    static {
+      theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Entity.Logfile"));
+    }
+
+    public Entity() {
+
+      this.changed = false;
+      instances++;
+      Integer i = new Integer(instances);
+      System.err.println("New abstract entity instance: "+i.toString());
+    }
+
+  /**
+   * Konstruktor
+   */
+  public Entity (StorageObject StorageObject) {
+    this();
+    setStorage(StorageObject);
+  }
+
+  /*
+   * Setzt das StorageObject der Entity.
+   */
+  public void setStorage (StorageObject storage) {
+    this.theStorageObject = storage;
+  }
+
+  /**
+   * Setzt die Werte der Entity
+   * @param theStringValues
+   */
+
+  public void setValues(HashMap theStringValues)
+  {
+    /** @todo should be synchronized */
+    theValuesHash = new HashMap();
+    String aKey;
+    Set set = theStringValues.keySet();
+    Iterator it = set.iterator();
+    int size = set.size();
+    for (int i = 0; i < size; i++) {
+      aKey = (String)it.next();
+      theValuesHash.put(aKey, (String)theStringValues.get(aKey));
+    }
+ }
+
+  /**
+   * Liefert boolschen Wert, ob sich der Inhalt der Entity geändert hat.
+   * @return true wenn ja, sonst false
+   */
+  public boolean changed () {
+    return  changed;
+  }
+
+  /**
+   * Liefert den Primärschluessel der Entity zurueck
+   * @return String Id
+   */
+  public String getId () {
+    return  (String)getValue(theStorageObject.getIdName());
+  }
+
+  /**
+   * Setzt den Primaerschluessel der Entity
+   * @param id
+   */
+  public void setId (String id) {
+    theValuesHash.put(theStorageObject.getIdName(), id);
+      }
+
+  /**
+   * Liefert den Wert für einen Feldnamen zurueck
+   * @param theFieldString
+   * @return Wert für Feld
+   */
+  public String getValue (String field) {
+    String returnValue = null;
+    if (field != null)
+    {
+      if (field.equals("webdb_create_formatted"))
+      {
+               if (hasValueForField("webdb_create"))
+                       returnValue=StringUtil.dateToReadableDate(getValue("webdb_create"));
+      }
+      else if (field.equals("webdb_lastchange_formatted"))
+      {
+        if (hasValueForField("webdblast_change"))
+                           returnValue=StringUtil.dateToReadableDate(getValue("webdb_lastchange"));
+      }
+      else
+        returnValue = (String)theValuesHash.get(field);
+    }
+    return returnValue;
+  }
+
+
+  public boolean hasValueForField(String field)
+  {
+    if (theValuesHash!=null)
+      return theValuesHash.containsKey(field);
+    return false;
+  }
+
+  /**
+   * Fügt Entity via StorageObject in Datenbank ein.
+   * @return Primary Key der Entity
+   * @exception StorageObjectException
+   */
+  public String insert () throws StorageObjectException {
+    theLog.printDebugInfo("Entity: trying to insert ...");
+    if (theStorageObject != null) {
+      return theStorageObject.insert((Entity)this);
+    }
+    else
+      throw  new StorageObjectException("Kein StorageObject gesetzt!");
+  }
+
+  /**
+   * Aktualisiert Aenderungen an der Entity in der Datenbank
+   * @exception StorageObjectException
+   */
+  public void update () throws StorageObjectException {
+    theStorageObject.update((Entity)this);
+  }
+
+  /**
+   * Setzt den Wert fuer ein Feld
+   * @param theProp
+   * @param theValue
+   * @exception StorageObjectException
+   */
+  public void setValueForProperty (String theProp, String theValue) throws StorageObjectException {
+    this.changed = true;
+    if (isField(theProp))
+      theValuesHash.put(theProp, theValue);
+    else
+      theLog.printWarning("Property not found: " + theProp+theValue);
+
+  }
+
+  /**
+   * Gibt die Feldnamen der Entity als ArrayList zurueck
+   * @return ArrayList mit Feldnamen
+   * @exception StorageObjectException wird geworfen, wenn kein Zugriff auf die Datenbank
+   *    möglich.
+   */
+  public ArrayList getFields () throws StorageObjectException {
+    return  theStorageObject.getFields();
+    }
+
+  /**
+   * Liefert ein int[] mit den Typen der Felder zurueck
+   * @return int[] mit den Feldtypen
+   * @exception StorageObjectException
+   */
+  public int[] getTypes () throws StorageObjectException {
+    return  theStorageObject.getTypes();
+    }
+
+  /**
+   * Liefert ArrayListe mit Feldnamen zurueck.
+   * @return Liste mit Feldnamen
+   * @exception StorageObjectException
+   */
+  public ArrayList getLabels () throws StorageObjectException {
+    return  theStorageObject.getLabels();
+    }
+
+  /**
+   * Liefert eine Hashmap mit allen Werten der Entity zurueck
+   * @return HashMap mit Feldname/Wert
+   *
+   * @deprecated This method is deprecated and will be deleted in the next release.
+   *  Entity interfaces freemarker.template.TemplateHashModel now and can
+   *  be used in the same way as SimpleHash.
+
+   */
+    public HashMap getValues() {
+      theLog.printWarning("## using deprecated Entity.getValues() - a waste of resources");
+      return theValuesHash;
+    }
+
+    /**
+     *  Liefert einen ArrayList mit allen Datenbankfeldern, die
+     *  als streamedInput ausgelesen werden muessen.
+     *  Waere automatisierbar ueber die types (blob, etc.)
+     *  Bisher manuell anzulegen in der erbenden Klasse
+     */
+
+  public ArrayList streamedInput() {
+    return streamedInput;
+  }
+
+   /* Fragt ab, ob fieldName einem Feld entspricht
+   * @param fieldName
+   * @return true, wennn ja, sonst false
+   * @exception StorageObjectException
+   */
+  public boolean isField (String fieldName) throws StorageObjectException {
+    return  theStorageObject.getFields().contains(fieldName);
+  }
+
+   /** Liefert Anzahl der Instanzen zurück
+   * @return int
+   */
+  public int getInstances() {
+     return instances;
+  }
+
+  protected void throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
+    theLog.printError( e.toString() + " Funktion: "+ wo);
+    throw  new StorageObjectException("Storage Object Exception in entity" +e.toString());
+  }
+
+  /**
+   * Gibt eine Instanz frei
+   */
+  public void finalize () {
+    instances--;
+    try {
+      super.finalize();
+    } catch (Throwable t) {
+      System.err.println(t.toString());
+    }
+  }
+
+
+  // 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));
+  }
+
+  public void put(java.lang.String key, TemplateModel model)
+  {
+    // putting should only take place via setValue
+  }
+
+  public void remove(java.lang.String key)
+  {
+    // do we need this?
+  }
+
+
+  //////////////////////////////////////////////////////////////////////////////////
 
 
 }
 
-
-
-
index 12f3d56..8a76699 100755 (executable)
@@ -11,8 +11,7 @@ package mir.entity;
  * @author /rk
  * @version 1.2
  */
-public class GenericEntity extends AbstractEntity
-               implements Entity {}
+public class GenericEntity extends Entity {}
 
 
 
index ef15a58..8a79705 100755 (executable)
@@ -42,9 +42,10 @@ public final class HTMLTemplateProcessor {
     templateDir = MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
     templateCache = new FileTemplateCache(templateDir);
     templateCache.setLoadingPolicy(templateCache.LOAD_ON_DEMAND);
-    templateCache.startAutoUpdate();
+    // gone in freemarker 1.7.1
+    // templateCache.startAutoUpdate();
+    theLog = Logfile.getInstance(MirConfig.getPropWithHome("HTMLTemplateProcessor.Logfile"));
     docRoot = MirConfig.getProp("RootUri");
-    theLog=Logfile.getInstance("HTMLTemplateProcessor");
     //the quick hack is back in effect as it was more broken than ever before
     // -mh
     // sorry: nadir back in town, i have to debug the mirbase.jar in the
@@ -53,8 +54,9 @@ public final class HTMLTemplateProcessor {
     // yeah, from my point too - tob.
        //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");
@@ -67,7 +69,7 @@ public final class HTMLTemplateProcessor {
   /**
    * empty private constructor, to avoid instantiation
    */
-  private HTMLTemplateProcessor ()  {}
+  private HTMLTemplateProcessor () }
 
 
   // process-methods to merge different datastructures
@@ -230,7 +232,7 @@ public final class HTMLTemplateProcessor {
     SimpleList  simpleList = new SimpleList();
     if (aList != null) {
       for(int i=0;i<aList.size();i++) {
-        simpleList.add(makeSimpleHash(aList.elementAt(i)));
+        simpleList.add(aList.elementAt(i));
       }
     }
     return simpleList;
@@ -251,7 +253,7 @@ public final class HTMLTemplateProcessor {
     if (aList != null) {
       for (int i=0;i<aList.size();i++) {
          currentEntity = (Entity)aList.elementAt(i);
-         simpleHash.put(currentEntity.getId(), makeSimpleHash(currentEntity));
+         simpleHash.put(currentEntity.getId(), currentEntity);
       }
     }
     return simpleHash;
@@ -262,10 +264,16 @@ public final class HTMLTemplateProcessor {
    *  @param entity ist die Entity
    *  @return SimpleHash mit den entsprechenden freemarker Daten
    *
+   *  @deprecated This method is deprecated and will be deleted in the next release.
+   *  AbstractEntity interfaces freemarker.template.TemplateHashModel now and can
+   *  be used in the same way as SimpleHash. It is not necessary any more to make
+   *  a SimpleHash from an Entity
    */
   public static SimpleHash makeSimpleHash(Entity entity) {
-    if (entity != null)
+    if (entity != null) {
+      theLog.printWarning("## using deprecated makeSimpleHash(entity) - a waste of resources");
       return makeSimpleHash(entity.getValues());
+    }
     else
       return null;
   }
@@ -335,11 +343,17 @@ public final class HTMLTemplateProcessor {
    */
   private static Template getTemplateFor(String templateFilename) throws HTMLParseException
   {
-    if (templateFilename!=null) return templateCache.getTemplate(templateFilename);
-    else {
+    Template returnTemplate = null;
+    if (templateFilename!=null)
+      returnTemplate = templateCache.getTemplate(templateFilename);
+
+
+    if (returnTemplate==null) {
       theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);
       throw new HTMLParseException("Templatefile: "+ templateFilename + " not found.");
     }
+
+    return returnTemplate;
   }
 
   public static void stopAutoUpdate(){
index b834130..68212d6 100755 (executable)
@@ -14,10 +14,17 @@ import  mir.entity.*;
 
 
 /**
+ * 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;
 
@@ -41,10 +48,10 @@ public class AbstractModule {
        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){
index 6bd2d87..6e4998b 100755 (executable)
@@ -14,6 +14,11 @@ import  mir.misc.*;
 
 
 /**
+ * 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.
  *
@@ -276,13 +281,24 @@ public abstract class ServletModule {
    * 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 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(HttpServletRequest req, HttpServletResponse res, Entity ent, String templateFilename)
+  public void deliver_compressed(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm, String templateFilename)
     throws ServletModuleException {
-    deliver(req, res,HTMLTemplateProcessor.makeSimpleHash(ent), templateFilename);
+    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());
+    }
   }
 
   /**
index 0a5b387..3bfdd1f 100755 (executable)
@@ -49,7 +49,7 @@ public class ServletModuleMonitor extends ServletModule
     }
   }
   protected int getInstances(){
-    AbstractEntity ent = new AbstractEntity();
+    Entity ent = new Entity();
     return ent.getInstances();
   }
   public String getInstancesInfo(){
index aeb5cb6..f6de097 100755 (executable)
@@ -7,8 +7,7 @@ import  java.sql.*;
 import  java.lang.*;
 import  java.io.*;
 import  java.util.*;
-import  freemarker.template.SimpleList;
-import  freemarker.template.SimpleHash;
+import  freemarker.template.*;
 import  com.javaexchange.dbConnectionBroker.*;
 import  mir.storage.StorageObject;
 import  mir.entity.*;
@@ -564,7 +563,6 @@ public class Database implements StorageObject {
     //cache
     invalidatePopupCache();
     try {
-      HashMap theEntityValues = theEntity.getValues();
       ArrayList streamedInput = theEntity.streamedInput();
       StringBuffer f = new StringBuffer();
       StringBuffer v = new StringBuffer();
@@ -584,8 +582,8 @@ public class Database implements StorageObject {
               aValue = "?";
             }
             else {
-              if (theEntityValues.containsKey(aField)) {
-                aValue = "'" + StringUtil.quote((String)theEntityValues.get(aField))
+              if (theEntity.hasValueForField(aField)) {
+                aValue = "'" + StringUtil.quote((String)theEntity.getValue(aField))
                     + "'";
               }
             }
@@ -613,7 +611,7 @@ public class Database implements StorageObject {
       pstmt = con.prepareStatement(sql);
       if (streamedInput != null) {
         for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString = (String)theEntityValues.get(streamedInput.get(i));
+          String inputString = (String)theEntity.getValue((String)streamedInput.get(i));
           pstmt.setBytes(i + 1, inputString.getBytes());
         }
       }
@@ -650,7 +648,6 @@ public class Database implements StorageObject {
     Connection con = null;
     PreparedStatement pstmt = null;
     ArrayList streamedInput = theEntity.streamedInput();
-    HashMap theEntityValues = theEntity.getValues();
     String id = theEntity.getId();
     String aField;
     StringBuffer fv = new StringBuffer();
@@ -663,14 +660,14 @@ public class Database implements StorageObject {
       // only normal cases
       if (!(aField.equals(thePKeyName) || aField.equals("webdb_create") ||
           aField.equals("webdb_lastchange") || (streamedInput != null && streamedInput.contains(aField)))) {
-        if (theEntityValues.containsKey(aField)) {
+        if (theEntity.hasValueForField(aField)) {
           if (firstField == false) {
             fv.append(", ");
           }
           else {
             firstField = false;
           }
-          fv.append(aField).append("='").append(StringUtil.quote((String)theEntityValues.get(aField))).append("'");
+          fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
         }
       }
     }
@@ -693,7 +690,7 @@ public class Database implements StorageObject {
       pstmt = con.prepareStatement(sql.toString());
       if (streamedInput != null) {
         for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString = (String)theEntityValues.get(streamedInput.get(i));
+          String inputString = theEntity.getValue((String)streamedInput.get(i));
           pstmt.setBytes(i + 1, inputString.getBytes());
         }
       }
index 1227601..86882a8 100755 (executable)
@@ -14,11 +14,13 @@ import java.io.*;
 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 Entity
 {
        private static int instances;
 
@@ -29,13 +31,9 @@ public class EntityBreaking extends AbstractEntity implements Entity
     super.finalize();
   }
 
+  /* @deprecated */
+  public HashMap getValues() {
+    return super.getValues();
+  }
 
-       public HashMap getValues() {
-               HashMap returnHash = super.getValues();
-               String date=null;
-
-               if ((date=(String)returnHash.get("webdb_create"))!=null)
-                       returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
-               return returnHash;
-       }
 }
index 4770334..e599d8e 100755 (executable)
@@ -19,7 +19,7 @@ import mir.storage.*;
  */
 
 
-public class EntityComment extends AbstractEntity implements Entity
+public class EntityComment extends Entity
 {
   private static int instances;
 
@@ -34,13 +34,6 @@ public class EntityComment extends AbstractEntity implements Entity
     setStorage(theStorage);
   }
 
-  public HashMap getValues() {
-    HashMap returnHash = super.getValues();
-    String create = (String)returnHash.get("webdb_create");
-    returnHash.put("date",StringUtil.dateToReadableDate(create));
-
-    return returnHash;
-  }
 
   /**
    * overridden method setValues to patch creator_main_url
@@ -51,7 +44,7 @@ public class EntityComment extends AbstractEntity implements Entity
       if (!theStringValues.containsKey("is_published")) {
        theStringValues.put("is_published","0");
                        }
-                   
+
                        if (theStringValues.containsKey("main_url")){
                                if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) {
                                        theStringValues.remove("main_url");
@@ -60,7 +53,7 @@ public class EntityComment extends AbstractEntity implements Entity
                                        theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url")));
                                }
                        }
-                       
+
     }
     super.setValues(theStringValues);
   }
index 14b8971..39b0428 100755 (executable)
@@ -22,7 +22,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityContent extends AbstractEntity implements Entity
+public class EntityContent extends Entity
 {
 
        private static int      instances;
@@ -129,21 +129,20 @@ public class EntityContent extends AbstractEntity implements Entity
        }
 
        /**
-        * overridden method getValues to include formatted date into every
+        * overridden method getValue to include formatted date into every
         * entityContent
         */
 
-       public HashMap getValues() {
-               HashMap returnHash = super.getValues();
-               String date=null;
-
-               if ((date=(String)returnHash.get("date"))!=null)
-                       returnHash.put("date_formatted", StringUtil.webdbDate2readableDate(date));
-               if ((date=(String)returnHash.get("webdb_create"))!=null)
-                       returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
-               if ((date=(String)returnHash.get("webdb_lastchange"))!=null)
-                       returnHash.put("webdb_lastchange_formatted", StringUtil.dateToReadableDate(date));
-               return returnHash;
+       public String getValue(String field)
+  {
+    if (field!=null && field.equals("date_formatted"))
+    {
+               if (hasValueForField("date"))
+       return StringUtil.webdbDate2readableDate(getValue("date"));
+      else return null;
+               }
+    else
+      return super.getValue(field);
        }
 
        /**
index de1f0de..16d422e 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityFeature extends AbstractEntity implements Entity
+public class EntityFeature extends Entity
 {
                private static int instances;
 
index 577f3f1..7e75b40 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityImages extends AbstractEntity implements Entity
+public class EntityImages extends Entity
 {
        private static int instances;
 
@@ -71,7 +71,7 @@ public class EntityImages extends AbstractEntity implements Entity
         if (imageType.equals("1"))
             type = 1;
          //end hack
-            
+
                if (uploadData!=null) {
                        Connection con=null;PreparedStatement pstmt=null;
                        try {
index 8c321d5..6b83557 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityLinksImcs extends AbstractEntity implements Entity
+public class EntityLinksImcs extends Entity
 {
   private static int instances;
 
index a1c4f63..c4cc9ab 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityMedia extends AbstractEntity implements Entity
+public class EntityMedia extends Entity
 {
   private static int instances;
 
index 409e301..6b985d8 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityTopics extends AbstractEntity implements Entity
+public class EntityTopics extends Entity
 {
   private static int instances;
 
index 95800ec..d7f0561 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityUploadedMedia extends AbstractEntity implements Entity
+public class EntityUploadedMedia extends Entity
 {
   private static int instances;
 
index 6527123..56f9912 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityUsers extends AbstractEntity implements Entity
+public class EntityUsers extends Entity
 {
                private static int instances;
 
index ae08955..fd44a60 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityVideo extends AbstractEntity implements Entity
+public class EntityVideo extends Entity
 {
        private static int instances;