*/
public final class HTMLTemplateProcessor {
- public static String templateDir;
- private static FileTemplateCache templateCache;
- private static Logfile theLog;
- private static String docRoot;
- private static String actionRoot;
- private static String productionHost;
- private static String audioHost;
- private static String videoHost;
- private static String imageHost;
- private static String openAction;
- protected static String producerDocRoot = MirConfig.getProp("Producer.DocRoot");
- protected static String producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
-
-
- //
- // Initialisierung
-
- static {
- templateDir = MirConfig.getProp("Home") + MirConfig.getProp("HTMLTemplateProcessor.Dir");
- templateCache = new FileTemplateCache(templateDir);
- templateCache.setLoadingPolicy(templateCache.LOAD_ON_DEMAND);
- templateCache.startAutoUpdate();
- theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("HTMLTemplateProcessor.Logfile"));
- docRoot = MirConfig.getProp("RootUri");
- //quickhack: action-root is only for Mir!!!!, idfx
- //actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");
- actionRoot = docRoot + "/servlet/Mir";
- openAction = MirConfig.getProp("Producer.OpenAction");
- productionHost = MirConfig.getProp("Producer.ProductionHost");
- videoHost = MirConfig.getProp("Producer.VideoHost");
- audioHost = MirConfig.getProp("Producer.AudioHost");
- imageHost = MirConfig.getProp("Producer.Image.Host");
- producerDocRoot = MirConfig.getProp("Producer.DocRoot");
- producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
+ public static String templateDir;
+ private static FileTemplateCache templateCache;
+ private static Logfile theLog;
+ private static String docRoot;
+ private static String actionRoot;
+ private static String productionHost;
+ private static String audioHost;
+ private static String videoHost;
+ private static String imageHost;
+ private static String openAction;
+ protected static String producerDocRoot = MirConfig.getProp("Producer.DocRoot");
+ protected static String producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
+
+
+ //
+ // init
+
+ static {
+
+ templateDir = MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
+ templateCache = new FileTemplateCache(templateDir);
+ templateCache.setLoadingPolicy(templateCache.LOAD_ON_DEMAND);
+ templateCache.startAutoUpdate();
+ theLog = Logfile.getInstance(MirConfig.getPropWithHome("HTMLTemplateProcessor.Logfile"));
+ docRoot = MirConfig.getProp("RootUri");
+ /** @todo
+ quickhack: action-root is only for Mir!!!!, idfx
+ actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");*/
+ actionRoot = docRoot + "/servlet/Mir";
+ openAction = MirConfig.getProp("Producer.OpenAction");
+ productionHost = MirConfig.getProp("Producer.ProductionHost");
+ videoHost = MirConfig.getProp("Producer.VideoHost");
+ audioHost = MirConfig.getProp("Producer.AudioHost");
+ imageHost = MirConfig.getProp("Producer.Image.Host");
+ producerDocRoot = MirConfig.getProp("Producer.DocRoot");
+ producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
-
- }
+ }
/**
- * Privater Konstruktor, um versehentliche Instantiierung zu verhindern
+ * empty private constructor, to avoid instantiation
*/
- private HTMLTemplateProcessor () {
- }
+ private HTMLTemplateProcessor () { }
- //
- // process-Methoden zum Mischen verschiedener Datenstrukturen mit HTML-Templates
+ // process-methods to merge different datastructures
+ // with freemarker templates
/**
public static void process(String templateFilename, Entity anEntity, PrintWriter out)
throws HTMLParseException {
- if (anEntity == null) throw new HTMLParseException("Entity leer!");
+ if (anEntity == null) throw new HTMLParseException("entity is empty!");
else process(templateFilename, anEntity, out);
}
- /**
+ /**
* Wandelt Liste mit Entities <code>entList</code> in freemarker-Struktur um, mischt die Daten mit
* Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter
* <code>out</code>
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename, EntityList entList, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename, EntityList entList, PrintWriter out)
throws HTMLParseException {
- process(res, templateFilename, entList, (String)null, (TemplateModelRoot)null, out);
- }
+ process(res, templateFilename, entList, (String)null, (TemplateModelRoot)null, out);
+ }
/**
* Wandelt Entitylist in freemarker-Struktur um, fügt <code>additionalModel</code>
SimpleHash modelRoot = new SimpleHash();
if (entList == null) {
- //theLog.printInfo("Keine Daten! Suche erfolglos.");
process(null,templateFilename, modelRoot, out);
} else {
try {
modelRoot = makeSimpleHashWithEntitylistInfos(entList);
- //
- // Hilfskruecke um mal ein Popup mit reinzunhemen ..
+
+ // Quickhack um mal ein Popup mit reinzunhemen ..
if (additionalModelName != null && additionalModel != null)
modelRoot.put(additionalModelName, additionalModel);
Template tmpl = getTemplateFor(templateFilename);
if (tmpl == null) throw new HTMLParseException("KEIN TEMPLATE: " + templateFilename);
if (tmr==null) tmr = new SimpleHash();
-
+
String session=null;
if (res!=null) {
session=res.encodeURL("");
}
/**
- * Private Methode, um für templateFilename das Template zu bekommen.
+ * Private methods to get template from a templateFilename
* @param templateFilename
* @return Template
* @exception HTMLParseException
*/
private static Template getTemplateFor(String templateFilename) throws HTMLParseException
- {
- if (templateFilename!=null) return templateCache.getTemplate(templateFilename);
- else {
- theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);
- throw new HTMLParseException("Templatedatei: "+ templateFilename + " nicht gefunden!");
- }
+ {
+ if (templateFilename!=null) return templateCache.getTemplate(templateFilename);
+ else {
+ theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);
+ throw new HTMLParseException("Templatefile: "+ templateFilename + " not found.");
}
+ }
+ public static void stopAutoUpdate(){
+ templateCache.stopAutoUpdate();
+ templateCache=null;
+ }
- public static void stopAutoUpdate(){
- templateCache.stopAutoUpdate();
- templateCache=null;
- }
}