major cleanup:
authorzapata <zapata>
Wed, 3 Sep 2003 17:49:37 +0000 (17:49 +0000)
committerzapata <zapata>
Wed, 3 Sep 2003 17:49:37 +0000 (17:49 +0000)
- freemarker dependencies isolated in 1 or 2 files
- all servlets use the generator infrastructure
- removed lots of dead wood
- misc. small fixes here and there

116 files changed:
bundles/admin_en.properties
source/Mir.java
source/default.properties
source/mir/entity/Entity.java
source/mir/entity/EntityList.java
source/mir/entity/EntityRelation.java [deleted file]
source/mir/entity/adapter/EntityAdapterDefinition.java
source/mir/entity/adapter/EntityListAdapter.java
source/mir/generator/FreemarkerGenerator.java
source/mir/media/MirMedia.java
source/mir/misc/HTMLTemplateProcessor.java [deleted file]
source/mir/module/AbstractModule.java
source/mir/producer/EntityBatchingProducerNode.java
source/mir/producer/reader/DefaultProducerNodeBuilders.java
source/mir/rss/RDFResource.java
source/mir/servlet/AbstractServlet.java
source/mir/servlet/ServletModule.java
source/mir/servlet/ServletModuleDispatch.java
source/mir/servlet/ServletModuleShow.java [deleted file]
source/mir/storage/Database.java
source/mir/storage/StorageObject.java
source/mir/util/DateTimeFunctions.java
source/mir/util/HTTPParsedRequest.java
source/mir/util/PropertiesManipulator.java
source/mircoders/entity/EntityContent.java
source/mircoders/entity/EntityMedia.java [deleted file]
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/localizer/basic/MirBasicAdminInterfaceLocalizer.java
source/mircoders/localizer/basic/MirBasicChildArticlePostingHandler.java
source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java
source/mircoders/media/MediaHandlerGeneric.java
source/mircoders/media/MediaHandlerImages.java
source/mircoders/media/MediaHandlerMp3.java
source/mircoders/media/MediaHandlerRealAudio.java
source/mircoders/media/MediaHandlerRealVideo.java
source/mircoders/module/ModuleArticleType.java
source/mircoders/module/ModuleComment.java
source/mircoders/module/ModuleMediaType.java
source/mircoders/module/ModuleMediafolder.java
source/mircoders/module/ModuleTopics.java
source/mircoders/pdf/PDFGenerator.java
source/mircoders/producer/ContentModifyingProducerNode.java
source/mircoders/producer/PDFPreFormattingProducerNode.java
source/mircoders/servlet/ServletHelper.java
source/mircoders/servlet/ServletModuleAdmin.java
source/mircoders/servlet/ServletModuleArticleType.java
source/mircoders/servlet/ServletModuleAudio.java
source/mircoders/servlet/ServletModuleBreaking.java
source/mircoders/servlet/ServletModuleComment.java
source/mircoders/servlet/ServletModuleCommentStatus.java
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/servlet/ServletModuleFileEdit.java
source/mircoders/servlet/ServletModuleHidden.java
source/mircoders/servlet/ServletModuleImages.java
source/mircoders/servlet/ServletModuleLanguage.java
source/mircoders/servlet/ServletModuleMediafolder.java
source/mircoders/servlet/ServletModuleMessage.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleOtherMedia.java
source/mircoders/servlet/ServletModuleTopics.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
source/mircoders/servlet/ServletModuleUsers.java
source/mircoders/servlet/ServletModuleVideo.java
source/mircoders/storage/DatabaseArticleType.java
source/mircoders/storage/DatabaseAudio.java
source/mircoders/storage/DatabaseComment.java
source/mircoders/storage/DatabaseCommentStatus.java
source/mircoders/storage/DatabaseCommentToMedia.java
source/mircoders/storage/DatabaseContent.java
source/mircoders/storage/DatabaseContentToMedia.java
source/mircoders/storage/DatabaseContentToTopics.java
source/mircoders/storage/DatabaseImageColor.java
source/mircoders/storage/DatabaseImageFormat.java
source/mircoders/storage/DatabaseImageLayout.java
source/mircoders/storage/DatabaseImageType.java
source/mircoders/storage/DatabaseImages.java
source/mircoders/storage/DatabaseLanguage.java
source/mircoders/storage/DatabaseMedia.java [deleted file]
source/mircoders/storage/DatabaseMediaType.java
source/mircoders/storage/DatabaseMediafolder.java
source/mircoders/storage/DatabaseOther.java
source/mircoders/storage/DatabaseRights.java
source/mircoders/storage/DatabaseTopics.java
source/mircoders/storage/DatabaseUploadedMedia.java
source/mircoders/storage/DatabaseUsers.java
source/mircoders/storage/DatabaseVideo.java
templates/admin/EDITFUNCTIONS.template
templates/admin/FUNCTIONS.template
templates/admin/FUNCTIONS_media.template
templates/admin/abuse.log.template
templates/admin/articletype.template
templates/admin/articletypelist.template
templates/admin/breaking.template
templates/admin/breakinglist.template
templates/admin/commentlist.template
templates/admin/commentstatus.template
templates/admin/commentstatuslist.template
templates/admin/content.template
templates/admin/contentlist.template
templates/admin/error.template
templates/admin/foot.template
templates/admin/head.template
templates/admin/head_nonavi.template
templates/admin/hiddenlist.template
templates/admin/language.template
templates/admin/languagelist.template
templates/admin/linksimcs.template [deleted file]
templates/admin/login.template
templates/admin/mediafolder.template
templates/admin/mediafolderlist.template
templates/admin/message.template
templates/admin/messagelist.template
templates/admin/start_admin.template
templates/admin/topic.template
templates/admin/topiclist.template
templates/admin/user.template

index 30d45e0..94ed8e7 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: english
-# $Id: admin_en.properties,v 1.48.2.8 2003/07/21 07:01:14 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.9 2003/09/03 17:49:37 zapata Exp $
 
 languagename=English
 
@@ -94,6 +94,7 @@ other_medialist.htmltitle=Other media overview
 # breaking
 breaking.htmltitle=Breaking news
 breaking.textinfo=(max. 5 lines / 250 characters)
+breaking.id = id
 breaking.text=text
 breaking.date=date
 
@@ -249,6 +250,7 @@ contentlist.select=Select
 
 # language
 language.htmltitle=Language
+language.id=Id
 language.name=Language
 language.code=Language code
 
@@ -266,6 +268,7 @@ login.submit=  OK
 
 # mediafolder
 mediafolder.htmltitle=mediafolder
+mediafolder.id=id
 mediafolder.date=date
 mediafolder.name=name
 mediafolder.location=location
@@ -277,6 +280,7 @@ mediafolderlist.htmltitle=media folder list
 
 # message
 message.htmltitle=messages
+message.id=id
 message.date=date
 message.title=title
 message.creator=author
@@ -334,7 +338,10 @@ start.superusermenu=super-user functions (use with care!)
 
 
 # topic
+
 topic.htmltitle=topic
+
+topic.id=id
 topic.title=name
 topic.description=description
 topic.filename=filename
index 328864f..dbdc8b6 100755 (executable)
@@ -29,9 +29,8 @@
  */\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.*;\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -46,22 +45,12 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;\r
 \r
 import org.apache.struts.util.MessageResources;\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateModel;\r
 import mir.config.MirPropertiesConfiguration;\r
-import mir.entity.adapter.EntityIteratorAdapter;\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.ServletModuleExc;\r
 import mir.servlet.ServletModuleUserExc;\r
-import mir.util.CachingRewindableIterator;\r
 import mir.util.ExceptionFunctions;\r
 import mir.util.StringRoutines;\r
 import mircoders.entity.EntityUsers;\r
@@ -69,8 +58,6 @@ import mircoders.global.MirGlobal;
 import mircoders.module.ModuleMessage;\r
 import mircoders.module.ModuleUsers;\r
 import mircoders.servlet.ServletHelper;\r
-import mircoders.servlet.ServletModuleFileEdit;\r
-import mircoders.servlet.ServletModuleLocalizer;\r
 import mircoders.storage.DatabaseUsers;\r
 \r
 \r
@@ -80,7 +67,7 @@ import mircoders.storage.DatabaseUsers;
  * Mir.java - main servlet, that dispatches to servletmodules\r
  *\r
  * @author $Author: zapata $\r
- * @version $Id: Mir.java,v 1.49.2.5 2003/07/20 05:49:47 zapata Exp $\r
+ * @version $Id: Mir.java,v 1.49.2.6 2003/09/03 17:49:38 zapata Exp $\r
  *\r
  */\r
 public class Mir extends AbstractServlet {\r
@@ -91,7 +78,7 @@ public class Mir extends AbstractServlet {
 \r
   private static List loginLanguages = null;\r
 \r
-  protected TemplateModel getLoginLanguages() throws ServletException {\r
+  protected List getLoginLanguages() throws ServletException {\r
     synchronized (Mir.class) {\r
       try {\r
         if (loginLanguages == null) {\r
@@ -127,7 +114,7 @@ public class Mir extends AbstractServlet {
           }\r
         }\r
 \r
-        return FreemarkerGenerator.makeAdapter(loginLanguages);\r
+        return loginLanguages;\r
       }\r
       catch (Throwable t) {\r
         throw new ServletException(t.getMessage());\r
@@ -212,30 +199,31 @@ public class Mir extends AbstractServlet {
           session.setAttribute("login.target", queryString);\r
         }\r
 \r
-        _sendLoginPage(aResponse, aRequest, aResponse.getWriter());\r
+        _sendLoginPage(aResponse, aRequest);\r
       }\r
       else {\r
         String moduleName = aRequest.getParameter("module");\r
         checkLanguage(session, aRequest);\r
 \r
         if ( ( (moduleName == null) || moduleName.equals(""))) {\r
-          _sendStartPage(aResponse, aRequest, aResponse.getWriter(),\r
-                         userEntity);\r
+          moduleName="Admin";\r
         }\r
-        else if (moduleName.equals("login")) {\r
+\r
+\r
+        if (moduleName.equals("login")) {\r
           String target = (String) session.getAttribute("login.target");\r
 \r
           if (target != null) {\r
             ServletHelper.redirect(aResponse, target);\r
           }\r
           else {\r
-            _sendStartPage(aResponse, aRequest, aResponse.getWriter(), userEntity);\r
+            ServletHelper.redirect(aResponse, "");\r
           }\r
         }\r
         else if (moduleName.equals("logout")) {\r
-          logger.info(userEntity.get("login") + " has logged out");\r
+          logger.info(userEntity.getValue("login") + " has logged out");\r
           session.invalidate();\r
-          _sendLoginPage(aResponse, aRequest, aResponse.getWriter());\r
+          _sendLoginPage(aResponse, aRequest);\r
           return;\r
         }\r
         else {\r
@@ -250,10 +238,9 @@ public class Mir extends AbstractServlet {
             Throwable cause = ExceptionFunctions.traceCauseException(e);\r
 \r
             if (cause instanceof ServletModuleUserExc)\r
-              handleUserError(aRequest, aResponse, aResponse.getWriter(),\r
-                              (ServletModuleUserExc) cause);\r
+              handleUserError(aRequest, aResponse, (ServletModuleUserExc) cause);\r
             else\r
-              handleError(aRequest, aResponse, aResponse.getWriter(), cause);\r
+              handleError(aRequest, aResponse, cause);\r
           }\r
 \r
           if (aRequest.getParameter("killsession")!=null)\r
@@ -269,13 +256,13 @@ public class Mir extends AbstractServlet {
   }\r
 \r
   /**\r
-   *  Private method getServletModuleForName returns ServletModule\r
-   *  from Cache\r
-   *\r
-   * @param moduleName\r
-   * @return ServletModule\r
+   * caching routine to get a module for a module name\r
    *\r
+   * @param moduleName the module name\r
+   * @return the requested module\r
+   * @throws ServletModuleExc\r
    */\r
+\r
   private static ServletModule getServletModuleForName(String moduleName) throws ServletModuleExc {\r
     // Instance in Map ?\r
     if (!servletModuleInstanceHash.containsKey(moduleName)) {\r
@@ -311,43 +298,33 @@ public class Mir extends AbstractServlet {
     }\r
   }\r
 \r
-  private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse,\r
-                               PrintWriter out, ServletModuleUserExc anException) {\r
+  private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, ServletModuleUserExc anException) {\r
     try {\r
       logger.info("user error: " + anException.getMessage());\r
-      SimpleHash modelRoot = new SimpleHash();\r
+\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()});\r
+\r
       MessageResources messages = MessageResources.getMessageResources("bundles.admin");\r
-      modelRoot.put("errorstring",\r
-          new SimpleScalar(\r
-              messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters())\r
-          ));\r
-      modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));\r
-      HTMLTemplateProcessor.process(\r
-          aResponse,\r
-          MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"),\r
-          modelRoot,\r
-          null,\r
-          out,\r
-          getLocale(aRequest),\r
-          fallbackLocale);\r
-      out.close();\r
+      responseData.put("errorstring", messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters()));\r
+      responseData.put("date", new GregorianCalendar().getTime());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"));\r
     }\r
     catch (Throwable e) {\r
       logger.error("Error handling user error" + e.toString());\r
     }\r
   }\r
 \r
-  private void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) {\r
+  private void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse, Throwable anException) {\r
     try {\r
       logger.error("error: " + anException);\r
-      SimpleHash modelRoot = new SimpleHash();\r
-      modelRoot.put("errorstring", new SimpleScalar(anException.getMessage()));\r
-      modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(\r
-                                               new GregorianCalendar())));\r
-      HTMLTemplateProcessor.process(\r
-          aResponse,MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"),\r
-          modelRoot,null,out, getLocale(aRequest), getFallbackLocale());\r
-      out.close();\r
+\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()});\r
+\r
+      responseData.put("errorstring", anException.toString());\r
+      responseData.put("date", new GregorianCalendar().getTime());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"));\r
     }\r
     catch (Throwable e) {\r
       logger.error("Error handling error: " + e.toString());\r
@@ -355,54 +332,19 @@ public class Mir extends AbstractServlet {
   }\r
 \r
   // Redirect-methods\r
-  private void _sendLoginPage(HttpServletResponse aResponse, HttpServletRequest aRequest,\r
-    PrintWriter out) {\r
+  private void _sendLoginPage(HttpServletResponse aResponse, HttpServletRequest aRequest) {\r
     String loginTemplate = configuration.getString("Mir.LoginTemplate");\r
-    String sessionUrl = aResponse.encodeURL("");\r
 \r
     try {\r
-      SimpleHash mergeData = new SimpleHash();\r
-      SimpleList languages = new SimpleList();\r
-\r
-      mergeData.put("session", sessionUrl);\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()});\r
 \r
-      mergeData.put("defaultlanguage", getDefaultLanguage(aRequest));\r
-      mergeData.put("languages", getLoginLanguages());\r
+      responseData.put("defaultlanguage", getDefaultLanguage(aRequest));\r
+      responseData.put("languages", getLoginLanguages());\r
 \r
-      HTMLTemplateProcessor.process(aResponse, loginTemplate, mergeData, null, out, getLocale(aRequest), getFallbackLocale());\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, loginTemplate);\r
     }\r
     catch (Throwable e) {\r
-      handleError(aRequest, aResponse, out, e);\r
-    }\r
-  }\r
-\r
-  private void _sendStartPage(HttpServletResponse aResponse, HttpServletRequest aRequest,\r
-    PrintWriter out, EntityUsers userEntity) {\r
-    String startTemplate = configuration.getString("Mir.StartTemplate");\r
-    String sessionUrl = aResponse.encodeURL("");\r
-\r
-    try {\r
-      Map mergeData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()}, "bundles.admin", "bundles.adminlocal");\r
-      mergeData.put("messages",\r
-             new CachingRewindableIterator(\r
-               new EntityIteratorAdapter( "", "webdb_create desc", 10,\r
-                 MirGlobal.localizer().dataModel().adapterModel(), "internalMessage", 10, 0)));\r
-\r
-      mergeData.put("fileeditentries", ((ServletModuleFileEdit) ServletModuleFileEdit.getInstance()).getEntries());\r
-      mergeData.put("administeroperations", ((ServletModuleLocalizer) ServletModuleLocalizer.getInstance()).getAdministerOperations());\r
-\r
-      mergeData.put("searchvalue", null);\r
-      mergeData.put("searchfield", null);\r
-      mergeData.put("searchispublished", null);\r
-      mergeData.put("searcharticletype", null);\r
-      mergeData.put("searchorder", null);\r
-      mergeData.put("selectarticleurl", null);\r
-\r
-      ServletHelper.generateResponse(out, mergeData, startTemplate);\r
-    }\r
-    catch (Exception e) {\r
-      e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
-      handleError(aRequest, aResponse, out, e);\r
+      handleError(aRequest, aResponse, e);\r
     }\r
   }\r
 \r
index 78faf9e..66aea54 100755 (executable)
@@ -438,88 +438,74 @@ Mir.StartTemplate=start_admin.template
 Mir.ErrorTemplate=error.template
 Mir.UserErrorTemplate=usererror.template
 
-ServletModule.Themen.ConfirmTemplate=confirm.template
-ServletModule.Themen.ObjektTemplate=topic.template
-ServletModule.Themen.ListTemplate=topiclist.template
+ServletModule.Default.ListSize = 30
 
-ServletModule.LinksImcs.ConfirmTemplate=confirm.template
-ServletModule.LinksImcs.ObjektTemplate=linksimcs.template
-ServletModule.LinksImcs.ListTemplate=linksimcslist.template
+ServletModule.Topics.DeleteConfirmationTemplate=confirm.template
+ServletModule.Topics.EditTemplate=topic.template
+ServletModule.Topics.ListTemplate=topiclist.template
 
-ServletModule.Users.ConfirmTemplate=confirm.template
-ServletModule.Users.ObjektTemplate=user.template
+ServletModule.Users.DeleteConfirmationTemplate=confirm.template
+ServletModule.Users.EditTemplate=user.template
 ServletModule.Users.ListTemplate=userlist.template
 
-ServletModule.Images.ConfirmTemplate=confirm.template
-ServletModule.Images.ObjektTemplate=image.template
+ServletModule.Images.DeleteConfirmationTemplate=confirm.template
+ServletModule.Images.EditTemplate=image.template
 ServletModule.Images.ListTemplate=imagelist.template
 
-ServletModule.Audio.ConfirmTemplate=confirm.template
-ServletModule.Audio.ObjektTemplate=audio.template
+ServletModule.Audio.DeleteConfirmationTemplate=confirm.template
+ServletModule.Audio.EditTemplate=audio.template
 ServletModule.Audio.ListTemplate=audiolist.template
 
-ServletModule.Video.ConfirmTemplate=confirm.template
-ServletModule.Video.ObjektTemplate=video.template
+ServletModule.Video.DeleteConfirmationTemplate=confirm.template
+ServletModule.Video.EditTemplate=video.template
 ServletModule.Video.ListTemplate=videolist.template
 
-ServletModule.OtherMedia.ConfirmTemplate=confirm.template
-ServletModule.OtherMedia.ObjektTemplate=other.template
+ServletModule.OtherMedia.DeleteConfirmationTemplate=confirm.template
+ServletModule.OtherMedia.EditTemplate=other.template
 ServletModule.OtherMedia.ListTemplate=medialist.template
 
-ServletModule.Content.ConfirmTemplate=confirm.template
-ServletModule.Content.ObjektTemplate=content.template
+ServletModule.Content.DeleteConfirmationTemplate=confirm.template
+ServletModule.Content.EditTemplate=content.template
 ServletModule.Content.ListTemplate=contentlist.template
 
-ServletModule.Mediafolder.ConfirmTemplate=confirm.template
-ServletModule.Mediafolder.ObjektTemplate=mediafolder.template
+ServletModule.Mediafolder.DeleteConfirmationTemplate=confirm.template
+ServletModule.Mediafolder.EditTemplate=mediafolder.template
 ServletModule.Mediafolder.ListTemplate=mediafolderlist.template
 
-#
-# config for ServletModuleComment - browsing/editing/deleting comments
-ServletModule.Comment.ConfirmTemplate=confirm.template
-ServletModule.Comment.ObjektTemplate=comment.template
+ServletModule.Comment.DeleteConfirmationTemplate=confirm.template
+ServletModule.Comment.EditTemplate=comment.template
 ServletModule.Comment.ListTemplate=commentlist.template
 
-#
-# config for ServletModuleHidden - lists all hidden articles of one month
 ServletModule.Hidden.ListTemplate=hiddenlist.template
 
-#
-# config for Breaking - browsing/editing/deleting breaking news
-ServletModule.Breaking.ConfirmTemplate=confirm.template
-ServletModule.Breaking.ObjektTemplate=breaking.template
+ServletModule.Breaking.DeleteConfirmationTemplate=confirm.template
+ServletModule.Breaking.EditTemplate=breaking.template
 ServletModule.Breaking.ListTemplate=breakinglist.template
 
-#
-# config for Breaking - editing text files
-ServletModule.FileEdit.ConfirmTemplate=confirm.template
-ServletModule.FileEdit.ObjektTemplate=fileedit.template
+ServletModule.FileEdit.DeleteConfirmationTemplate=confirm.template
+ServletModule.FileEdit.EditTemplate=fileedit.template
 ServletModule.FileEdit.ListTemplate=fileeditlist.template
 
-#
-# config for messages - browsing/editing/deleting internal messages
-ServletModule.Messages.ConfirmTemplate=confirm.template
-ServletModule.Messages.ObjektTemplate=message.template
-ServletModule.Messages.ListTemplate=messagelist.template
+ServletModule.Message.DeleteConfirmationTemplate=confirm.template
+ServletModule.Message.EditTemplate=message.template
+ServletModule.Message.ListTemplate=messagelist.template
 
-#
-# config for languages - browsing/editing/deleting languages
-ServletModule.Language.ConfirmTemplate=confirm.template
-ServletModule.Language.ObjektTemplate=language.template
+ServletModule.Language.DeleteConfirmationTemplate=confirm.template
+ServletModule.Language.EditTemplate=language.template
 ServletModule.Language.ListTemplate=languagelist.template
 
-#
-# config for article type
-ServletModule.ArticleType.ConfirmTemplate=confirm.template
+ServletModule.ArticleType.DeleteConfirmationTemplate=confirm.template
 ServletModule.ArticleType.EditTemplate=articletype.template
 ServletModule.ArticleType.ListTemplate=articletypelist.template
 
-#
-# config for comment status
-ServletModule.CommentStatus.ConfirmTemplate=confirm.template
+ServletModule.CommentStatus.DeleteConfirmationTemplate=confirm.template
 ServletModule.CommentStatus.EditTemplate=commentstatus.template
 ServletModule.CommentStatus.ListTemplate=commentstatuslist.template
 
+
+
+
+
 #
 # config for abuse
 ServletModule.Abuse.EditFilter.Template = abuse.filter.template\r
index 54317b6..306c6fb 100755 (executable)
@@ -40,23 +40,17 @@ import mir.misc.StringUtil;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateHashModel;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateModelRoot;
 
 /**
  * Base class the entities are derived from. Provides base functionality of
  * an entity. Entities are used to represent rows of a database table.<p>
- * Interfacing TemplateHashModel and TemplateModelRoot to be freemarker compliant
  *
- * @version $Id: Entity.java,v 1.21.2.3 2003/05/24 15:33:11 zapata Exp $
+ * @version $Id: Entity.java,v 1.21.2.4 2003/09/03 17:49:38 zapata Exp $
  * @author rk
  *
  */
 
-public class Entity implements TemplateHashModel, TemplateModelRoot
+public class Entity
 {
   protected static MirPropertiesConfiguration configuration;
 
@@ -259,31 +253,5 @@ public class Entity implements TemplateHashModel, TemplateModelRoot
 
     throw new StorageObjectFailure("Storage Object Exception in entity", e);
   }
-
-  // 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 {
-    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 and is limited to the
-    // database fields associated with the entity. no additional freemarker
-    // stuff will be available via Entity.
-    logger.warn("put is called on entity! - the values will be lost!");
-  }
-
-  public void remove(java.lang.String key) {
-    logger.warn("remove is called on entity!");
-  }
-
-  //////////////////////////////////////////////////////////////////////////////////
 }
 
index c2616f1..f792413 100755 (executable)
-/*
- * 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  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.entity;
-
-import java.util.ArrayList;
-import java.util.Set;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
-import mir.storage.store.StorableObject;
-import mir.storage.store.StoreContainerType;
-import mir.storage.store.StoreIdentifier;
-import mir.storage.store.StoreUtil;
-import freemarker.template.TemplateListModel;
-import freemarker.template.TemplateModel;
-
-/**
- *
- * Container class for lists of Entities.
- * Now implements freemarker.template.TemplateListModel
- * and @see mir.storage.store.StorableObject.
- *
- * @author <RK>
- * first version       27.6.1999
- *
- *  @version 1.0 (freemarker compliant & and storable in ObjectStore)
- */
-public class EntityList implements TemplateListModel, StorableObject {
-  protected static MirPropertiesConfiguration configuration;
-  protected LoggerWrapper logger;
-  private ArrayList           theEntityArrayList = new ArrayList();
-  private String              whereClause, orderClause;
-  private StorageObject       theStorage;
-  private int                 count, offset, limit;
-  private int                 offsetnext = -1, offsetprev = -1;
-  private int                 freemarkerListPointer=-1;
-
-
-  static {
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (PropertiesConfigExc e) {
-      throw new RuntimeException("Unable to get configuration: " + e.getMessage());
-    }
-  }
-
-  /**
-   * Constructor.
-   */
-  public EntityList(){
-    logger = new LoggerWrapper("Entity.List");
-  }
-
-/* get/set EntityClass of Objects stored in EntityList */
-  public void setStorage(StorageObject storage) { this.theStorage=storage; }
-  public StorageObject getStorage() { return theStorage; }
-
-  public void setLimit(int limit) { this.limit = limit; }
-
-  /**
-   * Sets the WHERE clause that fetched the Entities of this EntityList from the database.
-   * @param wc The string that contains the WHERE clause
-   */
-  public void setWhere(String wc) {
-    this.whereClause = wc;
-  }
-
-  /**
-   * Returns the WHERE clause that returned this EntityList from the database
-   * @return whereClause The WHERE clause
-   */
-  public String getWhere() {
-    return whereClause;
-  }
-
-
-  /**
-   * Sets the sorting criterium of this EntityList
-   * @param oc
-   */
-  public void setOrder(String oc) {
-    this.orderClause = oc;
-  }
-
-  /**
-   * Returns the sorting criterium.
-   * @return orderClause The sort order
-   */
-  public String getOrder() {
-    return orderClause;
-  }
-
-  /**
-   * Sets the number of rows that match the WHERE clause
-   * @param i The number of rows that match the WHERE clause
-   */
-  public void setCount(int i) {
-    this.count = i;
-  }
-
-  /**
-   * Returns the number of rows that match the WHERE clause
-   * @return The number of rows ...
-   */
-  public int getCount() {
-    return count;
-  }
-
-  /**
-   * Sets the offset
-   * @param i The offset
-   */
-  public void setOffset(int i) {
-    offset = i;
-  }
-
-  /**
-   * Returns the offset
-   * @return offset
-   */
-  public int getOffset() {
-    return offset;
-  }
-
-  /**
-   * Sets the offset of the next batch of Entities.
-   * @param i The next offset
-   */
-  public void setNextBatch(int i) {
-    offsetnext = i;
-  }
-
-  /**
-   * Returns the offset of the next batch of Entities.
-   * @return offset of the next batch
-   */
-  public int getNextBatch() {
-    return offsetnext;
-  }
-
-  /**
-   * Returns whether there is a next batch within the WHERE clause
-   * @return true if yes, false if no.
-   */
-  public boolean hasNextBatch() {
-    return (offsetnext >= 0);
-  }
-
-  /**
-   * Sets the offset of the previous batch.
-   * @param i the previous offset
-   */
-  public void setPrevBatch(int i) {
-    offsetprev = i;
-  }
-
-  /**
-   * Returns the offset of the previous batch.
-   * @return offset of the previous batch
-   */
-  public int getPrevBatch() {
-    return offsetprev;
-  }
-
-  /**
-   * Returns whether there is a previous batch.
-   * @return true if yes, false if no
-   */
-  public boolean hasPrevBatch() {
-    return (offsetprev >= 0);
-  }
-
-  /**
-   * Returns the start index of the batch.
-   * @return
-   */
-  public int getFrom() {
-    return offset+1;
-  }
-
-  /**
-   * Returns the end index of the batch.
-   * @return
-   */
-  public int getTo() {
-    if (hasNextBatch())
-      return offsetnext;
-    else
-      return count;
-  }
-
-  /**
-   * Inserts an Entity into the EntityList.
-   * @param anEntity The entity to be inserted.
-   */
-
-  public void add (Entity anEntity) {
-    if (anEntity!=null)
-      theEntityArrayList.add(anEntity);
-    else
-      logger.warn("EntityList: add called with empty Entity");
-  }
-
-
-  /**
-   * @return The number of Entities in the EntityList.
-   */
-
-  public int size() {
-    return theEntityArrayList.size();
-  }
-
-
-  /**
-   * Returns the element at position i in the EntityList as Entity
-   * @param i the position of the element in question
-   * @return The element at position i.
-   */
-
-  public Entity elementAt(int i) {
-    /** @todo check if i is in list.size() */
-    return (Entity)theEntityArrayList.get(i);
-  }
-
-
-// The following methods have to be implemented
-// for this class to be an implementation of the
-// TemplateListModel of the Freemarker packages
-
-  public TemplateModel get(int i) { return elementAt(i); }
-  public boolean isRewound() { return (freemarkerListPointer==-1) ? true : false; }
-  public void rewind() { freemarkerListPointer=-1; }
-
-  public TemplateModel next() {
-    if (hasNext()) {
-    freemarkerListPointer++;return get(freemarkerListPointer); }
-    else return null;
-  }
-
-
-  /**
-   * Returns whether there is a next element
-   * @return true if there is a next element, else false
-   */
-
-  public boolean hasNext() {
-    return theEntityArrayList.size()>0 && freemarkerListPointer+2<=theEntityArrayList.size();
-  }
-
-
-  /**
-   * Returns whether EntityList is empty or not
-   * @return true in case of empty list, false otherwise
-   */
-
-  public boolean isEmpty() {
-    if (theEntityArrayList!=null)
-      return theEntityArrayList.size()<1 ;
-    else return false;
-  }
-
-
-// Methods to implement StorableObject
-
-  public Set getNotifyOnReleaseSet() { return null; }
-
-  public StoreIdentifier getStoreIdentifier() {
-    if ( theStorage!=null ) {
-      return
-      new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,
-      StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),
-      whereClause, orderClause, offset, limit ));
-    }
-    logger.warn("EntityList could not return StoreIdentifier");
-    return 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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package  mir.entity;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Set;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.StorageObject;\r
+import mir.storage.store.StorableObject;\r
+import mir.storage.store.StoreContainerType;\r
+import mir.storage.store.StoreIdentifier;\r
+import mir.storage.store.StoreUtil;\r
+\r
+/**\r
+ *\r
+ * Container class for lists of Entities.\r
+ * Now implements @see mir.storage.store.StorableObject.\r
+ *\r
+ * @author <RK>\r
+ * first version       27.6.1999\r
+ *\r
+ * @version 1.1 (cleaned up)\r
+ */\r
+public class EntityList implements StorableObject {\r
+  protected static MirPropertiesConfiguration configuration;\r
+  protected LoggerWrapper logger;\r
+  private ArrayList           theEntityArrayList = new ArrayList();\r
+  private String              whereClause, orderClause;\r
+  private StorageObject       theStorage;\r
+  private int                 count, offset, limit;\r
+  private int                 offsetnext = -1, offsetprev = -1;\r
+\r
+  static {\r
+    try {\r
+      configuration = MirPropertiesConfiguration.instance();\r
+    }\r
+    catch (PropertiesConfigExc e) {\r
+      throw new RuntimeException("Unable to get configuration: " + e.getMessage());\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Constructor.\r
+   */\r
+  public EntityList(){\r
+    logger = new LoggerWrapper("Entity.List");\r
+  }\r
+\r
+/* get/set EntityClass of Objects stored in EntityList */\r
+  public void setStorage(StorageObject storage) { this.theStorage=storage; }\r
+  public StorageObject getStorage() { return theStorage; }\r
+\r
+  public void setLimit(int limit) { this.limit = limit; }\r
+\r
+  /**\r
+   * Sets the WHERE clause that fetched the Entities of this EntityList from the database.\r
+   * @param wc The string that contains the WHERE clause\r
+   */\r
+  public void setWhere(String wc) {\r
+    this.whereClause = wc;\r
+  }\r
+\r
+  /**\r
+   * Returns the WHERE clause that returned this EntityList from the database\r
+   * @return whereClause The WHERE clause\r
+   */\r
+  public String getWhere() {\r
+    return whereClause;\r
+  }\r
+\r
+\r
+  /**\r
+   * Sets the sorting criterium of this EntityList\r
+   * @param oc\r
+   */\r
+  public void setOrder(String oc) {\r
+    this.orderClause = oc;\r
+  }\r
+\r
+  /**\r
+   * Returns the sorting criterium.\r
+   * @return orderClause The sort order\r
+   */\r
+  public String getOrder() {\r
+    return orderClause;\r
+  }\r
+\r
+  /**\r
+   * Sets the number of rows that match the WHERE clause\r
+   * @param i The number of rows that match the WHERE clause\r
+   */\r
+  public void setCount(int i) {\r
+    this.count = i;\r
+  }\r
+\r
+  /**\r
+   * Returns the number of rows that match the WHERE clause\r
+   * @return The number of rows ...\r
+   */\r
+  public int getCount() {\r
+    return count;\r
+  }\r
+\r
+  /**\r
+   * Sets the offset\r
+   * @param i The offset\r
+   */\r
+  public void setOffset(int i) {\r
+    offset = i;\r
+  }\r
+\r
+  /**\r
+   * Returns the offset\r
+   * @return offset\r
+   */\r
+  public int getOffset() {\r
+    return offset;\r
+  }\r
+\r
+  /**\r
+   * Sets the offset of the next batch of Entities.\r
+   * @param i The next offset\r
+   */\r
+  public void setNextBatch(int i) {\r
+    offsetnext = i;\r
+  }\r
+\r
+  /**\r
+   * Returns the offset of the next batch of Entities.\r
+   * @return offset of the next batch\r
+   */\r
+  public int getNextBatch() {\r
+    return offsetnext;\r
+  }\r
+\r
+  /**\r
+   * Returns whether there is a next batch within the WHERE clause\r
+   * @return true if yes, false if no.\r
+   */\r
+  public boolean hasNextBatch() {\r
+    return (offsetnext >= 0);\r
+  }\r
+\r
+  /**\r
+   * Sets the offset of the previous batch.\r
+   * @param i the previous offset\r
+   */\r
+  public void setPrevBatch(int i) {\r
+    offsetprev = i;\r
+  }\r
+\r
+  /**\r
+   * Returns the offset of the previous batch.\r
+   * @return offset of the previous batch\r
+   */\r
+  public int getPrevBatch() {\r
+    return offsetprev;\r
+  }\r
+\r
+  /**\r
+   * Returns whether there is a previous batch.\r
+   * @return true if yes, false if no\r
+   */\r
+  public boolean hasPrevBatch() {\r
+    return (offsetprev >= 0);\r
+  }\r
+\r
+  /**\r
+   * Returns the start index of the batch.\r
+   * @return\r
+   */\r
+  public int getFrom() {\r
+    return offset+1;\r
+  }\r
+\r
+  /**\r
+   * Returns the end index of the batch.\r
+   * @return\r
+   */\r
+  public int getTo() {\r
+    if (hasNextBatch())\r
+      return offsetnext;\r
+    else\r
+      return count;\r
+  }\r
+\r
+  /**\r
+   * Inserts an Entity into the EntityList.\r
+   * @param anEntity The entity to be inserted.\r
+   */\r
+\r
+  public void add (Entity anEntity) {\r
+    if (anEntity!=null)\r
+      theEntityArrayList.add(anEntity);\r
+    else\r
+      logger.warn("EntityList: add called with empty Entity");\r
+  }\r
+\r
+\r
+  /**\r
+   * @return The number of Entities in the EntityList.\r
+   */\r
+\r
+  public int size() {\r
+    return theEntityArrayList.size();\r
+  }\r
+\r
+\r
+  /**\r
+   * Returns the element at position i in the EntityList as Entity\r
+   * @param i the position of the element in question\r
+   * @return The element at position i.\r
+   */\r
+\r
+  public Entity elementAt(int i) {\r
+    /** @todo check if i is in list.size() */\r
+    return (Entity)theEntityArrayList.get(i);\r
+  }\r
+\r
+\r
+\r
+// Methods to implement StorableObject\r
+\r
+  public Set getNotifyOnReleaseSet() { return null; }\r
+\r
+  public StoreIdentifier getStoreIdentifier() {\r
+    if ( theStorage!=null ) {\r
+      return\r
+      new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,\r
+      StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),\r
+      whereClause, orderClause, offset, limit ));\r
+    }\r
+    logger.warn("EntityList could not return StoreIdentifier");\r
+    return null;\r
+  }\r
+\r
+}\r
diff --git a/source/mir/entity/EntityRelation.java b/source/mir/entity/EntityRelation.java
deleted file mode 100755 (executable)
index 5713a85..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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  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.entity;
-
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-
-public class EntityRelation {
-
-  public String         fromId;
-  public String         toId;
-  public StorageObject  storage;
-  public int            type;
-
-  public final static int TO_ONE    =  1;
-  public final static int TO_MANY   =  2;
-
-
-  /**
-   *  Kontruktor fuer EntityRelation
-   *  @param fromId ist der Feldname in der ausgehenden Tabelle fuer die Relation
-   *  @param toId ist der Feldname in der Zieltablle
-   *  @param storage ist das StorageObject, ueber das der Zugriff auf die abhaengige
-   *         Tabelle erfolgt.
-   *  @param type ist der Typ der EntityRelation (TO_ONE oder TO_MANY)
-   */
-
-  public EntityRelation(String fromId, String toId, StorageObject storage, int type) {
-      this.fromId = fromId;
-      this.toId = toId;
-      this.storage = storage;
-      this.type = type;
-  }
-
-  /**
-   *   @return Liefert eine abhaengige Entity mit den verknuepften
-   *           Entities, wenn es sich um eine TO_ONE Beziehung handelt, ansonsten
-   *           null.
-   */
-
-  public Entity getOne(Entity entity) throws StorageObjectExc {
-    if (type==TO_ONE) {
-      return storage.selectById(entity.getValue(fromId));
-    }
-    else return null;
-  }
-
-  /**
-   *   @return Liefert eine freemarker.template.SimpleList mit den verknuepften
-   *           Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
-   *           null.
-   */
-
-  public EntityList getMany(Entity entity) throws StorageObjectFailure{
-    if (type==TO_MANY) {
-      return storage.selectByFieldValue(toId, entity.getValue(fromId));
-    }
-    else return null;
-  }
-
-  /**
-   *   @return Liefert eine freemarker.template.SimpleList mit den verknuepften
-   *           Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
-   *           null.
-   */
-
-  public EntityList getMany(Entity entity, String order) throws StorageObjectFailure{
-    if (type==TO_MANY) {
-      return storage.selectByWhereClause(toId+"="+entity.getValue(fromId), order,-1);
-    }
-    else return null;
-  }
-
-  /**
-   *   @return Liefert eine freemarker.template.SimpleList mit den verknuepften
-   *           Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
-   *           null.
-   */
-
-  public EntityList getMany(Entity entity, String order, String whereClause) throws StorageObjectFailure{
-    if (type==TO_MANY) {
-      return storage.selectByWhereClause(toId + "=" + entity.getValue(fromId) + " and " + whereClause, order,-1);
-    }
-    else return null;
-  }
-
-  /**
-   *   @return The reference name of the related table.
-   */
-
-  public String getName() {
-    return "to" + storage.getTableName();
-  }
-
-
-}
index bb132a5..68cdf2f 100755 (executable)
  */
 package mir.entity.adapter;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.*;
-import java.util.Map;
-
-import mir.entity.Entity;
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.GregorianCalendar;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.TimeZone;\r
+\r
+import mir.entity.Entity;\r
+import mir.misc.StringUtil;\r
 import mir.util.GeneratorFormatAdapters;
-import mir.misc.*;
 
 public class EntityAdapterDefinition {
-  Map calculatedFields;
+  private Map calculatedFields;
 
   public EntityAdapterDefinition() {
     calculatedFields = new HashMap();
index 5bf6ae4..f7ae65d 100755 (executable)
-/*
- * 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  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.entity.adapter;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Vector;
-
-import mir.entity.EntityBrowser;
-
-public class EntityListAdapter extends AbstractList {
-  private int skip;
-  private int maximumLength;
-  private EntityBrowser browser;
-  private boolean exhausted = false;
-  private boolean skipped = false;
-
-  private List cache;
-
-  protected EntityListAdapter(EntityBrowser aBrowser, int aSkip, int aMaximumLength) {
-    browser = aBrowser;
-    skip = aSkip;
-    maximumLength = aMaximumLength;
-    cache = new Vector();
-  }
-
-  protected EntityListAdapter(EntityBrowser aBrowser, int aMaximumLength) {
-    this(aBrowser, 0, aMaximumLength);
-  }
-
-  protected EntityListAdapter(EntityBrowser aBrowser) {
-    this(aBrowser, 0, -1);
-  }
-
-  private void skip() {
-    int i;
-
-    try {
-      if (!skipped) {
-        for(i=0; i<skip; i++)
-          if (browser.hasNext())
-            browser.next();
-      }
-      skipped=true;
-    }
-    catch (Throwable t) {
-      throw new RuntimeException(t.getMessage());
-    }
-  }
-
-  private void fetchNext() {
-    try {
-      if (!exhausted) {
-        if (browser.hasNext())
-          cache.add(browser.next());
-
-        exhausted = !browser.hasNext() || (maximumLength>0 && cache.size()>=maximumLength) ;
-      }
-    }
-    catch (Throwable t) {
-      throw new RuntimeException(t.getMessage());
-    }
-
-  }
-
-  private void exhaust() {
-    skip();
-
-    while (!exhausted)
-      fetchNext();
-  }
-
-  private void fetchUntil(int anIndex) {
-    skip();
-
-    while (!exhausted && anIndex>=cache.size())
-      fetchNext();
-  }
-
-  public int size() {
-    exhaust();
-
-    return cache.size();
-  }
-
-  public Object get(int anIndex) {
-    fetchUntil(anIndex);
-    return cache.get(anIndex);
-  }
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.entity.adapter;\r
+\r
+import java.util.AbstractList;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityBrowser;\r
+\r
+public class EntityListAdapter extends AbstractList {\r
+  private int skip;\r
+  private int maximumLength;\r
+  private EntityBrowser browser;\r
+  private EntityAdapterModel model;\r
+  private String definition;\r
+  private boolean exhausted = false;\r
+  private boolean skipped = false;\r
+\r
+  private List cache;\r
+\r
+  protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aSkip, int aMaximumLength) {\r
+    model = aModel;\r
+    definition = aDefinition;\r
+    browser = aBrowser;\r
+    skip = aSkip;\r
+    maximumLength = aMaximumLength;\r
+    cache = new Vector();\r
+  }\r
+\r
+  protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aMaximumLength) {\r
+    this(aModel, aDefinition, aBrowser, 0, aMaximumLength);\r
+  }\r
+\r
+  protected EntityListAdapter(EntityAdapterModel aModel, String  aDefinition, EntityBrowser aBrowser) {\r
+    this(aModel, aDefinition, aBrowser, 0, -1);\r
+  }\r
+\r
+  private void skip() {\r
+    int i;\r
+\r
+    try {\r
+      if (!skipped) {\r
+        for(i=0; i<skip; i++)\r
+          if (browser.hasNext())\r
+            browser.next();\r
+      }\r
+      skipped=true;\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException(t.getMessage());\r
+    }\r
+  }\r
+\r
+  private void fetchNext() {\r
+    try {\r
+      if (!exhausted) {\r
+        if (browser.hasNext())\r
+          cache.add(model.makeEntityAdapter(definition, (Entity) browser.next()));\r
+\r
+        exhausted = !browser.hasNext() || (maximumLength>0 && cache.size()>=maximumLength) ;\r
+      }\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException(t.getMessage());\r
+    }\r
+\r
+  }\r
+\r
+  private void exhaust() {\r
+    skip();\r
+\r
+    while (!exhausted)\r
+      fetchNext();\r
+  }\r
+\r
+  private void fetchUntil(int anIndex) {\r
+    skip();\r
+\r
+    while (!exhausted && anIndex>=cache.size())\r
+      fetchNext();\r
+  }\r
+\r
+  public int size() {\r
+    exhaust();\r
+\r
+    return cache.size();\r
+  }\r
+\r
+  public Object get(int anIndex) {\r
+    fetchUntil(anIndex);\r
+    return cache.get(anIndex);\r
+  }\r
 }
\ No newline at end of file
index 52efcb7..8b5ec61 100755 (executable)
@@ -142,7 +142,6 @@ public class FreemarkerGenerator implements Generator {
     }\r
 \r
     public void remove(String aKey) {\r
-      // ML: kinda tricky...\r
     }\r
 \r
     public boolean isEmpty() {\r
index 298809e..e706d9a 100755 (executable)
  */
 package  mir.media;
 
-import java.io.InputStream;
-
+import java.io.InputStream;\r
+import java.util.List;\r
+\r
 import mir.entity.Entity;
-import freemarker.template.SimpleList;
 
 /**
  * Interface for Media handling in Mir. All media handlers
@@ -79,7 +79,7 @@ import freemarker.template.SimpleList;
  * ) and just override the things that need to be specific. see MediaHandlerAudio
  *
  * @author <mh@nadir.org>, the Mir-coders group
- * @version $Id: MirMedia.java,v 1.18 2003/04/29 02:36:50 zapata Exp $
+ * @version $Id: MirMedia.java,v 1.18.2.1 2003/09/03 17:49:38 zapata Exp $
  */
 
 public interface  MirMedia{
@@ -144,7 +144,7 @@ public interface  MirMedia{
    * @see mir.entity.Entity
    * @see mir.misc.StringUtil
    */
-  public abstract SimpleList getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
+  public abstract List getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
 
         /**
    * Returns the absolute filesystem path to where the media
diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java
deleted file mode 100755 (executable)
index 5728168..0000000
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * 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  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.PrintWriter;
-import java.net.URLEncoder;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.entity.Entity;
-import mir.entity.EntityList;
-import mir.generator.FreemarkerGenerator;
-import mir.log.LoggerWrapper;
-import mir.storage.StorageObjectFailure;
-import mir.util.GeneratorHTMLFunctions;
-import mir.util.GeneratorIntegerFunctions;
-import mir.util.ResourceBundleGeneratorFunction;
-
-import org.apache.struts.util.MessageResources;
-
-import freemarker.template.FileTemplateCache;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleScalar;
-import freemarker.template.Template;
-import freemarker.template.TemplateModelRoot;
-
-/**
- * Hilfsklasse zum Mergen von Template und Daten
- */
-public final class HTMLTemplateProcessor {
-
-  public static String templateDir;
-  private static final String[] bundles = { "bundles.adminlocal", "bundles.admin" };
-  private static MirPropertiesConfiguration configuration;
-  private static FileTemplateCache templateCache;
-  private static String docRoot;
-  private static String actionRoot;
-  private static LoggerWrapper logger;
-
-  static {
-    // ML: configuration is not thread safe: it's risky to use it like this
-    //     actually I don't see why HTMLTemplateProcessor needs to be a
-    //     class with static methods. This causes more problems than it solves.
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (PropertiesConfigExc e) {
-      e.printStackTrace();
-    }
-
-    logger = new LoggerWrapper("TemplateEngine");
-
-    templateDir =
-        configuration.getStringWithHome("Mir.TemplateDir");
-    templateCache = new FileTemplateCache(templateDir);
-    templateCache.setLoadingPolicy(FileTemplateCache.LOAD_ON_DEMAND);
-    // gone in freemarker 1.7.1: templateCache.startAutoUpdate();
-
-
-    docRoot = configuration.getString("RootUri");
-    try {
-      actionRoot = docRoot +configuration.getString("Producer.ActionServlet");
-    }
-    catch (ConfigException ce) {
-      // if  Producer.ActionServlet is not set in the conf file
-      actionRoot = docRoot + "/Mir";
-    }
-  }
-
-  /**
-   * empty private constructor, to avoid instantiation
-   */
-  private HTMLTemplateProcessor() {
-  }
-
-  /**
-   * 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 templateFilename
-   * @param entList
-   * @param out
-   * @exception HTMLParseException
-   */
-
-  public static void process(HttpServletResponse res, String templateFilename, EntityList entList, PrintWriter out, Locale locale, Locale aFallbackLocale) throws HTMLParseException {
-    process(res, templateFilename, entList, (String)null, (TemplateModelRoot) null, out, locale, aFallbackLocale);
-  }
-
-  /**
-   * Wandelt Entitylist in freemarker-Struktur um, f?gt <code>additionalModel</code>
-       * unter dem Namen <code>additionalModelName</code> ein und mischt die Daten mit
-   * Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter
-   * <code>out</code>
-   *
-   * @param templateFilename
-   * @param entList
-   * @param additionalModelName
-   * @param additionalModel
-   * @param out
-   * @exception HTMLParseException
-   */
-
-  public static void process(HttpServletResponse res, String templateFilename,
-                             EntityList entList, String additionalModelName,
-                             TemplateModelRoot additionalModel, PrintWriter out,
-                             Locale locale, Locale aFallbackLocale) throws HTMLParseException {
-
-    SimpleHash modelRoot = new SimpleHash();
-
-    if (entList == null) {
-      process(null, templateFilename, modelRoot, null, out, locale, aFallbackLocale);
-    }
-    else {
-      try {
-        modelRoot = makeSimpleHashWithEntitylistInfos(entList);
-
-        // Quickhack um mal ein Popup mit reinzunhemen ..
-        if (additionalModelName != null && additionalModel != null)
-          modelRoot.put(additionalModelName, additionalModel);
-
-        process(res, templateFilename, modelRoot, null, out, locale, aFallbackLocale);
-      }
-      catch (StorageObjectFailure e) {
-        throw new HTMLParseException(e.toString());
-      }
-    }
-  }
-
-
-  /**
-   * Mischt die freemarker-Struktur <code>tmr</code> mit
-   * Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter
-   * <code>out</code>
-   *
-   * @param templateFilename
-   * @param mergeData
-   * @param out
-   * @exception HTMLParseException
-   */
-  public static void process(HttpServletResponse res, String templateFilename,
-                             TemplateModelRoot tmr, PrintWriter out,
-                             Locale locale, Locale aFallbackLocale) throws HTMLParseException {
-    process(res, templateFilename, tmr, null, out, locale, aFallbackLocale);
-  }
-
-  /**
-   * Mischt die freemarker-Struktur <code>tmr</code> mit
-   * Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter
-   * <code>out</code>
-   *
-   * @param templateFilename
-   * @param mergeData
-   * @param out
-   * @exception HTMLParseException
-   */
-  public static void process(HttpServletResponse res, String templateFilename,
-                             TemplateModelRoot tmr, TemplateModelRoot extra,
-                             PrintWriter out, Locale locale, Locale aFallbackLocale) throws HTMLParseException {
-
-    if (out == null)
-      throw new HTMLParseException("no outputstream");
-    Template tmpl = getTemplateFor(templateFilename);
-    if (tmpl == null)
-      throw new HTMLParseException("no template: " + templateFilename);
-    if (tmr == null)
-      tmr = new SimpleHash();
-
-      /** @todo  what is this for? (rk) */
-    SimpleHash configHash = new SimpleHash();
-
-    // pass the whole config hash to the templates
-    Iterator it = configuration.getKeys();
-    String key;
-    while (it.hasNext()) {
-      key = (String) it.next();
-      configHash.put(key, new SimpleScalar(
-        configuration.getString(key))
-      );
-    }
-
-    // this does not come directly from the config file
-    configHash.put("docRoot", new SimpleScalar(docRoot));
-
-    configHash.put("actionRoot", new SimpleScalar(res.encodeURL(actionRoot)));
-    configHash.put("now",
-                   new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
-
-    // this conform to updated freemarker syntax
-    configHash.put("compressWhitespace",
-                   new freemarker.template.utility.CompressWhitespace());
-
-    SimpleHash utilityHash = new SimpleHash();
-    try {
-      utilityHash.put("compressWhitespace",
-                      new freemarker.template.utility.CompressWhitespace());
-      utilityHash.put("encodeURI",
-                      FreemarkerGenerator.makeAdapter(new GeneratorHTMLFunctions.
-          encodeURIGeneratorFunction()));
-      utilityHash.put("encodeHTML",
-                      FreemarkerGenerator.makeAdapter(new GeneratorHTMLFunctions.
-          encodeHTMLGeneratorFunction()));
-      utilityHash.put("isOdd",
-                      FreemarkerGenerator.makeAdapter(new GeneratorIntegerFunctions.
-          isOddFunction()));
-      utilityHash.put("increment",
-                      FreemarkerGenerator.makeAdapter(new GeneratorIntegerFunctions.
-          incrementFunction()));
-    }
-    catch (Throwable t) {
-      throw new HTMLParseException(t.getMessage());
-    }
-
-    SimpleHash outPutHash = new SimpleHash();
-
-    if (extra != null) {
-      outPutHash.put("extra", extra);
-    }
-    outPutHash.put("data", tmr);
-    outPutHash.put("config", configHash);
-    outPutHash.put("utility", utilityHash);
-
-    MessageResources messages[] = new MessageResources[bundles.length];
-
-    for (int i=0; i<bundles.length; i++) {
-      messages[i] = MessageResources.getMessageResources(bundles[i]);
-    }
-
-    try {
-      outPutHash.put("lang", FreemarkerGenerator.makeAdapter(new ResourceBundleGeneratorFunction(new Locale[] {locale, aFallbackLocale}, messages)));
-    }
-    catch (Throwable t) {
-      throw new HTMLParseException(t.toString());
-    }
-
-    tmpl.process(outPutHash, out);
-  }
-
-  /**
-   *   Converts Entity-List to SimpleList of SimpleHashes.
-   *   @param aList ist eine Liste von Entity
-   *   @return eine freemarker.template.SimpleList von SimpleHashes.
-   *
-   *    @deprecated EntityLists comply with TemplateListModel now.
-   */
-  public static SimpleList makeSimpleList(EntityList aList) throws StorageObjectFailure {
-    logger.warn("using deprecated makeSimpleList(entityList) - a waste of resources");
-    SimpleList simpleList = new SimpleList();
-    if (aList != null) {
-      for (int i = 0; i < aList.size(); i++) {
-        simpleList.add(aList.elementAt(i));
-      }
-    }
-    return simpleList;
-  }
-
-  /**
-   *  Konvertiert ein EntityList in ein freemarker.template.SimpleHash-Modell. Im Hash
-   *  sind die einzelnen Entities ueber ihre id zu erreichen.
-   *  @param aList ist die EntityList
-   *  @return SimpleHash mit den entsprechenden freemarker Daten
-   *
-   */
-  public static SimpleHash makeSimpleHash(EntityList aList) throws
-      StorageObjectFailure {
-    SimpleHash simpleHash = new SimpleHash();
-    Entity currentEntity;
-
-    if (aList != null) {
-      for (int i = 0; i < aList.size(); i++) {
-        currentEntity = (Entity) aList.elementAt(i);
-        simpleHash.put(currentEntity.getId(), currentEntity);
-      }
-    }
-    return simpleHash;
-  }
-
-  /**
-   *  Konvertiert ein Hashtable mit den keys und values als String
-   *  in ein freemarker.template.SimpleHash-Modell
-   *  @param mergeData der Map mit den String / String Daten
-   *  @return SimpleHash mit den entsprechenden freemarker Daten
-   *
-   */
-  public static SimpleHash makeSimpleHash(Map mergeData) {
-    SimpleHash modelRoot = new SimpleHash();
-    String aField;
-    if (mergeData != null) {
-      Set set = mergeData.keySet();
-      Iterator it = set.iterator();
-      for (int i = 0; i < set.size(); i++) {
-        aField = (String) it.next();
-        modelRoot.put(aField, (String) mergeData.get(aField));
-      }
-    }
-    return modelRoot;
-  }
-
-  /**
-   * Converts EntityList in SimpleHash and adds additional information
-   * to the returned SimpleHash
-   *
-   * @param entList
-   * @return SimpleHash returns SimpleHash with the converted EntityList plus
-   *        additional Data about the list.
-   * @exception StorageObjectException
-   */
-
-  public static SimpleHash makeSimpleHashWithEntitylistInfos(EntityList entList) throws
-      StorageObjectFailure {
-    SimpleHash modelRoot = new SimpleHash();
-    if (entList != null) {
-      modelRoot.put("contentlist", entList);
-      modelRoot.put("count",
-                    new SimpleScalar( (new Integer(entList.getCount())).toString()));
-      if (entList.getWhere() != null) {
-        modelRoot.put("where", new SimpleScalar(entList.getWhere()));
-        modelRoot.put("where_encoded",
-                      new SimpleScalar(URLEncoder.encode(entList.getWhere())));
-      }
-      if (entList.getOrder() != null) {
-        modelRoot.put("order", new SimpleScalar(entList.getOrder()));
-        modelRoot.put("order_encoded",
-                      new SimpleScalar(URLEncoder.encode(entList.getOrder())));
-      }
-      modelRoot.put("from",
-                    new SimpleScalar( (new Integer(entList.getFrom())).toString()));
-      modelRoot.put("to",
-                    new SimpleScalar( (new Integer(entList.getTo())).toString()));
-
-      if (entList.hasNextBatch())
-        modelRoot.put("next",
-                      new SimpleScalar( (new Integer(entList.getNextBatch())).
-                                       toString()));
-      if (entList.hasPrevBatch())
-        modelRoot.put("prev",
-                      new SimpleScalar( (new Integer(entList.getPrevBatch())).
-                                       toString()));
-    }
-    return modelRoot;
-  }
-
-  /**
-   * Private methods to get template from a templateFilename
-   * @param templateFilename
-   * @return Template
-   * @exception HTMLParseException
-   */
-  private static Template getTemplateFor(String templateFilename) throws
-      HTMLParseException {
-    Template returnTemplate = null;
-    if (templateFilename != null)
-      returnTemplate = (Template) templateCache.getItem(templateFilename,
-          "template");
-
-    if (returnTemplate == null) {
-      logger.error("CACHE (ERR): Unknown template: " + templateFilename);
-      throw new HTMLParseException("Templatefile: " + templateFilename + " not found.");
-    }
-
-    return returnTemplate;
-  }
-}
\ No newline at end of file
index ab2b583..7d0c5c5 100755 (executable)
  * 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  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.  
+ * the code of this program with  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.module;
 
-import java.util.Map;
-
-import mir.entity.Entity;
-import mir.entity.EntityList;
+import java.util.Map;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityList;\r
 import mir.storage.StorageObject;
-import freemarker.template.SimpleHash;
 
 
 /**
@@ -233,14 +232,6 @@ public class AbstractModule {
   }
 
   /**
-   * Liefert den Lookuptable aller Objekte des StorageObjects
-   * @return freemarker.template.SimpleHash
-   */
-  public SimpleHash getHashData() {
-    return theStorage.getHashData();
-  }
-
-  /**
    * returns the number of rows
    */
   public int getSize(String where) throws ModuleExc, ModuleFailure {
index b643fa7..1aa17cd 100755 (executable)
  * 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  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.  
+ * the code of this program with  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.producer;
@@ -40,6 +40,21 @@ import mir.entity.adapter.EntityIteratorAdapter;
 import mir.log.LoggerWrapper;
 import mir.util.ParameterExpander;
 
+/**
+ * <p>Title: EntityBatchingProducerNode</p>
+ * <p>Description:
+ *     This producer makes it possible to show articles in batches, like on archive
+ *     pages.
+ *
+ *     <emph> The order by clause should lead to a result set in <b>reverse order<b>:
+ *         the first row will be the last entity in the last batch
+ * </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
 public class EntityBatchingProducerNode implements ProducerNode {
   private String batchInfoKey;
   private String batchDataKey;
@@ -110,10 +125,6 @@ public class EntityBatchingProducerNode implements ProducerNode {
     int nrEntitiesPerBatch;
     int minNrEntitiesInFirstBatch;
 
-//  ML: The order by clause should lead to a result set in _reverse order_: the first row will be
-//      the last entity presented on the last page
-
-
     try {
       nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, nrBatchesToProcessExpression, -1 );
 
index 63fbf7d..90bef9d 100755 (executable)
@@ -818,8 +818,6 @@ public class DefaultProducerNodeBuilders {
     private final static String[] BATCHER_OPTIONAL_ATTRIBUTES = { BATCHER_SELECTION_ATTRIBUTE, BATCHER_ORDER_ATTRIBUTE, BATCHER_MINBATCHSIZE_ATTRIBUTE, BATCHER_SKIP_ATTRIBUTE, BATCHER_PROCESS_ATTRIBUTE };
     private final static String[] BATCHER_SUBNODES = { BATCHER_BATCH_SUBNODE, BATCHER_BATCHLIST_SUBNODE };
 
-    // ML: batchSize, minBatchSize, skip should be expressions!
-
     private EntityAdapterModel model;
     private String batchDataKey;
     private String batchInfoKey;
index c720a55..b0c68a9 100755 (executable)
@@ -29,7 +29,8 @@
  */
 package mir.rss;
 
-import java.util.*;
+import java.util.HashMap;\r
+import java.util.Map;
 
 public class RDFResource {
   private String identifier;
index e343842..441ee33 100755 (executable)
-/*
- * 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  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.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Locale;
-import java.sql.*;
-
-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 com.codestudio.util.*;
-import com.codestudio.util.JDBCPoolMetaData;
-import com.codestudio.util.SQLManager;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.log.LoggerWrapper;
-import mircoders.global.*;
-
-/**
- * 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.30.2.3 2003/06/28 04:04:25 zapata Exp $
- */
-
-public abstract class AbstractServlet extends HttpServlet {
-  protected static String lang;
-  protected LoggerWrapper logger;
-  protected MirPropertiesConfiguration configuration;
-
-  /**
-   * Constructor for AbstractServlet.
-   */
-  public AbstractServlet() {
-    super();
-  }
-
-  protected void setNoCaching(HttpServletResponse aResponse) {
-    //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
-    aResponse.setHeader("Pragma", "no-cache");
-    aResponse.setDateHeader("Expires", 0);
-    aResponse.setHeader("Cache-Control", "no-cache");
-  }
-
-  /**
-   * Bind the language to the session
-   */
-  protected void setLanguage(HttpSession session, String language) {
-    logger.debug("setting language to " + language);
-
-    session.setAttribute("language", language);
-    session.setAttribute("locale", new Locale(language, ""));
-  }
-
-  /**
-   * Get the session-bound language
-   */
-  protected String getLanguage(HttpServletRequest aRequest, HttpSession session) {
-    String lang = (String) session.getAttribute("language");
-
-    if (lang == null || lang.length()==0) {
-      lang = getAcceptLanguage(aRequest);
-    }
-
-    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 aRequest) {
-    Locale loc = null;
-    HttpSession session = aRequest.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 = aRequest.getLocale();
-    }
-
-    logger.debug("getting locale: " + loc.getLanguage());
-
-    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 aRequest) {
-    Locale loc = aRequest.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 (Throwable t) {
-      throw new ServletException("can't read configuration: " + t.toString());
-    }
-
-    logger = new LoggerWrapper("Servlet");
-
-    try {
-      MirGlobal.localizer();
-    }
-    catch (Throwable t) {
-      logger.fatal("can't get localizer: " + t.toString());
-      throw new ServletException("can't get localizer: " + t.toString());
-    }
-
-    String dbUser = configuration.getString("Database.Username");
-    String dbPassword = configuration.getString("Database.Password");
-    String dbHost = configuration.getString("Database.Host");
-    String dbPort = configuration.getString("Database.Port");
-    String dbAdapName = configuration.getString("Database.Adaptor");
-    String dbName = configuration.getString("Database.Name");
-    String dbDriver = configuration.getString("Database.Driver");
-    String dbUrl = "jdbc:postgresql://"+dbHost+":"+dbPort+"/"+dbName;
-    int dbMin = configuration.getInteger("Database.poolMin", 1);
-    int dbMax = configuration.getInteger("Database.poolMax", 10);
-
-    JDBCPoolMetaData meta = new JDBCPoolMetaData();
-    meta.setDbname(dbName);
-    meta.setDriver(dbDriver);
-    meta.setURL(dbUrl);
-    meta.setUserName(dbUser);
-    meta.setPassword(dbPassword);
-    meta.setJNDIName("mir");
-    meta.setMaximumSize(dbMax);
-    meta.setMinimumSize(dbMin);
-    meta.setPoolPreparedStatements(false);
-    meta.setCacheEnabled(false);
-    meta.setCacheSize(15);
-    meta.setDebugging(false);
-
-    SQLManager manager = SQLManager.getInstance();
-
-    JDBCPool pool = null;
-    if (manager != null) {
-      pool = manager.createPool(meta);
-    }
-
-    Connection connection;
-    try {
-      connection = pool.requestConnection();
-      pool.closeConnection(connection);
-    }
-    catch (Throwable t) {
-      logger.fatal("Can't connect to database: " + t.toString());
-      throw new ServletException("Can't connect to database: " + t.toString());
-    }
-  }
-
-  private void setEncoding(HttpServletRequest request){
-    try {
-      Class reqClass = request.getClass();
-      Method method = reqClass.getMethod("setCharacterEncoding", new Class[]{String.class});
-      String encoding = configuration.getString("Mir.DefaultHTMLCharset");
-      method.invoke(request, new Object[]{encoding});
-    } catch (NoSuchMethodException e) {
-      // TODO set the encoding in a zapata-way
-//      logger.warn("set encoding not yet implemented: " + e.getMessage());
-    } catch (SecurityException e) {
-      logger.error(e.getMessage());
-      e.printStackTrace();
-    } catch (IllegalArgumentException e) {
-      logger.error(e.getMessage());
-      e.printStackTrace();
-    } catch (IllegalAccessException e) {
-      logger.error(e.getMessage());
-      e.printStackTrace();
-    } catch (InvocationTargetException e) {
-      logger.error(e.getMessage());
-      e.printStackTrace();
-    }
-  }
-
-  protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-    doPost(request, response);
-  }
-
-  protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-    if ((configuration.getString("RootUri") == null) || configuration.getString("RootUri").equals("")) {
-      configuration.setProperty("RootUri", request.getContextPath());
-    }
-    setEncoding(request);
-    process(request, response);
-  }
-
-  abstract public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;
-
-  /**
-   * Selects the language for the response.
-   *
-   * @param session
-   * @param aRequest
-   */
-  protected void checkLanguage(HttpSession aSession, HttpServletRequest aRequest) {
-    String requestLanguage = aRequest.getParameter("language");
-    String sessionLanguage = (String) aSession.getAttribute("language");
-    String acceptLanguage = aRequest.getLocale().getLanguage();
-    String defaultLanguage = configuration.getString("Mir.Login.DefaultLanguage", "en");
-
-    String language = requestLanguage;
-
-    if (language==null)
-      language = sessionLanguage;
-
-    if (language==null)
-      language = acceptLanguage;
-
-    if (language==null)
-      language = defaultLanguage;
-
-    setLanguage(aSession, language);
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.servlet;\r
+\r
+import java.io.IOException;\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+import java.sql.Connection;\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 com.codestudio.util.JDBCPool;\r
+import com.codestudio.util.JDBCPoolMetaData;\r
+import com.codestudio.util.SQLManager;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.log.LoggerWrapper;\r
+\r
+import mircoders.global.MirGlobal;\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.30.2.4 2003/09/03 17:49:38 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
+  }\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
+    logger.debug("setting language to " + language);\r
+\r
+    session.setAttribute("language", language);\r
+    session.setAttribute("locale", new Locale(language, ""));\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
+\r
+    logger.debug("getting locale: " + loc.getLanguage());\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
+\r
+    MirPropertiesConfiguration.setContext(config.getServletContext());\r
+    try {\r
+      configuration = MirPropertiesConfiguration.instance();\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletException("can't read configuration: " + t.toString());\r
+    }\r
+\r
+    logger = new LoggerWrapper("Servlet");\r
+\r
+    try {\r
+      MirGlobal.localizer();\r
+    }\r
+    catch (Throwable t) {\r
+      logger.fatal("can't get localizer: " + t.toString());\r
+      throw new ServletException("can't get localizer: " + t.toString());\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 dbPort = configuration.getString("Database.Port");\r
+    String dbAdapName = configuration.getString("Database.Adaptor");\r
+    String dbName = configuration.getString("Database.Name");\r
+    String dbDriver = configuration.getString("Database.Driver");\r
+    String dbUrl = "jdbc:postgresql://"+dbHost+":"+dbPort+"/"+dbName;\r
+    int dbMin = configuration.getInteger("Database.poolMin", 1);\r
+    int dbMax = configuration.getInteger("Database.poolMax", 10);\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(dbMax);\r
+    meta.setMinimumSize(dbMin);\r
+    meta.setPoolPreparedStatements(false);\r
+    meta.setCacheEnabled(false);\r
+    meta.setCacheSize(15);\r
+    meta.setDebugging(false);\r
+\r
+    SQLManager manager = SQLManager.getInstance();\r
+\r
+    JDBCPool pool = null;\r
+    if (manager != null) {\r
+      pool = manager.createPool(meta);\r
+    }\r
+\r
+    Connection connection;\r
+    try {\r
+      connection = pool.requestConnection();\r
+      pool.closeConnection(connection);\r
+    }\r
+    catch (Throwable t) {\r
+      logger.fatal("Can't connect to database: " + t.toString());\r
+      throw new ServletException("Can't connect to database: " + t.toString());\r
+    }\r
+  }\r
+\r
+  private void setEncoding(HttpServletRequest request){\r
+    try {\r
+      logger.info("Request has encoding: " + request.getCharacterEncoding());\r
+      logger.info("Config stipulates encoding: " + configuration.getString("Mir.DefaultHTMLCharset"));\r
+      Class reqClass = request.getClass();\r
+      Method method = reqClass.getMethod("setCharacterEncoding", new Class[]{String.class});\r
+      String encoding = configuration.getString("Mir.DefaultHTMLCharset");\r
+      method.invoke(request, new Object[]{encoding});\r
+      logger.info("Request now has encoding: " + request.getCharacterEncoding());\r
+    }\r
+    catch (NoSuchMethodException e) {\r
+      // TODO set the encoding in a zapata-way\r
+//      logger.warn("set encoding not yet implemented: " + e.getMessage());\r
+    }\r
+    catch (SecurityException e) {\r
+      logger.error(e.getMessage());\r
+      e.printStackTrace();\r
+    }\r
+    catch (IllegalArgumentException e) {\r
+      logger.error(e.getMessage());\r
+      e.printStackTrace();\r
+    }\r
+    catch (IllegalAccessException e) {\r
+      logger.error(e.getMessage());\r
+      e.printStackTrace();\r
+    }\r
+    catch (InvocationTargetException e) {\r
+      logger.error(e.getMessage());\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\r
+    doPost(request, response);\r
+  }\r
+\r
+  protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\r
+    if ((configuration.getString("RootUri") == null) || configuration.getString("RootUri").equals("")) {\r
+      configuration.setProperty("RootUri", request.getContextPath());\r
+    }\r
+    setEncoding(request);\r
+    process(request, response);\r
+  }\r
+\r
+  abstract public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;\r
+\r
+  /**\r
+   * Selects the language for the response.\r
+   *\r
+   * @param session\r
+   * @param aRequest\r
+   */\r
+  protected void checkLanguage(HttpSession aSession, HttpServletRequest aRequest) {\r
+    String requestLanguage = aRequest.getParameter("language");\r
+    String sessionLanguage = (String) aSession.getAttribute("language");\r
+    String acceptLanguage = aRequest.getLocale().getLanguage();\r
+    String defaultLanguage = configuration.getString("Mir.Login.DefaultLanguage", "en");\r
+\r
+    String language = requestLanguage;\r
+\r
+    if (language==null)\r
+      language = sessionLanguage;\r
+\r
+    if (language==null)\r
+      language = acceptLanguage;\r
+\r
+    if (language==null)\r
+      language = defaultLanguage;\r
+\r
+    setLanguage(aSession, language);\r
+  }\r
+}\r
index c8f252a..42519db 100755 (executable)
  */\r
 package mir.servlet;\r
 \r
-import java.io.PrintWriter;\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
-\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.entity.EntityList;\r
+import mir.entity.adapter.EntityAdapterDefinition;\r
+import mir.entity.adapter.EntityAdapterEngine;\r
+import mir.entity.adapter.EntityAdapterModel;\r
 import mir.log.LoggerWrapper;\r
-import mir.misc.HTMLTemplateProcessor;\r
-import mir.misc.LineFilterWriter;\r
 import mir.module.AbstractModule;\r
 import mir.storage.StorageObject;\r
 import mir.util.HTTPRequestParser;\r
-import mircoders.servlet.*;\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.TemplateModelRoot;\r
-\r
-\r
-\r
+import mir.util.URLBuilder;\r
+import mircoders.servlet.ServletHelper;\r
 \r
 /**\r
- * Abstract class ServletModule provides the base functionality for servlets.\r
- * Deriving a class from ServletModule enables class to insert/edit/update/delete\r
- * and list Entity from a Database via mainModule.\r
- *\r
- *\r
- *  Abstrakte Klasse ServletModule stellt die Basisfunktionalitaet der\r
- *  abgeleiteten ServletModule zur Verf?gung.\r
  *\r
- * @version 28.6.1999\r
- * @author RK\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
  */\r
 \r
 public abstract class ServletModule {\r
-\r
   public String defaultAction;\r
   protected LoggerWrapper logger;\r
   protected MirPropertiesConfiguration configuration;\r
-  protected AbstractModule mainModule;\r
   protected Locale fallbackLocale;\r
-  protected String templateListString;\r
-  protected String templateObjektString;\r
-  protected String templateConfirmString;\r
+\r
+  protected AbstractModule mainModule;\r
+  protected String definition;\r
+  protected EntityAdapterModel model;\r
+\r
+  protected String listGenerator;\r
+  protected String editGenerator;\r
+  protected String deleteConfirmationGenerator;\r
+  protected int nrEntitiesPerListPage;\r
 \r
 \r
   public ServletModule(){\r
+    definition = null;\r
+    model = null;\r
+\r
     try {\r
       configuration = MirPropertiesConfiguration.instance();\r
     }\r
@@ -88,20 +87,30 @@ public abstract class ServletModule {
       throw new RuntimeException("Can't get configuration: " + e.getMessage());\r
     }\r
 \r
+    listGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".ListTemplate");\r
+    editGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".EditTemplate");\r
+    deleteConfirmationGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".DeleteConfirmationTemplate");\r
+    nrEntitiesPerListPage =\r
+        configuration.getInt("ServletModule."+getOperationModuleName()+".ListSize",\r
+        configuration.getInt("ServletModule.Default.ListSize", 20));\r
+\r
     fallbackLocale = new Locale(configuration.getString("Mir.Admin.FallbackLanguage", "en"), "");\r
   }\r
 \r
 \r
   /**\r
-   * Singelton - Methode muss in den abgeleiteten Klassen ueberschrieben werden.\r
-   * @return ServletModule\r
+   * Singleton instance retrievel method. MUST be overridden in subclasses.\r
+   *\r
+   * @return ServletModule the single instance of the servletmodule class\r
    */\r
   public static ServletModule getInstance() {\r
     return null;\r
   }\r
 \r
   /**\r
-   * get the module name to be used for generic operations like delete.\r
+   * Get the module name\r
+   *\r
+   * @return\r
    */\r
   protected String getOperationModuleName() {\r
     return getClass().getName().substring((new String("mircoders.servlet.ServletModule")).length());\r
@@ -111,16 +120,16 @@ public abstract class ServletModule {
    * 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 req) {\r
+  public Locale getLocale(HttpServletRequest aRequest) {\r
     Locale loc = null;\r
-    HttpSession session = req.getSession(false);\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 = req.getLocale();\r
+      loc = aRequest.getLocale();\r
     }\r
     return loc;\r
   }\r
@@ -129,216 +138,212 @@ public abstract class ServletModule {
    * 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 getFallbackLocale(HttpServletRequest req) {\r
+  public Locale getFallbackLocale(HttpServletRequest aRequest) {\r
     return fallbackLocale;\r
   }\r
 \r
-  public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {\r
-    try {\r
-      aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?"+aQuery));\r
-    }\r
-    catch (Throwable t) {\r
-      throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);\r
-    }\r
-  }\r
-\r
   /**\r
-   *  list(req,res) - generische Listmethode. Wennn die Funktionalitaet\r
-   *  nicht reicht, muss sie in der abgeleiteten ServletModule-Klasse\r
-   *  ueberschreiben werden.\r
+   * Function to specify the default ordering for lists. May be overridden.\r
    *\r
-   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
+   *\r
+   * @return\r
    */\r
-  public void list(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
-    try {\r
-      EntityList theList;\r
-      String offsetParam = req.getParameter("offset");\r
-      int offset = 0;\r
-      PrintWriter out = res.getWriter();\r
-\r
-      // hier offsetcode bearbeiten\r
-      if (offsetParam != null && !offsetParam.equals("")) {\r
-        offset = Integer.parseInt(offsetParam);\r
-      }\r
-      if (req.getParameter("next") != null) {\r
-        offset = Integer.parseInt(req.getParameter("nextoffset"));\r
-      }\r
-      else {\r
-        if (req.getParameter("prev") != null) {\r
-          offset = Integer.parseInt(req.getParameter("prevoffset"));\r
-        }\r
-      }\r
-      theList = mainModule.getByWhereClause(null, offset);\r
+  public String getDefaultListOrdering() {\r
 \r
-      HTMLTemplateProcessor.process(res, templateListString, theList, null, null, out, getLocale(req), getFallbackLocale(req));\r
+    if (mainModule!=null && mainModule.getStorageObject()!=null){\r
+      if (mainModule.getStorageObject().getFields().contains("webdb_create"))\r
+        return "webdb_create desc";\r
     }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
-    }\r
-  }\r
 \r
-  /**\r
-   *  add(req,res) - generische Addmethode. Wennn die Funktionalitaet\r
-   *  nicht reicht, muss sie in der abgeleiteten ServletModule-Klasse\r
-   *  ueberschreiben werden.\r
-   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
-   */\r
-  public void add(HttpServletRequest req, HttpServletResponse res)\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 (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
-    }\r
+    return "id asc";\r
   }\r
 \r
   /**\r
-   *  insert(req,res) - generische Insertmethode, folgt auf add.\r
-   *  Wennn die Funktionalitaet\r
-   *  nicht reicht, muss sie in der abgeleiteten ServletModule-Klasse\r
-   *  ueberschreiben werden.\r
    *\r
-   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
+   * @param aResponse\r
+   * @param aQuery\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleFailure\r
    */\r
-  public void insert(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
+  public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {\r
     try {\r
-      Map withValues = getIntersectingValues(req, mainModule.getStorageObject());\r
-      logger.debug("--trying to add...");\r
-      String id = mainModule.add(withValues);\r
-      logger.debug("--trying to deliver..." + id);\r
-      list(req, res);\r
+      aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?"+aQuery));\r
     }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);\r
     }\r
   }\r
 \r
   /**\r
-   *  delete(req,res) - generic delete method. Can be overridden in subclasses.\r
+   * Generic list method\r
    *\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
    */\r
-/*\r
-  public void delete(HttpServletRequest req, HttpServletResponse res)\r
-      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
+\r
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+    String where = requestParser.getParameter("where");\r
+    String order = requestParser.getParameterWithDefault("order", getDefaultListOrdering());\r
+    int offset = requestParser.getIntegerWithDefault("offset", 0);\r
+\r
+    returnList(aRequest, aResponse, where, order, offset);\r
+  }\r
+\r
+\r
+  public void returnList(HttpServletRequest aRequest, HttpServletResponse aResponse,\r
+     String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {\r
+\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+    URLBuilder urlBuilder = new URLBuilder();\r
+    int count;\r
+\r
     try {\r
-      String idParam = req.getParameter("id");\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
 \r
-      if (idParam == null)\r
-        throw new ServletModuleExc("Invalid call to delete: no id supplied");\r
+      List list =\r
+         EntityAdapterEngine.retrieveAdapterList(model, definition, aWhereClause, anOrderByClause, nrEntitiesPerListPage, anOffset);\r
+\r
+      responseData.put("nexturl", null);\r
+      responseData.put("prevurl", null);\r
+      responseData.put("module", getOperationModuleName());\r
 \r
-      String confirmParam = req.getParameter("confirm");\r
-      String cancelParam = req.getParameter("cancel");\r
-      if (confirmParam == null && cancelParam == null) {\r
-        SimpleHash mergeData = new SimpleHash();\r
-\r
-        mergeData.put("module", getOperationModuleName());\r
-        mergeData.put("infoString", getOperationModuleName() + ": " + idParam);\r
-        mergeData.put("id", idParam);\r
-        mergeData.put("where", req.getParameter("where"));\r
-        mergeData.put("order", req.getParameter("order"));\r
-        mergeData.put("offset", req.getParameter("offset"));\r
-        // this stuff is to be compatible with the other more advanced\r
-        // search method used for media and comments\r
-        mergeData.put("query_media_folder", req.getParameter("query_media_folder"));\r
-        mergeData.put("query_is_published", req.getParameter("query_is_published"));\r
-        mergeData.put("query_text", req.getParameter("query_text"));\r
-        mergeData.put("query_field", req.getParameter("query_field"));\r
-\r
-        deliver(req, res, mergeData, templateConfirmString);\r
+      count=mainModule.getSize(aWhereClause);\r
+\r
+      urlBuilder.setValue("module", getOperationModuleName());\r
+      urlBuilder.setValue("do", "list");\r
+      urlBuilder.setValue("where", aWhereClause);\r
+      urlBuilder.setValue("order", anOrderByClause);\r
+\r
+      urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));\r
+      urlBuilder.setValue("searchtext", requestParser.getParameter("searchtext"));\r
+      urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));\r
+      urlBuilder.setValue("searchstatus", requestParser.getParameter("searchstatus"));\r
+      urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));\r
+\r
+      responseData.put("searchfield", requestParser.getParameter("searchfield"));\r
+      responseData.put("searchtext", requestParser.getParameter("searchtext"));\r
+      responseData.put("searchispublished", requestParser.getParameter("searchispublished"));\r
+      responseData.put("searchstatus", requestParser.getParameter("searchstatus"));\r
+      responseData.put("searchorder", requestParser.getParameter("searchorder"));\r
+\r
+      urlBuilder.setValue("offset", anOffset);\r
+      responseData.put("offset" , new Integer(anOffset).toString());\r
+      responseData.put("thisurl" , urlBuilder.getQuery());\r
+\r
+      if (count>anOffset+nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", anOffset + nrEntitiesPerListPage);\r
+        responseData.put("nexturl" , urlBuilder.getQuery());\r
       }\r
-      else {\r
-        if (confirmParam != null && !confirmParam.equals("")) {\r
-          //theLog.printInfo("delete confirmed!");\r
-          mainModule.deleteById(idParam);\r
-          list(req, res); // back to list\r
-        }\r
-        else {\r
-          if (req.getParameter("where") != null)\r
-            list(req, res);\r
-          else\r
-            edit(req, res);\r
-        }\r
+\r
+      if (anOffset>0) {\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
+        responseData.put("prevurl" , urlBuilder.getQuery());\r
       }\r
+\r
+      responseData.put("entities", list);\r
+      responseData.put("from" , Integer.toString(anOffset+1));\r
+      responseData.put("count", Integer.toString(count));\r
+      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
     }\r
   }\r
-*/\r
-  public void confirmdelete(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+\r
+  public void editObject(HttpServletRequest aRequest, HttpServletResponse aResponse, Object anObject, boolean anIsNew, String anId) throws ServletModuleExc {\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+    URLBuilder urlBuilder = new URLBuilder();\r
+    EntityAdapterModel model;\r
+\r
     try {\r
-      String idParam = aRequest.getParameter("id");\r
-      String confirmParam = aRequest.getParameter("confirm");\r
-      String cancelParam = aRequest.getParameter("cancel");\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
 \r
-      if (confirmParam != null && !confirmParam.equals("")) {\r
-        mainModule.deleteById(idParam);\r
-        redirect(aResponse, aRequest.getParameter("okurl"));\r
+      responseData.put("module", getOperationModuleName());\r
+      responseData.put("entity", anObject);\r
+      responseData.put("new", new Boolean(anIsNew));\r
+\r
+\r
+      urlBuilder.setValue("module", getOperationModuleName());\r
+      urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));\r
+      if (anIsNew)\r
+        urlBuilder.setValue("do", "add");\r
+      else {\r
+        urlBuilder.setValue("id", anId);\r
+        urlBuilder.setValue("do", "edit");\r
       }\r
-      else\r
-        redirect(aResponse, aRequest.getParameter("cancelurl"));\r
+      responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
+      responseData.put("thisurl", urlBuilder.getQuery());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);\r
     }\r
-    catch (Throwable t) {\r
-      throw new ServletModuleFailure(t);\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
-  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+\r
+  /**\r
+   * Generic add method\r
+   *\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
+   */\r
+  public void add(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
       throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
-    try {\r
-      String idParam = aRequest.getParameter("id");\r
 \r
-      if (idParam == null)\r
-        throw new ServletModuleExc("Invalid call to delete: no id supplied");\r
+    Map object = new HashMap();\r
 \r
-      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+    Iterator i = mainModule.getStorageObject().getFields().iterator();\r
 \r
-      responseData.put("module", getOperationModuleName());\r
-      responseData.put("id", idParam);\r
-      responseData.put("cancelurl", aRequest.getParameter("cancelurl"));\r
-      responseData.put("okurl", aRequest.getParameter("okurl"));\r
+    while (i.hasNext())\r
+      object.put(i.next(), "");\r
 \r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateConfirmString);\r
-    }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
-    }\r
+    initializeNewObject(object, aRequest, aResponse);\r
+\r
+    editObject(aRequest, aResponse, object, true, null);\r
+  }\r
+\r
+  protected void initializeNewObject(Map aNewObject, HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
   }\r
 \r
   /**\r
    * Method called when the user edits an object.\r
    *\r
-   * @param req\r
-   * @param res\r
+   * @param aRequest\r
+   * @param aResponse\r
    * @throws ServletModuleExc\r
    * @throws ServletModuleUserExc\r
    * @throws ServletModuleFailure\r
    */\r
-  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
-    edit(req, res, req.getParameter("id"));\r
+  public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
+    edit(aRequest, aResponse, aRequest.getParameter("id"));\r
   }\r
 \r
   /**\r
-   *  edit(req,res) - generische Editmethode. Wennn die Funktionalitaet\r
-   *  nicht reicht, muss sie in der abgeleiteten ServletModule-Klasse\r
-   *  ueberschreiben werden.\r
+   * Generic edit method\r
    *\r
-   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @param anIdentifier\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
    */\r
   public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse, String anIdentifier)\r
       throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
-      deliver(aRequest, aResponse, mainModule.getById(anIdentifier), templateObjektString);\r
+      editObject(aRequest, aResponse, model.makeEntityAdapter(definition, mainModule.getById(anIdentifier)), false, anIdentifier);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
@@ -346,29 +351,30 @@ public abstract class ServletModule {
   }\r
 \r
   /**\r
-   *  update(req,res) - generische Updatemethode. Wennn die Funktionalitaet\r
-   *  nicht reicht, muss sie in der abgeleiteten ServletModule-Klasse\r
-   *  ueberschreiben werden.\r
+   * Generic update method\r
    *\r
-   * @param req Http-Request, das vom Dispatcher durchgereicht wird\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
    */\r
-\r
-  public void update(HttpServletRequest req, HttpServletResponse res)\r
+  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
       throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
-      String idParam = req.getParameter("id");\r
-      Map withValues = getIntersectingValues(req, mainModule.getStorageObject());\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+      String id = aRequest.getParameter("id");\r
+      Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
+      mainModule.set(withValues);\r
 \r
-      String id = mainModule.set(withValues);\r
-      String whereParam = req.getParameter("where");\r
-      String orderParam = req.getParameter("order");\r
+      String returnUrl = requestParser.getParameter("returnurl");\r
 \r
-      if ((whereParam != null && !whereParam.equals("")) || (orderParam != null && !orderParam.equals(""))) {\r
-        list(req, res);\r
+      if (returnUrl!=null) {\r
+        redirect(aResponse, returnUrl);\r
       }\r
       else {\r
-        edit(req, res);\r
+        edit(aRequest, aResponse, id);\r
       }\r
     }\r
     catch (Throwable e) {\r
@@ -377,95 +383,93 @@ public abstract class ServletModule {
   }\r
 \r
   /**\r
-   * deliver liefert das Template mit dem Filenamen templateFilename\r
-   * an den HttpServletResponse res aus, nachdem es mit den Daten aus\r
-   * TemplateModelRoot rtm gemischt wurde\r
+   * Generic insert method\r
    *\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
-   * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den\r
-   *   Daten, die ins Template gemerged werden sollen.\r
-   * @param tmpl Name des Templates\r
-   * @exception ServletModuleException\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
    */\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
+  public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
-      PrintWriter out = res.getWriter();\r
-      HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out, getLocale(req), getFallbackLocale(req));\r
-\r
-      // we default to admin bundles here, which is not exactly beautiful...\r
-      // but this whole producer stuff is going to be rewritten soon.\r
-      // ServletModuleOpenIndy overwrites deliver() to use open bundles\r
-      // (br1)\r
-      out.close();\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+      Map object = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
+\r
+      String id = processInstertedObject(object, aRequest, aResponse);\r
+\r
+      String returnUrl = requestParser.getParameter("returnurl");\r
+\r
+      if (returnUrl!=null) {\r
+        redirect(aResponse, returnUrl);\r
+      }\r
+      else {\r
+        edit(aRequest, aResponse, id);\r
+      }\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
     }\r
   }\r
 \r
+  public String processInstertedObject(Map anObject, HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+    try {\r
+      return mainModule.add(anObject);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  };\r
 \r
   /**\r
-   * deliver liefert das Template mit dem Filenamen templateFilename\r
-   * an den HttpServletResponse res aus, nachdem es mit den Daten aus\r
-   * TemplateModelRoot rtm gemischt wurde\r
-   *\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
-   * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den\r
-   *   Daten, die ins Template gemerged werden sollen.\r
-   * @param tmpl Name des Templates\r
-   * @exception ServletModuleException\r
-   */\r
-  public void deliver(HttpServletRequest req, HttpServletResponse res,\r
-        TemplateModelRoot rtm, String templateFilename) throws ServletModuleFailure {\r
-    deliver(req, res, rtm, null, templateFilename);\r
-  }\r
-\r
-  /**\r
-   * deliver liefert das Template mit dem Filenamen templateFilename\r
-   * an den HttpServletResponse res aus, nachdem es mit den Daten aus\r
-   * TemplateModelRoot rtm gemischt wurde\r
    *\r
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird\r
-   * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den\r
-   *   Daten, die ins Template gemerged werden sollen.\r
-   * @param tmpl Name des Templates\r
-   * @exception ServletModuleException\r
+   * @param aRequest\r
+   * @param aResponse\r
    */\r
-  public void deliver_compressed(HttpServletRequest req, HttpServletResponse res,\r
-                                 TemplateModelRoot rtm, String templateFilename)\r
-      throws ServletModuleFailure {\r
-    if (rtm == null) rtm = new SimpleHash();\r
+  public void confirmdelete(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
     try {\r
-      PrintWriter out = new LineFilterWriter(res.getWriter());\r
-      //PrintWriter out =  res.getWriter();\r
-      HTMLTemplateProcessor.process(res, templateFilename, rtm, null, out, getLocale(req), getFallbackLocale(req));\r
-      out.close();\r
+      String idParam = aRequest.getParameter("id");\r
+      String confirmParam = aRequest.getParameter("confirm");\r
+      String cancelParam = aRequest.getParameter("cancel");\r
+\r
+      if (confirmParam != null && !confirmParam.equals("")) {\r
+        mainModule.deleteById(idParam);\r
+        redirect(aResponse, aRequest.getParameter("okurl"));\r
+      }\r
+      else\r
+        redirect(aResponse, aRequest.getParameter("cancelurl"));\r
     }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
     }\r
   }\r
 \r
   /**\r
-   * deliver liefert das Template mit dem Filenamen templateFilename\r
-   * an den HttpServletResponse res aus, nachdem es mit den Daten aus\r
-   * TemplateModelRoot rtm gemischt wurde\r
    *\r
-   * @param out ist der OutputStream, in den die gergten Daten geschickt werden sollen.\r
-   * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den\r
-   *   Daten, die ins Template gemerged werden sollen.\r
-   * @param tmpl Name des Templates\r
-   * @exception ServletModuleException\r
+   * @param aRequest\r
+   * @param aResponse\r
+   * @throws ServletModuleExc\r
+   * @throws ServletModuleUserExc\r
+   * @throws ServletModuleFailure\r
    */\r
-  private void deliver(HttpServletResponse res, HttpServletRequest req, PrintWriter out,\r
-                       TemplateModelRoot rtm, String templateFilename)\r
-      throws ServletModuleFailure {\r
+  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure  {\r
     try {\r
-      HTMLTemplateProcessor.process(res, templateFilename, rtm, null, out, getLocale(req), getFallbackLocale(req));\r
+      String idParam = aRequest.getParameter("id");\r
+\r
+      if (idParam == null)\r
+        throw new ServletModuleExc("Invalid call to delete: no id supplied");\r
+\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+\r
+      responseData.put("module", getOperationModuleName());\r
+      responseData.put("id", idParam);\r
+      responseData.put("cancelurl", aRequest.getParameter("cancelurl"));\r
+      responseData.put("okurl", aRequest.getParameter("okurl"));\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, deleteConfirmationGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
@@ -489,14 +493,14 @@ public abstract class ServletModule {
    *\r
    * @return Map with the values\r
    */\r
-  public Map getIntersectingValues(HttpServletRequest req, StorageObject theStorage)\r
+  public Map getIntersectingValues(HttpServletRequest aRequest, StorageObject theStorage)\r
       throws ServletModuleExc, ServletModuleFailure {\r
 \r
     try {\r
       HTTPRequestParser parser;\r
       List theFieldList;\r
 \r
-      parser = new HTTPRequestParser(req);\r
+      parser = new HTTPRequestParser(aRequest);\r
 \r
       theFieldList = theStorage.getFields();\r
 \r
index 88435d0..f5e841b 100755 (executable)
  * 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  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.  
+ * the code of this program with  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;
@@ -42,7 +42,7 @@ import mir.log.LoggerWrapper;
  * Dispatcher, calls the method passed to ServletModule Class, through the "do"
  * Parameter (via POST or GET)
  *
- * @version $Id: ServletModuleDispatch.java,v 1.15 2003/04/21 12:42:50 idfx Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.15.2.1 2003/09/03 17:49:38 zapata Exp $
  *
  * @Author rk
  *
@@ -52,56 +52,52 @@ public final class ServletModuleDispatch {
   private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Dispatch");
   private static final Class[] SIGNATURE = { HttpServletRequest.class, HttpServletResponse.class };
 
- /**
-  * private constructor to prevent unwanted instantiation;
-  */
 /**
+   * private parameter-less constructor to prevent unwanted instantiation
+   */
 
   private ServletModuleDispatch () {
   }
 
   /**
-   *  Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
-   *  mit dem per HttpServletRequest angegebenen Paramter <code>do</code> auf.
-   *  Ist kein Parameter angegeben, so wird versucht, in die <code>defaultAction</code>
-   *  des ServletModules zu springen.
+   * Method to dispatch servletmodule requests.
    *
-   * @param req Http-Request, das vom Dispatcher an die Methode des
-   *    ServletModules durchgereicht wird
-   * @param res Http-Response, die vom Dispatcher an die Methode des
-   *    ServletModules durchgereicht wird
-   * @param sMod ServletModule, an das dispatched wird.
-   * @param mod Name des Modules als String (f?r Logfile)
+   * @param aServletModule
+   * @param aRequest
+   * @param aResponse
+   * @throws ServletModuleExc
+   * @throws ServletModuleUserExc
+   * @throws ServletModuleFailure
    */
 
-  public static void dispatch(ServletModule sMod, HttpServletRequest req,
-          HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
+  public static void dispatch(ServletModule aServletModule, HttpServletRequest aRequest,
+       HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
   {
-    String doParam = req.getParameter("do");
-    logger.info("ServletModuleDispatch: " + sMod.toString() + " with method " + doParam);
+    String doParam = aRequest.getParameter("do");
+    logger.info("ServletModuleDispatch: " + aServletModule.toString() + " with method " + doParam);
     if (doParam == null) {
-      if (sMod.defaultAction() != null)
-        doParam = sMod.defaultAction();
+      if (aServletModule.defaultAction() != null)
+        doParam = aServletModule.defaultAction();
       else
         throw new ServletModuleExc("no parameter do supplied!");
     }
 
     try {
-      Method method = sMod.getClass().getMethod(doParam,SIGNATURE);
+      Method method = aServletModule.getClass().getMethod(doParam,SIGNATURE);
       if (method != null) {
-        method.invoke(sMod,new Object[] {req,res} );
+        method.invoke(aServletModule,new Object[] {aRequest,aResponse} );
         return;
       }
       else logger.debug("method lookup unsuccesful");
     }
     catch ( InvocationTargetException e) {
-      logger.error( "invocation target exception: " + e.getMessage());
+      logger.error( "invocation target exception: " + e.toString());
       e.getTargetException().printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
 
       throw new ServletModuleFailure(e.getTargetException().getMessage(), e.getTargetException());
     }
     catch (Throwable t) {
-      logger.error( "ServletModuleDispatch: " + t.getMessage());
-      t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
+      logger.error( "ServletModuleDispatch: " + t.toString());
       throw new ServletModuleFailure(t);
     }
   }
diff --git a/source/mir/servlet/ServletModuleShow.java b/source/mir/servlet/ServletModuleShow.java
deleted file mode 100755 (executable)
index 447f5f0..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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  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
-      ServletModuleExc {
-    try {
-      String idParam = req.getParameter("tmpl");
-      if (! (idParam == null || idParam.equals(""))) {
-        deliver(req, res, (TemplateModelRoot)null,
-                "html/" + idParam + ".template");
-      }
-      else {
-        throw new ServletModuleExc("Invalid template: " + idParam);
-      }
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-}
-
-
-
-
index 95be661..e2a678e 100755 (executable)
-/*
- * 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  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.storage;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.*;
-import java.util.Map;
-
-import com.codestudio.util.SQLManager;
-
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.entity.Entity;
-import mir.entity.EntityList;
-import mir.entity.StorableObjectEntity;
-import mir.log.LoggerWrapper;
-import mir.misc.HTMLTemplateProcessor;
-import mir.misc.StringUtil;
-import mir.storage.store.ObjectStore;
-import mir.storage.store.StorableObject;
-import mir.storage.store.StoreContainerType;
-import mir.storage.store.StoreIdentifier;
-import mir.storage.store.StoreUtil;
-import mir.util.JDBCStringRoutines;
-
-
-/**
- * Diese Klasse implementiert die Zugriffsschicht auf die Datenbank.
- * Alle Projektspezifischen Datenbankklassen erben von dieser Klasse.
- * In den Unterklassen wird im Minimalfall nur die Tabelle angegeben.
- * Im Konfigurationsfile findet sich eine Verweis auf den verwendeten
- * Treiber, Host, User und Passwort, ueber den der Zugriff auf die
- * Datenbank erfolgt.
- *
- * @version $Id: Database.java,v 1.44.2.5 2003/06/27 02:43:42 zapata Exp $
- * @author rk
- *
- */
-public class Database implements StorageObject {
-  private static Class GENERIC_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;
-  private static Class STORABLE_OBJECT_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;
-
-
-  private static SimpleHash POPUP_EMPTYLINE = new SimpleHash();
-  protected static final ObjectStore o_store = ObjectStore.getInstance();
-  private static final int _millisPerHour = 60 * 60 * 1000;
-  private static final int _millisPerMinute = 60 * 1000;
-
-  static {
-    // always same object saves a little space
-    POPUP_EMPTYLINE.put("key", "");
-    POPUP_EMPTYLINE.put("value", "--");
-  }
-
-  protected LoggerWrapper logger;
-  protected MirPropertiesConfiguration configuration;
-  protected String theTable;
-  protected String theCoreTable = null;
-  protected String thePKeyName = "id";
-  protected int thePKeyType;
-  protected int thePKeyIndex;
-  protected boolean evaluatedMetaData = false;
-  protected ArrayList metadataFields;
-  protected ArrayList metadataLabels;
-  protected ArrayList metadataNotNullFields;
-  protected int[] metadataTypes;
-  protected Class theEntityClass;
-  protected SimpleList popupCache = null;
-  protected boolean hasPopupCache = false;
-  protected SimpleHash hashCache = null;
-  protected boolean hasTimestamp = true;
-  private String database_driver;
-  private String database_url;
-  private int defaultLimit;
-
-  TimeZone timezone;
-  SimpleDateFormat internalDateFormat;
-  SimpleDateFormat userInputDateFormat;
-/*
-  private SimpleDateFormat _dateFormatterOut;
-  private SimpleDateFormat _dateFormatterIn;
-  _dateFormatterOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-  _dateFormatterIn = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-*/
-
-  /**
-   * Kontruktor bekommt den Filenamen des Konfigurationsfiles ?bergeben.
-   * Aus diesem file werden <code>Database.Logfile</code>,
-   * <code>Database.Username</code>,<code>Database.Password</code>,
-   * <code>Database.Host</code> und <code>Database.Adaptor</code>
-   * ausgelesen und ein Broker f?r die Verbindugen zur Datenbank
-   * erzeugt.
-   *
-   * @param   String confFilename Dateiname der Konfigurationsdatei
-   */
-  public Database() throws StorageObjectFailure {
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (PropertiesConfigExc e) {
-      throw new StorageObjectFailure(e);
-    }
-    logger = new LoggerWrapper("Database");
-    timezone = TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone"));
-    internalDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    internalDateFormat.setTimeZone(timezone);
-
-    userInputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-    userInputDateFormat.setTimeZone(timezone);
-
-
-    String theAdaptorName = configuration.getString("Database.Adaptor");
-    defaultLimit = Integer.parseInt(configuration.getString("Database.Limit"));
-
-    try {
-      theEntityClass = GENERIC_ENTITY_CLASS;
-    }
-    catch (Throwable e) {
-      logger.error("Error in Database() constructor with " + theAdaptorName + " -- " + e.getMessage());
-      throw new StorageObjectFailure("Error in Database() constructor.", e);
-    }
-  }
-
-  /**
-   * Liefert die Entity-Klasse zur?ck, in der eine Datenbankzeile gewrappt
-   * wird. Wird die Entity-Klasse durch die erbende Klasse nicht ?berschrieben,
-   * wird eine mir.entity.GenericEntity erzeugt.
-   *
-   * @return Class-Objekt der Entity
-   */
-  public java.lang.Class getEntityClass() {
-    return theEntityClass;
-  }
-
-  /**
-   * Liefert die Standardbeschr?nkung von select-Statements zur?ck, also
-   * wieviel Datens?tze per Default selektiert werden.
-   *
-   * @return Standard-Anzahl der Datens?tze
-   */
-  public int getLimit() {
-    return defaultLimit;
-  }
-
-  /**
-   * Liefert den Namen des Primary-Keys zur?ck. Wird die Variable nicht von
-   * der erbenden Klasse ?berschrieben, so ist der Wert <code>PKEY</code>
-   * @return Name des Primary-Keys
-   */
-  public String getIdName() {
-    return thePKeyName;
-  }
-
-  /**
-   * Liefert den Namen der Tabelle, auf das sich das Datenbankobjekt bezieht.
-   *
-   * @return Name der Tabelle
-   */
-  public String getTableName() {
-    return theTable;
-  }
-
-  /*
-  *   Dient dazu vererbte Tabellen bei objectrelationalen DBMS
-  *   zu speichern, wenn die id einer Tabelle in der parenttabelle verwaltet
-  *   wird.
-  *   @return liefert theCoreTabel als String zurueck, wenn gesetzt, sonst
-  *    the Table
-   */
-  public String getCoreTable() {
-    if (theCoreTable != null) {
-      return theCoreTable;
-    }
-    else {
-      return theTable;
-    }
-  }
-
-  /**
-   * Liefert Feldtypen der Felder der Tabelle zurueck (s.a. java.sql.Types)
-   * @return int-Array mit den Typen der Felder
-   * @exception StorageObjectException
-   */
-  public int[] getTypes() throws StorageObjectFailure {
-    if (metadataTypes == null) {
-      get_meta_data();
-    }
-
-    return metadataTypes;
-  }
-
-  /**
-   * Liefert eine Liste der Labels der Tabellenfelder
-   * @return ArrayListe mit Labeln
-   * @exception StorageObjectException
-   */
-  public List getLabels() throws StorageObjectFailure {
-    if (metadataLabels == null) {
-      get_meta_data();
-    }
-
-    return metadataLabels;
-  }
-
-  /**
-   * Liefert eine Liste der Felder der Tabelle
-   * @return ArrayList mit Feldern
-   * @exception StorageObjectException
-   */
-  public List getFields() throws StorageObjectFailure {
-    if (metadataFields == null) {
-      get_meta_data();
-    }
-
-    return metadataFields;
-  }
-
-  /*
-  *   Gets value out of ResultSet according to type and converts to String
-  *   @param inValue  Wert aus ResultSet.
-  *   @param aType  Datenbanktyp.
-  *   @return liefert den Wert als String zurueck. Wenn keine Umwandlung moeglich
-  *           dann /unsupported value/
-   */
-  private String getValueAsString(ResultSet rs, int valueIndex, int aType)
-    throws StorageObjectFailure {
-    String outValue = null;
-
-    if (rs != null) {
-      try {
-        switch (aType) {
-          case java.sql.Types.BIT:
-            outValue = (rs.getBoolean(valueIndex) == true) ? "1" : "0";
-
-            break;
-
-          case java.sql.Types.INTEGER:
-          case java.sql.Types.SMALLINT:
-          case java.sql.Types.TINYINT:
-          case java.sql.Types.BIGINT:
-
-            int out = rs.getInt(valueIndex);
-
-            if (!rs.wasNull()) {
-              outValue = new Integer(out).toString();
-            }
-
-            break;
-
-          case java.sql.Types.NUMERIC:
-
-            /** @todo Numeric can be float or double depending upon
-             *  metadata.getScale() / especially with oracle */
-            long outl = rs.getLong(valueIndex);
-
-            if (!rs.wasNull()) {
-              outValue = new Long(outl).toString();
-            }
-
-            break;
-
-          case java.sql.Types.REAL:
-
-            float tempf = rs.getFloat(valueIndex);
-
-            if (!rs.wasNull()) {
-              tempf *= 10;
-              tempf += 0.5;
-
-              int tempf_int = (int) tempf;
-              tempf = (float) tempf_int;
-              tempf /= 10;
-              outValue = "" + tempf;
-              outValue = outValue.replace('.', ',');
-            }
-
-            break;
-
-          case java.sql.Types.DOUBLE:
-
-            double tempd = rs.getDouble(valueIndex);
-
-            if (!rs.wasNull()) {
-              tempd *= 10;
-              tempd += 0.5;
-
-              int tempd_int = (int) tempd;
-              tempd = (double) tempd_int;
-              tempd /= 10;
-              outValue = "" + tempd;
-              outValue = outValue.replace('.', ',');
-            }
-
-            break;
-
-          case java.sql.Types.CHAR:
-          case java.sql.Types.VARCHAR:
-          case java.sql.Types.LONGVARCHAR:
-            outValue = rs.getString(valueIndex);
-
-            break;
-
-          case java.sql.Types.LONGVARBINARY:
-            outValue = rs.getString(valueIndex);
-
-            break;
-
-          case java.sql.Types.TIMESTAMP:
-
-            // it's important to use Timestamp here as getting it
-            // as a string is undefined and is only there for debugging
-            // according to the API. we can make it a string through formatting.
-            // -mh
-            Timestamp timestamp = (rs.getTimestamp(valueIndex));
-
-            if (!rs.wasNull()) {
-              java.util.Date date = new java.util.Date(timestamp.getTime());
-
-              Calendar calendar = new GregorianCalendar();
-              calendar.setTime(date);
-              calendar.setTimeZone(timezone);
-              outValue = internalDateFormat.format(date);
-
-              int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
-              String tzOffset = StringUtil.zeroPaddingNumber(Math.abs(offset) / _millisPerHour, 2, 2);
-
-              if (offset<0)
-                outValue = outValue + "-";
-              else
-                outValue = outValue + "+";
-              outValue = outValue + tzOffset;
-            }
-
-            break;
-
-          default:
-            outValue = "<unsupported value>";
-            logger.warn("Unsupported Datatype: at " + valueIndex + " (" + aType + ")");
-        }
-      } catch (SQLException e) {
-        throw new StorageObjectFailure("Could not get Value out of Resultset -- ",
-          e);
-      }
-    }
-
-    return outValue;
-  }
-
-  /*
-  *   select-Operator um einen Datensatz zu bekommen.
-  *   @param id Primaerschluessel des Datensatzes.
-  *   @return liefert EntityObject des gefundenen Datensatzes oder null.
-   */
-  public Entity selectById(String id) throws StorageObjectExc {
-    if ((id == null) || id.equals("")) {
-      throw new StorageObjectExc("Database.selectById: Missing id");
-    }
-
-    // ask object store for object
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      String uniqueId = id;
-
-      if (theEntityClass.equals(StorableObjectEntity.class)) {
-        uniqueId += ("@" + theTable);
-      }
-
-      StoreIdentifier search_sid = new StoreIdentifier(theEntityClass, uniqueId);
-      logger.debug("CACHE: (dbg) looking for sid " + search_sid.toString());
-
-      Entity hit = (Entity) o_store.use(search_sid);
-
-      if (hit != null) {
-        return hit;
-      }
-    }
-
-    Statement stmt = null;
-    Connection con = getPooledCon();
-    Entity returnEntity = null;
-
-    try {
-      ResultSet rs;
-
-      /** @todo better prepared statement */
-      String selectSql =
-        "select * from " + theTable + " where " + thePKeyName + "=" + id;
-      stmt = con.createStatement();
-      rs = executeSql(stmt, selectSql);
-
-      if (rs != null) {
-        if (evaluatedMetaData == false) {
-          evalMetaData(rs.getMetaData());
-        }
-
-        if (rs.next()) {
-          returnEntity = makeEntityFromResultSet(rs);
-        }
-        else {
-          logger.debug("No data for id: " + id + " in table " + theTable);
-        }
-
-        rs.close();
-      }
-      else {
-        logger.debug("No Data for Id " + id + " in Table " + theTable);
-      }
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "selectById");
-      return null;
-    }
-    catch (NumberFormatException e) {
-      logger.error("ID is no number: " + id);
-    }
-    finally {
-      freeConnection(con, stmt);
-    }
-
-    return returnEntity;
-  }
-
-  /**
-   *   select-Operator um Datensaetze zu bekommen, die key = value erfuellen.
-   *   @param key  Datenbankfeld der Bedingung.
-   *   @param value  Wert die der key anehmen muss.
-   *   @return EntityList mit den gematchten Entities
-   */
-  public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure {
-    return selectByFieldValue(aField, aValue, 0);
-  }
-
-  /**
-   *   select-Operator um Datensaetze zu bekommen, die key = value erfuellen.
-   *   @param key  Datenbankfeld der Bedingung.
-   *   @param value  Wert die der key anehmen muss.
-   *   @param offset  Gibt an ab welchem Datensatz angezeigt werden soll.
-   *   @return EntityList mit den gematchten Entities
-   */
-  public EntityList selectByFieldValue(String aField, String aValue, int offset) throws StorageObjectFailure {
-    return selectByWhereClause(aField + "=" + aValue, offset);
-  }
-
-  /**
-   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
-   * Also offset wird der erste Datensatz genommen.
-   *
-   * @param wc where-Clause
-   * @return EntityList mit den gematchten Entities
-   * @exception StorageObjectException
-   */
-  public EntityList selectByWhereClause(String where) throws StorageObjectFailure {
-    return selectByWhereClause(where, 0);
-  }
-
-  /**
-   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
-   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
-   *
-   * @param wc where-Clause
-   * @param offset ab welchem Datensatz.
-   * @return EntityList mit den gematchten Entities
-   * @exception StorageObjectException
-   */
-  public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure {
-    return selectByWhereClause(whereClause, null, offset);
-  }
-
-  /**
-   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
-   * Also offset wird der erste Datensatz genommen.
-   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
-   *
-   * @param wc where-Clause
-   * @param ob orderBy-Clause
-   * @return EntityList mit den gematchten Entities
-   * @exception StorageObjectException
-   */
-  public EntityList selectByWhereClause(String where, String order) throws StorageObjectFailure {
-    return selectByWhereClause(where, order, 0);
-  }
-
-  /**
-   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
-   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
-   *
-   * @param wc where-Clause
-   * @param ob orderBy-Clause
-   * @param offset ab welchem Datensatz
-   * @return EntityList mit den gematchten Entities
-   * @exception StorageObjectException
-   */
-  public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure {
-    return selectByWhereClause(whereClause, orderBy, offset, defaultLimit);
-  }
-
-  /**
-   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
-   * @param aWhereClause where-Clause
-   * @param anOrderByClause orderBy-Clause
-   * @param offset ab welchem Datensatz
-   * @param limit wieviele Datens?tze
-   * @return EntityList mit den gematchten Entities
-   * @exception StorageObjectException
-   */
-  public EntityList selectByWhereClause(String aWhereClause, String anOrderByClause,
-            int offset, int limit) throws StorageObjectFailure {
-
-    // check o_store for entitylist
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      StoreIdentifier search_sid =
-          new StoreIdentifier(
-            theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST,
-            StoreUtil.getEntityListUniqueIdentifierFor(theTable, aWhereClause, anOrderByClause, offset, limit));
-      EntityList hit = (EntityList) o_store.use(search_sid);
-
-      if (hit != null) {
-        logger.debug("CACHE (hit): " + search_sid.toString());
-
-        return hit;
-      }
-    }
-
-    // local
-    EntityList theReturnList = null;
-    Connection con = null;
-    Statement stmt = null;
-    ResultSet rs;
-    int offsetCount = 0;
-    int count = 0;
-
-    // build sql-statement
-
-    /** @todo count sql string should only be assembled if we really count
-     *  see below at the end of method //rk */
-    if ((aWhereClause != null) && (aWhereClause.trim().length() == 0)) {
-      aWhereClause = null;
-    }
-
-    StringBuffer countSql =
-      new StringBuffer("select count(*) from ").append(theTable);
-    StringBuffer selectSql =
-      new StringBuffer("select * from ").append(theTable);
-
-    if (aWhereClause != null) {
-      selectSql.append(" where ").append(aWhereClause);
-      countSql.append(" where ").append(aWhereClause);
-    }
-
-    if ((anOrderByClause != null) && !(anOrderByClause.trim().length() == 0)) {
-      selectSql.append(" order by ").append(anOrderByClause);
-    }
-
-    if ((limit > -1) && (offset > -1)) {
-      selectSql.append(" LIMIT ").append(limit).append(" OFFSET ").append(offset);
-    }
-
-    // execute sql
-    try {
-      con = getPooledCon();
-      stmt = con.createStatement();
-
-      // selecting...
-      rs = executeSql(stmt, selectSql.toString());
-
-      if (rs != null) {
-        if (!evaluatedMetaData) {
-          evalMetaData(rs.getMetaData());
-        }
-
-        theReturnList = new EntityList();
-
-        Entity theResultEntity;
-
-        while (rs.next()) {
-          theResultEntity = makeEntityFromResultSet(rs);
-          theReturnList.add(theResultEntity);
-          offsetCount++;
-        }
-
-        rs.close();
-      }
-
-      // making entitylist infos
-      count = offsetCount;
-
-      if (theReturnList != null) {
-        // now we decide if we have to know an overall count...
-        count = offsetCount;
-
-        if ((limit > -1) && (offset > -1)) {
-          if (offsetCount == limit) {
-            /** @todo counting should be deffered to entitylist
-             *  getSize() should be used */
-            rs = executeSql(stmt, countSql.toString());
-
-            if (rs != null) {
-              if (rs.next()) {
-                count = rs.getInt(1);
-              }
-
-              rs.close();
-            }
-            else {
-              logger.error("Could not count: " + countSql);
-            }
-          }
-        }
-
-        theReturnList.setCount(count);
-        theReturnList.setOffset(offset);
-        theReturnList.setWhere(aWhereClause);
-        theReturnList.setOrder(anOrderByClause);
-        theReturnList.setStorage(this);
-        theReturnList.setLimit(limit);
-
-        if (offset >= limit) {
-          theReturnList.setPrevBatch(offset - limit);
-        }
-
-        if ((offset + offsetCount) < count) {
-          theReturnList.setNextBatch(offset + limit);
-        }
-
-        if (StoreUtil.implementsStorableObject(theEntityClass)) {
-          StoreIdentifier sid = theReturnList.getStoreIdentifier();
-          logger.debug("CACHE (add): " + sid.toString());
-          o_store.add(sid);
-        }
-      }
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "selectByWhereClause");
-    }
-    finally {
-      try {
-        if (con != null) {
-          freeConnection(con, stmt);
-        }
-      } catch (Throwable t) {
-      }
-    }
-
-    return theReturnList;
-  }
-
-  /**
-   *  Bastelt aus einer Zeile der Datenbank ein EntityObjekt.
-   *
-   *  @param rs Das ResultSetObjekt.
-   *  @return Entity Die Entity.
-   */
-  private Entity makeEntityFromResultSet(ResultSet rs)
-    throws StorageObjectFailure {
-    /** @todo OS: get Pkey from ResultSet and consult ObjectStore */
-    Map theResultHash = new HashMap();
-    String theResult = null;
-    int theType;
-    Entity returnEntity = null;
-
-    try {
-      int size = metadataFields.size();
-
-      for (int i = 0; i < size; i++) {
-        // alle durchlaufen bis nix mehr da
-        theType = metadataTypes[i];
-
-        if (theType == java.sql.Types.LONGVARBINARY) {
-          InputStreamReader is =
-            (InputStreamReader) rs.getCharacterStream(i + 1);
-
-          if (is != null) {
-            char[] data = new char[32768];
-            StringBuffer theResultString = new StringBuffer();
-            int len;
-
-            while ((len = is.read(data)) > 0) {
-              theResultString.append(data, 0, len);
-            }
-
-            is.close();
-            theResult = theResultString.toString();
-          } else {
-            theResult = null;
-          }
-        } else {
-          theResult = getValueAsString(rs, (i + 1), theType);
-        }
-
-        if (theResult != null) {
-          theResultHash.put(metadataFields.get(i), theResult);
-        }
-      }
-
-      if (theEntityClass != null) {
-        returnEntity = (Entity) theEntityClass.newInstance();
-        returnEntity.setStorage(this);
-        returnEntity.setValues(theResultHash);
-
-        if (returnEntity instanceof StorableObject) {
-          logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + theTable);
-          o_store.add(((StorableObject) returnEntity).getStoreIdentifier());
-        }
-      } else {
-        throwStorageObjectException("Internal Error: theEntityClass not set!");
-      }
-    }
-    catch (IllegalAccessException e) {
-      throwStorageObjectException("No access! -- " + e.getMessage());
-    }
-    catch (IOException e) {
-      throwStorageObjectException("IOException! -- " + e.getMessage());
-    }
-    catch (InstantiationException e) {
-      throwStorageObjectException("No Instatiation! -- " + e.getMessage());
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "makeEntityFromResultSet");
-
-      return null;
-    }
-
-    return returnEntity;
-  }
-
-  /**
-   * Inserts an entity into the database.
-   *
-   * @param theEntity
-   * @return der Wert des Primary-keys der eingef?gten Entity
-   */
-  public String insert(Entity theEntity) throws StorageObjectFailure {
-    //cache
-    invalidatePopupCache();
-
-    // invalidating all EntityLists corresponding with theEntityClass
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      StoreContainerType stoc_type =
-        StoreContainerType.valueOf(theEntityClass,
-          StoreContainerType.STOC_TYPE_ENTITYLIST);
-      o_store.invalidate(stoc_type);
-    }
-
-    String returnId = null;
-    Connection con = null;
-    PreparedStatement pstmt = null;
-
-    try {
-      List streamedInput = theEntity.streamedInput();
-      StringBuffer f = new StringBuffer();
-      StringBuffer v = new StringBuffer();
-      String aField;
-      String aValue;
-      boolean firstField = true;
-
-      // make sql-string
-      for (int i = 0; i < getFields().size(); i++) {
-        aField = (String) getFields().get(i);
-
-        if (!aField.equals(thePKeyName)) {
-          aValue = null;
-
-          // exceptions
-          if (!theEntity.hasValueForField(aField) && (
-              aField.equals("webdb_create") ||
-              aField.equals("webdb_lastchange"))) {
-            aValue = "NOW()";
-          }
-          else {
-            if ((streamedInput != null) && streamedInput.contains(aField)) {
-              aValue = "?";
-            }
-            else {
-              if (theEntity.hasValueForField(aField)) {
-                aValue =
-                  "'" +
-                   JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField)) + "'";
-              }
-            }
-          }
-
-          // wenn Wert gegeben, dann einbauen
-          if (aValue != null) {
-            if (firstField == false) {
-              f.append(",");
-              v.append(",");
-            }
-            else {
-              firstField = false;
-            }
-
-            f.append(aField);
-            v.append(aValue);
-          }
-        }
-      }
-       // end for
-
-      // insert into db
-      StringBuffer sqlBuf =
-        new StringBuffer("insert into ").append(theTable).append("(").append(f)
-                                        .append(") values (").append(v).append(")");
-      String sql = sqlBuf.toString();
-
-      logger.debug("INSERT: " + sql);
-      con = getPooledCon();
-      con.setAutoCommit(false);
-      pstmt = con.prepareStatement(sql);
-
-      if (streamedInput != null) {
-        for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString =
-            (String) theEntity.getValue((String) streamedInput.get(i));
-          pstmt.setBytes(i + 1, inputString.getBytes());
-        }
-      }
-
-      int ret = pstmt.executeUpdate();
-
-      if (ret == 0) {
-        //insert failed
-        return null;
-      }
-
-      pstmt = con.prepareStatement("select currval('" + getCoreTable() + "_id_seq')");
-
-      ResultSet rs = pstmt.executeQuery();
-      rs.next();
-      returnId = rs.getString(1);
-      theEntity.setId(returnId);
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "insert");
-    }
-    finally {
-      try {
-        con.setAutoCommit(true);
-      }
-      catch (Exception e) {
-      }
-
-      freeConnection(con, pstmt);
-    }
-
-    /** @todo store entity in o_store */
-    return returnId;
-  }
-
-  /**
-   * Updates an entity in the database
-   *
-   * @param theEntity
-   */
-  public void update(Entity theEntity) throws StorageObjectFailure {
-    Connection con = null;
-    PreparedStatement pstmt = null;
-
-    /** @todo this is stupid: why do we prepare statement, when we
-     *  throw it away afterwards. should be regular statement
-     *  update/insert could better be one routine called save()
-     *  that chooses to either insert or update depending if we
-     *  have a primary key in the entity. i don't know if we
-     *  still need the streamed input fields. // rk  */
-    /** @todo extension: check if Entity did change, otherwise we don't need
-     *  the roundtrip to the database */
-    /** invalidating corresponding entitylists in o_store*/
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      StoreContainerType stoc_type =
-        StoreContainerType.valueOf(theEntityClass,
-          StoreContainerType.STOC_TYPE_ENTITYLIST);
-      o_store.invalidate(stoc_type);
-    }
-
-    List streamedInput = theEntity.streamedInput();
-    String id = theEntity.getId();
-    String aField;
-    StringBuffer fv = new StringBuffer();
-    boolean firstField = true;
-
-    //cache
-    invalidatePopupCache();
-
-    // build sql statement
-    for (int i = 0; i < getFields().size(); i++) {
-      aField = (String) metadataFields.get(i);
-
-      // only normal cases
-      if (  !(aField.equals(thePKeyName) ||
-            aField.equals("webdb_create") ||
-            aField.equals("webdb_lastchange") ||
-            ((streamedInput != null) && streamedInput.contains(aField)))) {
-        if (theEntity.hasValueForField(aField)) {
-          if (firstField == false) {
-            fv.append(", ");
-          }
-          else {
-            firstField = false;
-          }
-
-          fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField))).append("'");
-
-          //              fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
-        }
-      }
-    }
-
-    StringBuffer sql =
-      new StringBuffer("update ").append(theTable).append(" set ").append(fv);
-
-    // exceptions
-    if (metadataFields.contains("webdb_lastchange")) {
-      sql.append(",webdb_lastchange=NOW()");
-    }
-
-    // special case: the webdb_create requires the field in yyyy-mm-dd HH:mm
-    // format so anything extra will be ignored. -mh
-    if (metadataFields.contains("webdb_create") &&
-        theEntity.hasValueForField("webdb_create")) {
-      // minimum of 10 (yyyy-mm-dd)...
-      if (theEntity.getValue("webdb_create").length() >= 10) {
-        String dateString = theEntity.getValue("webdb_create");
-
-        // if only 10, then add 00:00 so it doesn't throw a ParseException
-        if (dateString.length() == 10) {
-          dateString = dateString + " 00:00";
-        }
-
-        // TimeStamp stuff
-        try {
-          java.util.Date d = userInputDateFormat.parse(dateString);
-//          Timestamp tStamp = new Timestamp(d.getTime());
-          sql.append(",webdb_create='" + JDBCStringRoutines.formatDate(d) + "'");
-        }
-        catch (ParseException e) {
-          throw new StorageObjectFailure(e);
-        }
-      }
-    }
-
-    if (streamedInput != null) {
-      for (int i = 0; i < streamedInput.size(); i++) {
-        sql.append(",").append(streamedInput.get(i)).append("=?");
-      }
-    }
-
-    sql.append(" where id=").append(id);
-    logger.debug("UPDATE: " + sql);
-
-    try {
-      con = getPooledCon();
-      con.setAutoCommit(false);
-      pstmt = con.prepareStatement(sql.toString());
-
-      if (streamedInput != null) {
-        for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString =
-            theEntity.getValue((String) streamedInput.get(i));
-          pstmt.setBytes(i + 1, inputString.getBytes());
-        }
-      }
-
-      pstmt.executeUpdate();
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "update");
-    }
-    finally {
-      try {
-        con.setAutoCommit(true);
-      }
-      catch (Exception e) {
-        ;
-      }
-
-      freeConnection(con, pstmt);
-    }
-  }
-
-  /*
-  *   delete-Operator
-  *   @param id des zu loeschenden Datensatzes
-  *   @return boolean liefert true zurueck, wenn loeschen erfolgreich war.
-   */
-  public boolean delete(String id) throws StorageObjectFailure {
-    invalidatePopupCache();
-
-    // ostore send notification
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      String uniqueId = id;
-
-      if (theEntityClass.equals(StorableObjectEntity.class)) {
-        uniqueId += ("@" + theTable);
-      }
-
-      logger.debug("CACHE: (del) " + id);
-
-      StoreIdentifier search_sid =
-        new StoreIdentifier(theEntityClass,
-          StoreContainerType.STOC_TYPE_ENTITY, uniqueId);
-      o_store.invalidate(search_sid);
-    }
-
-    /** @todo could be prepared Statement */
-    Statement stmt = null;
-    Connection con = null;
-    int res = 0;
-    String sql =
-      "delete from " + theTable + " where " + thePKeyName + "='" + id + "'";
-
-    //theLog.printInfo("DELETE " + sql);
-    try {
-      con = getPooledCon();
-      stmt = con.createStatement();
-      res = stmt.executeUpdate(sql);
-    } catch (SQLException sqe) {
-      throwSQLException(sqe, "delete");
-    } finally {
-      freeConnection(con, stmt);
-    }
-
-    return (res > 0) ? true : false;
-  }
-
-  /**
-   * Deletes entities based on a where clause
-   *
-   * @param aWhereClause
-   * @return
-   * @throws StorageObjectFailure
-   */
-  public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure {
-    invalidatePopupCache();
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
-      StoreContainerType stoc_type = StoreContainerType.valueOf(theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST);
-      o_store.invalidate(stoc_type);
-    }
-
-    Statement stmt = null;
-    Connection con = null;
-    int res = 0;
-    String sql =
-      "delete from " + theTable + " where " + aWhereClause;
-
-    //theLog.printInfo("DELETE " + sql);
-    try {
-      con = getPooledCon();
-      stmt = con.createStatement();
-      res = stmt.executeUpdate(sql);
-    }
-    catch (SQLException sqe) {
-      throwSQLException(sqe, "delete");
-    }
-    finally {
-      freeConnection(con, stmt);
-    }
-
-    return res;
-  }
-
-  /* noch nicht implementiert.
-  * @return immer false
-   */
-  public boolean delete(EntityList theEntityList) {
-    invalidatePopupCache();
-
-    return false;
-  }
-
-  /**
-   * Diese Methode sollte ueberschrieben werden, wenn fuer die abgeleitete Database-Klasse
-   * eine SimpleList mit Standard-Popupdaten erzeugt werden koennen soll.
-   * @return null
-   */
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return null;
-  }
-
-  /**
-   *  Holt Daten fuer Popups.
-   *  @param name  Name des Feldes.
-   *  @param hasNullValue  Wenn true wird eine leerer  Eintrag fuer die Popups erzeugt.
-   *  @return SimpleList Gibt freemarker.template.SimpleList zurueck.
-   */
-  public SimpleList getPopupData(String name, boolean hasNullValue)
-    throws StorageObjectFailure {
-    return getPopupData(name, hasNullValue, null);
-  }
-
-  /**
-   *  Holt Daten fuer Popups.
-   *  @param name  Name des Feldes.
-   *  @param hasNullValue  Wenn true wird eine leerer  Eintrag fuer die Popups erzeugt.
-   *  @param where  Schraenkt die Selektion der Datensaetze ein.
-   *  @return SimpleList Gibt freemarker.template.SimpleList zurueck.
-   */
-  public SimpleList getPopupData(String name, boolean hasNullValue, String where)
-    throws StorageObjectFailure {
-    return getPopupData(name, hasNullValue, where, null);
-  }
-
-  /**
-   *  Holt Daten fuer Popups.
-   *  @param name  Name des Feldes.
-   *  @param hasNullValue  Wenn true wird eine leerer  Eintrag fuer die Popups erzeugt.
-   *  @param where  Schraenkt die Selektion der Datensaetze ein.
-   *  @param order  Gibt ein Feld als Sortierkriterium an.
-   *  @return SimpleList Gibt freemarker.template.SimpleList zurueck.
-   */
-  public SimpleList getPopupData(String name, boolean hasNullValue,
-    String where, String order) throws StorageObjectFailure {
-    // caching
-    if (hasPopupCache && (popupCache != null)) {
-      return popupCache;
-    }
-
-    SimpleList simpleList = null;
-    Connection con = null;
-    Statement stmt = null;
-
-    // build sql
-    StringBuffer sql =
-      new StringBuffer("select ").append(thePKeyName).append(",").append(name)
-                                 .append(" from ").append(theTable);
-
-    if ((where != null) && !(where.length() == 0)) {
-      sql.append(" where ").append(where);
-    }
-
-    sql.append(" order by ");
-
-    if ((order != null) && !(order.length() == 0)) {
-      sql.append(order);
-    } else {
-      sql.append(name);
-    }
-
-    // execute sql
-    try {
-      con = getPooledCon();
-    } catch (Exception e) {
-      throw new StorageObjectFailure(e);
-    }
-
-    try {
-      stmt = con.createStatement();
-
-      ResultSet rs = executeSql(stmt, sql.toString());
-
-      if (rs != null) {
-        if (!evaluatedMetaData) {
-          get_meta_data();
-        }
-
-        simpleList = new SimpleList();
-
-        // if popup has null-selector
-        if (hasNullValue) {
-          simpleList.add(POPUP_EMPTYLINE);
-        }
-
-        SimpleHash popupDict;
-
-        while (rs.next()) {
-          popupDict = new SimpleHash();
-          popupDict.put("key", getValueAsString(rs, 1, thePKeyType));
-          popupDict.put("value", rs.getString(2));
-          simpleList.add(popupDict);
-        }
-
-        rs.close();
-      }
-    }
-    catch (Exception e) {
-      logger.error("getPopupData: " + e.getMessage());
-      throw new StorageObjectFailure(e);
-    } finally {
-      freeConnection(con, stmt);
-    }
-
-    if (hasPopupCache) {
-      popupCache = simpleList;
-    }
-
-    return simpleList;
-  }
-
-  /**
-   * Liefert alle Daten der Tabelle als SimpleHash zurueck. Dies wird verwandt,
-   * wenn in den Templates ein Lookup-Table benoetigt wird. Sollte nur bei kleinen
-   * Tabellen Verwendung finden.
-   * @return SimpleHash mit den Tabellezeilen.
-   */
-  public SimpleHash getHashData() {
-    /** @todo dangerous! this should have a flag to be enabled, otherwise
-     *  very big Hashes could be returned */
-    if (hashCache == null) {
-      try {
-        hashCache =
-          HTMLTemplateProcessor.makeSimpleHash(selectByWhereClause("", -1));
-      }
-      catch (StorageObjectFailure e) {
-        logger.debug(e.getMessage());
-      }
-    }
-
-    return hashCache;
-  }
-
-  /* invalidates the popupCache
-   */
-  protected void invalidatePopupCache() {
-    /** @todo  invalidates toooo much */
-    popupCache = null;
-    hashCache = null;
-  }
-
-  /**
-   * Diese Methode fuehrt den Sqlstring <i>sql</i> aus und timed im Logfile.
-   * @param stmt Statemnt
-   * @param sql Sql-String
-   * @return ResultSet
-   * @exception StorageObjectException
-   */
-  public ResultSet executeSql(Statement stmt, String sql)
-                            throws StorageObjectFailure, SQLException {
-    ResultSet rs;
-    long startTime = System.currentTimeMillis();
-
-    try {
-      rs = stmt.executeQuery(sql);
-
-      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-    }
-    catch (SQLException e) {
-      logger.error(e.getMessage() +"\n" + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-      throw e;
-    }
-
-    return rs;
-  }
-/*
-  public ResultSet executeSql(String sql) throws StorageObjectFailure, SQLException {
-    long startTime = System.currentTimeMillis();
-    Connection connection = null;
-    Statement statement = null;
-
-    try {
-      connection = getPooledCon();
-      statement = connection.createStatement();
-      ResultSet result;
-
-      result = statement.executeQuery(sql);
-
-      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-      return result;
-    }
-    catch (Throwable e) {
-      logger.error(e.getMessage() +"\n" + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-      throw new StorageObjectFailure(e);
-    }
-    finally {
-      if (connection!=null) {
-        freeConnection(connection, statement);
-      }
-    }
-  }
-*/
-  private Map processRow(ResultSet aResultSet) throws StorageObjectFailure, StorageObjectExc {
-    try {
-      Map result = new HashMap();
-      ResultSetMetaData metaData = aResultSet.getMetaData();
-      int nrColumns = metaData.getColumnCount();
-      for (int i=0; i<nrColumns; i++) {
-        result.put(metaData.getColumnName(i+1), getValueAsString(aResultSet, i+1, metaData.getColumnType(i+1)));
-      }
-
-      return result;
-    }
-    catch (Throwable e) {
-      throw new StorageObjectFailure(e);
-    }
-  }
-
-  public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc {
-    Connection connection = null;
-    Statement statement = null;
-    try {
-      List result = new Vector();
-      connection = getPooledCon();
-      statement = connection.createStatement();
-      ResultSet resultset = executeSql(statement, sql);
-      try {
-        while (resultset.next() && result.size() < aLimit) {
-          result.add(processRow(resultset));
-        }
-      }
-      finally {
-        resultset.close();
-      }
-
-      return result;
-    }
-    catch (Throwable e) {
-      throw new StorageObjectFailure(e);
-    }
-    finally {
-      if (connection!=null) {
-        freeConnection(connection, statement);
-      }
-    }
-  };
-
-  public Map executeFreeSingleRowSql(String anSqlStatement) throws StorageObjectFailure, StorageObjectExc {
-    try {
-      List resultList = executeFreeSql(anSqlStatement, 1);
-      try {
-        if (resultList.size()>0)
-          return (Map) resultList.get(0);
-        else
-          return null;
-      }
-      finally {
-      }
-    }
-    catch (Throwable t) {
-      throw new StorageObjectFailure(t);
-    }
-  };
-
-  public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc {
-    Map row = executeFreeSingleRowSql(sql);
-
-    if (row==null)
-      return null;
-
-    Iterator i = row.values().iterator();
-    if (i.hasNext())
-      return (String) i.next();
-    else
-      return null;
-  };
-
-  /**
-   * returns the number of rows in the table
-   */
-  public int getSize(String where) throws SQLException, StorageObjectFailure {
-    long startTime = System.currentTimeMillis();
-    String sql = "SELECT Count(*) FROM " + theTable;
-
-    if ((where != null) && (where.length() != 0)) {
-      sql = sql + " where " + where;
-    }
-
-    Connection con = null;
-    Statement stmt = null;
-    int result = 0;
-
-    try {
-      con = getPooledCon();
-      stmt = con.createStatement();
-
-      ResultSet rs = executeSql(stmt, sql);
-
-      while (rs.next()) {
-        result = rs.getInt(1);
-      }
-    }
-    catch (SQLException e) {
-      logger.error("Database.getSize: " + e.getMessage());
-    }
-    finally {
-      freeConnection(con, stmt);
-    }
-
-    //theLog.printInfo(theTable + " has "+ result +" rows where " + where);
-    logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-
-    return result;
-  }
-
-  public int executeUpdate(Statement stmt, String sql)
-    throws StorageObjectFailure, SQLException {
-    int rs;
-    long startTime = System.currentTimeMillis();
-
-    try {
-      rs = stmt.executeUpdate(sql);
-
-      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-    }
-    catch (SQLException e) {
-      logger.error("Failed: " + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-      throw e;
-    }
-
-    return rs;
-  }
-
-  public int executeUpdate(String sql)
-    throws StorageObjectFailure, SQLException {
-    int result = -1;
-    long startTime = System.currentTimeMillis();
-    Connection con = null;
-    PreparedStatement pstmt = null;
-
-    try {
-      con = getPooledCon();
-      pstmt = con.prepareStatement(sql);
-      result = pstmt.executeUpdate();
-    }
-    catch (Throwable e) {
-      logger.error("Database.executeUpdate(" + sql + "): " + e.getMessage());
-      throw new StorageObjectFailure("Database.executeUpdate(" + sql + "): " + e.getMessage(), e);
-    }
-    finally {
-      freeConnection(con, pstmt);
-    }
-
-    logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);
-    return result;
-  }
-
-  /**
-   * Wertet ResultSetMetaData aus und setzt interne Daten entsprechend
-   * @param md ResultSetMetaData
-   * @exception StorageObjectException
-   */
-  private void evalMetaData(ResultSetMetaData md) throws StorageObjectFailure {
-    this.evaluatedMetaData = true;
-    this.metadataFields = new ArrayList();
-    this.metadataLabels = new ArrayList();
-    this.metadataNotNullFields = new ArrayList();
-
-    try {
-      int numFields = md.getColumnCount();
-      this.metadataTypes = new int[numFields];
-
-      String aField;
-      int aType;
-
-      for (int i = 1; i <= numFields; i++) {
-        aField = md.getColumnName(i);
-        metadataFields.add(aField);
-        metadataLabels.add(md.getColumnLabel(i));
-        aType = md.getColumnType(i);
-        metadataTypes[i - 1] = aType;
-
-        if (aField.equals(thePKeyName)) {
-          thePKeyType = aType;
-          thePKeyIndex = i;
-        }
-
-        if (md.isNullable(i) == ResultSetMetaData.columnNullable) {
-          metadataNotNullFields.add(aField);
-        }
-      }
-    }
-    catch (SQLException e) {
-      throwSQLException(e, "evalMetaData");
-    }
-  }
-
-  /**
-   *  Wertet die Metadaten eines Resultsets fuer eine Tabelle aus,
-   *  um die alle Columns und Typen einer Tabelle zu ermitteln.
-   */
-  private void get_meta_data() throws StorageObjectFailure {
-    Connection con = null;
-    PreparedStatement pstmt = null;
-    String sql = "select * from " + theTable + " where 0=1";
-
-    try {
-      con = getPooledCon();
-      pstmt = con.prepareStatement(sql);
-
-      logger.debug("METADATA: " + sql);
-      ResultSet rs = pstmt.executeQuery();
-      evalMetaData(rs.getMetaData());
-      rs.close();
-    }
-    catch (SQLException e) {
-      throwSQLException(e, "get_meta_data");
-    }
-    finally {
-      freeConnection(con, pstmt);
-    }
-  }
-
-  public Connection getPooledCon() throws StorageObjectFailure {
-    Connection con = null;
-
-    try {
-      con = SQLManager.getInstance().requestConnection();
-    }
-    catch (SQLException e) {
-      logger.error("could not connect to the database " + e.getMessage());
-
-      throw new StorageObjectFailure("Could not connect to the database", e);
-    }
-
-    return con;
-  }
-
-  public void freeConnection(Connection con, Statement stmt)
-    throws StorageObjectFailure {
-    SQLManager.closeStatement(stmt);
-    SQLManager.getInstance().returnConnection(con);
-  }
-
-  /**
-   * Wertet SQLException aus und wirft dannach eine StorageObjectException
-   * @param sqe SQLException
-   * @param wo Funktonsname, in der die SQLException geworfen wurde
-   * @exception StorageObjectException
-   */
-  protected void throwSQLException(SQLException sqe, String aFunction) throws StorageObjectFailure {
-    String state = "";
-    String message = "";
-    int vendor = 0;
-
-    if (sqe != null) {
-      state = sqe.getSQLState();
-      message = sqe.getMessage();
-      vendor = sqe.getErrorCode();
-    }
-
-    String information =
-        "SQL Error: " +
-        "state= " + state +
-        ", vendor= " + vendor +
-        ", message=" + message +
-        ", function= " + aFunction;
-
-    logger.error(information);
-
-    throw new StorageObjectFailure(information, sqe);
-  }
-
-  protected void _throwStorageObjectException(Exception e, String aFunction)
-    throws StorageObjectFailure {
-
-    if (e != null) {
-      logger.error(e.getMessage() + aFunction);
-      throw new StorageObjectFailure(aFunction, e);
-    }
-  }
-
-  /**
-   * Loggt Fehlermeldung mit dem Parameter Message und wirft dannach
-   * eine StorageObjectException
-   * @param message Nachricht mit dem Fehler
-   * @exception StorageObjectException
-   */
-  void throwStorageObjectException(String aMessage) throws StorageObjectFailure {
-    logger.error(aMessage);
-    throw new StorageObjectFailure(aMessage, 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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.storage;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+import java.sql.Connection;\r
+import java.sql.PreparedStatement;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.SQLException;\r
+import java.sql.Statement;\r
+import java.sql.Timestamp;\r
+import java.text.ParseException;\r
+import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.GregorianCalendar;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.TimeZone;\r
+import java.util.Vector;\r
+\r
+import com.codestudio.util.SQLManager;\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+import mir.entity.Entity;\r
+import mir.entity.EntityList;\r
+import mir.entity.StorableObjectEntity;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.storage.store.ObjectStore;\r
+import mir.storage.store.StorableObject;\r
+import mir.storage.store.StoreContainerType;\r
+import mir.storage.store.StoreIdentifier;\r
+import mir.storage.store.StoreUtil;\r
+import mir.util.JDBCStringRoutines;\r
+\r
+\r
+/**\r
+ * Diese Klasse implementiert die Zugriffsschicht auf die Datenbank.\r
+ * Alle Projektspezifischen Datenbankklassen erben von dieser Klasse.\r
+ * In den Unterklassen wird im Minimalfall nur die Tabelle angegeben.\r
+ * Im Konfigurationsfile findet sich eine Verweis auf den verwendeten\r
+ * Treiber, Host, User und Passwort, ueber den der Zugriff auf die\r
+ * Datenbank erfolgt.\r
+ *\r
+ * @version $Id: Database.java,v 1.44.2.6 2003/09/03 17:49:39 zapata Exp $\r
+ * @author rk\r
+ *\r
+ */\r
+public class Database implements StorageObject {\r
+  private static Class GENERIC_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;\r
+  private static Class STORABLE_OBJECT_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;\r
+\r
+\r
+  private static Map POPUP_EMPTYLINE = new HashMap();\r
+  protected static final ObjectStore o_store = ObjectStore.getInstance();\r
+  private static final int _millisPerHour = 60 * 60 * 1000;\r
+  private static final int _millisPerMinute = 60 * 1000;\r
+\r
+  static {\r
+    // always same object saves a little space\r
+    POPUP_EMPTYLINE.put("key", "");\r
+    POPUP_EMPTYLINE.put("value", "--");\r
+  }\r
+\r
+  protected LoggerWrapper logger;\r
+  protected MirPropertiesConfiguration configuration;\r
+  protected String theTable;\r
+  protected String theCoreTable = null;\r
+  protected String thePKeyName = "id";\r
+  protected int thePKeyType;\r
+  protected int thePKeyIndex;\r
+  protected boolean evaluatedMetaData = false;\r
+  protected ArrayList metadataFields;\r
+  protected ArrayList metadataLabels;\r
+  protected ArrayList metadataNotNullFields;\r
+  protected int[] metadataTypes;\r
+  protected Class theEntityClass;\r
+  protected List popupCache = null;\r
+  protected boolean hasPopupCache = false;\r
+  protected Map hashCache = null;\r
+  protected boolean hasTimestamp = true;\r
+  private String database_driver;\r
+  private String database_url;\r
+  private int defaultLimit;\r
+\r
+  TimeZone timezone;\r
+  SimpleDateFormat internalDateFormat;\r
+  SimpleDateFormat userInputDateFormat;\r
+/*\r
+  private SimpleDateFormat _dateFormatterOut;\r
+  private SimpleDateFormat _dateFormatterIn;\r
+  _dateFormatterOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");\r
+  _dateFormatterIn = new SimpleDateFormat("yyyy-MM-dd HH:mm");\r
+*/\r
+\r
+  /**\r
+   * Kontruktor bekommt den Filenamen des Konfigurationsfiles ?bergeben.\r
+   * Aus diesem file werden <code>Database.Logfile</code>,\r
+   * <code>Database.Username</code>,<code>Database.Password</code>,\r
+   * <code>Database.Host</code> und <code>Database.Adaptor</code>\r
+   * ausgelesen und ein Broker f?r die Verbindugen zur Datenbank\r
+   * erzeugt.\r
+   *\r
+   * @param   String confFilename Dateiname der Konfigurationsdatei\r
+   */\r
+  public Database() throws StorageObjectFailure {\r
+    try {\r
+      configuration = MirPropertiesConfiguration.instance();\r
+    }\r
+    catch (PropertiesConfigExc e) {\r
+      throw new StorageObjectFailure(e);\r
+    }\r
+    logger = new LoggerWrapper("Database");\r
+    timezone = TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone"));\r
+    internalDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");\r
+    internalDateFormat.setTimeZone(timezone);\r
+\r
+    userInputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");\r
+    userInputDateFormat.setTimeZone(timezone);\r
+\r
+\r
+    String theAdaptorName = configuration.getString("Database.Adaptor");\r
+    defaultLimit = Integer.parseInt(configuration.getString("Database.Limit"));\r
+\r
+    try {\r
+      theEntityClass = GENERIC_ENTITY_CLASS;\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("Error in Database() constructor with " + theAdaptorName + " -- " + e.getMessage());\r
+      throw new StorageObjectFailure("Error in Database() constructor.", e);\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Liefert die Entity-Klasse zur?ck, in der eine Datenbankzeile gewrappt\r
+   * wird. Wird die Entity-Klasse durch die erbende Klasse nicht ?berschrieben,\r
+   * wird eine mir.entity.GenericEntity erzeugt.\r
+   *\r
+   * @return Class-Objekt der Entity\r
+   */\r
+  public java.lang.Class getEntityClass() {\r
+    return theEntityClass;\r
+  }\r
+\r
+  /**\r
+   * Liefert die Standardbeschr?nkung von select-Statements zur?ck, also\r
+   * wieviel Datens?tze per Default selektiert werden.\r
+   *\r
+   * @return Standard-Anzahl der Datens?tze\r
+   */\r
+  public int getLimit() {\r
+    return defaultLimit;\r
+  }\r
+\r
+  /**\r
+   * Liefert den Namen des Primary-Keys zur?ck. Wird die Variable nicht von\r
+   * der erbenden Klasse ?berschrieben, so ist der Wert <code>PKEY</code>\r
+   * @return Name des Primary-Keys\r
+   */\r
+  public String getIdName() {\r
+    return thePKeyName;\r
+  }\r
+\r
+  /**\r
+   * Liefert den Namen der Tabelle, auf das sich das Datenbankobjekt bezieht.\r
+   *\r
+   * @return Name der Tabelle\r
+   */\r
+  public String getTableName() {\r
+    return theTable;\r
+  }\r
+\r
+  /*\r
+  *   Dient dazu vererbte Tabellen bei objectrelationalen DBMS\r
+  *   zu speichern, wenn die id einer Tabelle in der parenttabelle verwaltet\r
+  *   wird.\r
+  *   @return liefert theCoreTabel als String zurueck, wenn gesetzt, sonst\r
+  *    the Table\r
+   */\r
+  public String getCoreTable() {\r
+    if (theCoreTable != null) {\r
+      return theCoreTable;\r
+    }\r
+    else {\r
+      return theTable;\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Liefert Feldtypen der Felder der Tabelle zurueck (s.a. java.sql.Types)\r
+   * @return int-Array mit den Typen der Felder\r
+   * @exception StorageObjectException\r
+   */\r
+  public int[] getTypes() throws StorageObjectFailure {\r
+    if (metadataTypes == null) {\r
+      get_meta_data();\r
+    }\r
+\r
+    return metadataTypes;\r
+  }\r
+\r
+  /**\r
+   * Liefert eine Liste der Labels der Tabellenfelder\r
+   * @return ArrayListe mit Labeln\r
+   * @exception StorageObjectException\r
+   */\r
+  public List getLabels() throws StorageObjectFailure {\r
+    if (metadataLabels == null) {\r
+      get_meta_data();\r
+    }\r
+\r
+    return metadataLabels;\r
+  }\r
+\r
+  /**\r
+   * Liefert eine Liste der Felder der Tabelle\r
+   * @return ArrayList mit Feldern\r
+   * @exception StorageObjectException\r
+   */\r
+  public List getFields() throws StorageObjectFailure {\r
+    if (metadataFields == null) {\r
+      get_meta_data();\r
+    }\r
+\r
+    return metadataFields;\r
+  }\r
+\r
+  /*\r
+  *   Gets value out of ResultSet according to type and converts to String\r
+  *   @param inValue  Wert aus ResultSet.\r
+  *   @param aType  Datenbanktyp.\r
+  *   @return liefert den Wert als String zurueck. Wenn keine Umwandlung moeglich\r
+  *           dann /unsupported value/\r
+   */\r
+  private String getValueAsString(ResultSet rs, int valueIndex, int aType)\r
+    throws StorageObjectFailure {\r
+    String outValue = null;\r
+\r
+    if (rs != null) {\r
+      try {\r
+        switch (aType) {\r
+          case java.sql.Types.BIT:\r
+            outValue = (rs.getBoolean(valueIndex) == true) ? "1" : "0";\r
+\r
+            break;\r
+\r
+          case java.sql.Types.INTEGER:\r
+          case java.sql.Types.SMALLINT:\r
+          case java.sql.Types.TINYINT:\r
+          case java.sql.Types.BIGINT:\r
+\r
+            int out = rs.getInt(valueIndex);\r
+\r
+            if (!rs.wasNull()) {\r
+              outValue = new Integer(out).toString();\r
+            }\r
+\r
+            break;\r
+\r
+          case java.sql.Types.NUMERIC:\r
+\r
+            /** @todo Numeric can be float or double depending upon\r
+             *  metadata.getScale() / especially with oracle */\r
+            long outl = rs.getLong(valueIndex);\r
+\r
+            if (!rs.wasNull()) {\r
+              outValue = new Long(outl).toString();\r
+            }\r
+\r
+            break;\r
+\r
+          case java.sql.Types.REAL:\r
+\r
+            float tempf = rs.getFloat(valueIndex);\r
+\r
+            if (!rs.wasNull()) {\r
+              tempf *= 10;\r
+              tempf += 0.5;\r
+\r
+              int tempf_int = (int) tempf;\r
+              tempf = (float) tempf_int;\r
+              tempf /= 10;\r
+              outValue = "" + tempf;\r
+              outValue = outValue.replace('.', ',');\r
+            }\r
+\r
+            break;\r
+\r
+          case java.sql.Types.DOUBLE:\r
+\r
+            double tempd = rs.getDouble(valueIndex);\r
+\r
+            if (!rs.wasNull()) {\r
+              tempd *= 10;\r
+              tempd += 0.5;\r
+\r
+              int tempd_int = (int) tempd;\r
+              tempd = (double) tempd_int;\r
+              tempd /= 10;\r
+              outValue = "" + tempd;\r
+              outValue = outValue.replace('.', ',');\r
+            }\r
+\r
+            break;\r
+\r
+          case java.sql.Types.CHAR:\r
+          case java.sql.Types.VARCHAR:\r
+          case java.sql.Types.LONGVARCHAR:\r
+            outValue = rs.getString(valueIndex);\r
+\r
+            break;\r
+\r
+          case java.sql.Types.LONGVARBINARY:\r
+            outValue = rs.getString(valueIndex);\r
+\r
+            break;\r
+\r
+          case java.sql.Types.TIMESTAMP:\r
+\r
+            // it's important to use Timestamp here as getting it\r
+            // as a string is undefined and is only there for debugging\r
+            // according to the API. we can make it a string through formatting.\r
+            // -mh\r
+            Timestamp timestamp = (rs.getTimestamp(valueIndex));\r
+\r
+            if (!rs.wasNull()) {\r
+              java.util.Date date = new java.util.Date(timestamp.getTime());\r
+\r
+              Calendar calendar = new GregorianCalendar();\r
+              calendar.setTime(date);\r
+              calendar.setTimeZone(timezone);\r
+              outValue = internalDateFormat.format(date);\r
+\r
+              int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);\r
+              String tzOffset = StringUtil.zeroPaddingNumber(Math.abs(offset) / _millisPerHour, 2, 2);\r
+\r
+              if (offset<0)\r
+                outValue = outValue + "-";\r
+              else\r
+                outValue = outValue + "+";\r
+              outValue = outValue + tzOffset;\r
+            }\r
+\r
+            break;\r
+\r
+          default:\r
+            outValue = "<unsupported value>";\r
+            logger.warn("Unsupported Datatype: at " + valueIndex + " (" + aType + ")");\r
+        }\r
+      } catch (SQLException e) {\r
+        throw new StorageObjectFailure("Could not get Value out of Resultset -- ",\r
+          e);\r
+      }\r
+    }\r
+\r
+    return outValue;\r
+  }\r
+\r
+  /*\r
+  *   select-Operator um einen Datensatz zu bekommen.\r
+  *   @param id Primaerschluessel des Datensatzes.\r
+  *   @return liefert EntityObject des gefundenen Datensatzes oder null.\r
+   */\r
+  public Entity selectById(String id) throws StorageObjectExc {\r
+    if ((id == null) || id.equals("")) {\r
+      throw new StorageObjectExc("Database.selectById: Missing id");\r
+    }\r
+\r
+    // ask object store for object\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      String uniqueId = id;\r
+\r
+      if (theEntityClass.equals(StorableObjectEntity.class)) {\r
+        uniqueId += ("@" + theTable);\r
+      }\r
+\r
+      StoreIdentifier search_sid = new StoreIdentifier(theEntityClass, uniqueId);\r
+      logger.debug("CACHE: (dbg) looking for sid " + search_sid.toString());\r
+\r
+      Entity hit = (Entity) o_store.use(search_sid);\r
+\r
+      if (hit != null) {\r
+        return hit;\r
+      }\r
+    }\r
+\r
+    Statement stmt = null;\r
+    Connection con = getPooledCon();\r
+    Entity returnEntity = null;\r
+\r
+    try {\r
+      ResultSet rs;\r
+\r
+      /** @todo better prepared statement */\r
+      String selectSql =\r
+        "select * from " + theTable + " where " + thePKeyName + "=" + id;\r
+      stmt = con.createStatement();\r
+      rs = executeSql(stmt, selectSql);\r
+\r
+      if (rs != null) {\r
+        if (evaluatedMetaData == false) {\r
+          evalMetaData(rs.getMetaData());\r
+        }\r
+\r
+        if (rs.next()) {\r
+          returnEntity = makeEntityFromResultSet(rs);\r
+        }\r
+        else {\r
+          logger.debug("No data for id: " + id + " in table " + theTable);\r
+        }\r
+\r
+        rs.close();\r
+      }\r
+      else {\r
+        logger.debug("No Data for Id " + id + " in Table " + theTable);\r
+      }\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "selectById");\r
+      return null;\r
+    }\r
+    catch (NumberFormatException e) {\r
+      logger.error("ID is no number: " + id);\r
+    }\r
+    finally {\r
+      freeConnection(con, stmt);\r
+    }\r
+\r
+    return returnEntity;\r
+  }\r
+\r
+  /**\r
+   *   select-Operator um Datensaetze zu bekommen, die key = value erfuellen.\r
+   *   @param key  Datenbankfeld der Bedingung.\r
+   *   @param value  Wert die der key anehmen muss.\r
+   *   @return EntityList mit den gematchten Entities\r
+   */\r
+  public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure {\r
+    return selectByFieldValue(aField, aValue, 0);\r
+  }\r
+\r
+  /**\r
+   *   select-Operator um Datensaetze zu bekommen, die key = value erfuellen.\r
+   *   @param key  Datenbankfeld der Bedingung.\r
+   *   @param value  Wert die der key anehmen muss.\r
+   *   @param offset  Gibt an ab welchem Datensatz angezeigt werden soll.\r
+   *   @return EntityList mit den gematchten Entities\r
+   */\r
+  public EntityList selectByFieldValue(String aField, String aValue, int offset) throws StorageObjectFailure {\r
+    return selectByWhereClause(aField + "=" + aValue, offset);\r
+  }\r
+\r
+  /**\r
+   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.\r
+   * Also offset wird der erste Datensatz genommen.\r
+   *\r
+   * @param wc where-Clause\r
+   * @return EntityList mit den gematchten Entities\r
+   * @exception StorageObjectException\r
+   */\r
+  public EntityList selectByWhereClause(String where) throws StorageObjectFailure {\r
+    return selectByWhereClause(where, 0);\r
+  }\r
+\r
+  /**\r
+   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.\r
+   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.\r
+   *\r
+   * @param wc where-Clause\r
+   * @param offset ab welchem Datensatz.\r
+   * @return EntityList mit den gematchten Entities\r
+   * @exception StorageObjectException\r
+   */\r
+  public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure {\r
+    return selectByWhereClause(whereClause, null, offset);\r
+  }\r
+\r
+  /**\r
+   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.\r
+   * Also offset wird der erste Datensatz genommen.\r
+   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.\r
+   *\r
+   * @param wc where-Clause\r
+   * @param ob orderBy-Clause\r
+   * @return EntityList mit den gematchten Entities\r
+   * @exception StorageObjectException\r
+   */\r
+  public EntityList selectByWhereClause(String where, String order) throws StorageObjectFailure {\r
+    return selectByWhereClause(where, order, 0);\r
+  }\r
+\r
+  /**\r
+   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.\r
+   * Als maximale Anzahl wird das Limit auf der Konfiguration genommen.\r
+   *\r
+   * @param wc where-Clause\r
+   * @param ob orderBy-Clause\r
+   * @param offset ab welchem Datensatz\r
+   * @return EntityList mit den gematchten Entities\r
+   * @exception StorageObjectException\r
+   */\r
+  public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure {\r
+    return selectByWhereClause(whereClause, orderBy, offset, defaultLimit);\r
+  }\r
+\r
+  /**\r
+   * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.\r
+   * @param aWhereClause where-Clause\r
+   * @param anOrderByClause orderBy-Clause\r
+   * @param offset ab welchem Datensatz\r
+   * @param limit wieviele Datens?tze\r
+   * @return EntityList mit den gematchten Entities\r
+   * @exception StorageObjectException\r
+   */\r
+  public EntityList selectByWhereClause(String aWhereClause, String anOrderByClause,\r
+            int offset, int limit) throws StorageObjectFailure {\r
+\r
+    // check o_store for entitylist\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      StoreIdentifier search_sid =\r
+          new StoreIdentifier(\r
+            theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST,\r
+            StoreUtil.getEntityListUniqueIdentifierFor(theTable, aWhereClause, anOrderByClause, offset, limit));\r
+      EntityList hit = (EntityList) o_store.use(search_sid);\r
+\r
+      if (hit != null) {\r
+        logger.debug("CACHE (hit): " + search_sid.toString());\r
+\r
+        return hit;\r
+      }\r
+    }\r
+\r
+    // local\r
+    EntityList theReturnList = null;\r
+    Connection con = null;\r
+    Statement stmt = null;\r
+    ResultSet rs;\r
+    int offsetCount = 0;\r
+    int count = 0;\r
+\r
+    // build sql-statement\r
+\r
+    /** @todo count sql string should only be assembled if we really count\r
+     *  see below at the end of method //rk */\r
+    if ((aWhereClause != null) && (aWhereClause.trim().length() == 0)) {\r
+      aWhereClause = null;\r
+    }\r
+\r
+    StringBuffer countSql =\r
+      new StringBuffer("select count(*) from ").append(theTable);\r
+    StringBuffer selectSql =\r
+      new StringBuffer("select * from ").append(theTable);\r
+\r
+    if (aWhereClause != null) {\r
+      selectSql.append(" where ").append(aWhereClause);\r
+      countSql.append(" where ").append(aWhereClause);\r
+    }\r
+\r
+    if ((anOrderByClause != null) && !(anOrderByClause.trim().length() == 0)) {\r
+      selectSql.append(" order by ").append(anOrderByClause);\r
+    }\r
+\r
+    if ((limit > -1) && (offset > -1)) {\r
+      selectSql.append(" LIMIT ").append(limit).append(" OFFSET ").append(offset);\r
+    }\r
+\r
+    // execute sql\r
+    try {\r
+      con = getPooledCon();\r
+      stmt = con.createStatement();\r
+\r
+      // selecting...\r
+      rs = executeSql(stmt, selectSql.toString());\r
+\r
+      if (rs != null) {\r
+        if (!evaluatedMetaData) {\r
+          evalMetaData(rs.getMetaData());\r
+        }\r
+\r
+        theReturnList = new EntityList();\r
+\r
+        Entity theResultEntity;\r
+\r
+        while (rs.next()) {\r
+          theResultEntity = makeEntityFromResultSet(rs);\r
+          theReturnList.add(theResultEntity);\r
+          offsetCount++;\r
+        }\r
+\r
+        rs.close();\r
+      }\r
+\r
+      // making entitylist infos\r
+      count = offsetCount;\r
+\r
+      if (theReturnList != null) {\r
+        // now we decide if we have to know an overall count...\r
+        count = offsetCount;\r
+\r
+        if ((limit > -1) && (offset > -1)) {\r
+          if (offsetCount == limit) {\r
+            /** @todo counting should be deffered to entitylist\r
+             *  getSize() should be used */\r
+            rs = executeSql(stmt, countSql.toString());\r
+\r
+            if (rs != null) {\r
+              if (rs.next()) {\r
+                count = rs.getInt(1);\r
+              }\r
+\r
+              rs.close();\r
+            }\r
+            else {\r
+              logger.error("Could not count: " + countSql);\r
+            }\r
+          }\r
+        }\r
+\r
+        theReturnList.setCount(count);\r
+        theReturnList.setOffset(offset);\r
+        theReturnList.setWhere(aWhereClause);\r
+        theReturnList.setOrder(anOrderByClause);\r
+        theReturnList.setStorage(this);\r
+        theReturnList.setLimit(limit);\r
+\r
+        if (offset >= limit) {\r
+          theReturnList.setPrevBatch(offset - limit);\r
+        }\r
+\r
+        if ((offset + offsetCount) < count) {\r
+          theReturnList.setNextBatch(offset + limit);\r
+        }\r
+\r
+        if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+          StoreIdentifier sid = theReturnList.getStoreIdentifier();\r
+          logger.debug("CACHE (add): " + sid.toString());\r
+          o_store.add(sid);\r
+        }\r
+      }\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "selectByWhereClause");\r
+    }\r
+    finally {\r
+      try {\r
+        if (con != null) {\r
+          freeConnection(con, stmt);\r
+        }\r
+      } catch (Throwable t) {\r
+      }\r
+    }\r
+\r
+    return theReturnList;\r
+  }\r
+\r
+  /**\r
+   *  Bastelt aus einer Zeile der Datenbank ein EntityObjekt.\r
+   *\r
+   *  @param rs Das ResultSetObjekt.\r
+   *  @return Entity Die Entity.\r
+   */\r
+  private Entity makeEntityFromResultSet(ResultSet rs)\r
+    throws StorageObjectFailure {\r
+    /** @todo OS: get Pkey from ResultSet and consult ObjectStore */\r
+    Map theResultHash = new HashMap();\r
+    String theResult = null;\r
+    int theType;\r
+    Entity returnEntity = null;\r
+\r
+    try {\r
+      int size = metadataFields.size();\r
+\r
+      for (int i = 0; i < size; i++) {\r
+        // alle durchlaufen bis nix mehr da\r
+        theType = metadataTypes[i];\r
+\r
+        if (theType == java.sql.Types.LONGVARBINARY) {\r
+          InputStreamReader is =\r
+            (InputStreamReader) rs.getCharacterStream(i + 1);\r
+\r
+          if (is != null) {\r
+            char[] data = new char[32768];\r
+            StringBuffer theResultString = new StringBuffer();\r
+            int len;\r
+\r
+            while ((len = is.read(data)) > 0) {\r
+              theResultString.append(data, 0, len);\r
+            }\r
+\r
+            is.close();\r
+            theResult = theResultString.toString();\r
+          } else {\r
+            theResult = null;\r
+          }\r
+        } else {\r
+          theResult = getValueAsString(rs, (i + 1), theType);\r
+        }\r
+\r
+        if (theResult != null) {\r
+          theResultHash.put(metadataFields.get(i), theResult);\r
+        }\r
+      }\r
+\r
+      if (theEntityClass != null) {\r
+        returnEntity = (Entity) theEntityClass.newInstance();\r
+        returnEntity.setStorage(this);\r
+        returnEntity.setValues(theResultHash);\r
+\r
+        if (returnEntity instanceof StorableObject) {\r
+          logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + theTable);\r
+          o_store.add(((StorableObject) returnEntity).getStoreIdentifier());\r
+        }\r
+      } else {\r
+        throwStorageObjectException("Internal Error: theEntityClass not set!");\r
+      }\r
+    }\r
+    catch (IllegalAccessException e) {\r
+      throwStorageObjectException("No access! -- " + e.getMessage());\r
+    }\r
+    catch (IOException e) {\r
+      throwStorageObjectException("IOException! -- " + e.getMessage());\r
+    }\r
+    catch (InstantiationException e) {\r
+      throwStorageObjectException("No Instatiation! -- " + e.getMessage());\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "makeEntityFromResultSet");\r
+\r
+      return null;\r
+    }\r
+\r
+    return returnEntity;\r
+  }\r
+\r
+  /**\r
+   * Inserts an entity into the database.\r
+   *\r
+   * @param theEntity\r
+   * @return der Wert des Primary-keys der eingef?gten Entity\r
+   */\r
+  public String insert(Entity theEntity) throws StorageObjectFailure {\r
+    //cache\r
+    invalidatePopupCache();\r
+\r
+    // invalidating all EntityLists corresponding with theEntityClass\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      StoreContainerType stoc_type =\r
+        StoreContainerType.valueOf(theEntityClass,\r
+          StoreContainerType.STOC_TYPE_ENTITYLIST);\r
+      o_store.invalidate(stoc_type);\r
+    }\r
+\r
+    String returnId = null;\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+\r
+    try {\r
+      List streamedInput = theEntity.streamedInput();\r
+      StringBuffer f = new StringBuffer();\r
+      StringBuffer v = new StringBuffer();\r
+      String aField;\r
+      String aValue;\r
+      boolean firstField = true;\r
+\r
+      // make sql-string\r
+      for (int i = 0; i < getFields().size(); i++) {\r
+        aField = (String) getFields().get(i);\r
+\r
+        if (!aField.equals(thePKeyName)) {\r
+          aValue = null;\r
+\r
+          // exceptions\r
+          if (!theEntity.hasValueForField(aField) && (\r
+              aField.equals("webdb_create") ||\r
+              aField.equals("webdb_lastchange"))) {\r
+            aValue = "NOW()";\r
+          }\r
+          else {\r
+            if ((streamedInput != null) && streamedInput.contains(aField)) {\r
+              aValue = "?";\r
+            }\r
+            else {\r
+              if (theEntity.hasValueForField(aField)) {\r
+                aValue =\r
+                  "'" +\r
+                   JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField)) + "'";\r
+              }\r
+            }\r
+          }\r
+\r
+          // wenn Wert gegeben, dann einbauen\r
+          if (aValue != null) {\r
+            if (firstField == false) {\r
+              f.append(",");\r
+              v.append(",");\r
+            }\r
+            else {\r
+              firstField = false;\r
+            }\r
+\r
+            f.append(aField);\r
+            v.append(aValue);\r
+          }\r
+        }\r
+      }\r
+       // end for\r
+\r
+      // insert into db\r
+      StringBuffer sqlBuf =\r
+        new StringBuffer("insert into ").append(theTable).append("(").append(f)\r
+                                        .append(") values (").append(v).append(")");\r
+      String sql = sqlBuf.toString();\r
+\r
+      logger.debug("INSERT: " + sql);\r
+      con = getPooledCon();\r
+      con.setAutoCommit(false);\r
+      pstmt = con.prepareStatement(sql);\r
+\r
+      if (streamedInput != null) {\r
+        for (int i = 0; i < streamedInput.size(); i++) {\r
+          String inputString =\r
+            (String) theEntity.getValue((String) streamedInput.get(i));\r
+          pstmt.setBytes(i + 1, inputString.getBytes());\r
+        }\r
+      }\r
+\r
+      int ret = pstmt.executeUpdate();\r
+\r
+      if (ret == 0) {\r
+        //insert failed\r
+        return null;\r
+      }\r
+\r
+      pstmt = con.prepareStatement("select currval('" + getCoreTable() + "_id_seq')");\r
+\r
+      ResultSet rs = pstmt.executeQuery();\r
+      rs.next();\r
+      returnId = rs.getString(1);\r
+      theEntity.setId(returnId);\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "insert");\r
+    }\r
+    finally {\r
+      try {\r
+        con.setAutoCommit(true);\r
+      }\r
+      catch (Exception e) {\r
+      }\r
+\r
+      freeConnection(con, pstmt);\r
+    }\r
+\r
+    /** @todo store entity in o_store */\r
+    return returnId;\r
+  }\r
+\r
+  /**\r
+   * Updates an entity in the database\r
+   *\r
+   * @param theEntity\r
+   */\r
+  public void update(Entity theEntity) throws StorageObjectFailure {\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+\r
+    /** @todo this is stupid: why do we prepare statement, when we\r
+     *  throw it away afterwards. should be regular statement\r
+     *  update/insert could better be one routine called save()\r
+     *  that chooses to either insert or update depending if we\r
+     *  have a primary key in the entity. i don't know if we\r
+     *  still need the streamed input fields. // rk  */\r
+    /** @todo extension: check if Entity did change, otherwise we don't need\r
+     *  the roundtrip to the database */\r
+    /** invalidating corresponding entitylists in o_store*/\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      StoreContainerType stoc_type =\r
+        StoreContainerType.valueOf(theEntityClass,\r
+          StoreContainerType.STOC_TYPE_ENTITYLIST);\r
+      o_store.invalidate(stoc_type);\r
+    }\r
+\r
+    List streamedInput = theEntity.streamedInput();\r
+    String id = theEntity.getId();\r
+    String aField;\r
+    StringBuffer fv = new StringBuffer();\r
+    boolean firstField = true;\r
+\r
+    //cache\r
+    invalidatePopupCache();\r
+\r
+    // build sql statement\r
+    for (int i = 0; i < getFields().size(); i++) {\r
+      aField = (String) metadataFields.get(i);\r
+\r
+      // only normal cases\r
+      if (  !(aField.equals(thePKeyName) ||\r
+            aField.equals("webdb_create") ||\r
+            aField.equals("webdb_lastchange") ||\r
+            ((streamedInput != null) && streamedInput.contains(aField)))) {\r
+        if (theEntity.hasValueForField(aField)) {\r
+          if (firstField == false) {\r
+            fv.append(", ");\r
+          }\r
+          else {\r
+            firstField = false;\r
+          }\r
+\r
+          fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField))).append("'");\r
+\r
+          //              fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");\r
+        }\r
+      }\r
+    }\r
+\r
+    StringBuffer sql =\r
+      new StringBuffer("update ").append(theTable).append(" set ").append(fv);\r
+\r
+    // exceptions\r
+    if (metadataFields.contains("webdb_lastchange")) {\r
+      sql.append(",webdb_lastchange=NOW()");\r
+    }\r
+\r
+    // special case: the webdb_create requires the field in yyyy-mm-dd HH:mm\r
+    // format so anything extra will be ignored. -mh\r
+    if (metadataFields.contains("webdb_create") &&\r
+        theEntity.hasValueForField("webdb_create")) {\r
+      // minimum of 10 (yyyy-mm-dd)...\r
+      if (theEntity.getValue("webdb_create").length() >= 10) {\r
+        String dateString = theEntity.getValue("webdb_create");\r
+\r
+        // if only 10, then add 00:00 so it doesn't throw a ParseException\r
+        if (dateString.length() == 10) {\r
+          dateString = dateString + " 00:00";\r
+        }\r
+\r
+        // TimeStamp stuff\r
+        try {\r
+          java.util.Date d = userInputDateFormat.parse(dateString);\r
+//          Timestamp tStamp = new Timestamp(d.getTime());\r
+          sql.append(",webdb_create='" + JDBCStringRoutines.formatDate(d) + "'");\r
+        }\r
+        catch (ParseException e) {\r
+          throw new StorageObjectFailure(e);\r
+        }\r
+      }\r
+    }\r
+\r
+    if (streamedInput != null) {\r
+      for (int i = 0; i < streamedInput.size(); i++) {\r
+        sql.append(",").append(streamedInput.get(i)).append("=?");\r
+      }\r
+    }\r
+\r
+    sql.append(" where id=").append(id);\r
+    logger.debug("UPDATE: " + sql);\r
+\r
+    try {\r
+      con = getPooledCon();\r
+      con.setAutoCommit(false);\r
+      pstmt = con.prepareStatement(sql.toString());\r
+\r
+      if (streamedInput != null) {\r
+        for (int i = 0; i < streamedInput.size(); i++) {\r
+          String inputString =\r
+            theEntity.getValue((String) streamedInput.get(i));\r
+          pstmt.setBytes(i + 1, inputString.getBytes());\r
+        }\r
+      }\r
+\r
+      pstmt.executeUpdate();\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "update");\r
+    }\r
+    finally {\r
+      try {\r
+        con.setAutoCommit(true);\r
+      }\r
+      catch (Exception e) {\r
+        ;\r
+      }\r
+\r
+      freeConnection(con, pstmt);\r
+    }\r
+  }\r
+\r
+  /*\r
+  *   delete-Operator\r
+  *   @param id des zu loeschenden Datensatzes\r
+  *   @return boolean liefert true zurueck, wenn loeschen erfolgreich war.\r
+   */\r
+  public boolean delete(String id) throws StorageObjectFailure {\r
+    invalidatePopupCache();\r
+\r
+    // ostore send notification\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      String uniqueId = id;\r
+\r
+      if (theEntityClass.equals(StorableObjectEntity.class)) {\r
+        uniqueId += ("@" + theTable);\r
+      }\r
+\r
+      logger.debug("CACHE: (del) " + id);\r
+\r
+      StoreIdentifier search_sid =\r
+        new StoreIdentifier(theEntityClass,\r
+          StoreContainerType.STOC_TYPE_ENTITY, uniqueId);\r
+      o_store.invalidate(search_sid);\r
+    }\r
+\r
+    /** @todo could be prepared Statement */\r
+    Statement stmt = null;\r
+    Connection con = null;\r
+    int res = 0;\r
+    String sql =\r
+      "delete from " + theTable + " where " + thePKeyName + "='" + id + "'";\r
+\r
+    //theLog.printInfo("DELETE " + sql);\r
+    try {\r
+      con = getPooledCon();\r
+      stmt = con.createStatement();\r
+      res = stmt.executeUpdate(sql);\r
+    } catch (SQLException sqe) {\r
+      throwSQLException(sqe, "delete");\r
+    } finally {\r
+      freeConnection(con, stmt);\r
+    }\r
+\r
+    return (res > 0) ? true : false;\r
+  }\r
+\r
+  /**\r
+   * Deletes entities based on a where clause\r
+   *\r
+   * @param aWhereClause\r
+   * @return\r
+   * @throws StorageObjectFailure\r
+   */\r
+  public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure {\r
+    invalidatePopupCache();\r
+    if (StoreUtil.implementsStorableObject(theEntityClass)) {\r
+      StoreContainerType stoc_type = StoreContainerType.valueOf(theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST);\r
+      o_store.invalidate(stoc_type);\r
+    }\r
+\r
+    Statement stmt = null;\r
+    Connection con = null;\r
+    int res = 0;\r
+    String sql =\r
+      "delete from " + theTable + " where " + aWhereClause;\r
+\r
+    //theLog.printInfo("DELETE " + sql);\r
+    try {\r
+      con = getPooledCon();\r
+      stmt = con.createStatement();\r
+      res = stmt.executeUpdate(sql);\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "delete");\r
+    }\r
+    finally {\r
+      freeConnection(con, stmt);\r
+    }\r
+\r
+    return res;\r
+  }\r
+\r
+  /* noch nicht implementiert.\r
+  * @return immer false\r
+   */\r
+  public boolean delete(EntityList theEntityList) {\r
+    invalidatePopupCache();\r
+\r
+    return false;\r
+  }\r
+\r
+  /* invalidates the popupCache\r
+   */\r
+  protected void invalidatePopupCache() {\r
+    /** @todo  invalidates toooo much */\r
+    popupCache = null;\r
+    hashCache = null;\r
+  }\r
+\r
+  /**\r
+   * Diese Methode fuehrt den Sqlstring <i>sql</i> aus und timed im Logfile.\r
+   * @param stmt Statemnt\r
+   * @param sql Sql-String\r
+   * @return ResultSet\r
+   * @exception StorageObjectException\r
+   */\r
+  public ResultSet executeSql(Statement stmt, String sql)\r
+                            throws StorageObjectFailure, SQLException {\r
+    ResultSet rs;\r
+    long startTime = System.currentTimeMillis();\r
+\r
+    try {\r
+      rs = stmt.executeQuery(sql);\r
+\r
+      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+    }\r
+    catch (SQLException e) {\r
+      logger.error(e.getMessage() +"\n" + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+      throw e;\r
+    }\r
+\r
+    return rs;\r
+  }\r
+/*\r
+  public ResultSet executeSql(String sql) throws StorageObjectFailure, SQLException {\r
+    long startTime = System.currentTimeMillis();\r
+    Connection connection = null;\r
+    Statement statement = null;\r
+\r
+    try {\r
+      connection = getPooledCon();\r
+      statement = connection.createStatement();\r
+      ResultSet result;\r
+\r
+      result = statement.executeQuery(sql);\r
+\r
+      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+      return result;\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error(e.getMessage() +"\n" + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+      throw new StorageObjectFailure(e);\r
+    }\r
+    finally {\r
+      if (connection!=null) {\r
+        freeConnection(connection, statement);\r
+      }\r
+    }\r
+  }\r
+*/\r
+  private Map processRow(ResultSet aResultSet) throws StorageObjectFailure, StorageObjectExc {\r
+    try {\r
+      Map result = new HashMap();\r
+      ResultSetMetaData metaData = aResultSet.getMetaData();\r
+      int nrColumns = metaData.getColumnCount();\r
+      for (int i=0; i<nrColumns; i++) {\r
+        result.put(metaData.getColumnName(i+1), getValueAsString(aResultSet, i+1, metaData.getColumnType(i+1)));\r
+      }\r
+\r
+      return result;\r
+    }\r
+    catch (Throwable e) {\r
+      throw new StorageObjectFailure(e);\r
+    }\r
+  }\r
+\r
+  public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc {\r
+    Connection connection = null;\r
+    Statement statement = null;\r
+    try {\r
+      List result = new Vector();\r
+      connection = getPooledCon();\r
+      statement = connection.createStatement();\r
+      ResultSet resultset = executeSql(statement, sql);\r
+      try {\r
+        while (resultset.next() && result.size() < aLimit) {\r
+          result.add(processRow(resultset));\r
+        }\r
+      }\r
+      finally {\r
+        resultset.close();\r
+      }\r
+\r
+      return result;\r
+    }\r
+    catch (Throwable e) {\r
+      throw new StorageObjectFailure(e);\r
+    }\r
+    finally {\r
+      if (connection!=null) {\r
+        freeConnection(connection, statement);\r
+      }\r
+    }\r
+  };\r
+\r
+  public Map executeFreeSingleRowSql(String anSqlStatement) throws StorageObjectFailure, StorageObjectExc {\r
+    try {\r
+      List resultList = executeFreeSql(anSqlStatement, 1);\r
+      try {\r
+        if (resultList.size()>0)\r
+          return (Map) resultList.get(0);\r
+        else\r
+          return null;\r
+      }\r
+      finally {\r
+      }\r
+    }\r
+    catch (Throwable t) {\r
+      throw new StorageObjectFailure(t);\r
+    }\r
+  };\r
+\r
+  public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc {\r
+    Map row = executeFreeSingleRowSql(sql);\r
+\r
+    if (row==null)\r
+      return null;\r
+\r
+    Iterator i = row.values().iterator();\r
+    if (i.hasNext())\r
+      return (String) i.next();\r
+    else\r
+      return null;\r
+  };\r
+\r
+  /**\r
+   * returns the number of rows in the table\r
+   */\r
+  public int getSize(String where) throws SQLException, StorageObjectFailure {\r
+    long startTime = System.currentTimeMillis();\r
+    String sql = "SELECT Count(*) FROM " + theTable;\r
+\r
+    if ((where != null) && (where.length() != 0)) {\r
+      sql = sql + " where " + where;\r
+    }\r
+\r
+    Connection con = null;\r
+    Statement stmt = null;\r
+    int result = 0;\r
+\r
+    try {\r
+      con = getPooledCon();\r
+      stmt = con.createStatement();\r
+\r
+      ResultSet rs = executeSql(stmt, sql);\r
+\r
+      while (rs.next()) {\r
+        result = rs.getInt(1);\r
+      }\r
+    }\r
+    catch (SQLException e) {\r
+      logger.error("Database.getSize: " + e.getMessage());\r
+    }\r
+    finally {\r
+      freeConnection(con, stmt);\r
+    }\r
+\r
+    //theLog.printInfo(theTable + " has "+ result +" rows where " + where);\r
+    logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+\r
+    return result;\r
+  }\r
+\r
+  public int executeUpdate(Statement stmt, String sql)\r
+    throws StorageObjectFailure, SQLException {\r
+    int rs;\r
+    long startTime = System.currentTimeMillis();\r
+\r
+    try {\r
+      rs = stmt.executeUpdate(sql);\r
+\r
+      logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+    }\r
+    catch (SQLException e) {\r
+      logger.error("Failed: " + (System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+      throw e;\r
+    }\r
+\r
+    return rs;\r
+  }\r
+\r
+  public int executeUpdate(String sql)\r
+    throws StorageObjectFailure, SQLException {\r
+    int result = -1;\r
+    long startTime = System.currentTimeMillis();\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+\r
+    try {\r
+      con = getPooledCon();\r
+      pstmt = con.prepareStatement(sql);\r
+      result = pstmt.executeUpdate();\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("Database.executeUpdate(" + sql + "): " + e.getMessage());\r
+      throw new StorageObjectFailure("Database.executeUpdate(" + sql + "): " + e.getMessage(), e);\r
+    }\r
+    finally {\r
+      freeConnection(con, pstmt);\r
+    }\r
+\r
+    logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql);\r
+    return result;\r
+  }\r
+\r
+  /**\r
+   * Wertet ResultSetMetaData aus und setzt interne Daten entsprechend\r
+   * @param md ResultSetMetaData\r
+   * @exception StorageObjectException\r
+   */\r
+  private void evalMetaData(ResultSetMetaData md) throws StorageObjectFailure {\r
+    this.evaluatedMetaData = true;\r
+    this.metadataFields = new ArrayList();\r
+    this.metadataLabels = new ArrayList();\r
+    this.metadataNotNullFields = new ArrayList();\r
+\r
+    try {\r
+      int numFields = md.getColumnCount();\r
+      this.metadataTypes = new int[numFields];\r
+\r
+      String aField;\r
+      int aType;\r
+\r
+      for (int i = 1; i <= numFields; i++) {\r
+        aField = md.getColumnName(i);\r
+        metadataFields.add(aField);\r
+        metadataLabels.add(md.getColumnLabel(i));\r
+        aType = md.getColumnType(i);\r
+        metadataTypes[i - 1] = aType;\r
+\r
+        if (aField.equals(thePKeyName)) {\r
+          thePKeyType = aType;\r
+          thePKeyIndex = i;\r
+        }\r
+\r
+        if (md.isNullable(i) == ResultSetMetaData.columnNullable) {\r
+          metadataNotNullFields.add(aField);\r
+        }\r
+      }\r
+    }\r
+    catch (SQLException e) {\r
+      throwSQLException(e, "evalMetaData");\r
+    }\r
+  }\r
+\r
+  /**\r
+   *  Wertet die Metadaten eines Resultsets fuer eine Tabelle aus,\r
+   *  um die alle Columns und Typen einer Tabelle zu ermitteln.\r
+   */\r
+  private void get_meta_data() throws StorageObjectFailure {\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+    String sql = "select * from " + theTable + " where 0=1";\r
+\r
+    try {\r
+      con = getPooledCon();\r
+      pstmt = con.prepareStatement(sql);\r
+\r
+      logger.debug("METADATA: " + sql);\r
+      ResultSet rs = pstmt.executeQuery();\r
+      evalMetaData(rs.getMetaData());\r
+      rs.close();\r
+    }\r
+    catch (SQLException e) {\r
+      throwSQLException(e, "get_meta_data");\r
+    }\r
+    finally {\r
+      freeConnection(con, pstmt);\r
+    }\r
+  }\r
+\r
+  public Connection getPooledCon() throws StorageObjectFailure {\r
+    Connection con = null;\r
+\r
+    try {\r
+      con = SQLManager.getInstance().requestConnection();\r
+    }\r
+    catch (SQLException e) {\r
+      logger.error("could not connect to the database " + e.getMessage());\r
+\r
+      throw new StorageObjectFailure("Could not connect to the database", e);\r
+    }\r
+\r
+    return con;\r
+  }\r
+\r
+  public void freeConnection(Connection con, Statement stmt)\r
+    throws StorageObjectFailure {\r
+    SQLManager.closeStatement(stmt);\r
+    SQLManager.getInstance().returnConnection(con);\r
+  }\r
+\r
+  /**\r
+   * Wertet SQLException aus und wirft dannach eine StorageObjectException\r
+   * @param sqe SQLException\r
+   * @param wo Funktonsname, in der die SQLException geworfen wurde\r
+   * @exception StorageObjectException\r
+   */\r
+  protected void throwSQLException(SQLException sqe, String aFunction) throws StorageObjectFailure {\r
+    String state = "";\r
+    String message = "";\r
+    int vendor = 0;\r
+\r
+    if (sqe != null) {\r
+      state = sqe.getSQLState();\r
+      message = sqe.getMessage();\r
+      vendor = sqe.getErrorCode();\r
+    }\r
+\r
+    String information =\r
+        "SQL Error: " +\r
+        "state= " + state +\r
+        ", vendor= " + vendor +\r
+        ", message=" + message +\r
+        ", function= " + aFunction;\r
+\r
+    logger.error(information);\r
+\r
+    throw new StorageObjectFailure(information, sqe);\r
+  }\r
+\r
+  protected void _throwStorageObjectException(Exception e, String aFunction)\r
+    throws StorageObjectFailure {\r
+\r
+    if (e != null) {\r
+      logger.error(e.getMessage() + aFunction);\r
+      throw new StorageObjectFailure(aFunction, e);\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Loggt Fehlermeldung mit dem Parameter Message und wirft dannach\r
+   * eine StorageObjectException\r
+   * @param message Nachricht mit dem Fehler\r
+   * @exception StorageObjectException\r
+   */\r
+  void throwStorageObjectException(String aMessage) throws StorageObjectFailure {\r
+    logger.error(aMessage);\r
+    throw new StorageObjectFailure(aMessage, null);\r
+  }\r
+}\r
index ac6cd29..921ce85 100755 (executable)
@@ -36,9 +36,6 @@ import java.sql.Statement;
 import java.util.List;
 import java.util.Map;
 
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
 import mir.entity.Entity;
 import mir.entity.EntityList;
 
@@ -184,12 +181,6 @@ public interface StorageObject {
 
   /**
    * Dokumentation siehe Database.java
-   * @return SimpleHash
-   */
-  abstract public SimpleHash getHashData();
-
-  /**
-   * Dokumentation siehe Database.java
    * @return Connection
    * @exception StorageObjectException
    */
@@ -238,25 +229,14 @@ public interface StorageObject {
   abstract public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
 
   /**
-   * Dokumentation siehe Database.java
    * @param con
    * @param stmt
    */
-  abstract public void freeConnection(Connection con, Statement stmt)
-    throws StorageObjectFailure;
-
-  /**
-   * Dokumentation siehe Database.java
-   * @return
-   */
-  abstract public SimpleList getPopupData() throws StorageObjectFailure;
+  abstract public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure;
 
-  abstract public int executeUpdate(Statement a, String sql)
-    throws StorageObjectFailure, SQLException;
+  abstract public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException;
 
-  abstract public int executeUpdate(String sql)
-    throws StorageObjectFailure, SQLException;
+  abstract public int executeUpdate(String sql) throws StorageObjectFailure, SQLException;
 
-  abstract public int getSize(String where)
-    throws SQLException, StorageObjectFailure;
+  abstract public int getSize(String where) throws SQLException, StorageObjectFailure;
 }
index 4bfe083..691bd57 100755 (executable)
@@ -36,13 +36,11 @@ import java.util.GregorianCalendar;
 import java.util.SimpleTimeZone;
 import java.util.TimeZone;
 
-import mir.log.*;
-
 public class DateTimeFunctions {
   /**
    * private parameter-less constructor to prevent construction
    */
-  private static LoggerWrapper logger = new LoggerWrapper("Utility.DatTimeFunctions");
+//  private static LoggerWrapper logger = new LoggerWrapper("Utility.DatTimeFunctions");
 
 
   private DateTimeFunctions() {
@@ -150,7 +148,7 @@ public class DateTimeFunctions {
       return calendar.getTime();
     }
     catch (Throwable t) {
-      logger.error("DateTimeFunctions.parseW3CDTFString: error parsing " + aString + ": " + t.toString());
+//      logger.error("DateTimeFunctions.parseW3CDTFString: error parsing " + aString + ": " + t.toString());
 
       throw new UtilFailure(t);
     }
index ba30796..3ca02f1 100755 (executable)
@@ -59,7 +59,7 @@ public class HTTPParsedRequest {
   private LoggerWrapper logger;
 
   public HTTPParsedRequest(HttpServletRequest aRequest, String anEncoding, int aMaxUploadSize, String aTempDir) throws UtilExc, UtilFailure {
-    logger = new LoggerWrapper("Utility,HTTPParsedRequest");
+    logger = new LoggerWrapper("Utility.HTTPParsedRequest");
 
     request = aRequest;
     encoding = anEncoding;
index ae88073..c76cbbd 100755 (executable)
  * 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  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.  
+ * the code of this program with  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;
@@ -202,7 +202,6 @@ public class PropertiesManipulator {
   private final static String SEPARATOR = "[\t\n\r ]*[:=]?[\t\n\r ]*";
   private final static String VALUE = "(([\\\\].)|([^\\\\]))*";
 
-
   public static PropertiesManipulator readProperties(InputStream anInputStream) throws PropertiesManipulatorExc, PropertiesManipulatorFailure {
     return readProperties(anInputStream, "ISO-8859-1");
   }
index 4c76c9e..8f5a4ee 100755 (executable)
@@ -45,15 +45,12 @@ import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseContent;
 import mircoders.storage.DatabaseContentToMedia;
 import mircoders.storage.DatabaseContentToTopics;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
 
 /**
  * this class implements mapping of one line of the database table content
  * to a java object
  *
- * @version $Id: EntityContent.java,v 1.19.2.1 2003/06/19 02:24:12 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.2 2003/09/03 17:49:39 zapata Exp $
  * @author mir-coders group
  *
  */
@@ -164,87 +161,6 @@ public class EntityContent extends Entity
   }
 
   /**
-   * overridden method getValue to include formatted date into every
-   * entityContent
-   */
-
-  public TemplateModel get(java.lang.String key) throws TemplateModelException
-  {
-    if (key!=null) {
-      if (_entCache.containsKey(key)) {
-        return (TemplateModel)_entCache.get(key);
-      }
-/*      if (key.equals("to_comments")) {
-        try {
-          _entCache.put(key, getComments());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getComments: could not fetch data " + ex.toString());
-
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      if (key.equals("to_media_images")) {
-        try {
-          _entCache.put(key, getImagesForContent());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getImagesForContent: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      if (key.equals("to_media_audio")) {
-        try {
-          _entCache.put(key, getAudioForContent());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getAudioForContent: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      if (key.equals("to_media_video")) {
-        try {
-          _entCache.put(key, getVideoForContent());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getVideoForContent: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      if (key.equals("to_media_other")) {
-        try {
-          _entCache.put(key, getOtherMediaForContent());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getOtherMediaForContent: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      else if (key.equals("to_topics")) {
-        try {
-          _entCache.put(key,
-                        DatabaseContentToTopics.getInstance().getTopics(this));
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          logger.warn("EntityContent.getTopics: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-      else {
-        return new SimpleScalar(getValue(key));
-      }
-*/
-    }
-    return null;
-  }
-
-  /**
    * overridden method setValues to patch creator_main_url
    */
   public void setValues(Map theStringValues) {
@@ -261,15 +177,6 @@ public class EntityContent extends Entity
     super.setValues(theStringValues);
   }
 
-  /**
-   * fetches all the comments belonging to an article
-   *
-   * @return freemarker.template.SimpleList
-   */
-//  private EntityList getComments() throws StorageObjectFailure {
-//    return ((DatabaseContent)theStorageObject).getComments(this);
-//  }
-
   private boolean hasMedia() throws StorageObjectFailure
   {
     if (_hasMedia == null) {
@@ -282,43 +189,4 @@ public class EntityContent extends Entity
     }
     return _hasMedia.booleanValue();
   }
-
-  //######## @todo all of the following getBlahForContent should have
-  // and optimized version where LIMIT=1 sql for list view.
-  private EntityList getImagesForContent()
-      throws StorageObjectFailure, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getImages(this);
-    else
-      return null;
-  }
-
-  private EntityList getAudioForContent()
-      throws StorageObjectFailure, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getAudio(this) ;
-    else
-      return null;
-  }
-
-  private EntityList getVideoForContent()
-      throws StorageObjectFailure, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getVideo(this) ;
-    else
-      return null;
-  }
-
-  private EntityList getOtherMediaForContent()
-      throws StorageObjectFailure, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getOther(this);
-    else
-      return null;
-  }
-
 }
diff --git a/source/mircoders/entity/EntityMedia.java b/source/mircoders/entity/EntityMedia.java
deleted file mode 100755 (executable)
index 029793a..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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  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 mircoders.entity;
-
-import mir.entity.Entity;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseMedia;
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK
- * @version 29.6.1999
- */
-
-
-public class EntityMedia extends Entity
-{
-
-  public EntityMedia(){
-    super();
-  }
-
-  public EntityMedia(StorageObject theStorage)
-  {
-    this();
-    setStorage(theStorage);
-  }
-
-  /**
-   * fetches the MediaType entry assiciated w/ this media
-   *
-   * @return mir.entity.Entity
-   */
-  public Entity getMediaType() throws StorageObjectFailure {
-    try {
-      return ( (DatabaseMedia) theStorageObject).getMediaType(this);
-    }
-    catch (StorageObjectFailure e) {
-      throw new StorageObjectFailure("getMediaType(): ", e);
-    }
-    catch (StorageObjectExc e) {
-      throw new StorageObjectFailure("getMediaType(): ", e);
-    }
-
-  }
-}
index 2d5e011..d48ed40 100755 (executable)
-/*
- * 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  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 mircoders.entity;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.misc.NumberUtils;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseUploadedMedia;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-
-/**
- *
- * @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26 2003/04/21 12:42:53 idfx Exp $
- */
-
-
-public class EntityUploadedMedia extends Entity {
-
-
-  public EntityUploadedMedia() {
-    super();
-
-    logger = new LoggerWrapper("Entity.UploadedMedia");
-  }
-
-  public EntityUploadedMedia(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
-  public void update() throws StorageObjectFailure {
-    super.update();
-    try {
-      theStorageObject.executeUpdate("update content set is_produced='0' where exists(select * from content_x_media where to_content=content.id and to_media=" + getId()+")");
-    }
-    catch (SQLException e) {
-      throwStorageObjectFailure(e, "EntityAudio :: update :: failed!! ");
-    }
-  }
-
-  public void setValues(Map theStringValues) {
-    if (theStringValues != null) {
-      if (!theStringValues.containsKey("is_published"))
-        theStringValues.put("is_published", "0");
-    }
-    super.setValues(theStringValues);
-  }
-
-
-  /**
-   * fetches the MediaType entry assiciated w/ this media
-   *
-   * @return mir.entity.Entity
-   */
-  public Entity getMediaType() throws StorageObjectFailure {
-    Entity ent = null;
-    try {
-      ent = DatabaseUploadedMedia.getInstance().getMediaType(this);
-    }
-    catch (StorageObjectFailure e) {
-      throwStorageObjectFailure(e, "get MediaType failed -- ");
-    }
-    return ent;
-  }
-
-  public String getValue(String key) {
-    String returnValue = null;
-
-    if (key != null) {
-      if (key.equals("big_icon"))
-        returnValue = getBigIconName();
-      else if (key.equals("descr") || key.equals("media_descr"))
-        returnValue = getDescr();
-      else if (key.equals("mediatype"))
-        returnValue = getMediaTypeString();
-      else if (key.equals("mimetype"))
-        returnValue = getMimeType();
-      else if (key.equals("human_readable_size")) {
-        String size = super.getValue("size");
-        if (size != null)
-          returnValue = NumberUtils.humanReadableSize(Double.parseDouble(size));
-      }
-      else
-        returnValue = super.getValue(key);
-    }
-    return returnValue;
-  }
-
-  public TemplateModel get(java.lang.String key) throws TemplateModelException {
-    if (key.equals("url"))
-      return getUrl();
-    return new SimpleScalar(getValue(key));
-  }
-
-  // @todo  all these methods should be merged into 1
-  // and the MediaHandler should be cached somehow.
-  private String getMediaTypeString() {
-    MirMedia mediaHandler = null;
-    Entity mediaType = null;
-
-    try {
-      mediaType = getMediaType();
-      mediaHandler = MediaHelper.getHandler(mediaType);
-      String t;
-      if (mediaHandler.isAudio())
-        return "audio";
-      else if (mediaHandler.isImage())
-        return "image";
-      else if (mediaHandler.isVideo())
-        return "video";
-      else
-        return "other";
-    }
-    catch (Exception ex) {
-      logger.warn("EntityUploadedMedia.getMediaTypeString: could not fetch data: " + ex.toString());
-    }
-    return null;
-  }
-
-  private String getBigIconName() {
-    MirMedia mediaHandler = null;
-    Entity mediaType = null;
-
-    try {
-      mediaType = getMediaType();
-      mediaHandler = MediaHelper.getHandler(mediaType);
-      return mediaHandler.getBigIconName();
-    }
-    catch (Exception ex) {
-      logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
-    }
-    return null;
-  }
-
-  private SimpleList getUrl() {
-    MirMedia mediaHandler = null;
-    Entity mediaType = null;
-
-    try {
-      mediaType = getMediaType();
-      mediaHandler = MediaHelper.getHandler(mediaType);
-      return mediaHandler.getURL(this, mediaType);
-    }
-    catch (Throwable t) {
-      logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString());
-    }
-    return null;
-  }
-
-  private String getDescr() {
-    MirMedia mediaHandler = null;
-    Entity mediaType = null;
-
-    try {
-      mediaType = getMediaType();
-      mediaHandler = MediaHelper.getHandler(mediaType);
-      return mediaHandler.getDescr(mediaType);
-    }
-    catch (Exception ex) {
-      logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());
-    }
-    return null;
-  }
-  private String getMimeType() {
-    Entity mediaType = null;
-
-    try {
-      mediaType = getMediaType();
-      return mediaType.getValue("mime_type");
-    }
-    catch (Exception ex) {
-      logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
-    }
-    return 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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.entity;\r
+\r
+import java.sql.SQLException;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaHelper;\r
+import mir.media.MirMedia;\r
+import mir.misc.NumberUtils;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.storage.DatabaseUploadedMedia;\r
+\r
+/**\r
+ *\r
+ * @author mh, mir-coders group\r
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.1 2003/09/03 17:49:39 zapata Exp $\r
+ */\r
+\r
+\r
+public class EntityUploadedMedia extends Entity {\r
+\r
+\r
+  public EntityUploadedMedia() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Entity.UploadedMedia");\r
+  }\r
+\r
+  public EntityUploadedMedia(StorageObject theStorage) {\r
+    this();\r
+    setStorage(theStorage);\r
+  }\r
+\r
+  public void update() throws StorageObjectFailure {\r
+    super.update();\r
+    try {\r
+      theStorageObject.executeUpdate("update content set is_produced='0' where exists(select * from content_x_media where to_content=content.id and to_media=" + getId()+")");\r
+    }\r
+    catch (SQLException e) {\r
+      throwStorageObjectFailure(e, "EntityAudio :: update :: failed!! ");\r
+    }\r
+  }\r
+\r
+  public void setValues(Map theStringValues) {\r
+    if (theStringValues != null) {\r
+      if (!theStringValues.containsKey("is_published"))\r
+        theStringValues.put("is_published", "0");\r
+    }\r
+    super.setValues(theStringValues);\r
+  }\r
+\r
+\r
+  /**\r
+   * fetches the MediaType entry assiciated w/ this media\r
+   *\r
+   * @return mir.entity.Entity\r
+   */\r
+  public Entity getMediaType() throws StorageObjectFailure {\r
+    Entity ent = null;\r
+    try {\r
+      ent = DatabaseUploadedMedia.getInstance().getMediaType(this);\r
+    }\r
+    catch (StorageObjectFailure e) {\r
+      throwStorageObjectFailure(e, "get MediaType failed -- ");\r
+    }\r
+    return ent;\r
+  }\r
+\r
+  public String getValue(String key) {\r
+    String returnValue = null;\r
+\r
+    if (key != null) {\r
+      if (key.equals("big_icon"))\r
+        returnValue = getBigIconName();\r
+      else if (key.equals("descr") || key.equals("media_descr"))\r
+        returnValue = getDescr();\r
+      else if (key.equals("mediatype"))\r
+        returnValue = getMediaTypeString();\r
+      else if (key.equals("mimetype"))\r
+        returnValue = getMimeType();\r
+      else if (key.equals("human_readable_size")) {\r
+        String size = super.getValue("size");\r
+        if (size != null)\r
+          returnValue = NumberUtils.humanReadableSize(Double.parseDouble(size));\r
+      }\r
+      else\r
+        returnValue = super.getValue(key);\r
+    }\r
+    return returnValue;\r
+  }\r
+\r
+  // @todo  all these methods should be merged into 1\r
+  // and the MediaHandler should be cached somehow.\r
+  private String getMediaTypeString() {\r
+    MirMedia mediaHandler = null;\r
+    Entity mediaType = null;\r
+\r
+    try {\r
+      mediaType = getMediaType();\r
+      mediaHandler = MediaHelper.getHandler(mediaType);\r
+      String t;\r
+      if (mediaHandler.isAudio())\r
+        return "audio";\r
+      else if (mediaHandler.isImage())\r
+        return "image";\r
+      else if (mediaHandler.isVideo())\r
+        return "video";\r
+      else\r
+        return "other";\r
+    }\r
+    catch (Exception ex) {\r
+      logger.warn("EntityUploadedMedia.getMediaTypeString: could not fetch data: " + ex.toString());\r
+    }\r
+    return null;\r
+  }\r
+\r
+  private String getBigIconName() {\r
+    MirMedia mediaHandler = null;\r
+    Entity mediaType = null;\r
+\r
+    try {\r
+      mediaType = getMediaType();\r
+      mediaHandler = MediaHelper.getHandler(mediaType);\r
+      return mediaHandler.getBigIconName();\r
+    }\r
+    catch (Exception ex) {\r
+      logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
+    }\r
+    return null;\r
+  }\r
+\r
+  private List getUrl() {\r
+    MirMedia mediaHandler = null;\r
+    Entity mediaType = null;\r
+\r
+    try {\r
+      mediaType = getMediaType();\r
+      mediaHandler = MediaHelper.getHandler(mediaType);\r
+      return mediaHandler.getURL(this, mediaType);\r
+    }\r
+    catch (Throwable t) {\r
+      logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString());\r
+    }\r
+    return null;\r
+  }\r
+\r
+  private String getDescr() {\r
+    MirMedia mediaHandler = null;\r
+    Entity mediaType = null;\r
+\r
+    try {\r
+      mediaType = getMediaType();\r
+      mediaHandler = MediaHelper.getHandler(mediaType);\r
+      return mediaHandler.getDescr(mediaType);\r
+    }\r
+    catch (Exception ex) {\r
+      logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());\r
+    }\r
+    return null;\r
+  }\r
+  private String getMimeType() {\r
+    Entity mediaType = null;\r
+\r
+    try {\r
+      mediaType = getMediaType();\r
+      return mediaType.getValue("mime_type");\r
+    }\r
+    catch (Exception ex) {\r
+      logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
+    }\r
+    return null;\r
+  }\r
+\r
+}\r
index 7196ea1..4ed7d6a 100755 (executable)
@@ -236,6 +236,33 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     }
   }
 
+  protected static class SetCommentFieldsOperation extends CommentModifyingOperation {
+    private Map values;
+
+    public SetCommentFieldsOperation(String aName, String aFields[], String aValues[]) throws MirLocalizerExc {
+      super(aName);
+
+      values = new HashMap();
+
+      for (int i=0; i<aFields.length; i++)
+        values.put(aFields[i], aValues[i]);
+    }
+
+    protected boolean isAvailable(EntityComment aComment) {
+      return true;
+    }
+
+    protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectFailure {
+      Iterator i = values.entrySet().iterator();
+
+      while (i.hasNext()) {
+        Map.Entry entry = (Map.Entry) i.next();
+        aComment.setValueForProperty((String) entry.getKey(), (String) entry.getValue());
+      }
+    }
+  }
+
+
   protected static class ModifyCommentFieldOperation extends CommentModifyingOperation {
     private String field;
     private String value;
index ffcb5b2..4a2cee7 100755 (executable)
@@ -1,65 +1,62 @@
-/*
- * 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  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 mircoders.localizer.basic;
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.localizer.basic;\r
+\r
 import mir.session.Request;\r
 import mir.session.Session;\r
 import mir.session.SessionExc;\r
 import mir.session.SessionFailure;\r
-import mircoders.entity.EntityContent;
-
-
-public class MirBasicChildArticlePostingHandler extends MirBasicArticlePostingHandler {
-  public MirBasicChildArticlePostingHandler() {
-    super();
-
-    setNormalResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));
-  }
-
-  public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {
-    super.finalizeArticle(aRequest, aSession, anArticle);
-
-    anArticle.setValueForProperty("to_content", (String) aSession.getAttribute("to_content"));
-  }
-
-  protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
-    super.initializeSession(aRequest, aSession);
-
-    String parentId = aRequest.getParameter("to_content");
-    if (parentId==null)
-      throw new SessionExc("initializeSession: parent id not set!");
-
-    aSession.setAttribute("to_content", parentId);
-  };
-
-
-
+import mircoders.entity.EntityContent;\r
+\r
+\r
+public class MirBasicChildArticlePostingHandler extends MirBasicArticlePostingHandler {\r
+  public MirBasicChildArticlePostingHandler() {\r
+    super();\r
+\r
+    setNormalResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));\r
+  }\r
+\r
+  public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {\r
+    super.finalizeArticle(aRequest, aSession, anArticle);\r
+\r
+    anArticle.setValueForProperty("to_content", (String) aSession.getAttribute("to_content"));\r
+  }\r
+\r
+  protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
+    super.initializeSession(aRequest, aSession);\r
+\r
+    String parentId = aRequest.getParameter("to_content");\r
+    if (parentId==null)\r
+      throw new SessionExc("initializeSession: parent id not set!");\r
+\r
+    aSession.setAttribute("to_content", parentId);\r
+  };\r
 }
\ No newline at end of file
index fa8ce8d..f96b394 100755 (executable)
-/*
- * 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  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 mircoders.localizer.basic;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.Entity;
-import mir.entity.adapter.EntityAdapter;
-import mir.entity.adapter.EntityAdapterDefinition;
-import mir.entity.adapter.EntityAdapterModel;
-import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.util.ParameterExpander;
-import mir.util.RewindableIterator;
-import mir.util.StructuredContentParser;
-import mircoders.entity.EntityUploadedMedia;
-import mircoders.global.MirGlobal;
-import mircoders.localizer.MirAdminInterfaceLocalizer;
-import mircoders.localizer.MirDataModelLocalizer;
-import mircoders.localizer.MirLocalizerExc;
-import mircoders.localizer.MirLocalizerFailure;
-import mircoders.storage.DatabaseArticleType;
-import mircoders.storage.DatabaseAudio;
-import mircoders.storage.DatabaseBreaking;
-import mircoders.storage.DatabaseComment;
-import mircoders.storage.DatabaseCommentStatus;
-import mircoders.storage.DatabaseContent;
-import mircoders.storage.DatabaseContentToTopics;
-import mircoders.storage.DatabaseImageType;
-import mircoders.storage.DatabaseImages;
-import mircoders.storage.DatabaseLanguage;
-import mircoders.storage.DatabaseMedia;
-import mircoders.storage.DatabaseMediaType;
-import mircoders.storage.DatabaseMediafolder;
-import mircoders.storage.DatabaseMessages;
-import mircoders.storage.DatabaseOther;
-import mircoders.storage.DatabaseTopics;
-import mircoders.storage.DatabaseUploadedMedia;
-import mircoders.storage.DatabaseUsers;
-import mircoders.storage.DatabaseVideo;
-
-public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
-  protected LoggerWrapper logger;
-  protected MirPropertiesConfiguration configuration;
-
-  public MirBasicDataModelLocalizer() throws MirLocalizerFailure, MirLocalizerExc {
-    logger = new LoggerWrapper("Localizer.DataModel");
-
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (Throwable e) {
-      throw new MirLocalizerFailure("Can't get configuration: " + e.getMessage(), e);
-    }
-  }
-
-  protected void constructContentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure, MirLocalizerExc {
-    try {
-      anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
-      anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));
-      anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));
-      anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());
-      anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());
-      anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());
-
-      anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));
-      anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField(""));
-
-      anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new ContentToMediaField( "uploadedMedia" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_images",  new ContentToMediaField( "image" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_audio", new ContentToMediaField( "audio" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_video", new ContentToMediaField( "video" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_other", new ContentToMediaField( "otherMedia" ));
-      anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new ContentToMediaField( "uploadedMedia", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_images",  new ContentToMediaField( "image", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new ContentToMediaField( "audio", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new ContentToMediaField( "video", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new ContentToMediaField( "otherMedia", false));
-      anEntityAdapterDefinition.addCalculatedField("to_media_icon", new ContentToIconField());
-
-      anEntityAdapterDefinition.addCalculatedField("article_type", new ContentToArticleTypeField());
-
-      anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));
-      anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));
-
-      anEntityAdapterDefinition.addCalculatedField("children", new ContentToChildrenField());
-      anEntityAdapterDefinition.addCalculatedField("parent", new ContentToParentField());
-
-      anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Article.PublicUrl")));
-
-      anEntityAdapterDefinition.addCalculatedField("operations",
-          new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleArticleOperations()));
-    }
-    catch (Throwable t) {
-      throw new MirLocalizerFailure(t.getMessage(), t);
-    }
-  }
-
-  protected void constructCommentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure {
-    try {
-      anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
-      anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());
-      anEntityAdapterDefinition.addCalculatedField("status", new CommentToStatusField());
-
-      anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new CommentToMediaField( "uploadedMedia" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_images",  new CommentToMediaField( "image" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_audio", new CommentToMediaField( "audio" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_video", new CommentToMediaField( "video" ));
-      anEntityAdapterDefinition.addCalculatedField("to_media_other", new CommentToMediaField( "otherMedia" ));
-      anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new CommentToMediaField( "uploadedMedia", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_images",  new CommentToMediaField( "image", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new CommentToMediaField( "audio", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new CommentToMediaField( "video", false));
-      anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new CommentToMediaField( "otherMedia", false));
-
-      anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Comment.PublicUrl")));
-
-      anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));
-      anEntityAdapterDefinition.addCalculatedField("operations",
-          new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleCommentOperations()));
-    }
-    catch (Throwable t) {
-      throw new MirLocalizerFailure(t.getMessage(), t);
-    }
-  }
-
-  public EntityAdapterModel adapterModel() throws MirLocalizerFailure, MirLocalizerExc {
-    EntityAdapterModel result = new EntityAdapterModel();
-
-    try {
-      EntityAdapterDefinition definition;
-
-      definition = new EntityAdapterDefinition();
-      constructContentAdapterDefinition( definition );
-      result.addMapping( "content", DatabaseContent.getInstance(), definition);
-
-      definition = new EntityAdapterDefinition();
-      constructCommentAdapterDefinition( definition );
-      result.addMapping( "comment", DatabaseComment.getInstance(), definition);
-
-      result.addMapping( "articleType", DatabaseArticleType.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "commentStatus", DatabaseCommentStatus.getInstance(), new EntityAdapterDefinition());
-
-      definition = new EntityAdapterDefinition();
-      definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
-      result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition);
-
-      definition = new EntityAdapterDefinition();
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
-      result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition);
-      definition = new EntityAdapterDefinition();
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
-      result.addMapping( "image", DatabaseImages.getInstance(), definition);
-      definition = new EntityAdapterDefinition();
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
-      result.addMapping( "audio", DatabaseAudio.getInstance(), definition);
-      definition = new EntityAdapterDefinition();
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
-      result.addMapping( "video", DatabaseVideo.getInstance(), definition);
-      definition = new EntityAdapterDefinition();
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
-      result.addMapping( "otherMedia", DatabaseOther.getInstance(), definition);
-
-
-      result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "internalMessage", DatabaseMessages.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "topic", DatabaseTopics.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "user", DatabaseUsers.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "media", DatabaseMedia.getInstance(), new EntityAdapterDefinition());
-      result.addMapping( "otherMedia", DatabaseOther.getInstance(), new EntityAdapterDefinition());
-
-      result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());
-
-    }
-    catch (Throwable t) {
-      throw new MirLocalizerFailure(t.getMessage(), t);
-    }
-
-    return result;
-  }
-
-  protected class CommentToContentField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_media"),
-                    "id",
-                    "content" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class CommentToStatusField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_comment_status"),
-                    "id",
-                    "commentStatus" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class EntityToSimpleOperationsField implements EntityAdapterDefinition.CalculatedField {
-    private List operations;
-
-    public EntityToSimpleOperationsField(List anOperations) {
-      operations = anOperations;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        Iterator i = operations.iterator();
-        List availableOperations = new Vector();
-
-        while (i.hasNext()) {
-          MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =
-            (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();
-
-          if (operation.isAvailable(anEntityAdapter)) {
-            availableOperations.add(operation.getName());
-          }
-        };
-
-        return availableOperations;
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class FilteredField implements EntityAdapterDefinition.CalculatedField {
-    private String fieldName;
-
-    public FilteredField(String aFieldName) {
-      fieldName = aFieldName;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        if (anEntityAdapter.get("is_html")!=null && anEntityAdapter.get("is_html").equals("1")) {
-          return MirGlobal.localizer().producerAssistant().filterHTMLText((String) anEntityAdapter.get(fieldName));
-        }
-        else {
-          return MirGlobal.localizer().producerAssistant().filterNonHTMLText((String) anEntityAdapter.get(fieldName));
-        }
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class StructuredContentField implements EntityAdapterDefinition.CalculatedField {
-    private String expression;
-
-    public StructuredContentField(String anExpression) {
-      expression = anExpression;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return StructuredContentParser.parse(ParameterExpander.evaluateStringExpression(anEntityAdapter, expression));
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ExpandedField implements EntityAdapterDefinition.CalculatedField {
-    private String expression;
-
-    public ExpandedField(String anExpression) {
-      expression = anExpression;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return ParameterExpander.expandExpression(anEntityAdapter, expression);
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class EvaluatedField implements EntityAdapterDefinition.CalculatedField {
-    private String expression;
-
-    public EvaluatedField(String anExpression) {
-      expression = anExpression;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return ParameterExpander.evaluateExpression(anEntityAdapter, expression);
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        logger.debug("ContentToParentField.getValue");
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_content"),
-                    "id",
-                    "content" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToChildrenField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getRelation(
-                    "to_content="+anEntityAdapter.get("id"),
-                    "id",
-                    "content" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToLanguageField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_language"),
-                    "id",
-                    "language" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToArticleTypeField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_article_type"),
-                    "id",
-                    "articleType" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class MediaToMediaFolderField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getToOneRelation(
-                    "id="+anEntityAdapter.get("to_media_folder"),
-                    "id",
-                    "mediaFolder" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToCommentsField implements EntityAdapterDefinition.CalculatedField {
-    private String extracondition;
-    private String order;
-
-    public ContentToCommentsField() {
-      this ( " and is_published='1'", "webdb_create");
-    }
-
-    public ContentToCommentsField(String anExtraCondition, String anOrder) {
-      order = anOrder;
-      extracondition = anExtraCondition;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return anEntityAdapter.getRelation(
-                    "to_media="+anEntityAdapter.get("id")+" " + extracondition,
-                    order,
-                    "comment" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToTopicsField implements EntityAdapterDefinition.CalculatedField {
-    private String topicCondition;
-
-    public ContentToTopicsField() {
-      this(null);
-    }
-
-    public ContentToTopicsField(String aTopicCondition) {
-      topicCondition = aTopicCondition;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        String condition = "exists (select * from content_x_topic where content_id="+anEntityAdapter.get("id")+" and topic_id=id)";
-        if (topicCondition!=null && topicCondition.length()>0)
-          condition = "(" + topicCondition + ") and " + condition;
-
-        return anEntityAdapter.getRelation(
-                    condition,
-                    "title",
-                    "topic" );
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToMediaField implements EntityAdapterDefinition.CalculatedField {
-    private String definition;
-    private boolean published;
-
-    public ContentToMediaField(String aDefinition, boolean anOnlyPublished) {
-      definition = aDefinition;
-      published = anOnlyPublished;
-    }
-
-    public ContentToMediaField(String aDefinition) {
-      this(aDefinition, true);
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        String condition = "exists (select * from content_x_media where content_id="+anEntityAdapter.get("id")+" and media_id=id)";
-        if (published)
-          condition = "is_published='t' and " + condition;
-        return anEntityAdapter.getRelation(
-           condition,
-          "id",
-          definition);
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class CommentToMediaField implements EntityAdapterDefinition.CalculatedField {
-    private String definition;
-    private boolean published;
-
-    public CommentToMediaField(String aDefinition, boolean anOnlyPublished) {
-      definition = aDefinition;
-      published = anOnlyPublished;
-    }
-
-    public CommentToMediaField(String aDefinition) {
-      this(aDefinition, true);
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        String condition = "exists (select * from comment_x_media where comment_id="+anEntityAdapter.get("id")+" and media_id=id)";
-        if (published)
-          condition = "is_published='t' and " + condition;
-        return anEntityAdapter.getRelation(
-           condition,
-          "id",
-          definition);
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-
-  protected class ContentToIconField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      EntityAdapter media;
-      Entity mediaType;
-      RewindableIterator iterator;
-      Map result;
-      MirMedia mediaHandler;
-      String tinyIcon;
-      String iconAlt;
-
-      try {
-        iterator = (RewindableIterator) (anEntityAdapter.get("to_uploaded_media"));
-        iterator.rewind();
-
-        tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyText");
-        iconAlt = "Text";
-
-        if (iterator.hasNext()) {
-          media = (EntityAdapter) iterator.next();
-
-          mediaType = ((EntityUploadedMedia) (media.getEntity())).getMediaType();
-          mediaHandler = MediaHelper.getHandler( mediaType );
-
-          if (mediaHandler.isVideo()) {
-            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyVideo");
-            iconAlt = "Video";
-          }
-          else if (mediaHandler.isAudio()) {
-            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyAudio");
-            iconAlt = "Audio";
-          }
-          else if (mediaHandler.isImage()) {
-            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyImage");
-            iconAlt = "Image";
-          }
-          else {
-            tinyIcon = mediaHandler.getTinyIconName();
-            iconAlt = mediaHandler.getIconAltName();
-          }
-
-        }
-      }
-      catch (Throwable t) {
-        logger.error("ContentToIconField: " +t.getMessage());
-        throw new RuntimeException(t.getMessage());
-      }
-
-      result = new HashMap();
-      result.put("tiny_icon", MirGlobal.config().getString("Producer.ImageRoot") + "/" + tinyIcon);
-      result.put("icon_alt", iconAlt);
-
-      return result;
-    }
-  }
-
-  protected class ContentCommentCountField implements EntityAdapterDefinition.CalculatedField {
-    private String extraCondition;
-
-    public ContentCommentCountField(String anExtraCondition) {
-      super();
-
-      extraCondition = anExtraCondition;
-    }
-
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return Integer.toString(
-            DatabaseComment.getInstance().getSize(
-                  "to_media="+anEntityAdapter.get("id")+" " + extraCondition));
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
-    }
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.localizer.basic;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.Entity;\r
+import mir.entity.adapter.EntityAdapter;\r
+import mir.entity.adapter.EntityAdapterDefinition;\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaHelper;\r
+import mir.media.MirMedia;\r
+import mir.util.ParameterExpander;\r
+import mir.util.RewindableIterator;\r
+import mir.util.StructuredContentParser;\r
+import mircoders.entity.EntityUploadedMedia;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.localizer.MirAdminInterfaceLocalizer;\r
+import mircoders.localizer.MirDataModelLocalizer;\r
+import mircoders.localizer.MirLocalizerExc;\r
+import mircoders.localizer.MirLocalizerFailure;\r
+import mircoders.storage.DatabaseArticleType;\r
+import mircoders.storage.DatabaseAudio;\r
+import mircoders.storage.DatabaseBreaking;\r
+import mircoders.storage.DatabaseComment;\r
+import mircoders.storage.DatabaseCommentStatus;\r
+import mircoders.storage.DatabaseContent;\r
+import mircoders.storage.DatabaseContentToMedia;\r
+import mircoders.storage.DatabaseContentToTopics;\r
+import mircoders.storage.DatabaseImageType;\r
+import mircoders.storage.DatabaseImages;\r
+import mircoders.storage.DatabaseLanguage;\r
+import mircoders.storage.DatabaseMediaType;\r
+import mircoders.storage.DatabaseMediafolder;\r
+import mircoders.storage.DatabaseMessages;\r
+import mircoders.storage.DatabaseOther;\r
+import mircoders.storage.DatabaseTopics;\r
+import mircoders.storage.DatabaseUploadedMedia;\r
+import mircoders.storage.DatabaseUsers;\r
+import mircoders.storage.DatabaseVideo;\r
+\r
+public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {\r
+  protected LoggerWrapper logger;\r
+  protected MirPropertiesConfiguration configuration;\r
+\r
+  public MirBasicDataModelLocalizer() throws MirLocalizerFailure, MirLocalizerExc {\r
+    logger = new LoggerWrapper("Localizer.DataModel");\r
+\r
+    try {\r
+      configuration = MirPropertiesConfiguration.instance();\r
+    }\r
+    catch (Throwable e) {\r
+      throw new MirLocalizerFailure("Can't get configuration: " + e.getMessage(), e);\r
+    }\r
+  }\r
+\r
+  protected void constructContentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure, MirLocalizerExc {\r
+    try {\r
+      anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+      anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));\r
+      anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));\r
+      anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());\r
+      anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());\r
+      anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));\r
+      anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField(""));\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new ContentToMediaField( "uploadedMedia" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_images",  new ContentToMediaField( "image" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_audio", new ContentToMediaField( "audio" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_video", new ContentToMediaField( "video" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_other", new ContentToMediaField( "otherMedia" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new ContentToMediaField( "uploadedMedia", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_images",  new ContentToMediaField( "image", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new ContentToMediaField( "audio", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new ContentToMediaField( "video", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new ContentToMediaField( "otherMedia", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_icon", new ContentToIconField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("article_type", new ContentToArticleTypeField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
+      anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("children", new ContentToChildrenField());\r
+      anEntityAdapterDefinition.addCalculatedField("parent", new ContentToParentField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Article.PublicUrl")));\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("operations",\r
+          new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleArticleOperations()));\r
+    }\r
+    catch (Throwable t) {\r
+      throw new MirLocalizerFailure(t.getMessage(), t);\r
+    }\r
+  }\r
+\r
+  protected void constructCommentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure {\r
+    try {\r
+      anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+      anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());\r
+      anEntityAdapterDefinition.addCalculatedField("status", new CommentToStatusField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new CommentToMediaField( "uploadedMedia" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_images",  new CommentToMediaField( "image" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_audio", new CommentToMediaField( "audio" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_video", new CommentToMediaField( "video" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_media_other", new CommentToMediaField( "otherMedia" ));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new CommentToMediaField( "uploadedMedia", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_images",  new CommentToMediaField( "image", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new CommentToMediaField( "audio", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new CommentToMediaField( "video", false));\r
+      anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new CommentToMediaField( "otherMedia", false));\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Comment.PublicUrl")));\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
+      anEntityAdapterDefinition.addCalculatedField("operations",\r
+          new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleCommentOperations()));\r
+    }\r
+    catch (Throwable t) {\r
+      throw new MirLocalizerFailure(t.getMessage(), t);\r
+    }\r
+  }\r
+\r
+  public EntityAdapterModel adapterModel() throws MirLocalizerFailure, MirLocalizerExc {\r
+    EntityAdapterModel result = new EntityAdapterModel();\r
+\r
+    try {\r
+      EntityAdapterDefinition definition;\r
+\r
+      definition = new EntityAdapterDefinition();\r
+      constructContentAdapterDefinition( definition );\r
+      result.addMapping( "content", DatabaseContent.getInstance(), definition);\r
+\r
+      definition = new EntityAdapterDefinition();\r
+      constructCommentAdapterDefinition( definition );\r
+      result.addMapping( "comment", DatabaseComment.getInstance(), definition);\r
+\r
+      result.addMapping( "articleType", DatabaseArticleType.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "commentStatus", DatabaseCommentStatus.getInstance(), new EntityAdapterDefinition());\r
+\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+      result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition);\r
+\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+      result.addMapping( "internalMessage", DatabaseMessages.getInstance(), definition);\r
+\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition);\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      result.addMapping( "image", DatabaseImages.getInstance(), definition);\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      result.addMapping( "audio", DatabaseAudio.getInstance(), definition);\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      result.addMapping( "video", DatabaseVideo.getInstance(), definition);\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      result.addMapping( "otherMedia", DatabaseOther.getInstance(), definition);\r
+\r
+\r
+      result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "topic", DatabaseTopics.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "user", DatabaseUsers.getInstance(), new EntityAdapterDefinition());\r
+      result.addMapping( "otherMedia", DatabaseOther.getInstance(), new EntityAdapterDefinition());\r
+\r
+      result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());\r
+\r
+    }\r
+    catch (Throwable t) {\r
+      throw new MirLocalizerFailure(t.getMessage(), t);\r
+    }\r
+\r
+    return result;\r
+  }\r
+\r
+  protected class CommentToContentField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_media"),\r
+                    "id",\r
+                    "content" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class CommentToStatusField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_comment_status"),\r
+                    "id",\r
+                    "commentStatus" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class EntityToSimpleOperationsField implements EntityAdapterDefinition.CalculatedField {\r
+    private List operations;\r
+\r
+    public EntityToSimpleOperationsField(List anOperations) {\r
+      operations = anOperations;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        Iterator i = operations.iterator();\r
+        List availableOperations = new Vector();\r
+\r
+        while (i.hasNext()) {\r
+          MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =\r
+            (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();\r
+\r
+          if (operation.isAvailable(anEntityAdapter)) {\r
+            availableOperations.add(operation.getName());\r
+          }\r
+        };\r
+\r
+        return availableOperations;\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class FilteredField implements EntityAdapterDefinition.CalculatedField {\r
+    private String fieldName;\r
+\r
+    public FilteredField(String aFieldName) {\r
+      fieldName = aFieldName;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        if (anEntityAdapter.get("is_html")!=null && anEntityAdapter.get("is_html").equals("1")) {\r
+          return MirGlobal.localizer().producerAssistant().filterHTMLText((String) anEntityAdapter.get(fieldName));\r
+        }\r
+        else {\r
+          return MirGlobal.localizer().producerAssistant().filterNonHTMLText((String) anEntityAdapter.get(fieldName));\r
+        }\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class StructuredContentField implements EntityAdapterDefinition.CalculatedField {\r
+    private String expression;\r
+\r
+    public StructuredContentField(String anExpression) {\r
+      expression = anExpression;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return StructuredContentParser.parse(ParameterExpander.evaluateStringExpression(anEntityAdapter, expression));\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ExpandedField implements EntityAdapterDefinition.CalculatedField {\r
+    private String expression;\r
+\r
+    public ExpandedField(String anExpression) {\r
+      expression = anExpression;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return ParameterExpander.expandExpression(anEntityAdapter, expression);\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class EvaluatedField implements EntityAdapterDefinition.CalculatedField {\r
+    private String expression;\r
+\r
+    public EvaluatedField(String anExpression) {\r
+      expression = anExpression;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return ParameterExpander.evaluateExpression(anEntityAdapter, expression);\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        logger.debug("ContentToParentField.getValue");\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_content"),\r
+                    "id",\r
+                    "content" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToChildrenField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getRelation(\r
+                    "to_content="+anEntityAdapter.get("id"),\r
+                    "id",\r
+                    "content" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToLanguageField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_language"),\r
+                    "id",\r
+                    "language" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToArticleTypeField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_article_type"),\r
+                    "id",\r
+                    "articleType" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class MediaToMediaFolderField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getToOneRelation(\r
+                    "id="+anEntityAdapter.get("to_media_folder"),\r
+                    "id",\r
+                    "mediaFolder" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToCommentsField implements EntityAdapterDefinition.CalculatedField {\r
+    private String extracondition;\r
+    private String order;\r
+\r
+    public ContentToCommentsField() {\r
+      this ( " and is_published='1'", "webdb_create");\r
+    }\r
+\r
+    public ContentToCommentsField(String anExtraCondition, String anOrder) {\r
+      order = anOrder;\r
+      extracondition = anExtraCondition;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return anEntityAdapter.getRelation(\r
+                    "to_media="+anEntityAdapter.get("id")+" " + extracondition,\r
+                    order,\r
+                    "comment" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToTopicsField implements EntityAdapterDefinition.CalculatedField {\r
+    private String topicCondition;\r
+\r
+    public ContentToTopicsField() {\r
+      this(null);\r
+    }\r
+\r
+    public ContentToTopicsField(String aTopicCondition) {\r
+      topicCondition = aTopicCondition;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        String condition = "exists (select * from content_x_topic where content_id="+anEntityAdapter.get("id")+" and topic_id=id)";\r
+        if (topicCondition!=null && topicCondition.length()>0)\r
+          condition = "(" + topicCondition + ") and " + condition;\r
+\r
+        return anEntityAdapter.getRelation(\r
+                    condition,\r
+                    "title",\r
+                    "topic" );\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToMediaField implements EntityAdapterDefinition.CalculatedField {\r
+    private String definition;\r
+    private boolean published;\r
+\r
+    public ContentToMediaField(String aDefinition, boolean anOnlyPublished) {\r
+      definition = aDefinition;\r
+      published = anOnlyPublished;\r
+    }\r
+\r
+    public ContentToMediaField(String aDefinition) {\r
+      this(aDefinition, true);\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        String condition = "exists (select * from content_x_media where content_id="+anEntityAdapter.get("id")+" and media_id=id)";\r
+        if (published)\r
+          condition = "is_published='t' and " + condition;\r
+        return anEntityAdapter.getRelation(\r
+           condition,\r
+          "id",\r
+          definition);\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class CommentToMediaField implements EntityAdapterDefinition.CalculatedField {\r
+    private String definition;\r
+    private boolean published;\r
+\r
+    public CommentToMediaField(String aDefinition, boolean anOnlyPublished) {\r
+      definition = aDefinition;\r
+      published = anOnlyPublished;\r
+    }\r
+\r
+    public CommentToMediaField(String aDefinition) {\r
+      this(aDefinition, true);\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        String condition = "exists (select * from comment_x_media where comment_id="+anEntityAdapter.get("id")+" and media_id=id)";\r
+        if (published)\r
+          condition = "is_published='t' and " + condition;\r
+        return anEntityAdapter.getRelation(\r
+           condition,\r
+          "id",\r
+          definition);\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentToIconField implements EntityAdapterDefinition.CalculatedField {\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      EntityAdapter media;\r
+      Entity mediaType;\r
+      RewindableIterator iterator;\r
+      Map result;\r
+      MirMedia mediaHandler;\r
+      String tinyIcon;\r
+      String iconAlt;\r
+\r
+      try {\r
+        iterator = (RewindableIterator) (anEntityAdapter.get("to_uploaded_media"));\r
+        iterator.rewind();\r
+\r
+        tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyText");\r
+        iconAlt = "Text";\r
+\r
+        if (iterator.hasNext()) {\r
+          media = (EntityAdapter) iterator.next();\r
+\r
+          mediaType = ((EntityUploadedMedia) (media.getEntity())).getMediaType();\r
+          mediaHandler = MediaHelper.getHandler( mediaType );\r
+\r
+          if (mediaHandler.isVideo()) {\r
+            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyVideo");\r
+            iconAlt = "Video";\r
+          }\r
+          else if (mediaHandler.isAudio()) {\r
+            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyAudio");\r
+            iconAlt = "Audio";\r
+          }\r
+          else if (mediaHandler.isImage()) {\r
+            tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyImage");\r
+            iconAlt = "Image";\r
+          }\r
+          else {\r
+            tinyIcon = mediaHandler.getTinyIconName();\r
+            iconAlt = mediaHandler.getIconAltName();\r
+          }\r
+\r
+        }\r
+      }\r
+      catch (Throwable t) {\r
+        logger.error("ContentToIconField: " +t.getMessage());\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+\r
+      result = new HashMap();\r
+      result.put("tiny_icon", MirGlobal.config().getString("Producer.ImageRoot") + "/" + tinyIcon);\r
+      result.put("icon_alt", iconAlt);\r
+\r
+      return result;\r
+    }\r
+  }\r
+\r
+  protected class ContentCommentCountField implements EntityAdapterDefinition.CalculatedField {\r
+    private String extraCondition;\r
+\r
+    public ContentCommentCountField(String anExtraCondition) {\r
+      super();\r
+\r
+      extraCondition = anExtraCondition;\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        return Integer.toString(\r
+            DatabaseComment.getInstance().getSize(\r
+                  "to_media="+anEntityAdapter.get("id")+" " + extraCondition));\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+\r
+  protected class ContentMediaCountField implements EntityAdapterDefinition.CalculatedField {\r
+    private String table;\r
+    private boolean published;\r
+\r
+    public ContentMediaCountField(String aTable, boolean anOnlyPublished) {\r
+      table = aTable;\r
+      published = anOnlyPublished;\r
+    }\r
+\r
+    public ContentMediaCountField(String aTable) {\r
+      this(aTable, true);\r
+    }\r
+\r
+    public Object getValue(EntityAdapter anEntityAdapter) {\r
+      try {\r
+        String subQuery = "select * from "+table+" where id = media_id";\r
+        if (published)\r
+          subQuery = subQuery + " and is_published='t'";\r
+\r
+        return Integer.toString(\r
+            DatabaseContentToMedia.getInstance().getSize(\r
+                  "exists ("+subQuery+")"));\r
+      }\r
+      catch (Throwable t) {\r
+        throw new RuntimeException(t.getMessage());\r
+      }\r
+    }\r
+  }\r
+}\r
index 9e80068..3d531ab 100755 (executable)
  */
 package  mircoders.media;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import javax.servlet.ServletContext;
-
-import freemarker.template.SimpleList;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaExc;
-import mir.media.MediaFailure;
-import mir.media.MirMedia;
-import mir.misc.FileUtil;
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.InputStream;\r
+import java.util.List;\r
+import java.util.Vector;\r
+import javax.servlet.ServletContext;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
+import mir.media.MirMedia;\r
+import mir.misc.FileUtil;\r
 import mir.misc.StringUtil;
 
 
@@ -63,7 +63,7 @@ import mir.misc.StringUtil;
  *
  * @see mir.media.MirMedia
  * @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerGeneric.java,v 1.20.2.1 2003/08/04 20:03:25 zapata Exp $
+ * @version $Id: MediaHandlerGeneric.java,v 1.20.2.2 2003/09/03 17:49:39 zapata Exp $
  */
 
 public class MediaHandlerGeneric implements MirMedia
@@ -177,9 +177,9 @@ public class MediaHandlerGeneric implements MirMedia
         return "Generic media";
     }
 
-    public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
+    public List getURL(Entity ent, Entity mediaTypeEnt)
     {
-      SimpleList theList = new SimpleList();
+      List theList = new Vector();
       theList.add(ent);
       return theList;
     }
index 210ad37..18b3532 100755 (executable)
@@ -31,6 +31,7 @@ package mircoders.media;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.*;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
@@ -42,7 +43,6 @@ import mir.media.MirMedia;
 import mir.misc.FileUtil;
 import mir.misc.StringUtil;
 import mircoders.entity.EntityImages;
-import freemarker.template.SimpleList;
 
 /**
  * This class handles saving, fetching creating representations
@@ -58,7 +58,7 @@ import freemarker.template.SimpleList;
  *
  * @see mir.media.MirMedia
  * @author mh
- * @version $Id: MediaHandlerImages.java,v 1.23 2003/04/30 00:37:27 zapata Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.23.2.1 2003/09/03 17:49:39 zapata Exp $
  */
 
 
@@ -161,8 +161,8 @@ public abstract class MediaHandlerImages implements MirMedia
     return in;
   }
 
-  public SimpleList getURL(Entity ent, Entity mediaTypeEnt) {
-    SimpleList theList = new SimpleList();
+  public List getURL(Entity ent, Entity mediaTypeEnt) {
+    List theList = new Vector();
     theList.add(ent);
     return theList;
   }
index f69cec8..81bf55a 100755 (executable)
-/*
- * 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  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  mircoders.media;
-
-import java.io.StringReader;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaExc;
-import mir.media.MediaFailure;
-import mir.media.MirMedia;
-import mir.misc.FileUtil;
-import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-/**
- * Please note: this media handler produces
- * 3 media files, the raw .mp3, a .m3u which is
- * contains the URL for the mp3 and a .pls which
- * contains the URL to the mp3 in shoutcast playlist
- * format. What's important is that the web server (of
- * the media host) must recognize the .m3u and .pls file
- * extensions and send the proper "audio/x-mpegurl"
- * and "audio/x-scpls" mime-types respectively.
- * If the web server is apache, it's easy, just
- * add:
- *
- * audio/x-mpegurl                 m3u
- * audio/x-scpl                    pls
- *
- * to the file pointed to by the "TypesConfig"
- * command in your apache config file. Or add
- * and equivalent AddType command to your httpd.conf.
- * Of course this assumes that the mod_mime is loaded.
- *
- * If the web server is not apache, then your on your own.
- *
- * @see mir.media.MirMedia
- * @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerMp3.java,v 1.15 2003/04/21 12:42:48 idfx Exp $
- */
-
-public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia
-{
-  protected LoggerWrapper logger;
-
-  public MediaHandlerMp3() {
-    logger = new LoggerWrapper("Media.Audio.Mp3");
-  }
-
-  public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
-
-    // first check if the file exists
-    super.produce(ent, mediaTypeEnt);
-
-    String baseName = ent.getId();
-    String date = ent.getValue("date");
-    String datePath = StringUtil.webdbDate2path(date);
-    String mp3Pointer = getPublishHost() + ent.getValue("publish_path");
-    String mpegURLFile = baseName + ".m3u";
-    String playlistFile = baseName + ".pls";
-
-    try {
-      //write the "meta" files
-      //first the .m3u since it only contains one line
-      FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,
-                     new StringReader(mp3Pointer), "US-ASCII");
-      //now the .pls file
-      FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,
-                     new StringReader(mp3Pointer), "US-ASCII");
-    }
-    catch (Throwable e) {
-      logger.error("MediaHandlerMp3.produce: " + e.toString());
-
-      throw new MediaFailure(e);
-    }
-  }
-
-  public SimpleList getURL(Entity ent, Entity mediaTypeEnt) {
-    SimpleList theList = new SimpleList();
-
-    //String stringSize = ent.getValue("size");
-    //int size = Integer.parseInt(stringSize, 10)/1024;
-    theList.add(ent);
-
-    String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),
-                                               ".mp3$", "");
-
-    // @todo the texts ("title") below urgently need to be sanely localizaeble
-    // somehow
-    SimpleHash m3uHash = new SimpleHash();
-    m3uHash.put("publish_path", basePath + ".m3u");
-    m3uHash.put("publish_server", ent.getValue("publish_server"));
-    m3uHash.put("title", "stream URL");
-    theList.add(m3uHash);
-
-    SimpleHash plsHash = new SimpleHash();
-    plsHash.put("publish_path", basePath + ".pls");
-    plsHash.put("publish_server", ent.getValue("publish_server"));
-    plsHash.put("title", "playlist URL");
-    theList.add(plsHash);
-
-    return theList;
-
-  }
-
-  public String getDescr(Entity mediaType) {
-    return "mp3";
-  }
-}
-
-
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package  mircoders.media;\r
+\r
+import java.io.StringReader;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
+import mir.media.MirMedia;\r
+import mir.misc.FileUtil;\r
+import mir.misc.StringUtil;\r
+\r
+/**\r
+ * Please note: this media handler produces\r
+ * 3 media files, the raw .mp3, a .m3u which is\r
+ * contains the URL for the mp3 and a .pls which\r
+ * contains the URL to the mp3 in shoutcast playlist\r
+ * format. What's important is that the web server (of\r
+ * the media host) must recognize the .m3u and .pls file\r
+ * extensions and send the proper "audio/x-mpegurl"\r
+ * and "audio/x-scpls" mime-types respectively.\r
+ * If the web server is apache, it's easy, just\r
+ * add:\r
+ *\r
+ * audio/x-mpegurl                 m3u\r
+ * audio/x-scpl                    pls\r
+ *\r
+ * to the file pointed to by the "TypesConfig"\r
+ * command in your apache config file. Or add\r
+ * and equivalent AddType command to your httpd.conf.\r
+ * Of course this assumes that the mod_mime is loaded.\r
+ *\r
+ * If the web server is not apache, then your on your own.\r
+ *\r
+ * @see mir.media.MirMedia\r
+ * @author mh <mh@nadir.org>\r
+ * @version $Id: MediaHandlerMp3.java,v 1.15.2.1 2003/09/03 17:49:39 zapata Exp $\r
+ */\r
+\r
+public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia\r
+{\r
+  protected LoggerWrapper logger;\r
+\r
+  public MediaHandlerMp3() {\r
+    logger = new LoggerWrapper("Media.Audio.Mp3");\r
+  }\r
+\r
+  public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
+\r
+    // first check if the file exists\r
+    super.produce(ent, mediaTypeEnt);\r
+\r
+    String baseName = ent.getId();\r
+    String date = ent.getValue("date");\r
+    String datePath = StringUtil.webdbDate2path(date);\r
+    String mp3Pointer = getPublishHost() + ent.getValue("publish_path");\r
+    String mpegURLFile = baseName + ".m3u";\r
+    String playlistFile = baseName + ".pls";\r
+\r
+    try {\r
+      //write the "meta" files\r
+      //first the .m3u since it only contains one line\r
+      FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,\r
+                     new StringReader(mp3Pointer), "US-ASCII");\r
+      //now the .pls file\r
+      FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,\r
+                     new StringReader(mp3Pointer), "US-ASCII");\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("MediaHandlerMp3.produce: " + e.toString());\r
+\r
+      throw new MediaFailure(e);\r
+    }\r
+  }\r
+\r
+  public List getURL(Entity ent, Entity mediaTypeEnt) {\r
+    List theList = new Vector();\r
+\r
+    //String stringSize = ent.getValue("size");\r
+    //int size = Integer.parseInt(stringSize, 10)/1024;\r
+    theList.add(ent);\r
+\r
+    String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),\r
+                                               ".mp3$", "");\r
+\r
+    // @todo the texts ("title") below urgently need to be sanely localizaeble\r
+    // somehow\r
+    Map m3uHash = new HashMap();\r
+    m3uHash.put("publish_path", basePath + ".m3u");\r
+    m3uHash.put("publish_server", ent.getValue("publish_server"));\r
+    m3uHash.put("title", "stream URL");\r
+    theList.add(m3uHash);\r
+\r
+    Map plsHash = new HashMap();\r
+    plsHash.put("publish_path", basePath + ".pls");\r
+    plsHash.put("publish_server", ent.getValue("publish_server"));\r
+    plsHash.put("title", "playlist URL");\r
+    theList.add(plsHash);\r
+\r
+    return theList;\r
+\r
+  }\r
+\r
+  public String getDescr(Entity mediaType) {\r
+    return "mp3";\r
+  }\r
+}\r
+\r
+\r
+\r
index 62dc5a2..a2c9e08 100755 (executable)
-/*
- * 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  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  mircoders.media;
-
-import java.io.StringReader;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaExc;
-import mir.media.MediaFailure;
-import mir.media.MirMedia;
-import mir.misc.FileUtil;
-import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-
-
-/**
- * Handles realAudio .it manages the ram file.
- *
- * 03.2002 - reworked Realmedia handling. -mh
- *
- * @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
- * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @version $Id: MediaHandlerRealAudio.java,v 1.19 2003/04/21 12:42:48 idfx Exp $
- */
-
-
-public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia
-{
-  public MediaHandlerRealAudio() {
-    logger = new LoggerWrapper("Media.Audio.Real");
-  }
-
-  public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
-
-    // first see if the file exists
-    super.produce(ent, mediaTypeEnt);
-
-    String baseName = ent.getId();
-    String date = ent.getValue("date");
-    String datePath = StringUtil.webdbDate2path(date);
-    String rtspDir = configuration.getString("Producer.RealMedia.Path");
-    String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
-
-    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
-    String RealMediaFile = datePath+ent.getId()+".ram";
-    try {
-      //write an rm (ram?. -mh) file
-      FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
-                      new StringReader(RealMediaPointer), "US-ASCII");
-    }
-    catch (Throwable e) {
-      logger.error("MediaHandlerRealAudio.produce: " + e.toString());
-      throw new MediaFailure(e);
-    }
-  }
-
-  public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
-  {
-    SimpleList theList = new SimpleList();
-
-    //String stringSize = ent.getValue("size");
-    //int size = Integer.parseInt(stringSize, 10)/1024;
-    theList.add(ent);
-
-    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
-                                            ".ra$","");
-
-    // @todo the texts ("title") below urgently need to be sanely localizaeble
-    // somehow
-    SimpleHash ramHash = new SimpleHash();
-    ramHash.put("publish_path", basePath+".ram");
-    ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));
-    ramHash.put("title", "stream URL");
-    theList.add(ramHash);
-
-    return theList;
-  }
-
-  public String getStoragePath()
-  {
-    return configuration.getString("Producer.RealMedia.Path");
-  }
-
-  public String getDescr(Entity mediaType)
-  {
-    return "RealMedia";
-  }
-
-  public String getPublishHost()
-  {
-    return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));
-  }
-
-}
-
-
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package  mircoders.media;\r
+\r
+import java.io.StringReader;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
+import mir.media.MirMedia;\r
+import mir.misc.FileUtil;\r
+import mir.misc.StringUtil;\r
+\r
+\r
+\r
+/**\r
+ * Handles realAudio .it manages the ram file.\r
+ *\r
+ * 03.2002 - reworked Realmedia handling. -mh\r
+ *\r
+ * @see mir.media.MediaHandlerGeneric\r
+ * @see mir.media.MirMedia\r
+ * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>\r
+ * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $\r
+ */\r
+\r
+\r
+public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia\r
+{\r
+  public MediaHandlerRealAudio() {\r
+    logger = new LoggerWrapper("Media.Audio.Real");\r
+  }\r
+\r
+  public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {\r
+\r
+    // first see if the file exists\r
+    super.produce(ent, mediaTypeEnt);\r
+\r
+    String baseName = ent.getId();\r
+    String date = ent.getValue("date");\r
+    String datePath = StringUtil.webdbDate2path(date);\r
+    String rtspDir = configuration.getString("Producer.RealMedia.Path");\r
+    String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");\r
+\r
+    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");\r
+    String RealMediaFile = datePath+ent.getId()+".ram";\r
+    try {\r
+      //write an rm (ram?. -mh) file\r
+      FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,\r
+                      new StringReader(RealMediaPointer), "US-ASCII");\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("MediaHandlerRealAudio.produce: " + e.toString());\r
+      throw new MediaFailure(e);\r
+    }\r
+  }\r
+\r
+  public List getURL(Entity ent, Entity mediaTypeEnt)\r
+  {\r
+    List theList = new Vector();\r
+\r
+    //String stringSize = ent.getValue("size");\r
+    //int size = Integer.parseInt(stringSize, 10)/1024;\r
+    theList.add(ent);\r
+\r
+    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),\r
+                                            ".ra$","");\r
+\r
+    // @todo the texts ("title") below urgently need to be sanely localizaeble\r
+    // somehow\r
+    Map ramHash = new HashMap();\r
+    ramHash.put("publish_path", basePath+".ram");\r
+    ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));\r
+    ramHash.put("title", "stream URL");\r
+    theList.add(ramHash);\r
+\r
+    return theList;\r
+  }\r
+\r
+  public String getStoragePath()\r
+  {\r
+    return configuration.getString("Producer.RealMedia.Path");\r
+  }\r
+\r
+  public String getDescr(Entity mediaType)\r
+  {\r
+    return "RealMedia";\r
+  }\r
+\r
+  public String getPublishHost()\r
+  {\r
+    return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));\r
+  }\r
+\r
+}\r
+\r
+\r
+\r
index 947a905..12af17f 100755 (executable)
-/*
- * 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  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  mircoders.media;
-
-import java.io.File;
-import java.io.StringReader;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaExc;
-import mir.media.MediaFailure;
-import mir.media.MirMedia;
-import mir.misc.FileUtil;
-import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-
-
-/**
- * Handles realVideo .it manages the ram file.
- *
- * 03.2002 - reworked Realmedia handling. -mh
- *
- * @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
- * @author john <john@manifestor.org>, mh <mh@nadir.org>
- * @version $Id: MediaHandlerRealVideo.java,v 1.19 2003/04/21 12:42:48 idfx Exp $
- */
-
-
-public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia
-{
-  protected LoggerWrapper logger;
-
-  public MediaHandlerRealVideo() {
-    logger = new LoggerWrapper("Media.Video.Real");
-  }
-
-  public void produce (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
-    // first see if the file exists
-    super.produce(ent, mediaTypeEnt);
-
-    String baseName = ent.getId();
-    String date = ent.getValue("date");
-    String datePath = StringUtil.webdbDate2path(date);
-    String rtspDir = configuration.getString("Producer.RealMedia.Path");
-    String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
-
-    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
-    String RealMediaFile = datePath+ent.getId()+".ram";
-    try {
-      //write an rm (ram?. -mh) file
-      FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile,
-                      new StringReader(RealMediaPointer), "US-ASCII");
-    }
-    catch (Throwable e) {
-      logger.error("MediaHandlerRealVideo.produce: " + e.toString());
-
-      throw new MediaFailure(e);
-    }
-  }
-
-  public SimpleList getURL(Entity ent, Entity mediaTypeEnt) {
-    SimpleList theList = new SimpleList();
-
-    //String stringSize = ent.getValue("size");
-    //int size = Integer.parseInt(stringSize, 10)/1024;
-    theList.add(ent);
-
-    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
-                                            ".rm$","");
-
-    // @todo the texts ("title") below urgently need to be sanely localizaeble
-    // somehow
-    SimpleHash ramHash = new SimpleHash();
-    ramHash.put("publish_path", basePath+".ram");
-    ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));
-    ramHash.put("title", "stream URL");
-    theList.add(ramHash);
-
-    return theList;
-
-  }
-
-  public String getStoragePath() {
-    return configuration.getString("Producer.RealMedia.Path");
-  }
-
-  public String getDescr(Entity mediaType) {
-    return "RealMedia";
-  }
-
-  public String getPublishHost() {
-    return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));
-  }
-
-}
-
-
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package  mircoders.media;\r
+\r
+import java.io.File;\r
+import java.io.StringReader;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
+import mir.media.MirMedia;\r
+import mir.misc.FileUtil;\r
+import mir.misc.StringUtil;\r
+\r
+\r
+\r
+/**\r
+ * Handles realVideo .it manages the ram file.\r
+ *\r
+ * 03.2002 - reworked Realmedia handling. -mh\r
+ *\r
+ * @see mir.media.MediaHandlerGeneric\r
+ * @see mir.media.MirMedia\r
+ * @author john <john@manifestor.org>, mh <mh@nadir.org>\r
+ * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $\r
+ */\r
+\r
+\r
+public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia\r
+{\r
+  protected LoggerWrapper logger;\r
+\r
+  public MediaHandlerRealVideo() {\r
+    logger = new LoggerWrapper("Media.Video.Real");\r
+  }\r
+\r
+  public void produce (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
+    // first see if the file exists\r
+    super.produce(ent, mediaTypeEnt);\r
+\r
+    String baseName = ent.getId();\r
+    String date = ent.getValue("date");\r
+    String datePath = StringUtil.webdbDate2path(date);\r
+    String rtspDir = configuration.getString("Producer.RealMedia.Path");\r
+    String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");\r
+\r
+    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");\r
+    String RealMediaFile = datePath+ent.getId()+".ram";\r
+    try {\r
+      //write an rm (ram?. -mh) file\r
+      FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile,\r
+                      new StringReader(RealMediaPointer), "US-ASCII");\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("MediaHandlerRealVideo.produce: " + e.toString());\r
+\r
+      throw new MediaFailure(e);\r
+    }\r
+  }\r
+\r
+  public List getURL(Entity ent, Entity mediaTypeEnt) {\r
+    List theList = new Vector();\r
+\r
+    //String stringSize = ent.getValue("size");\r
+    //int size = Integer.parseInt(stringSize, 10)/1024;\r
+    theList.add(ent);\r
+\r
+    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),\r
+                                            ".rm$","");\r
+\r
+    // @todo the texts ("title") below urgently need to be sanely localizaeble\r
+    // somehow\r
+    Map ramHash = new HashMap();\r
+    ramHash.put("publish_path", basePath+".ram");\r
+    ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));\r
+    ramHash.put("title", "stream URL");\r
+    theList.add(ramHash);\r
+\r
+    return theList;\r
+\r
+  }\r
+\r
+  public String getStoragePath() {\r
+    return configuration.getString("Producer.RealMedia.Path");\r
+  }\r
+\r
+  public String getDescr(Entity mediaType) {\r
+    return "RealMedia";\r
+  }\r
+\r
+  public String getPublishHost() {\r
+    return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));\r
+  }\r
+\r
+}\r
+\r
+\r
+\r
index 13f4d7f..9e52a29 100755 (executable)
  */
 package mircoders.module;
 
-import mir.log.LoggerWrapper;
-import mir.module.*;
-import mir.util.*;
-import mir.storage.StorageObject;
+import mir.log.LoggerWrapper;\r
+import mir.module.AbstractModule;\r
+import mir.module.ModuleExc;\r
+import mir.module.ModuleFailure;\r
+import mir.storage.StorageObject;\r
+import mir.util.JDBCStringRoutines;
 
 public class ModuleArticleType extends AbstractModule {
   static LoggerWrapper logger = new LoggerWrapper("Module.ArticleType");
index 9055e9e..b936159 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.module;
 
-import java.util.Map;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.module.AbstractModule;
-import mir.module.ModuleExc;
-import mir.module.ModuleFailure;
-import mir.storage.StorageObject;
-import mircoders.storage.DatabaseComment;
+import java.util.Map;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.module.AbstractModule;\r
+import mir.module.ModuleExc;\r
+import mir.module.ModuleFailure;\r
+import mir.storage.StorageObject;\r
 import mircoders.storage.DatabaseContent;
-import freemarker.template.SimpleList;
 
 
 /*
@@ -58,15 +56,6 @@ public class ModuleComment extends AbstractModule
     this.theStorage = theStorage;
   }
 
-  public SimpleList getCommentAsSimpleList() throws ModuleExc, ModuleFailure {
-    try {
-      return ((DatabaseComment)theStorage).getPopupData();
-    }
-    catch (Throwable e) {
-      throw new ModuleFailure(e);
-    }
-  }
-
   public void deleteById (String anId) throws ModuleExc, ModuleFailure {
     try {
       Entity theEntity = theStorage.selectById((String)anId);
index 317ff24..b6d5dad 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.module;
 
 import java.util.List;
@@ -72,7 +72,7 @@ public class ModuleMediaType extends AbstractModule {
       throw new UnsupportedMimeTypeExc("Unsupported mimetype: " + aMimeType, aMimeType);
     }
 
-    return (Entity) mediaTypes.get(0);
+    return (Entity) mediaTypes.elementAt(0);
   }
 
   public static class MimeTypeExc extends ModuleExc {
index 562a8b6..98b25b1 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.module;
@@ -44,15 +44,12 @@ import mir.module.ModuleExc;
 import mir.module.ModuleFailure;
 import mir.storage.StorageObject;
 import mircoders.storage.DatabaseMediafolder;
-import freemarker.template.SimpleList;
 
 
 public class ModuleMediafolder extends AbstractModule
 {
   static LoggerWrapper logger = new LoggerWrapper("Module.Mediafolder");
 
-// Kontruktor
-
   public ModuleMediafolder(StorageObject aStorage)
   {
     if (aStorage == null)
@@ -60,17 +57,4 @@ public class ModuleMediafolder extends AbstractModule
 
     theStorage = aStorage;
   }
-
-// Methoden
-
-  public SimpleList getPopupData() throws ModuleExc, ModuleFailure {
-    try {
-      return ((DatabaseMediafolder)theStorage).getPopupData();
-    }
-    catch (Throwable e) {
-      throw new ModuleFailure(e);
-    }
-  }
-
-
 }
index cd8a781..d868ab6 100755 (executable)
@@ -39,14 +39,6 @@ import mir.module.ModuleExc;
 import mir.module.ModuleFailure;
 import mir.storage.StorageObject;
 import mircoders.storage.DatabaseTopics;
-import freemarker.template.SimpleList;
-
-/*
- *  ThemenModule -
- *
- *
- * @author RK
- */
 
 public class ModuleTopics extends AbstractModule {
 
@@ -56,15 +48,6 @@ public class ModuleTopics extends AbstractModule {
     this.theStorage = theStorage;
   }
 
-  public SimpleList getTopicsAsSimpleList() throws ModuleExc, ModuleFailure {
-    try {
-      return ((DatabaseTopics) theStorage).getPopupData();
-    }
-    catch (Throwable e) {
-      throw new ModuleFailure(e);
-    }
-  }
-
   /**
    *  Method getTopicList
    *
index 9487e0c..b3d5f62 100755 (executable)
@@ -32,6 +32,7 @@ package mircoders.pdf;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.util.*;
 
 import com.lowagie.text.BadElementException;
 import com.lowagie.text.Document;
@@ -53,13 +54,13 @@ import gnu.regexp.REMatch;
 import gnu.regexp.REMatchEnumeration;
 
 import mir.config.MirPropertiesConfiguration;
-import mir.entity.EntityList;
+import mir.entity.*;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.util.DateTimeFunctions;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityImages;
-import mircoders.storage.DatabaseContentToMedia;
+import mircoders.storage.*;
 
 public class PDFGenerator{
 
@@ -417,7 +418,7 @@ public class PDFGenerator{
       logger.error("runaway description...try increasing the line height or decreasing the font size");
   }
 
-  public void addArticleContent(ColumnText ct,String theContent,EntityList images){
+  public void addArticleContent(ColumnText ct,String theContent,Iterator images){
     //let's go ahead and add in all the body text
     Paragraph contentP=new Paragraph(theContent,new Font(contentFontFamily,contentFontSize));
     ct.addText(contentP);
@@ -635,7 +636,11 @@ public class PDFGenerator{
      * source
     */
 
-    EntityList images=DatabaseContentToMedia.getInstance().getImages(entityContent);
+   Iterator images = new EntityBrowser(
+      DatabaseImages.getInstance(),
+       "exists (select * from content_x_media where content_id=" + entityContent.getId() + " and media_id=id)",
+       "id desc", 30, -1, 0);
+
     String isHTML  = entityContent.getValue("is_html");
     String theTitle = entityContent.getValue("title");
     String theCreator = entityContent.getValue("creator");
index 61e0155..3f78883 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.producer;
@@ -80,7 +80,7 @@ public class ContentModifyingProducerNode implements ProducerNode {
       entity.setValueForProperty(fieldName, value);
       entity.update();
 
-      aLogger.info("  Modified content " + entity.get("id") + ": " + fieldName + " = " + value );
+      aLogger.info("  Modified content " + entity.getId() + ": " + fieldName + " = " + value );
     }
     catch (Throwable t) {
       aLogger.error("Error while modifying content: " + t.getMessage());
index 86ad9a9..77fd4c6 100755 (executable)
-/*
- * 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  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 mircoders.producer;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import mir.entity.Entity;
-import mir.entity.EntityList;
-import mir.entity.adapter.EntityAdapter;
-import mir.log.LoggerToWriterAdapter;
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.producer.ProducerFailure;
-import mir.producer.ProducerNode;
-import mir.util.CachingRewindableIterator;
-import mir.util.HTMLRoutines;
-import mir.util.ParameterExpander;
-import mircoders.entity.EntityContent;
-import mircoders.entity.EntityImages;
-import mircoders.storage.DatabaseContentToMedia;
-
-//because images are returned as a template model!(maybe not needed after all!)
-//import freemarker.template.*;
-
-
-public class PDFPreFormattingProducerNode implements ProducerNode {
-  private String contentKey;
-  private int numLinesBetweenImages;
-  private float contentAreaWidthCM;
-  private float characterWidthCM;
-  private float pixelWidthCM;
-  private float lineHeightCM;
-
-  public PDFPreFormattingProducerNode(String aContentKey,String someNumLinesBetweenImages,String aContentAreaWidthCM,String aCharacterWidthCM,String aPixelWidthCM,String aLineHeightCM) {
-    contentKey = aContentKey;
-    numLinesBetweenImages=(new Integer(someNumLinesBetweenImages)).intValue();
-    contentAreaWidthCM=(new Float(aContentAreaWidthCM)).floatValue();
-    characterWidthCM=(new Float(aCharacterWidthCM)).floatValue();
-    pixelWidthCM=(new Float(aPixelWidthCM)).floatValue();
-    lineHeightCM=(new Float(aLineHeightCM)).floatValue();
-
-    //    float characterWidthCM = 0.17F;
-    //float contentAreaWidthCM = 16;
-    //float pixelWidthCM = .03F;
-    //float lineHeightCM = .5F;
-  }
-
-  public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure {
-    Object data;
-    Entity entity;
-
-    try {
-      data = ParameterExpander.findValueForKey( aValueMap, contentKey );
-
-      if (! (data instanceof EntityAdapter)) {
-        throw new ProducerFailure("PDFPreFormattingProducerNode: value of '"+contentKey+"' is not an EntityAdapter, but an " + data.getClass().getName(), null);
-      }
-
-      entity = ((EntityAdapter) data).getEntity();
-      if (! (entity instanceof EntityContent)) {
-        throw new ProducerFailure("PDFPreFormattingProducerNode: value of '"+contentKey+"' is not a content EntityAdapter, but a " + entity.getClass().getName() + " adapter", null);
-      }
-
-      int currentPosition = 0;
-
-      //int numLinesBetweenImages=3;
-
-
-
-
-      int numCharsInAnImagelessRow = (new Float(numLinesBetweenImages * (contentAreaWidthCM/characterWidthCM))).intValue();
-
-      boolean outOfText = false;
-
-      ArrayList brokenUpContent = new ArrayList();
-
-
-      EntityList images=DatabaseContentToMedia.getInstance().getImages((EntityContent)entity);
-      String theContent = ((EntityContent) entity).getValue("content_data");
-      //remove pesky characters
-      theContent = HTMLRoutines.encodeXML(theContent);
-      //put in the <BR> tags so we can turn them to empty blocks
-      theContent = StringUtil.convertNewline2Break(theContent);
-
-      if (images == null){
-          Map row = new HashMap();
-          row.put("text",theContent);
-          row.put("hasImage","0");
-          brokenUpContent.add(row);
-      }
-      if (images != null){
-          //need to add checks for out of content!
-          Map row0 = new HashMap();
-          if (numCharsInAnImagelessRow>(theContent).length()){
-              row0.put("text",theContent);
-              outOfText = true;
-          }
-          else {
-              //break on words so we don't split html entities
-              int lastSpaceAt = theContent.lastIndexOf(" ",numCharsInAnImagelessRow);
-              row0.put("text",theContent.substring(0,lastSpaceAt));
-              currentPosition=lastSpaceAt;
-          }
-          row0.put("hasImage","0");
-          brokenUpContent.add(row0);
-          aLogger.debug("CP1 is "+ currentPosition);
-          while(images.hasNext()){
-              Map row1 = new HashMap();
-              Map row2 = new HashMap();
-              EntityImages currentImage=(EntityImages) images.next();
-              float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
-              float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
-
-              //oversize images must be shrunk
-              if (img_width>250){
-                  img_height=(new Float((new Float(img_height*(250.0F/img_width))).intValue())).floatValue();
-                  img_width=250.0F;
-              }
-
-
-              //calculate how much text goes in the column(use 8 pixels to pad the column)
-              float text_widthCM = contentAreaWidthCM-((img_width+8)*pixelWidthCM);
-              float number_of_lines = img_height*pixelWidthCM/lineHeightCM; //don't worry we will make it an int
-              //add one line for image description
-              int text_amount= (new Float((text_widthCM/characterWidthCM)*(number_of_lines+1))).intValue();
-
-              row1.put("text_widthCM",Float.toString(text_widthCM));
-
-              row1.put("img_title",currentImage.getValue("title"));
-
-              row1.put("img_width",Float.toString(img_width));
-              row1.put("img_height",Float.toString(img_height));
-
-              aLogger.debug("img_width " +Float.toString(img_width));
-              aLogger.debug("img_height "+Float.toString(img_height));
-
-              row1.put("img_src",currentImage.getValue("publish_path"));
-              row1.put("hasImage","1");
-              if (! outOfText){
-                  try {
-                      int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+text_amount);
-                      row1.put("text",theContent.substring(currentPosition,lastSpaceAt));
-                      currentPosition=lastSpaceAt;
-                  }
-                  catch (IndexOutOfBoundsException e){
-                      row1.put("text",theContent.substring(currentPosition));
-                      outOfText = true;
-                          }
-              }
-              aLogger.debug("CP2 is "+ currentPosition);
-              brokenUpContent.add(row1);
-
-              if (! outOfText){
-                  try {
-                      int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+numCharsInAnImagelessRow);
-                      row2.put("text",theContent.substring(currentPosition,lastSpaceAt));
-                      currentPosition=lastSpaceAt;
-                  }
-                  catch (IndexOutOfBoundsException e){
-                      row2.put("text",theContent.substring(currentPosition));
-                      outOfText = true;
-                          }
-              }
-              row2.put("hasImage","0");
-              brokenUpContent.add(row2);
-
-              aLogger.debug("CP3 is "+ currentPosition);
-          }
-          Map row3 = new HashMap();
-          if (! outOfText){
-              row3.put("text",theContent.substring(currentPosition));
-              row3.put("hasImage","0");
-              brokenUpContent.add(row3);
-          }
-
-      }
-
-
-
-
-
-      ParameterExpander.setValueForKey(
-                                       aValueMap,
-                                       "data.formatted_content",
-                                       new CachingRewindableIterator(brokenUpContent.iterator())
-                                       );
-
-
-    }
-    catch (Throwable t) {
-      aLogger.error("Error while formatting content for PDF: " + t.getMessage());
-      t.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(aLogger, LoggerWrapper.DEBUG_MESSAGE)));
-    }
-  }
-}
-
-
-
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.producer;\r
+\r
+import java.io.PrintWriter;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.*;\r
+\r
+import mir.entity.*;\r
+import mir.entity.EntityList;\r
+import mir.entity.adapter.EntityAdapter;\r
+import mir.log.LoggerToWriterAdapter;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.producer.ProducerFailure;\r
+import mir.producer.ProducerNode;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.HTMLRoutines;\r
+import mir.util.ParameterExpander;\r
+import mircoders.entity.EntityContent;\r
+import mircoders.entity.EntityImages;\r
+import mircoders.storage.*;\r
+\r
+\r
+public class PDFPreFormattingProducerNode implements ProducerNode {\r
+  private String contentKey;\r
+  private int numLinesBetweenImages;\r
+  private float contentAreaWidthCM;\r
+  private float characterWidthCM;\r
+  private float pixelWidthCM;\r
+  private float lineHeightCM;\r
+\r
+  public PDFPreFormattingProducerNode(String aContentKey,String someNumLinesBetweenImages,String aContentAreaWidthCM,String aCharacterWidthCM,String aPixelWidthCM,String aLineHeightCM) {\r
+    contentKey = aContentKey;\r
+    numLinesBetweenImages=(new Integer(someNumLinesBetweenImages)).intValue();\r
+    contentAreaWidthCM=(new Float(aContentAreaWidthCM)).floatValue();\r
+    characterWidthCM=(new Float(aCharacterWidthCM)).floatValue();\r
+    pixelWidthCM=(new Float(aPixelWidthCM)).floatValue();\r
+    lineHeightCM=(new Float(aLineHeightCM)).floatValue();\r
+\r
+    //    float characterWidthCM = 0.17F;\r
+    //float contentAreaWidthCM = 16;\r
+    //float pixelWidthCM = .03F;\r
+    //float lineHeightCM = .5F;\r
+  }\r
+\r
+  public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure {\r
+    Object data;\r
+    Entity entity;\r
+\r
+    try {\r
+      data = ParameterExpander.findValueForKey( aValueMap, contentKey );\r
+\r
+      if (! (data instanceof EntityAdapter)) {\r
+        throw new ProducerFailure("PDFPreFormattingProducerNode: value of '"+contentKey+"' is not an EntityAdapter, but an " + data.getClass().getName(), null);\r
+      }\r
+\r
+      entity = ((EntityAdapter) data).getEntity();\r
+      if (! (entity instanceof EntityContent)) {\r
+        throw new ProducerFailure("PDFPreFormattingProducerNode: value of '"+contentKey+"' is not a content EntityAdapter, but a " + entity.getClass().getName() + " adapter", null);\r
+      }\r
+\r
+      int currentPosition = 0;\r
+\r
+      //int numLinesBetweenImages=3;\r
+\r
+\r
+\r
+\r
+      int numCharsInAnImagelessRow = (new Float(numLinesBetweenImages * (contentAreaWidthCM/characterWidthCM))).intValue();\r
+\r
+      boolean outOfText = false;\r
+\r
+      ArrayList brokenUpContent = new ArrayList();\r
+\r
+      Iterator images = new EntityBrowser(\r
+         DatabaseImages.getInstance(),\r
+          "exists (select * from content_x_media where content_id=" + entity.getId() + " and media_id=id)",\r
+          "id desc", 30, -1, 0);\r
+\r
+      String theContent = ((EntityContent) entity).getValue("content_data");\r
+      //remove pesky characters\r
+      theContent = HTMLRoutines.encodeXML(theContent);\r
+      //put in the <BR> tags so we can turn them to empty blocks\r
+      theContent = StringUtil.convertNewline2Break(theContent);\r
+\r
+      if (images == null){\r
+          Map row = new HashMap();\r
+          row.put("text",theContent);\r
+          row.put("hasImage","0");\r
+          brokenUpContent.add(row);\r
+      }\r
+      if (images != null){\r
+          //need to add checks for out of content!\r
+          Map row0 = new HashMap();\r
+          if (numCharsInAnImagelessRow>(theContent).length()){\r
+              row0.put("text",theContent);\r
+              outOfText = true;\r
+          }\r
+          else {\r
+              //break on words so we don't split html entities\r
+              int lastSpaceAt = theContent.lastIndexOf(" ",numCharsInAnImagelessRow);\r
+              row0.put("text",theContent.substring(0,lastSpaceAt));\r
+              currentPosition=lastSpaceAt;\r
+          }\r
+          row0.put("hasImage","0");\r
+          brokenUpContent.add(row0);\r
+          aLogger.debug("CP1 is "+ currentPosition);\r
+          while(images.hasNext()){\r
+              Map row1 = new HashMap();\r
+              Map row2 = new HashMap();\r
+              EntityImages currentImage=(EntityImages) images.next();\r
+              float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();\r
+              float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();\r
+\r
+              //oversize images must be shrunk\r
+              if (img_width>250){\r
+                  img_height=(new Float((new Float(img_height*(250.0F/img_width))).intValue())).floatValue();\r
+                  img_width=250.0F;\r
+              }\r
+\r
+\r
+              //calculate how much text goes in the column(use 8 pixels to pad the column)\r
+              float text_widthCM = contentAreaWidthCM-((img_width+8)*pixelWidthCM);\r
+              float number_of_lines = img_height*pixelWidthCM/lineHeightCM; //don't worry we will make it an int\r
+              //add one line for image description\r
+              int text_amount= (new Float((text_widthCM/characterWidthCM)*(number_of_lines+1))).intValue();\r
+\r
+              row1.put("text_widthCM",Float.toString(text_widthCM));\r
+\r
+              row1.put("img_title",currentImage.getValue("title"));\r
+\r
+              row1.put("img_width",Float.toString(img_width));\r
+              row1.put("img_height",Float.toString(img_height));\r
+\r
+              aLogger.debug("img_width " +Float.toString(img_width));\r
+              aLogger.debug("img_height "+Float.toString(img_height));\r
+\r
+              row1.put("img_src",currentImage.getValue("publish_path"));\r
+              row1.put("hasImage","1");\r
+              if (! outOfText){\r
+                  try {\r
+                      int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+text_amount);\r
+                      row1.put("text",theContent.substring(currentPosition,lastSpaceAt));\r
+                      currentPosition=lastSpaceAt;\r
+                  }\r
+                  catch (IndexOutOfBoundsException e){\r
+                      row1.put("text",theContent.substring(currentPosition));\r
+                      outOfText = true;\r
+                          }\r
+              }\r
+              aLogger.debug("CP2 is "+ currentPosition);\r
+              brokenUpContent.add(row1);\r
+\r
+              if (! outOfText){\r
+                  try {\r
+                      int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+numCharsInAnImagelessRow);\r
+                      row2.put("text",theContent.substring(currentPosition,lastSpaceAt));\r
+                      currentPosition=lastSpaceAt;\r
+                  }\r
+                  catch (IndexOutOfBoundsException e){\r
+                      row2.put("text",theContent.substring(currentPosition));\r
+                      outOfText = true;\r
+                          }\r
+              }\r
+              row2.put("hasImage","0");\r
+              brokenUpContent.add(row2);\r
+\r
+              aLogger.debug("CP3 is "+ currentPosition);\r
+          }\r
+          Map row3 = new HashMap();\r
+          if (! outOfText){\r
+              row3.put("text",theContent.substring(currentPosition));\r
+              row3.put("hasImage","0");\r
+              brokenUpContent.add(row3);\r
+          }\r
+\r
+      }\r
+\r
+\r
+\r
+\r
+\r
+      ParameterExpander.setValueForKey(\r
+                                       aValueMap,\r
+                                       "data.formatted_content",\r
+                                       new CachingRewindableIterator(brokenUpContent.iterator())\r
+                                       );\r
+\r
+\r
+    }\r
+    catch (Throwable t) {\r
+      aLogger.error("Error while formatting content for PDF: " + t.getMessage());\r
+      t.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(aLogger, LoggerWrapper.DEBUG_MESSAGE)));\r
+    }\r
+  }\r
+}\r
+\r
+\r
+\r
+\r
index 11e2375..5ed322c 100755 (executable)
-/*
- * 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  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 mircoders.servlet;
-
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts.util.MessageResources;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.adapter.EntityIteratorAdapter;
-import mir.generator.Generator;
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import mir.util.CachingRewindableIterator;
-import mir.util.ResourceBundleGeneratorFunction;
-import mircoders.entity.EntityUsers;
-import mircoders.global.MirGlobal;
-
-
-public class ServletHelper {
-  static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper");
-
-
-  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc {
-    return makeGenerationData(aRequest, aResponse, aLocales, "bundles.adminlocal", "bundles.admin");
-  }
-
-  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc {
-    return makeGenerationData(aRequest, aResponse, aLocales, aBundle, aBundle);
-  }
-
-  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc {
-
-    try {
-      Map result = new HashMap();
-
-      MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result);
-
-      // ML: hackish
-      ((Map) result.get("config")).put("actionRoot",
-             aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir"));
-
-      result.put("returnurl", null);
-      result.put("login_user", getUser(aRequest));
-
-      Object languages =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter( "", "id", 30,
-               MirGlobal.localizer().dataModel().adapterModel(), "language"));
-
-      Object topics =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter("", "id", 30,
-               MirGlobal.localizer().dataModel().adapterModel(), "topic"));
-
-      Object articleTypes =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter( "", "id", 30,
-               MirGlobal.localizer().dataModel().adapterModel(), "articleType"));
-
-      Object commentStatuses =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter( "", "id", 30,
-               MirGlobal.localizer().dataModel().adapterModel(), "commentStatus"));
-
-      result.put("commentstatuses", commentStatuses);
-      result.put("articletypes", articleTypes);
-      result.put("languages", languages);
-      result.put("topics", topics);
-
-      result.put( "lang",
-          new ResourceBundleGeneratorFunction( aLocales,
-             new MessageResources[] { MessageResources.getMessageResources(aBundle),
-                MessageResources.getMessageResources(aDefaultBundle)}));
-
-      return result;
-    }
-    catch (Throwable t) {
-      throw new ServletModuleFailure(t);
-    }
-  }
-
-  public static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {
-    Generator generator;
-
-    try {
-      generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator);
-
-      generator.generate(aWriter, aGenerationData, logger);
-    }
-    catch (Throwable t) {
-      throw new ServletModuleFailure(t);
-    }
-  }
-
-  public static void generateOpenPostingResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {
-    Generator generator;
-
-    try {
-      generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator);
-
-      generator.generate(aWriter, aGenerationData, logger);
-    }
-    catch (Throwable t) {
-      throw new ServletModuleFailure(t);
-    }
-  }
-
-  public static void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {
-    try {
-      aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/servlet/Mir?"+aQuery));
-    }
-    catch (Throwable t) {
-      throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);
-    }
-  }
-
-  public static void redirect(HttpServletResponse aResponse, String aModule, String aMethod) throws ServletModuleExc, ServletModuleFailure {
-    redirect(aResponse, "module="+aModule+"&do="+aMethod);
-  }
-
-  public static void setUser(HttpServletRequest aRequest, EntityUsers aUser) {
-    if (aUser!=null)
-      aRequest.getSession().setAttribute("login.uid", aUser);
-    else
-      aRequest.getSession().removeAttribute("login.uid");
-  }
-
-  public static EntityUsers getUser(HttpServletRequest aRequest) {
-    return (EntityUsers) aRequest.getSession().getAttribute("login.uid");
-  }
-  public static String getUserName(HttpServletRequest aRequest) {
-    EntityUsers user = getUser(aRequest);
-
-    if (user!=null)
-      return user.getValue("login");
-    else
-      return "nobody";
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
+import java.io.PrintWriter;\r
+import java.util.HashMap;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.apache.struts.util.MessageResources;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.adapter.*;\r
+import mir.generator.Generator;\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.ResourceBundleGeneratorFunction;\r
+import mircoders.entity.EntityUsers;\r
+import mircoders.global.MirGlobal;\r
+\r
+\r
+public class ServletHelper {\r
+  static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper");\r
+\r
+\r
+  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc {\r
+    return makeGenerationData(aRequest, aResponse, aLocales, "bundles.adminlocal", "bundles.admin");\r
+  }\r
+\r
+  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc {\r
+    return makeGenerationData(aRequest, aResponse, aLocales, aBundle, aBundle);\r
+  }\r
+\r
+  public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc {\r
+\r
+    try {\r
+      Map result = new HashMap();\r
+\r
+      MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result);\r
+\r
+      // ML: hackish\r
+      ((Map) result.get("config")).put("actionRoot",\r
+             aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir"));\r
+\r
+      result.put("returnurl", null);\r
+      result.put("login_user", getUserAdapter(aRequest));\r
+\r
+      Object languages =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter( "", "id", 30,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "language"));\r
+\r
+      Object topics =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter("", "id", 30,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "topic"));\r
+\r
+      Object articleTypes =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter( "", "id", 30,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "articleType"));\r
+\r
+      Object commentStatuses =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter( "", "id", 30,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "commentStatus"));\r
+\r
+      result.put("commentstatuses", commentStatuses);\r
+      result.put("articletypes", articleTypes);\r
+      result.put("languages", languages);\r
+      result.put("topics", topics);\r
+\r
+      result.put( "lang",\r
+          new ResourceBundleGeneratorFunction( aLocales,\r
+             new MessageResources[] { MessageResources.getMessageResources(aBundle),\r
+                MessageResources.getMessageResources(aDefaultBundle)}));\r
+\r
+      return result;\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  }\r
+\r
+  public static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {\r
+    logger.debug("generator used: " + aGenerator);\r
+\r
+    Generator generator;\r
+\r
+    try {\r
+      generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator);\r
+\r
+      generator.generate(aWriter, aGenerationData, logger);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  }\r
+\r
+  public static void generateOpenPostingResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc {\r
+    Generator generator;\r
+\r
+    try {\r
+      generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator);\r
+\r
+      generator.generate(aWriter, aGenerationData, logger);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  }\r
+\r
+  public static void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {\r
+    try {\r
+      aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/servlet/Mir?"+aQuery));\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);\r
+    }\r
+  }\r
+\r
+  public static void redirect(HttpServletResponse aResponse, String aModule, String aMethod) throws ServletModuleExc, ServletModuleFailure {\r
+    redirect(aResponse, "module="+aModule+"&do="+aMethod);\r
+  }\r
+\r
+  public static void setUser(HttpServletRequest aRequest, EntityUsers aUser) {\r
+    if (aUser!=null)\r
+      aRequest.getSession().setAttribute("login.uid", aUser);\r
+    else\r
+      aRequest.getSession().removeAttribute("login.uid");\r
+  }\r
+\r
+  public static EntityUsers getUser(HttpServletRequest aRequest) {\r
+    return (EntityUsers) aRequest.getSession().getAttribute("login.uid");\r
+  }\r
+\r
+  public static EntityAdapter getUserAdapter(HttpServletRequest aRequest) {\r
+    try {\r
+      return MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter( "user", (EntityUsers) aRequest.getSession().getAttribute("login.uid"));\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure (t);\r
+    }\r
+  }\r
+\r
+  public static String getUserName(HttpServletRequest aRequest) {\r
+    EntityUsers user = getUser(aRequest);\r
+\r
+    if (user!=null)\r
+      return user.getValue("login");\r
+    else\r
+      return "nobody";\r
+  }\r
+}\r
index f7534b6..ec85a08 100755 (executable)
-/*
- * 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  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 mircoders.servlet;
-
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleFailure;
-import mir.util.URLBuilder;
-
-public class ServletModuleAdmin extends ServletModule
-{
-  private static ServletModuleAdmin instance = new ServletModuleAdmin();
-  public static ServletModule getInstance() { return instance; }
-
-  private ServletModuleAdmin() {
-    logger = new LoggerWrapper("ServletModule.Admin");
-    defaultAction = "showSuperUserMenu";
-  }
-
-  public void superusermenu(HttpServletRequest aRequest, HttpServletResponse aResponse) {
-    URLBuilder urlBuilder = new URLBuilder();
-    int count;
-
-    try {
-      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
-      urlBuilder.setValue("module", "Admin");
-      urlBuilder.setValue("do", "superusermenu");
-
-      responseData.put("thisurl" , urlBuilder.getQuery());
-
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, "superusermenu.template");
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.entity.adapter.EntityIteratorAdapter;\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.URLBuilder;\r
+import mircoders.global.MirGlobal;\r
+\r
+public class ServletModuleAdmin extends ServletModule\r
+{\r
+  private static ServletModuleAdmin instance = new ServletModuleAdmin();\r
+  public static ServletModule getInstance() { return instance; }\r
+\r
+  private ServletModuleAdmin() {\r
+    logger = new LoggerWrapper("ServletModule.Admin");\r
+    defaultAction = "start";\r
+  }\r
+\r
+  public void superusermenu(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+    URLBuilder urlBuilder = new URLBuilder();\r
+    int count;\r
+\r
+    try {\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+      urlBuilder.setValue("module", "Admin");\r
+      urlBuilder.setValue("do", "superusermenu");\r
+\r
+      responseData.put("thisurl" , urlBuilder.getQuery());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, "superusermenu.template");\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void start(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+    String startTemplate = configuration.getString("Mir.StartTemplate");\r
+    String sessionUrl = aResponse.encodeURL("");\r
+\r
+    try {\r
+      Map mergeData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}\r
+          , "bundles.admin", "bundles.adminlocal");\r
+      mergeData.put("messages",\r
+                    new CachingRewindableIterator(\r
+          new EntityIteratorAdapter("", "webdb_create desc", 10,\r
+                                    MirGlobal.localizer().dataModel().adapterModel(), "internalMessage", 10, 0)));\r
+\r
+      mergeData.put("fileeditentries", ( (ServletModuleFileEdit) ServletModuleFileEdit.getInstance()).getEntries());\r
+      mergeData.put("administeroperations", ( (ServletModuleLocalizer) ServletModuleLocalizer.getInstance()).getAdministerOperations());\r
+\r
+      mergeData.put("searchvalue", null);\r
+      mergeData.put("searchfield", null);\r
+      mergeData.put("searchispublished", null);\r
+      mergeData.put("searcharticletype", null);\r
+      mergeData.put("searchorder", null);\r
+      mergeData.put("selectarticleurl", null);\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), mergeData, startTemplate);\r
+    }\r
+    catch (Exception e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+}\r
index 826d4f8..63de8b3 100755 (executable)
@@ -1,56 +1,64 @@
-/*
- * 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  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 mircoders.servlet;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModule;
-import mircoders.module.ModuleArticleType;
-import mircoders.storage.DatabaseArticleType;
-
-public class ServletModuleArticleType extends ServletModule
-{
-  private static ServletModuleArticleType instance = new ServletModuleArticleType();
-  public static ServletModule getInstance() { return instance; }
-
-  private ServletModuleArticleType() {
-    logger = new LoggerWrapper("ServletModule.ArticleType");
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-      templateListString = configuration.getString("ServletModule.ArticleType.ListTemplate");
-      templateObjektString = configuration.getString("ServletModule.ArticleType.EditTemplate");
-      templateConfirmString = configuration.getString("ServletModule.ArticleType.ConfirmTemplate");
-      mainModule = new ModuleArticleType(DatabaseArticleType.getInstance());
-    }
-    catch (Exception e) {
-      logger.error("Initialization of ServletModuleArticleType failed!: " + e.getMessage());
-    }
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleArticleType;\r
+import mircoders.storage.DatabaseArticleType;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+public class ServletModuleArticleType extends ServletModule\r
+{\r
+  private static ServletModuleArticleType instance = new ServletModuleArticleType();\r
+  public static ServletModule getInstance() { return instance; }\r
+\r
+  private ServletModuleArticleType() {\r
+    logger = new LoggerWrapper("ServletModule.ArticleType");\r
+\r
+    try {\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+      definition = "articleType";\r
+      mainModule = new ModuleArticleType(DatabaseArticleType.getInstance());\r
+    }\r
+    catch (Exception e) {\r
+      logger.error("Initialization of ServletModuleArticleType failed!: " + e.getMessage());\r
+    }\r
+  }\r
+}\r
index 43262ad..a35f177 100755 (executable)
@@ -34,6 +34,7 @@ import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
 import mircoders.module.ModuleUploadedMedia;
 import mircoders.storage.DatabaseAudio;
+import mircoders.global.*;
 
 /*
  *
@@ -42,10 +43,6 @@ import mircoders.storage.DatabaseAudio;
  */
 
 public class ServletModuleAudio extends ServletModuleUploadedMedia {
-
-  //private static DatabaseRights dbRights;
-
-  // Singelton / Contructor
   private static ServletModuleAudio instance = new ServletModuleAudio();
 
   public static ServletModule getInstance() {
@@ -55,18 +52,14 @@ public class ServletModuleAudio extends ServletModuleUploadedMedia {
   private ServletModuleAudio() {
     logger = new LoggerWrapper("ServletModule.Audio");
 
-    entityName = "audio";
     moduleName = "Audio";
 
     try {
-      configuration = MirPropertiesConfiguration.instance();
-      templateListString = configuration.getString("ServletModule.Audio.ListTemplate");
-      templateObjektString = configuration.getString("ServletModule.Audio.ObjektTemplate");
-      templateConfirmString = configuration.getString("ServletModule.Audio.ConfirmTemplate");
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "audio";
       mainModule = new ModuleUploadedMedia(DatabaseAudio.getInstance());
-      //dbRights = DatabaseRights.getInstance();
     }
-    catch (Exception e) {
+    catch (Throwable e) {
       logger.error("servletmodule audio could not be initialized: " + e.getMessage());
     }
   }
index 536d6da..ca65981 100755 (executable)
-/*
- * 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  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 mircoders.servlet;
-
-import java.net.URLEncoder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.misc.HTMLTemplateProcessor;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleFailure;
-import mircoders.module.ModuleBreaking;
-import mircoders.storage.DatabaseBreaking;
-import freemarker.template.SimpleHash;
-
-/*
- *  ServletModuleBreaking -
- *  Authentified Navigation for Breaking News
- *
- *
- */
-
-public class ServletModuleBreaking extends ServletModule
-{
-
-// Singelton / Kontruktor
-
-  private static ServletModuleBreaking instance = new ServletModuleBreaking();
-  public static ServletModule getInstance() { return instance; }
-
-  private ServletModuleBreaking() {
-    logger = new LoggerWrapper("ServletModule.Breaking");
-    try {
-                        configuration = MirPropertiesConfiguration.instance();
-
-      templateListString = configuration.getString("ServletModule.Breaking.ListTemplate");
-      templateObjektString = configuration.getString("ServletModule.Breaking.ObjektTemplate");
-      templateConfirmString = configuration.getString("ServletModule.Breaking.ConfirmTemplate");
-
-      DatabaseBreaking dbb = DatabaseBreaking.getInstance();
-      mainModule = new ModuleBreaking(dbb);
-    }
-    catch (Exception e) {
-      logger.error("Initialisation of ServletModuleBreaking failed!: " + e.getMessage());
-    }
-  }
-
-  public void list(HttpServletRequest req, HttpServletResponse res)
-  {
-    logger.debug("-- breaking: list");
-// fetch and deliver
-    try {
-      SimpleHash mergeData = new SimpleHash();
-      String offset = req.getParameter("offset");
-      if (offset==null || offset.equals("")) offset="0";
-      mergeData.put("offset",offset);
-      EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue());
-      mergeData.put("contentlist",theList);
-      if(theList.getOrder()!=null) {
-        mergeData.put("order", theList.getOrder());
-        mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
-      }
-      mergeData.put("count", (new Integer(theList.getCount())).toString());
-      mergeData.put("from", (new Integer(theList.getFrom())).toString());
-      mergeData.put("to", (new Integer(theList.getTo())).toString());
-      if (theList.hasNextBatch())
-        mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
-      if (theList.hasPrevBatch())
-        mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
-
-// raus damit
-      HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req), getFallbackLocale(req));
-    }
-    catch (Exception e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.servlet;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleBreaking;\r
+import mircoders.storage.DatabaseBreaking;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+\r
+public class ServletModuleBreaking extends ServletModule\r
+{\r
+  private static ServletModuleBreaking instance = new ServletModuleBreaking();\r
+  public static ServletModule getInstance() { return instance; }\r
+\r
+  private ServletModuleBreaking() {\r
+    logger = new LoggerWrapper("ServletModule.Breaking");\r
+\r
+    try {\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+      definition = "breakingNews";\r
+      mainModule = new ModuleBreaking(DatabaseBreaking.getInstance());\r
+    }\r
+    catch (Exception e) {\r
+      logger.error("Initialisation of ServletModuleBreaking failed!: " + e.getMessage());\r
+    }\r
+  }\r
+}\r
index 2c74318..251c37c 100755 (executable)
@@ -75,11 +75,6 @@ public class ServletModuleComment extends ServletModule
   private ServletModuleComment() {\r
     logger = new LoggerWrapper("ServletModule.Comment");\r
     try {\r
-      configuration = MirPropertiesConfiguration.instance();\r
-      templateListString = configuration.getString("ServletModule.Comment.ListTemplate");\r
-      templateObjektString = configuration.getString("ServletModule.Comment.ObjektTemplate");\r
-      templateConfirmString = configuration.getString("ServletModule.Comment.ConfirmTemplate");\r
-\r
       mainModule = new ModuleComment(DatabaseComment.getInstance());\r
       moduleContent = new ModuleContent(DatabaseContent.getInstance());\r
     }\r
@@ -140,7 +135,7 @@ public class ServletModuleComment extends ServletModule
       responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
       responseData.put("thisurl", urlBuilder.getQuery());\r
 \r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateObjektString);\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
@@ -261,7 +256,6 @@ public class ServletModuleComment extends ServletModule
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
     URLBuilder urlBuilder = new URLBuilder();\r
     EntityAdapterModel model;\r
-    int nrCommentsPerPage = 20;\r
     int count;\r
 \r
     try {\r
@@ -270,8 +264,8 @@ public class ServletModuleComment extends ServletModule
 \r
       Object commentList =\r
           new CachingRewindableIterator(\r
-            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrCommentsPerPage,\r
-              MirGlobal.localizer().dataModel().adapterModel(), "comment", nrCommentsPerPage, anOffset)\r
+            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrEntitiesPerListPage,\r
+              MirGlobal.localizer().dataModel().adapterModel(), "comment", nrEntitiesPerListPage, anOffset)\r
       );\r
 \r
       responseData.put("nexturl", null);\r
@@ -300,22 +294,22 @@ public class ServletModuleComment extends ServletModule
       responseData.put("offset" , new Integer(anOffset).toString());\r
       responseData.put("thisurl" , urlBuilder.getQuery());\r
 \r
-      if (count>=anOffset+nrCommentsPerPage) {\r
-        urlBuilder.setValue("offset", anOffset + nrCommentsPerPage);\r
+      if (count>=anOffset+nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", anOffset + nrEntitiesPerListPage);\r
         responseData.put("nexturl" , urlBuilder.getQuery());\r
       }\r
 \r
       if (anOffset>0) {\r
-        urlBuilder.setValue("offset", Math.max(anOffset - nrCommentsPerPage, 0));\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
         responseData.put("prevurl" , urlBuilder.getQuery());\r
       }\r
 \r
       responseData.put("comments", commentList);\r
       responseData.put("from" , Integer.toString(anOffset+1));\r
       responseData.put("count", Integer.toString(count));\r
-      responseData.put("to", Integer.toString(Math.min(anOffset+nrCommentsPerPage, count)));\r
+      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));\r
 \r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, "commentlist.template");\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
index 2f13787..7696fee 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.servlet;
@@ -34,6 +34,8 @@ import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
 import mircoders.module.ModuleCommentStatus;
 import mircoders.storage.DatabaseCommentStatus;
+import mircoders.global.*;
+
 
 public class ServletModuleCommentStatus extends ServletModule
 {
@@ -44,13 +46,11 @@ public class ServletModuleCommentStatus extends ServletModule
     logger = new LoggerWrapper("ServletModule.CommentStatus");
 
     try {
-      configuration = MirPropertiesConfiguration.instance();
-      templateListString = configuration.getString("ServletModule.CommentStatus.ListTemplate");
-      templateObjektString = configuration.getString("ServletModule.CommentStatus.EditTemplate");
-      templateConfirmString = configuration.getString("ServletModule.CommentStatus.ConfirmTemplate");
-
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "commentStatus";
       mainModule = new ModuleCommentStatus(DatabaseCommentStatus.getInstance());
-    } catch (Exception e) {
+    }
+    catch (Throwable e) {
       logger.error("Initialization of ServletModuleCommentStatus failed!: " + e.getMessage());
     }
   }
index 4f423d4..87506c0 100755 (executable)
@@ -36,15 +36,8 @@ import java.util.Iterator;
 import java.util.List;\r
 import java.util.Locale;\r
 import java.util.Map;\r
-\r
 import javax.servlet.http.HttpServletRequest;\r
 import javax.servlet.http.HttpServletResponse;\r
-import javax.servlet.http.HttpSession;\r
-\r
-import org.apache.lucene.index.IndexReader;\r
-\r
-import freemarker.template.SimpleHash;\r
-\r
 \r
 import mir.entity.adapter.EntityAdapterModel;\r
 import mir.entity.adapter.EntityIteratorAdapter;\r
@@ -58,44 +51,32 @@ import mir.util.HTTPRequestParser;
 import mir.util.JDBCStringRoutines;\r
 import mir.util.SQLQueryBuilder;\r
 import mir.util.URLBuilder;\r
-\r
-import mircoders.global.*;\r
 import mircoders.entity.EntityContent;\r
-import mircoders.entity.EntityUsers;\r
 import mircoders.global.MirGlobal;\r
 import mircoders.module.ModuleContent;\r
-import mircoders.search.IndexUtil;\r
-import mircoders.storage.DatabaseComment;\r
 import mircoders.storage.DatabaseContent;\r
-import mircoders.storage.DatabaseContentToMedia;\r
 import mircoders.storage.DatabaseContentToTopics;\r
 \r
 /*\r
  *  ServletModuleContent -\r
  *  deliver html for the article admin form.\r
  *\r
- * @version $Id: ServletModuleContent.java,v 1.52.2.5 2003/08/13 02:43:56 zapata Exp $\r
+ * @version $Id: ServletModuleContent.java,v 1.52.2.6 2003/09/03 17:49:40 zapata Exp $\r
  * @author rk, mir-coders\r
  *\r
  */\r
 \r
 public class ServletModuleContent extends ServletModule\r
 {\r
-  private String editTemplate = configuration.getString("ServletModule.Content.ObjektTemplate");;\r
-  private String listTemplate = configuration.getString("ServletModule.Content.ListTemplate");\r
-\r
   private static ServletModuleContent instance = new ServletModuleContent();\r
   public static ServletModule getInstance() { return instance; }\r
 \r
   private ServletModuleContent() {\r
     super();\r
-    logger = new LoggerWrapper("ServletModule.Content");\r
-    try {\r
 \r
-      templateListString = configuration.getString("ServletModule.Content.ListTemplate");\r
-      templateObjektString = configuration.getString("ServletModule.Content.ObjektTemplate");\r
-      templateConfirmString = configuration.getString("ServletModule.Content.ConfirmTemplate");\r
+    logger = new LoggerWrapper("ServletModule.Content");\r
 \r
+    try {\r
       mainModule = new ModuleContent(DatabaseContent.getInstance());\r
     }\r
     catch (Throwable e) {\r
@@ -282,7 +263,7 @@ public class ServletModuleContent extends ServletModule
       String id = mainModule.set(withValues);\r
       DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"), aRequest.getParameterValues("to_topic"));\r
 \r
-      if (returnUrl!=null){\r
+      if (returnUrl!=null && !returnUrl.equals("")){\r
         redirect(aResponse, returnUrl);\r
       }\r
       else\r
@@ -345,7 +326,7 @@ public class ServletModuleContent extends ServletModule
       responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
       responseData.put("thisurl", urlBuilder.getQuery());\r
 \r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
@@ -363,7 +344,6 @@ public class ServletModuleContent extends ServletModule
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
     URLBuilder urlBuilder = new URLBuilder();\r
     EntityAdapterModel model;\r
-    int nrArticlesPerPage = 20;\r
     int count;\r
 \r
     try {\r
@@ -372,8 +352,8 @@ public class ServletModuleContent extends ServletModule
 \r
       Object articleList =\r
           new CachingRewindableIterator(\r
-            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage,\r
-               MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset)\r
+            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrEntitiesPerListPage,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "content", nrEntitiesPerListPage, anOffset)\r
       );\r
 \r
       responseData.put("nexturl", null);\r
@@ -405,13 +385,13 @@ public class ServletModuleContent extends ServletModule
       responseData.put("offset" , new Integer(anOffset).toString());\r
       responseData.put("thisurl" , urlBuilder.getQuery());\r
 \r
-      if (count>=anOffset+nrArticlesPerPage) {\r
-        urlBuilder.setValue("offset", (anOffset + nrArticlesPerPage));\r
+      if (count>=anOffset+nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", (anOffset + nrEntitiesPerListPage));\r
         responseData.put("nexturl" , urlBuilder.getQuery());\r
       }\r
 \r
       if (anOffset>0) {\r
-        urlBuilder.setValue("offset", Math.max(anOffset - nrArticlesPerPage, 0));\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
         responseData.put("prevurl" , urlBuilder.getQuery());\r
       }\r
 \r
@@ -419,12 +399,12 @@ public class ServletModuleContent extends ServletModule
 \r
       responseData.put("from" , Integer.toString(anOffset+1));\r
       responseData.put("count", Integer.toString(count));\r
-      responseData.put("to", Integer.toString(Math.min(anOffset+nrArticlesPerPage, count)));\r
+      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));\r
       responseData.put("offset" , Integer.toString(anOffset));\r
       responseData.put("order", anOrderByClause);\r
       responseData.put("where" , aWhereClause);\r
 \r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
     }\r
     catch (Throwable e) {\r
       throw new ServletModuleFailure(e);\r
index 87803e3..99f4d62 100755 (executable)
@@ -59,7 +59,7 @@ import mir.util.URLBuilder;
  *  in the config file.
  *
  * @author $Author: zapata $
- * @version $Revision: 1.13.2.1 $ $Date: 2003/06/19 02:24:13 $
+ * @version $Revision: 1.13.2.2 $ $Date: 2003/09/03 17:49:40 $
  *
  */
 
@@ -137,10 +137,6 @@ public class ServletModuleFileEdit extends ServletModule
     }
 
     dirFilter = new FileFunctions.DirectoryFilter();
-
-    templateListString =configuration.getString("ServletModule.FileEdit.ListTemplate");
-    templateObjektString =configuration.getString("ServletModule.FileEdit.ObjektTemplate");
-    templateConfirmString =configuration.getString("ServletModule.FileEdit.ConfirmTemplate");
   }
 
   public List getEntries() {
@@ -255,7 +251,7 @@ public class ServletModuleFileEdit extends ServletModule
       responseData.put("subdirectory", aSubDirectory);
       responseData.put("entry", aDirectory.getName());
 
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateListString);
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);
     }
     catch (Throwable e) {
       throw new ServletModuleFailure(e);
@@ -295,7 +291,7 @@ public class ServletModuleFileEdit extends ServletModule
         responseData.put("subdirectory", aSubDirectory);
         responseData.put("returnurl", urlBuilder.getQuery());
 
-        ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateObjektString);
+        ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);
       }
     }
     catch (Throwable e) {
index b563571..6ae6d20 100755 (executable)
  */
 package mircoders.servlet;
 
-import java.util.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.entity.EntityList;
-import mir.entity.adapter.*;
-import mir.log.LoggerWrapper;
-import mir.misc.HTMLTemplateProcessor;
-import mir.util.*;
-import mir.servlet.*;
-import mir.servlet.ServletModuleFailure;
-import mir.storage.StorageObjectFailure;
-import mircoders.module.ModuleContent;
+import java.util.Iterator;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.entity.adapter.EntityIteratorAdapter;\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.storage.StorageObjectFailure;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.HTTPRequestParser;\r
+import mir.util.JDBCStringRoutines;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleContent;\r
 import mircoders.storage.DatabaseContent;
-import mircoders.global.*;
 
 /*
  *  ServletModuleHidden - output of so called "censored" articles
@@ -62,7 +64,6 @@ public class ServletModuleHidden extends ServletModule
     super();
 
     logger = new LoggerWrapper("ServletModule.Hidden");
-    templateListString = configuration.getString("ServletModule.Hidden.ListTemplate");
 
     try {
       mainModule = new ModuleContent(DatabaseContent.getInstance());
@@ -98,7 +99,7 @@ public class ServletModuleHidden extends ServletModule
         responseData.put("articles", articleList);
       }
 
-      ServletHelper.generateResponse(res.getWriter(), responseData, templateListString);
+      ServletHelper.generateResponse(res.getWriter(), responseData, listGenerator);
     }
     catch (Throwable e) {
       throw new ServletModuleFailure(e);
index 70e5b84..2364264 100755 (executable)
@@ -34,11 +34,12 @@ import mir.servlet.ServletModule;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleImages;
 import mircoders.storage.DatabaseImages;
+import mircoders.global.*;
 
 /*
  *  ServletModuleImages -
  *
- * @version $Id: ServletModuleImages.java,v 1.26.2.1 2003/08/13 02:43:56 zapata Exp $
+ * @version $Id: ServletModuleImages.java,v 1.26.2.2 2003/09/03 17:49:40 zapata Exp $
  * @author RK, the mir-coders group
  */
 
@@ -52,16 +53,14 @@ public class ServletModuleImages extends ServletModuleUploadedMedia
   private ServletModuleImages() {
     super();
     logger = new LoggerWrapper("ServletModule.Images");
-    entityName = "image";
     moduleName = "Images";
-    templateListString = configuration.getString("ServletModule.Images.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Images.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Images.ConfirmTemplate");
 
     try {
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "image";
       mainModule = new ModuleImages(DatabaseImages.getInstance());
     }
-    catch (StorageObjectFailure e) {
+    catch (Throwable e) {
       logger.error("Initialization of ServletModuleImages failed!: " + e.getMessage());
     }
   }
index 724d73f..d6526cd 100755 (executable)
  * 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  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.  
+ * the code of this program with  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 mircoders.servlet;
@@ -34,6 +34,7 @@ import mir.servlet.ServletModule;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleLanguage;
 import mircoders.storage.DatabaseLanguage;
+import mircoders.global.*;
 
 /*
  *  ServletModuleLanguage -
@@ -52,14 +53,12 @@ public class ServletModuleLanguage extends ServletModule
     super();
     logger = new LoggerWrapper("ServletModule.Language");
 
-    templateListString = configuration.getString("ServletModule.Language.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Language.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Language.ConfirmTemplate");
-
     try {
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "language";
       mainModule = new ModuleLanguage(DatabaseLanguage.getInstance());
     }
-    catch (StorageObjectFailure e) {
+    catch (Throwable e) {
       logger.error("Initialization of ServletModuleLanguage failed: " + e.getMessage());
     }
   }
index ac35350..bb33dd2 100755 (executable)
@@ -1,85 +1,68 @@
-/*
- * 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  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 mircoders.servlet;
-
-/**
- * Title:        Mir
- * Description:
- * @author       rk
- * @version      02
- */
-
-import java.util.GregorianCalendar;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.servlet.ServletModule;
-import mir.storage.StorageObjectFailure;
-import mircoders.module.ModuleMediafolder;
-import mircoders.storage.DatabaseMediafolder;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
-
-
-public class ServletModuleMediafolder extends ServletModule
-{
-  public static ServletModule getInstance() { return instance; }
-  private static ServletModuleMediafolder instance = new ServletModuleMediafolder();
-
-  private ServletModuleMediafolder() {
-    super();
-    logger = new LoggerWrapper("ServletModule.Mediafolder");
-
-    templateListString = configuration.getString("ServletModule.Mediafolder.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Mediafolder.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Mediafolder.ConfirmTemplate");
-
-    try {
-      mainModule = new ModuleMediafolder(DatabaseMediafolder.getInstance());
-    }
-    catch (StorageObjectFailure e) {
-      logger.error("Failed to initialize ServletModuleMediafolder: " + e.getMessage());
-    }
-  }
-
-  public void add(HttpServletRequest req, HttpServletResponse res)
-  {
-    SimpleHash mergeData = new SimpleHash();
-    mergeData.put("new", "1");
-    String now = StringUtil.date2webdbDate(new GregorianCalendar());
-// date auf now
-    mergeData.put("date", new SimpleScalar(now));
-    deliver(req, res, mergeData, templateObjektString);
-  }
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
+/**\r
+ *\r
+ */\r
+\r
+import java.util.GregorianCalendar;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.servlet.ServletModule;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.module.ModuleMediafolder;\r
+import mircoders.storage.DatabaseMediafolder;\r
+\r
+public class ServletModuleMediafolder extends ServletModule\r
+{\r
+  public static ServletModule getInstance() { return instance; }\r
+  private static ServletModuleMediafolder instance = new ServletModuleMediafolder();\r
+\r
+  private ServletModuleMediafolder() {\r
+    super();\r
+    logger = new LoggerWrapper("ServletModule.Mediafolder");\r
+\r
+    try {\r
+      mainModule = new ModuleMediafolder(DatabaseMediafolder.getInstance());\r
+    }\r
+    catch (StorageObjectFailure e) {\r
+      logger.error("Failed to initialize ServletModuleMediafolder: " + e.getMessage());\r
+    }\r
+  }\r
+\r
+  protected void initializeNewObject(Map aNewObject, HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+    aNewObject.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));\r
+  }\r
 }
\ No newline at end of file
index efd1e6b..a8ec504 100755 (executable)
-/*
- * 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  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 mircoders.servlet;
-
-import java.net.URLEncoder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.misc.HTMLTemplateProcessor;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import mir.storage.StorageObjectFailure;
-import mircoders.module.ModuleMessage;
-import mircoders.storage.DatabaseMessages;
-import freemarker.template.SimpleHash;
-
-/**
- * Title:       ServletModuleMessage
- * Description:
- * Copyright:   Copyright (c) 2001-2002
- * Company:     mir-coders
- * @author
- * @version 1.0
- */
-
-
-public class ServletModuleMessage extends ServletModule
-{
-
-  // Singelton / Kontruktor
-
-  private static ServletModuleMessage instance = new ServletModuleMessage();
-  public static ServletModule getInstance() { return instance; }
-
-  private ServletModuleMessage() {
-    super();
-    logger = new LoggerWrapper("ServletModule.Messages");
-
-    templateListString = configuration.getString("ServletModule.Messages.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Messages.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Messages.ConfirmTemplate");
-
-    try {
-      mainModule = new ModuleMessage(DatabaseMessages.getInstance());
-    }
-    catch (StorageObjectFailure e) {
-      logger.error("initialization of ServletModuleMessage failed!: " + e.getMessage());
-
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
-  {
-// fetch and deliver
-    try {
-      SimpleHash mergeData = new SimpleHash();
-      String offset = req.getParameter("offset");
-      if (offset==null || offset.equals("")) offset="0";
-      mergeData.put("offset",offset);
-      EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue());
-      mergeData.put("contentlist",theList);
-      if(theList.getOrder()!=null) {
-        mergeData.put("order", theList.getOrder());
-        mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
-      }
-      mergeData.put("count", (new Integer(theList.getCount())).toString());
-      mergeData.put("from", (new Integer(theList.getFrom())).toString());
-      mergeData.put("to", (new Integer(theList.getTo())).toString());
-      if (theList.hasNextBatch())
-        mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
-      if (theList.hasPrevBatch())
-        mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
-
-      HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req), getFallbackLocale(req));
-
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleFailure;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleMessage;\r
+import mircoders.storage.DatabaseMessages;\r
+\r
+/**\r
+ * Title:       ServletModuleMessage\r
+ * Description:\r
+ * Copyright:   Copyright (c) 2001-2002\r
+ * Company:     mir-coders\r
+ * @author\r
+ * @version 1.0\r
+ */\r
+\r
+\r
+public class ServletModuleMessage extends ServletModule\r
+{\r
+  private static ServletModuleMessage instance = new ServletModuleMessage();\r
+  public static ServletModule getInstance() { return instance; }\r
+\r
+  private ServletModuleMessage() {\r
+    super();\r
+    logger = new LoggerWrapper("ServletModule.Messages");\r
+\r
+    try {\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+      definition = "internalMessage";\r
+      mainModule = new ModuleMessage(DatabaseMessages.getInstance());\r
+    }\r
+    catch (Throwable e) {\r
+      logger.error("initialization of ServletModuleMessage failed!: " + e.getMessage());\r
+\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  protected void initializeNewObject(Map aNewObject, HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+    aNewObject.put("creator", ServletHelper.getUserName(aRequest));\r
+  }\r
+}\r
index 5b21ad4..c75380a 100755 (executable)
@@ -120,7 +120,7 @@ import mircoders.storage.DatabaseTopics;
  *    open-postings to the newswire
  *
  * @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.6 2003/06/30 16:13:24 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.7 2003/09/03 17:49:40 zapata Exp $
  *
  */
 
@@ -354,7 +354,7 @@ public class ServletModuleOpenIndy extends ServletModule
 
       Map extraInfo = new HashMap();
       extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData());
-      extraInfo.put("themenPopupData", topicsModule.getTopicsAsSimpleList());
+      extraInfo.put("themenPopupData", DatabaseTopics.getInstance().getPopupData());
 
       extraInfo.put("topics", topicsModule.getTopicsList());
       deliver(req, res, mergeData, extraInfo, postingFormTemplate);
@@ -773,7 +773,7 @@ public class ServletModuleOpenIndy extends ServletModule
       }
 
       try {
-        mergeData.put("topics", topicsModule.getTopicsAsSimpleList());
+        mergeData.put("topics", DatabaseTopics.getInstance().getPopupData());
       }
       catch (Throwable e) {
         logger.debug("Can't get topics: " + e.toString());
index d42d748..0940696 100755 (executable)
@@ -35,6 +35,7 @@ import mir.servlet.ServletModule;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleUploadedMedia;
 import mircoders.storage.DatabaseOther;
+import mircoders.global.*;
 
 /**
  *
@@ -56,16 +57,14 @@ public class ServletModuleOtherMedia extends ServletModuleUploadedMedia {
   private ServletModuleOtherMedia() {
     super();
     logger = new LoggerWrapper("ServletModule.OtherMedia");
-    entityName = "otherMedia";
     moduleName = "OtherMedia";
 
-    templateListString = configuration.getString("ServletModule.OtherMedia.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.OtherMedia.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.OtherMedia.ConfirmTemplate");
     try {
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "otherMedia";
       mainModule = new ModuleUploadedMedia(DatabaseOther.getInstance());
     }
-    catch (StorageObjectFailure e) {
+    catch (Throwable e) {
       logger.error("servletmodule otherMedia could not be initialized: " + e.getMessage());
     }
   }
index d2a3916..63fdd7c 100755 (executable)
  * 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  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.  
+ * the code of this program with  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.
  */
 
@@ -35,18 +35,20 @@ import mir.servlet.ServletModule;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleTopics;
 import mircoders.storage.DatabaseTopics;
+import mircoders.global.*;
 
-/*
- *  ServletModuleTopics
- *
+/**
  *
- *
- * @author RK
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
  */
 
 public class ServletModuleTopics extends ServletModule
 {
-// Singelton / Constructor
   private static ServletModuleTopics instance = new ServletModuleTopics();
   public static ServletModule getInstance() { return instance; }
 
@@ -54,14 +56,12 @@ public class ServletModuleTopics extends ServletModule
     super();
     logger = new LoggerWrapper("ServletModule.Topics");
 
-    templateListString = configuration.getString("ServletModule.Themen.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Themen.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Themen.ConfirmTemplate");
-
     try {
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "topic";
       mainModule = new ModuleTopics(DatabaseTopics.getInstance());
     }
-    catch (StorageObjectFailure e) {
+    catch (Throwable e) {
       logger.error("Initialization of ServletModuleTopics failed!: " + e.getMessage());
     }
   }
index 556d18c..6dddfa7 100755 (executable)
@@ -83,8 +83,6 @@ import mircoders.storage.DatabaseContent;
  */\r
 \r
 public abstract class ServletModuleUploadedMedia extends ServletModule {\r
-  protected int nrMediaPerPage = 20;\r
-  protected String entityName = "uploadedMedia";\r
   protected String moduleName = "UploadedMedia";\r
 \r
   public static ServletModule getInstance() {\r
@@ -94,7 +92,14 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
   public ServletModuleUploadedMedia() {\r
     super();\r
 \r
+    definition = "uploadedMedia";\r
     logger = new LoggerWrapper("ServletModule.UploadedMedia");\r
+    try {\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
   }\r
 \r
   public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
@@ -231,7 +236,7 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
       responseData.put("medialist", aList);\r
 \r
       addExtraData(responseData);\r
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateListString);\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
     }\r
     catch (Throwable t) {\r
       throw new ServletModuleFailure(t);\r
@@ -255,8 +260,8 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
 \r
       Object mediaList =\r
           new CachingRewindableIterator(\r
-          new EntityIteratorAdapter(aWhereClause, anOrderByClause, nrMediaPerPage,\r
-                   MirGlobal.localizer().dataModel().adapterModel(), entityName, nrMediaPerPage, anOffset)\r
+          new EntityIteratorAdapter(aWhereClause, anOrderByClause, nrEntitiesPerListPage,\r
+                   model, definition, nrEntitiesPerListPage, anOffset)\r
           );\r
 \r
       count = mainModule.getSize(aWhereClause);\r
@@ -278,18 +283,18 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
       urlBuilder.setValue("offset", anOffset);\r
       thisUrl = urlBuilder.getQuery();\r
 \r
-      if (count >= anOffset + nrMediaPerPage) {\r
-        urlBuilder.setValue("offset", anOffset + nrMediaPerPage);\r
+      if (count >= anOffset + nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", anOffset + nrEntitiesPerListPage);\r
         nextPageUrl = urlBuilder.getQuery();\r
       }\r
 \r
       if (anOffset > 0) {\r
-        urlBuilder.setValue("offset", Math.max(anOffset - nrMediaPerPage, 0));\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
         previousPageUrl = urlBuilder.getQuery();\r
       }\r
 \r
       returnUploadedMediaList(aRequest, aResponse, mediaList,\r
-              anOffset+1, anOffset+nrMediaPerPage, count, thisUrl,\r
+              anOffset+1, anOffset+nrEntitiesPerListPage, count, thisUrl,\r
               nextPageUrl, previousPageUrl);\r
     }\r
     catch (Throwable e) {\r
@@ -376,7 +381,7 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
       responseData.put("nrmedia", new Integer(nrMedia));\r
       responseData.put("mediafields", mediaFields);\r
 \r
-      responseData.put("edittemplate", templateObjektString);\r
+      responseData.put("edittemplate", editGenerator);\r
       responseData.put("module", moduleName);\r
 \r
       addExtraData(responseData);\r
@@ -397,14 +402,14 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
       try {\r
         Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});\r
         EntityAdapter object =\r
-            MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter(entityName, mainModule.getById(idParam));\r
+            model.makeEntityAdapter(definition, mainModule.getById(idParam));\r
         responseData.put("uploadedmedia", object);\r
         responseData.put("new", Boolean.FALSE);\r
         responseData.put("articleid", null);\r
         responseData.put("commentid", null);\r
         responseData.put("returnurl", null);\r
 \r
-        responseData.put("edittemplate", templateObjektString);\r
+        responseData.put("edittemplate", editGenerator);\r
         responseData.put("module", moduleName);\r
 \r
         addExtraData(responseData);\r
index 7dd44fa..25e824c 100755 (executable)
@@ -1,35 +1,35 @@
-/*
- * 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  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 mircoders.servlet;
-
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.servlet;\r
+\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -52,331 +52,328 @@ import mir.util.URLBuilder;
 import mircoders.entity.EntityUsers;\r
 import mircoders.global.MirGlobal;\r
 import mircoders.module.ModuleUsers;\r
-import mircoders.storage.DatabaseUsers;
-
-/*
- *  ServletModuleUsers -
- *  liefert HTML fuer Users
- *
- *
- * @author RK
- */
-
-public class ServletModuleUsers extends ServletModule
-{
-  private String editTemplate;
-  private String listTemplate;
-
-  private static ServletModuleUsers instance = new ServletModuleUsers();
-  public static ServletModule getInstance() { return instance; }
-  protected ModuleUsers usersModule;
-
-  private ServletModuleUsers() {
-    super();
-    logger = new LoggerWrapper("ServletModule.Users");
-
-    listTemplate = configuration.getString("ServletModule.Users.ListTemplate");
-    editTemplate = configuration.getString("ServletModule.Users.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Users.ConfirmTemplate");
-
-    try {
-      usersModule = new ModuleUsers(DatabaseUsers.getInstance());
-      mainModule = usersModule;
-    }
-    catch (StorageObjectFailure e) {
-      logger.debug("initialization of ServletModuleUsers failed!: " + e.getMessage());
-    }
-  }
-
-  public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
-    String idParam = aRequest.getParameter("id");
-
-    if (idParam == null)
-      throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");
-
-    try {
-      EntityUsers user = (EntityUsers) mainModule.getById(idParam);
-      MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);
-
-      showUser(idParam, false, aRequest, aResponse);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void add(HttpServletRequest aRequest, HttpServletResponse aResponse)
-      throws ServletModuleExc
-  {
-    try {
-      MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));
-
-      showUser(null, false, aRequest, aResponse);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public String validatePassword(EntityUsers aUser, HTTPRequestParser aRequestParser) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
-  {
-    if ( (aRequestParser.getParameter("newpassword") != null &&
-          aRequestParser.getParameter("newpassword").length() > 0) ||
-        (aRequestParser.getParameter("newpassword2") != null &&
-         aRequestParser.getParameter("newpassword2").length() > 0)
-        ) {
-      String newPassword = aRequestParser.getParameterWithDefault("newpassword", "");
-      String newPassword2 = aRequestParser.getParameterWithDefault("newpassword2", "");
-      String oldPassword = aRequestParser.getParameterWithDefault("oldpassword", "");
-
-      try {
-        if (!usersModule.checkUserPassword(aUser, oldPassword)) {
-          throw new ServletModuleUserExc("user.error.incorrectpassword", new String[] {});
-        }
-      }
-      catch (Throwable t) {
-        throw new ServletModuleFailure(t);
-      }
-
-
-      if (newPassword.length() == 0 || newPassword2.length() == 0) {
-        throw new ServletModuleUserExc("user.error.missingpasswords", new String[] {});
-      }
-
-      if (!newPassword.equals(newPassword2)) {
-        throw new ServletModuleUserExc("user.error.passwordmismatch", new String[] {});
-      }
-
-      return newPassword;
-    }
-    else
-      return null;
-  }
-
-  public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)
-      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
-  {
-    try {
-      MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));
-
-      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-      Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());
-
-      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
-      if (newPassword!=null)
-        withValues.put("password", newPassword);
-      else
-        throw new ServletModuleUserExc("user.error.missingpassword", new String[] {});
-
-      String id = mainModule.add(withValues);
-      if (requestParser.hasParameter("returnurl"))
-        redirect(aResponse, requestParser.getParameter("returnurl"));
-      else
-        list(aRequest, aResponse);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
-  {
-    try {
-      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-      EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));
-      MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);
-
-      Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());
-      if (!withValues.containsKey("is_admin"))
-        withValues.put("is_admin","0");
-
-      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
-      if (newPassword!=null)
-        withValues.put("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));
-
-      mainModule.set(withValues);
-
-      if (requestParser.hasParameter("returnurl"))
-        redirect(aResponse, requestParser.getParameter("returnurl"));
-      else
-        list(aRequest, aResponse);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void updatepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
-  {
-    try {
-      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-      EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));
-      MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);
-
-      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
-      if (newPassword!=null) {
-        user.setValueForProperty("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));
-        user.update();
-
-        // hackish: to make sure the cached logged in user is up-to-date:
-        ServletHelper.setUser(aRequest, (EntityUsers) mainModule.getById(ServletHelper.getUser(aRequest).getId()));
-      }
-
-      if (requestParser.hasParameter("returnurl"))
-        redirect(aResponse, requestParser.getParameter("returnurl"));
-      else
-        redirect(aResponse, "");
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
-    int offset = requestParser.getIntegerWithDefault("offset", 0);
-
-    returnUserList(aRequest, aResponse, offset);
-  }
-
-  public void returnUserList(
-       HttpServletRequest aRequest,
-       HttpServletResponse aResponse,
-       int anOffset) throws ServletModuleExc {
-
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-    URLBuilder urlBuilder = new URLBuilder();
-    EntityAdapterModel model;
-    int count;
-    int nrUsersPerPage = 20;
-
-    try {
-      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
-      model = MirGlobal.localizer().dataModel().adapterModel();
-
-      Object userList =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter( "", "login", nrUsersPerPage,
-               MirGlobal.localizer().dataModel().adapterModel(), "user", nrUsersPerPage, anOffset)
-      );
-
-      responseData.put("nexturl", null);
-      responseData.put("prevurl", null);
-
-      count=mainModule.getSize("");
-
-      urlBuilder.setValue("module", "Users");
-      urlBuilder.setValue("do", "list");
-
-      urlBuilder.setValue("offset", anOffset);
-      responseData.put("offset" , new Integer(anOffset).toString());
-      responseData.put("thisurl" , urlBuilder.getQuery());
-
-      if (count>=anOffset+nrUsersPerPage) {
-        urlBuilder.setValue("offset", (anOffset + nrUsersPerPage));
-        responseData.put("nexturl" , urlBuilder.getQuery());
-      }
-
-      if (anOffset>0) {
-        urlBuilder.setValue("offset", Math.max(anOffset - nrUsersPerPage, 0));
-        responseData.put("prevurl" , urlBuilder.getQuery());
-      }
-
-      responseData.put("users", userList);
-      responseData.put("mayDeleteUsers", new Boolean(MirGlobal.accessControl().user().mayDeleteUsers(ServletHelper.getUser(aRequest))));
-      responseData.put("mayAddUsers", new Boolean(MirGlobal.accessControl().user().mayAddUsers(ServletHelper.getUser(aRequest))));
-      responseData.put("mayEditUsers", new Boolean(MirGlobal.accessControl().user().mayEditUsers(ServletHelper.getUser(aRequest))));
-
-      responseData.put("from" , Integer.toString(anOffset+1));
-      responseData.put("count", Integer.toString(count));
-      responseData.put("to", Integer.toString(Math.min(anOffset+nrUsersPerPage, count)));
-      responseData.put("offset" , Integer.toString(anOffset));
-
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void showUser(String anId, boolean anOnlyPassword, HttpServletRequest aRequest, HttpServletResponse aResponse)
-      throws ServletModuleExc {
-    try {
-      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
-      EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
-      Map user;
-      URLBuilder urlBuilder = new URLBuilder();
-
-      urlBuilder.setValue("module", "Users");
-      if (anOnlyPassword)
-        urlBuilder.setValue("do", "changepassword");
-      else
-        urlBuilder.setValue("do", "edit");
-      urlBuilder.setValue("id", anId);
-      urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
-
-      if (anId!=null) {
-        responseData.put("new", Boolean.FALSE);
-        user = model.makeEntityAdapter("user", mainModule.getById(anId));
-      }
-      else {
-        List fields = DatabaseUsers.getInstance().getFields();
-        responseData.put("new", Boolean.TRUE);
-        user = new HashMap();
-        Iterator i = fields.iterator();
-        while (i.hasNext()) {
-          user.put(i.next(), null);
-        }
-
-        MirGlobal.localizer().adminInterface().initializeArticle(user);
-      }
-      responseData.put("user", user);
-      responseData.put("passwordonly", new Boolean(anOnlyPassword));
-
-      responseData.put("returnurl", requestParser.getParameter("returnurl"));
-      responseData.put("thisurl", urlBuilder.getQuery());
-
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleUserExc, ServletModuleExc, ServletModuleFailure {
-    try {
-      EntityUsers user = (EntityUsers) mainModule.getById(aRequest.getParameter("id"));
-
-      MirGlobal.accessControl().user().assertMayDeleteUser(ServletHelper.getUser(aRequest), user);
-
-      super.delete(aRequest, aResponse);
-    }
-    catch (Throwable t) {
-      throw new ServletModuleFailure(t);
-    }
-  }
-
-  public void changepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
-    String idParam = aRequest.getParameter("id");
-
-    if (idParam == null)
-      throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");
-
-    try {
-      EntityUsers user = (EntityUsers) mainModule.getById(idParam);
-      MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);
-
-      showUser(idParam, true, aRequest, aResponse);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-}
-
+import mircoders.storage.DatabaseUsers;\r
+import mircoders.global.*;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+public class ServletModuleUsers extends ServletModule\r
+{\r
+  private static ServletModuleUsers instance = new ServletModuleUsers();\r
+  public static ServletModule getInstance() { return instance; }\r
+  protected ModuleUsers usersModule;\r
+\r
+  private ServletModuleUsers() {\r
+    super();\r
+    logger = new LoggerWrapper("ServletModule.Users");\r
+\r
+    try {\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+      definition = "user";\r
+      usersModule = new ModuleUsers(DatabaseUsers.getInstance());\r
+      mainModule = usersModule;\r
+    }\r
+    catch (Throwable e) {\r
+      logger.debug("initialization of ServletModuleUsers failed!: " + e.getMessage());\r
+    }\r
+  }\r
+\r
+  public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String idParam = aRequest.getParameter("id");\r
+\r
+    if (idParam == null)\r
+      throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");\r
+\r
+    try {\r
+      EntityUsers user = (EntityUsers) mainModule.getById(idParam);\r
+      MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);\r
+\r
+      showUser(idParam, false, aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void add(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+      throws ServletModuleExc\r
+  {\r
+    try {\r
+      MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));\r
+\r
+      showUser(null, false, aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public String validatePassword(EntityUsers aUser, HTTPRequestParser aRequestParser) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
+    if ( (aRequestParser.getParameter("newpassword") != null &&\r
+          aRequestParser.getParameter("newpassword").length() > 0) ||\r
+        (aRequestParser.getParameter("newpassword2") != null &&\r
+         aRequestParser.getParameter("newpassword2").length() > 0)\r
+        ) {\r
+      String newPassword = aRequestParser.getParameterWithDefault("newpassword", "");\r
+      String newPassword2 = aRequestParser.getParameterWithDefault("newpassword2", "");\r
+      String oldPassword = aRequestParser.getParameterWithDefault("oldpassword", "");\r
+\r
+      try {\r
+        if (!usersModule.checkUserPassword(aUser, oldPassword)) {\r
+          throw new ServletModuleUserExc("user.error.incorrectpassword", new String[] {});\r
+        }\r
+      }\r
+      catch (Throwable t) {\r
+        throw new ServletModuleFailure(t);\r
+      }\r
+\r
+\r
+      if (newPassword.length() == 0 || newPassword2.length() == 0) {\r
+        throw new ServletModuleUserExc("user.error.missingpasswords", new String[] {});\r
+      }\r
+\r
+      if (!newPassword.equals(newPassword2)) {\r
+        throw new ServletModuleUserExc("user.error.passwordmismatch", new String[] {});\r
+      }\r
+\r
+      return newPassword;\r
+    }\r
+    else\r
+      return null;\r
+  }\r
+\r
+  public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+      throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
+    try {\r
+      MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));\r
+\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+      Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
+\r
+      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);\r
+      if (newPassword!=null)\r
+        withValues.put("password", newPassword);\r
+      else\r
+        throw new ServletModuleUserExc("user.error.missingpassword", new String[] {});\r
+\r
+      String id = mainModule.add(withValues);\r
+      if (requestParser.hasParameter("returnurl"))\r
+        redirect(aResponse, requestParser.getParameter("returnurl"));\r
+      else\r
+        list(aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
+    try {\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+      EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));\r
+      MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);\r
+\r
+      Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
+      if (!withValues.containsKey("is_admin"))\r
+        withValues.put("is_admin","0");\r
+\r
+      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);\r
+      if (newPassword!=null)\r
+        withValues.put("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));\r
+\r
+      mainModule.set(withValues);\r
+\r
+      if (requestParser.hasParameter("returnurl"))\r
+        redirect(aResponse, requestParser.getParameter("returnurl"));\r
+      else\r
+        list(aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void updatepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure\r
+  {\r
+    try {\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+      EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));\r
+      MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);\r
+\r
+      String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);\r
+      if (newPassword!=null) {\r
+        user.setValueForProperty("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));\r
+        user.update();\r
+\r
+        // hackish: to make sure the cached logged in user is up-to-date:\r
+        ServletHelper.setUser(aRequest, (EntityUsers) mainModule.getById(ServletHelper.getUser(aRequest).getId()));\r
+      }\r
+\r
+      if (requestParser.hasParameter("returnurl"))\r
+        redirect(aResponse, requestParser.getParameter("returnurl"));\r
+      else\r
+        redirect(aResponse, "");\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+    int offset = requestParser.getIntegerWithDefault("offset", 0);\r
+\r
+    returnUserList(aRequest, aResponse, offset);\r
+  }\r
+\r
+  public void returnUserList(\r
+       HttpServletRequest aRequest,\r
+       HttpServletResponse aResponse,\r
+       int anOffset) throws ServletModuleExc {\r
+\r
+// ML: to be deleted, support for 3 extra vars to be added\r
+\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+    URLBuilder urlBuilder = new URLBuilder();\r
+    EntityAdapterModel model;\r
+    int count;\r
+\r
+    try {\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+\r
+      Object userList =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter( "", "login", nrEntitiesPerListPage,\r
+               MirGlobal.localizer().dataModel().adapterModel(), "user", nrEntitiesPerListPage, anOffset)\r
+      );\r
+\r
+      responseData.put("nexturl", null);\r
+      responseData.put("prevurl", null);\r
+\r
+      count=mainModule.getSize("");\r
+\r
+      urlBuilder.setValue("module", "Users");\r
+      urlBuilder.setValue("do", "list");\r
+\r
+      urlBuilder.setValue("offset", anOffset);\r
+      responseData.put("offset" , new Integer(anOffset).toString());\r
+      responseData.put("thisurl" , urlBuilder.getQuery());\r
+\r
+      if (count>=anOffset+nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", (anOffset + nrEntitiesPerListPage));\r
+        responseData.put("nexturl" , urlBuilder.getQuery());\r
+      }\r
+\r
+      if (anOffset>0) {\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
+        responseData.put("prevurl" , urlBuilder.getQuery());\r
+      }\r
+\r
+      responseData.put("users", userList);\r
+      responseData.put("mayDeleteUsers", new Boolean(MirGlobal.accessControl().user().mayDeleteUsers(ServletHelper.getUser(aRequest))));\r
+      responseData.put("mayAddUsers", new Boolean(MirGlobal.accessControl().user().mayAddUsers(ServletHelper.getUser(aRequest))));\r
+      responseData.put("mayEditUsers", new Boolean(MirGlobal.accessControl().user().mayEditUsers(ServletHelper.getUser(aRequest))));\r
+\r
+      responseData.put("from" , Integer.toString(anOffset+1));\r
+      responseData.put("count", Integer.toString(count));\r
+      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));\r
+      responseData.put("offset" , Integer.toString(anOffset));\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void showUser(String anId, boolean anOnlyPassword, HttpServletRequest aRequest, HttpServletResponse aResponse)\r
+      throws ServletModuleExc {\r
+    try {\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+      EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();\r
+      Map user;\r
+      URLBuilder urlBuilder = new URLBuilder();\r
+\r
+      urlBuilder.setValue("module", "Users");\r
+      if (anOnlyPassword)\r
+        urlBuilder.setValue("do", "changepassword");\r
+      else\r
+        urlBuilder.setValue("do", "edit");\r
+      urlBuilder.setValue("id", anId);\r
+      urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));\r
+\r
+      if (anId!=null) {\r
+        responseData.put("new", Boolean.FALSE);\r
+        user = model.makeEntityAdapter("user", mainModule.getById(anId));\r
+      }\r
+      else {\r
+        List fields = DatabaseUsers.getInstance().getFields();\r
+        responseData.put("new", Boolean.TRUE);\r
+        user = new HashMap();\r
+        Iterator i = fields.iterator();\r
+        while (i.hasNext()) {\r
+          user.put(i.next(), null);\r
+        }\r
+\r
+        MirGlobal.localizer().adminInterface().initializeArticle(user);\r
+      }\r
+      responseData.put("user", user);\r
+      responseData.put("passwordonly", new Boolean(anOnlyPassword));\r
+\r
+      responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
+      responseData.put("thisurl", urlBuilder.getQuery());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleUserExc, ServletModuleExc, ServletModuleFailure {\r
+    try {\r
+      EntityUsers user = (EntityUsers) mainModule.getById(aRequest.getParameter("id"));\r
+\r
+      MirGlobal.accessControl().user().assertMayDeleteUser(ServletHelper.getUser(aRequest), user);\r
+\r
+      super.delete(aRequest, aResponse);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  }\r
+\r
+  public void changepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String idParam = aRequest.getParameter("id");\r
+\r
+    if (idParam == null)\r
+      throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");\r
+\r
+    try {\r
+      EntityUsers user = (EntityUsers) mainModule.getById(idParam);\r
+      MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);\r
+\r
+      showUser(idParam, true, aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+}\r
+\r
index de487f8..2499be3 100755 (executable)
@@ -35,42 +35,38 @@ import mir.servlet.ServletModule;
 import mir.storage.StorageObjectFailure;
 import mircoders.module.ModuleUploadedMedia;
 import mircoders.storage.DatabaseVideo;
+import mircoders.global.*;
 
-/*
- *
+/**
  *
- * @author br1
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
  */
 
 public class ServletModuleVideo extends ServletModuleUploadedMedia {
-
-  //private static DatabaseRights dbRights;
-
-  // Singelton / Contructor
   private static ServletModuleVideo instance = new ServletModuleVideo();
 
   public static ServletModule getInstance() {
     return instance;
   }
 
-
   private ServletModuleVideo() {
     super();
     logger = new LoggerWrapper("ServletModule.Video");
 
-    entityName = "video";
     moduleName = "Video";
 
-    templateListString = configuration.getString("ServletModule.Video.ListTemplate");
-    templateObjektString = configuration.getString("ServletModule.Video.ObjektTemplate");
-    templateConfirmString = configuration.getString("ServletModule.Video.ConfirmTemplate");
     try {
+      model = MirGlobal.localizer().dataModel().adapterModel();
+      definition = "video";
       mainModule = new ModuleUploadedMedia(DatabaseVideo.getInstance());
-      //dbRights = DatabaseRights.getInstance();
     }
-    catch (StorageObjectFailure e) {
+    catch (Throwable e) {
       logger.error("servletmodule video could not be initialized: " + e.getMessage());
     }
   }
-}
-
+}
\ No newline at end of file
index 9ba7abc..d6ed182 100755 (executable)
@@ -39,17 +39,17 @@ package mircoders.storage;
  * @version 1.0
  */
 
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
+import java.util.List;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
 
 public class DatabaseArticleType extends Database implements StorageObject{
 
   private static DatabaseArticleType instance;
-  private static SimpleList articletypePopupData;
+  private static List articletypePopupData;
 
   public synchronized static DatabaseArticleType getInstance() throws StorageObjectFailure {
     if (instance == null) {
@@ -65,7 +65,4 @@ public class DatabaseArticleType extends Database implements StorageObject{
     this.theTable = "article_type";
   }
 
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", false);
-  }
 }
index bed4e44..24d6b06 100755 (executable)
@@ -1,90 +1,84 @@
-/*
- * 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  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 mircoders.storage;
-
-import java.util.GregorianCalendar;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-public class DatabaseAudio extends Database implements StorageObject{
-
-  private static DatabaseAudio instance;
-  private static SimpleList publisherPopupData;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseAudio getInstance() {
-    if (instance == null) {
-      instance = new DatabaseAudio();
-    }
-    return instance;
-  }
-
-  private DatabaseAudio() throws StorageObjectFailure {
-    super();
-    logger = new LoggerWrapper("Database.Audio");
-
-    hasTimestamp = true;
-    theTable = "audio";
-    theCoreTable = "media";
-    theEntityClass = mircoders.entity.EntityAudio.class;
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-
-  public void update(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-
-    super.update(theEntity);
-  }
-
-  public String insert(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-    return super.insert(theEntity);
-  }
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.storage;\r
+\r
+import java.util.GregorianCalendar;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+public class DatabaseAudio extends Database implements StorageObject{\r
+\r
+  private static DatabaseAudio instance;\r
+\r
+  // the following *has* to be sychronized cause this static method\r
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
+  // see the "Singletons with needles and thread" article at JavaWorld -mh\r
+  public synchronized static DatabaseAudio getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseAudio();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseAudio() throws StorageObjectFailure {\r
+    super();\r
+    logger = new LoggerWrapper("Database.Audio");\r
+\r
+    hasTimestamp = true;\r
+    theTable = "audio";\r
+    theCoreTable = "media";\r
+    theEntityClass = mircoders.entity.EntityAudio.class;\r
+  }\r
+\r
+  public void update(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+\r
+    super.update(theEntity);\r
+  }\r
+\r
+  public String insert(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+    return super.insert(theEntity);\r
+  }\r
+\r
+}\r
index 3151c99..56f3e33 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+import java.sql.Statement;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
  * <b>This class implements the access to the comment-table for the
@@ -67,10 +66,6 @@ public class DatabaseComment extends Database implements StorageObject{
     this.theEntityClass = mircoders.entity.EntityComment.class;
   }
 
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-
   public boolean deleteByContentId(String id) throws StorageObjectFailure {
     Statement stmt = null;
     Connection con = null;
index c2f5cc8..7cd02d8 100755 (executable)
@@ -39,11 +39,10 @@ package mircoders.storage;
  * @version 1.0
  */
 
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 
 public class DatabaseCommentStatus extends Database implements StorageObject{
@@ -64,8 +63,4 @@ public class DatabaseCommentStatus extends Database implements StorageObject{
     theTable = "comment_status";
     logger = new LoggerWrapper("Database.CommentStatus");
   }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", false);
-  }
 }
\ No newline at end of file
index 9868d6b..e0424d4 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityComment;
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectExc;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.entity.EntityComment;\r
 import mircoders.entity.EntityUploadedMedia;
 
 /**
  * <b>implements abstract DB connection to the comment_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseCommentToMedia.java,v 1.3 2003/05/03 00:21:22 zapata Exp $
+ * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.1 2003/09/03 17:49:41 zapata Exp $
  *
  */
 
@@ -72,33 +72,6 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{
     theEntityClass = mir.entity.GenericEntity.class;
   }
 
-  /**
-   * get all the media-files belonging to a comment entity
-   *
-   */
-  public EntityList getMedia(EntityComment comment) throws StorageObjectFailure {
-    EntityList returnList = null;
-    if (comment != null) {
-      // get all to_topic from media_x_topic
-      String id = comment.getId();
-      String subselect = "id in (select media_id from " + theTable +
-          " where comment_id=" + id + ")";
-
-      try {
-        // media should stay in uploaded order. this is especially important
-        // for photo stories which require a specific chronologic order.
-        // this is why we have the the second parameter "id"
-        returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,
-            "id", -1);
-      }
-      catch (Throwable e) {
-        logger.debug("-- get media failed " + e.toString());
-        throw new StorageObjectFailure("-- get media failed ", e);
-      }
-    }
-    return returnList;
-  }
-
   public boolean hasMedia(EntityComment comment) throws StorageObjectFailure,
       StorageObjectExc {
     if (comment != null) {
index c1d494b..b28c5e0 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.Statement;
-
-import mir.entity.EntityList;
-import mir.entity.EntityRelation;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
+import java.sql.Connection;\r
+import java.sql.Statement;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
 import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
 
 /**
  * <b>this class implements the access to the content-table</b>
@@ -50,7 +47,6 @@ import mircoders.entity.EntityContent;
 public class DatabaseContent extends Database implements StorageObject {
 
   private static DatabaseContent      instance;
-  private static EntityRelation       relationComments;
 
   // Contructors / Singleton
 
@@ -72,8 +68,6 @@ public class DatabaseContent extends Database implements StorageObject {
     theCoreTable="media";
     logger = new LoggerWrapper("Database.Content");
 
-    relationComments =
-        new EntityRelation("id", "to_media", DatabaseComment.getInstance(), EntityRelation.TO_MANY);
     theEntityClass = mircoders.entity.EntityContent.class;
   }
 
index 8cb8a56..5f147b6 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectExc;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.entity.EntityContent;\r
 import mircoders.entity.EntityUploadedMedia;
 
 /**
  * <b>implements abstract DB connection to the content_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseContentToMedia.java,v 1.19 2003/05/03 00:21:22 zapata Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.1 2003/09/03 17:49:41 zapata Exp $
  *
  */
 
@@ -72,33 +72,6 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     theEntityClass = mir.entity.GenericEntity.class;
   }
 
-  /**
-   * get all the media-files belonging to a content entity
-   *
-   */
-  public EntityList getMedia(EntityContent content) throws StorageObjectFailure {
-    EntityList returnList = null;
-    if (content != null) {
-      // get all to_topic from media_x_topic
-      String id = content.getId();
-      String subselect = "id in (select media_id from " + theTable +
-          " where content_id=" + id + ")";
-
-      try {
-        // media should stay in uploaded order. this is especially important
-        // for photo stories which require a specific chronologic order.
-        // this is why we have the the second parameter "id"
-        returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,
-            "id", -1);
-      }
-      catch (Throwable e) {
-        logger.debug("-- get media failed " + e.toString());
-        throw new StorageObjectFailure("-- get media failed ", e);
-      }
-    }
-    return returnList;
-  }
-
   public boolean hasMedia(EntityContent content) throws StorageObjectFailure,
       StorageObjectExc {
     if (content != null) {
index 7475e90..4a696e4 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.entity.EntityContent;\r
 import mircoders.entity.EntityTopics;
 
 /**
index f857d70..bbf37db 100755 (executable)
 
 package mircoders.storage;
 
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
 import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -45,7 +43,6 @@ import freemarker.template.SimpleList;
 public class DatabaseImageColor extends Database implements StorageObject{
 
   private static DatabaseImageColor instance;
-  private static SimpleList publisherPopupData;
 
   // the following *has* to be sychronized cause this static method
   // could get preemted and we could end up with 2 instances of DatabaseFoo..
@@ -64,7 +61,4 @@ public class DatabaseImageColor extends Database implements StorageObject{
     theTable = "img_color";
   }
 
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", true);
-  }
 }
index 310987d..26f2a8d 100755 (executable)
 
 package mircoders.storage;
 
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
 import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -45,7 +43,6 @@ import freemarker.template.SimpleList;
 public class DatabaseImageFormat extends Database implements StorageObject{
 
   private static DatabaseImageFormat instance;
-  private static SimpleList publisherPopupData;
 
   // the following *has* to be sychronized cause this static method
   // could get preemted and we could end up with 2 instances of DatabaseFoo..
@@ -63,9 +60,4 @@ public class DatabaseImageFormat extends Database implements StorageObject{
     hasTimestamp = false;
     theTable = "img_format";
   }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", true);
-  }
-
 }
index 1fac5a3..641f903 100755 (executable)
 
 package mircoders.storage;
 
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
 import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -45,7 +43,6 @@ import freemarker.template.SimpleList;
 public class DatabaseImageLayout extends Database implements StorageObject{
 
   private static DatabaseImageLayout instance;
-  private static SimpleList publisherPopupData;
 
   // the following *has* to be sychronized cause this static method
   // could get preemted and we could end up with 2 instances of DatabaseFoo..
@@ -64,9 +61,4 @@ public class DatabaseImageLayout extends Database implements StorageObject{
     hasTimestamp = false;
     theTable = "img_layout";
   }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", true);
-  }
-
 }
index 377f1f7..a924eb5 100755 (executable)
@@ -1,69 +1,63 @@
-/*
- * 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  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 mircoders.storage;
-
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-
-public class DatabaseImageType extends Database implements StorageObject{
-  private static DatabaseImageType instance;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseImageType getInstance() {
-    if (instance == null) {
-      instance = new DatabaseImageType();
-    }
-    return instance;
-  }
-
-  private DatabaseImageType() {
-    super();
-    logger = new LoggerWrapper("Database.ImageType");
-
-    hasTimestamp = false;
-    theTable = "img_type";
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", true);
-  }
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.storage;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+\r
+public class DatabaseImageType extends Database implements StorageObject{\r
+  private static DatabaseImageType instance;\r
+\r
+  public synchronized static DatabaseImageType getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseImageType();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseImageType() {\r
+    super();\r
+    logger = new LoggerWrapper("Database.ImageType");\r
+\r
+    hasTimestamp = false;\r
+    theTable = "img_type";\r
+  }\r
+}\r
index d525df4..681fbaa 100755 (executable)
-/*
- * 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  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 mircoders.storage;
-
-import java.util.GregorianCalendar;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-
-public class DatabaseImages extends Database implements StorageObject{
-
-  private static DatabaseImages instance;
-  private static SimpleList publisherPopupData;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseImages getInstance() {
-    if (instance == null) {
-      instance = new DatabaseImages();
-    }
-    return instance;
-  }
-
-  private DatabaseImages() {
-    super();
-
-    logger = new LoggerWrapper("Database.Images");
-
-    hasTimestamp = true;
-    theTable = "images";
-    theCoreTable = "media";
-    theEntityClass = mircoders.entity.EntityImages.class;
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-
-  public void update(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-
-    super.update(theEntity);
-  }
-
-  public String insert(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-
-    return super.insert(theEntity);
-  }
-
-  // initialisierungen aus den statischen Tabellen
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+import java.util.GregorianCalendar;\r
+import java.util.List;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+/**\r
+ * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle\r
+ *\r
+ *\r
+ */\r
+\r
+public class DatabaseImages extends Database implements StorageObject{\r
+\r
+  private static DatabaseImages instance;\r
+\r
+  public synchronized static DatabaseImages getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseImages();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseImages() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.Images");\r
+\r
+    hasTimestamp = true;\r
+    theTable = "images";\r
+    theCoreTable = "media";\r
+    theEntityClass = mircoders.entity.EntityImages.class;\r
+  }\r
+\r
+  public void update(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+\r
+    super.update(theEntity);\r
+  }\r
+\r
+  public String insert(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+\r
+    return super.insert(theEntity);\r
+  }\r
+}\r
index e0b15bc..a1ed74d 100755 (executable)
@@ -1,79 +1,93 @@
-/*
- * 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  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 mircoders.storage;
-
-/**
- * Title: DatabaseLanguage
- * Description:
- * Copyright:    Copyright (c) 2001
- * Company:      Indymedia
- * @author
- * @version 1.0
- */
-
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-
-public class DatabaseLanguage extends Database implements StorageObject{
-
-  private static DatabaseLanguage instance;
-  private static SimpleList languagePopupData;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseLanguage getInstance() throws
-      StorageObjectFailure {
-    if (instance == null) {
-      instance = new DatabaseLanguage();
-    }
-    return instance;
-  }
-
-  private DatabaseLanguage() throws StorageObjectFailure {
-    super();
-    logger = new LoggerWrapper("Database.Language");
-
-    this.hasTimestamp = false;
-    this.theTable = "language";
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    SimpleList pData = null;
-    pData = getPopupData("name", false);
-
-    return pData;
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+/**\r
+ * Title: DatabaseLanguage\r
+ * Description:\r
+ * Copyright:    Copyright (c) 2001\r
+ * Company:      Indymedia\r
+ * @author\r
+ * @version 1.0\r
+ */\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityBrowser;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+\r
+public class DatabaseLanguage extends Database implements StorageObject{\r
+  private static DatabaseLanguage instance;\r
+\r
+  // the following *has* to be sychronized cause this static method\r
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
+  // see the "Singletons with needles and thread" article at JavaWorld -mh\r
+  public synchronized static DatabaseLanguage getInstance() throws\r
+      StorageObjectFailure {\r
+    if (instance == null) {\r
+      instance = new DatabaseLanguage();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseLanguage() throws StorageObjectFailure {\r
+    super();\r
+    logger = new LoggerWrapper("Database.Language");\r
+\r
+    this.hasTimestamp = false;\r
+    this.theTable = "language";\r
+  }\r
+\r
+  public List getPopupData() throws StorageObjectFailure {\r
+    List result = new Vector();\r
+    Iterator i = new EntityBrowser(this, "", "name", 100, -1, 0);\r
+\r
+    while (i.hasNext()) {\r
+      Entity e = (Entity) i.next();\r
+      Map entry = new HashMap();\r
+      entry.put("key", e.getId());\r
+      entry.put("value", e.getValue("name"));\r
+\r
+      result.add(entry);\r
+    }\r
+\r
+    return result;\r
+  }\r
+}\r
diff --git a/source/mircoders/storage/DatabaseMedia.java b/source/mircoders/storage/DatabaseMedia.java
deleted file mode 100755 (executable)
index ed653a5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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  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 mircoders.storage;
-
-import mir.entity.Entity;
-import mir.entity.EntityRelation;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-
-public class DatabaseMedia extends Database implements StorageObject{
-
-  private static DatabaseMedia instance;
-  private static EntityRelation         relationMediaType;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseMedia getInstance() {
-    if (instance == null) {
-      instance = new DatabaseMedia();
-    }
-    return instance;
-  }
-
-  private DatabaseMedia() {
-    super();
-
-    logger = new LoggerWrapper("Database.Media");
-
-    hasTimestamp = false;
-    theTable="media";
-    relationMediaType =
-        new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE);
-    theEntityClass = mircoders.entity.EntityMedia.class;
-  }
-
-  // methods
-
-
-  /**
-   * returns the comments that belong to the article (via entityrelation)
-   * where db-flag is_published is true
-   */
-  public Entity getMediaType(Entity ent) throws StorageObjectFailure, StorageObjectExc {
-    try {
-      return relationMediaType.getOne(ent);
-    }
-    catch (Throwable e) {
-      logger.error("failed to get media_type: " + e.getMessage());
-      throw new StorageObjectFailure("DatabaseMedia.getMediaType :" + e.getMessage(),e);
-    }
-  }
-
-}
index 398acb2..cd2cf1a 100755 (executable)
@@ -42,12 +42,8 @@ import mir.storage.StorageObjectFailure;
  */
 
 public class DatabaseMediaType extends Database implements StorageObject{
-
   private static DatabaseMediaType instance;
 
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
   public synchronized static DatabaseMediaType getInstance() {
     if (instance == null) {
       instance = new DatabaseMediaType();
index 01be686..aaccbe4 100755 (executable)
@@ -1,77 +1,59 @@
-/*
- * 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  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 mircoders.storage;
-
-/**
- * Title:        Mir
- * Description:  Ihre Beschreibung
- * Copyright:    Copyright (c) 1999
- * Company:
- * @author
- * @version
- */
-
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-
-
-public class DatabaseMediafolder extends Database implements StorageObject{
-
-  private static DatabaseMediafolder instance;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseMediafolder getInstance() {
-    if (instance == null) {
-      instance = new DatabaseMediafolder();
-    }
-    return instance;
-  }
-
-  private DatabaseMediafolder() {
-    super();
-
-    logger = new LoggerWrapper("Database.Mediafolder");
-
-    hasTimestamp = false;
-    theTable="media_folder";
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name",true);
-  }
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+/**\r
+ *\r
+ */\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+\r
+public class DatabaseMediafolder extends Database implements StorageObject{\r
+  private static DatabaseMediafolder instance;\r
+\r
+  public synchronized static DatabaseMediafolder getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseMediafolder();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseMediafolder() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.Mediafolder");\r
+\r
+    hasTimestamp = false;\r
+    theTable="media_folder";\r
+  }\r
+}\r
index 22f4875..712f542 100755 (executable)
@@ -1,98 +1,97 @@
-/*
- * 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  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 mircoders.storage;
-
-
-import java.util.GregorianCalendar;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-
-public class DatabaseOther extends Database implements StorageObject{
-  private static DatabaseOther instance;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseOther getInstance() {
-    if (instance == null) {
-      instance = new DatabaseOther();
-    }
-    return instance;
-  }
-
-  private DatabaseOther() {
-    super();
-
-    logger = new LoggerWrapper("Database.OtherMedia");
-
-    hasTimestamp = true;
-    theTable = "other_media";
-    theCoreTable = "media";
-    theEntityClass = mircoders.entity.EntityOther.class;
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-
-  public void update(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-
-    super.update(theEntity);
-  }
-
-  public String insert(Entity theEntity) throws StorageObjectFailure {
-    String date = theEntity.getValue("date");
-    if (date == null) {
-      date = StringUtil.date2webdbDate(new GregorianCalendar());
-      theEntity.setValueForProperty("date", date);
-    }
-    return super.insert(theEntity);
-  }
-
-  // initialisierungen aus den statischen Tabellen
-
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.storage;\r
+\r
+\r
+import java.util.GregorianCalendar;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mir.misc.StringUtil;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+\r
+public class DatabaseOther extends Database implements StorageObject{\r
+  private static DatabaseOther instance;\r
+\r
+  // the following *has* to be sychronized cause this static method\r
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
+  // see the "Singletons with needles and thread" article at JavaWorld -mh\r
+  public synchronized static DatabaseOther getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseOther();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseOther() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.OtherMedia");\r
+\r
+    hasTimestamp = true;\r
+    theTable = "other_media";\r
+    theCoreTable = "media";\r
+    theEntityClass = mircoders.entity.EntityOther.class;\r
+  }\r
+\r
+  public void update(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+\r
+    super.update(theEntity);\r
+  }\r
+\r
+  public String insert(Entity theEntity) throws StorageObjectFailure {\r
+    String date = theEntity.getValue("date");\r
+    if (date == null) {\r
+      date = StringUtil.date2webdbDate(new GregorianCalendar());\r
+      theEntity.setValueForProperty("date", date);\r
+    }\r
+    return super.insert(theEntity);\r
+  }\r
+\r
+  // initialisierungen aus den statischen Tabellen\r
+\r
+}\r
index 11914a8..5bdbd08 100755 (executable)
@@ -34,20 +34,20 @@ import mir.log.LoggerWrapper;
 import mir.storage.Database;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
  *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
  */
 
 public class DatabaseRights extends Database implements StorageObject{
   private static DatabaseRights instance;
 
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
   public synchronized static DatabaseRights getInstance() {
     if (instance == null) {
       instance = new DatabaseRights();
@@ -63,9 +63,4 @@ public class DatabaseRights extends Database implements StorageObject{
     hasTimestamp = false;
     theTable = "rights";
   }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("name", true);
-  }
-
 }
index 2b502cb..95f5df8 100755 (executable)
@@ -1,72 +1,91 @@
-/*
- * 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  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 mircoders.storage;
-
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-
-public class DatabaseTopics extends Database implements StorageObject{
-
-  private static DatabaseTopics instance;
-
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
-  public synchronized static DatabaseTopics getInstance() {
-    if (instance == null) {
-      instance = new DatabaseTopics();
-    }
-    return instance;
-  }
-
-  private DatabaseTopics() throws StorageObjectFailure {
-    super();
-
-    logger = new LoggerWrapper("Database.Topics");
-
-    hasTimestamp = false;
-    theTable = "topic";
-    theEntityClass = mircoders.entity.EntityTopics.class;
-  }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-}
+/*\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  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityBrowser;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+/**\r
+ *\r
+ * <p>Title: </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+\r
+public class DatabaseTopics extends Database implements StorageObject{\r
+  private static DatabaseTopics instance;\r
+\r
+  public synchronized static DatabaseTopics getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseTopics();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseTopics() throws StorageObjectFailure {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.Topics");\r
+\r
+    hasTimestamp = false;\r
+    theTable = "topic";\r
+    theEntityClass = mircoders.entity.EntityTopics.class;\r
+  }\r
+\r
+  public List getPopupData() throws StorageObjectFailure {\r
+    List result = new Vector();\r
+    Iterator i = new EntityBrowser(this, "", "title", 100, -1, 0);\r
+\r
+    while (i.hasNext()) {\r
+      Entity e = (Entity) i.next();\r
+      Map entry = new HashMap();\r
+      entry.put("key", e.getId());\r
+      entry.put("value", e.getValue("title"));\r
+\r
+      result.add(entry);\r
+    }\r
+\r
+    return result;\r
+  }\r
+}\r
index 0e077ed..8c2000f 100755 (executable)
 
 package mircoders.storage;
 
-import mir.entity.Entity;
-import mir.entity.EntityRelation;
-import mir.log.LoggerWrapper;
-import mir.storage.Database;
-import mir.storage.StorageObject;
+import java.util.Iterator;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityBrowser;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
 import mir.storage.StorageObjectFailure;
 
 public class DatabaseUploadedMedia extends Database implements StorageObject {
   private static DatabaseUploadedMedia  instance;
-  private static EntityRelation         relationMediaType;
 
   public synchronized static DatabaseUploadedMedia getInstance() {
     if (instance == null ) {
@@ -56,7 +57,6 @@ public class DatabaseUploadedMedia extends Database implements StorageObject {
 
     theTable="uploaded_media";
     theCoreTable="media";
-    relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE);
     theEntityClass = mircoders.entity.EntityUploadedMedia.class;
   }
 
@@ -68,7 +68,9 @@ public class DatabaseUploadedMedia extends Database implements StorageObject {
   public Entity getMediaType(Entity ent) throws StorageObjectFailure {
     Entity type=null;
     try {
-      type = relationMediaType.getOne(ent);
+      Iterator i = new EntityBrowser(DatabaseMediaType.getInstance(), ent.getValue("to_media_type") + " = id" , "id", 1);
+      if (i.hasNext())
+        type = (Entity) i.next();
     }
     catch (Throwable t) {
       logger.error("DatabaseUploadedMedia :: failed to get media_type: " + t.getMessage());
index 89e1ae6..29dddac 100755 (executable)
@@ -34,12 +34,15 @@ import mir.log.LoggerWrapper;
 import mir.storage.Database;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
  *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
  */
 
 public class DatabaseUsers extends Database implements StorageObject{
@@ -65,8 +68,4 @@ public class DatabaseUsers extends Database implements StorageObject{
     theTable = "webdb_users";
     theEntityClass = mircoders.entity.EntityUsers.class;
   }
-
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("login", true);
-  }
 }
index a51d5b1..5f2b138 100755 (executable)
@@ -30,7 +30,7 @@
 
 package mircoders.storage;
 
-import java.util.GregorianCalendar;
+import java.util.*;
 
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
@@ -38,18 +38,20 @@ import mir.misc.StringUtil;
 import mir.storage.Database;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleList;
 
 /**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
  *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
  */
 
 public class DatabaseVideo extends Database implements StorageObject{
 
   private static DatabaseVideo instance;
-  private static SimpleList publisherPopupData;
 
   // the following *has* to be sychronized cause this static method
   // could get preemted and we could end up with 2 instances of DatabaseFoo..
@@ -72,10 +74,6 @@ public class DatabaseVideo extends Database implements StorageObject{
     theEntityClass = mircoders.entity.EntityVideo.class;
   }
 
-  public SimpleList getPopupData() throws StorageObjectFailure {
-    return getPopupData("title", true);
-  }
-
   public void update(Entity theEntity) throws StorageObjectFailure {
     String date = theEntity.getValue("date");
     if (date == null) {
index 14a7a51..d9830b9 100755 (executable)
 <function EditFieldEnd()>\r
     </td>
   </tr>\r
-</function>  \r
+</function>  
+
+<function EditSubmitButtonNormal(aLabel, aFieldName)>\r
+  <tr>
+    <td class="${TABLE_FOOT_CLASS}" colspan="2" align="right"> 
+      <input type="submit" name="${aFieldName}" value="${aLabel}">
+    </td>
+  </tr>
+</function>  
+\r
 \r
+<function EditReadonlyTextNormal(label, fieldcontent)>\r
+  <call EditFieldStart(label, "", "table-left", "listrow2")>
+      ${utility.encodeHTML(fieldcontent)}
+  <call EditFieldEnd()>
+</function>
+
 
 <function EditText(label, size, maxlength, fieldname, fieldcontent, aLabelClass, aValueClass)>\r
   <call EditFieldStart(label, "", aLabelClass, aValueClass)>
index b9c68bc..2b1eeed 100755 (executable)
 </function>
 
 
-
-<comment>creates a full table incl. edit/delete entry.id</comment>
-<function ListTable(contentlist, data_keys, aHeaders, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>
-  <assign nrColumns="1">
-  <list aHeaders as h>
-    <assign nrColumns=utility.increment(nrColumns)>
-  </list>
-
-<table cellspacing="2" border="0">
-  
-  <tr class="${column_head_CSS}">
-    <list aHeaders as indexVariable>
-      <td class="${column_head_CSS}">
-        <b>${indexVariable}</b> 
-      </td>
-    </list>
-      <td class="${column_head_CSS}">
-        &nbsp;
-      </td> 
-  </tr>
-  <assign grey="0">
-  
-  <list contentlist as entry>
-    <if grey=="1">
-      <assign grey="0">
-      <tr class="${listrow1CSS}">
-    <else>
-      <assign grey="1"> 
-      <tr class="${listrow2CSS}">
-    </if>
-      
-    <list data_keys as indexVariable>   
-        <td>
-          ${entry[indexVariable]}
-        </td>
-    </list>
-      <td>
-        <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=delete&id=${entry.id}">${lang("delete")}</a>
-        | <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=edit&id=${entry.id}">${lang("edit")}</a>
-      </td>
-    </tr>
-  </list>
-  
-  
-  <tr>    
-    <td colspan="${nrColumns}" class="table-foot">
-      ${data.count} ${lang("records")} / ${lang("show_from_to", data.from, data.to)}
-    </td>
-  </tr>
-
-</table>
-</function>
-
 <assign TABLE_HEAD_CLASS          "table-head">
 <assign TABLE_FOOT_CLASS          "table-foot">
 <assign LIST_ROW_CLASS             "listrow1">
 </function>
 
 
-<comment>creates browse links, only called if necessary</comment>
-<function PrevNextPage(module_name)>
-  <p>
-      <if (data.prev || data.next)>
-        <form method="post" action="${config.actionRoot}">
-          <input type="hidden" name="module" value="${module_name}">
-          <input type="hidden" name="where" value="${data.where}">
-          <if data.prev>
-            <input type="hidden" name="do" value="list">
-            <input type="hidden" name="prevoffset" value="${data.prev}">
-            <input type="submit" name="prev" value="${lang("list.previous")}">
-          </if>
-          <if data.next>
-            <input type="hidden" name="do" value="list">
-            <input type="hidden" name="nextoffset" value="${data.next}">
-            <input type="submit" name="next" value="${lang("list.next")}">
-          </if>
-        </form>
-      </if>
-  </p>
-</function>
-
 <comment>extra navigation</comment>
 <function AddOrBack(module_name, module_jumpback, do_jumpback)>
     <p>
 </function>
 
 <function showBack(aBackUrl)>
-  <p><a class="link-box" href="${config.actionRoot}${aBackUrl}">[&lt;] ${lang("back")} </a> &nbsp;</p>
+  <p><a class="link-box" href="${config.actionRoot}?${aBackUrl}">[&lt;] ${lang("back")} </a> &nbsp;</p>
 </function>
 
-
-
 <function PulldownTableRow (label, fieldname, entrieslist, keyfield, valuefield, value, langprefix)>
   <tr>
      <td align="right" class="table-left">
index a2a04bf..3a0932c 100755 (executable)
@@ -3,6 +3,8 @@
   not used for image-list because imagelist uses other display method
 </comment>
 
+<include "FUNCTIONS.template">
+
 <function MediaSearch (module)>
 
 <form method="post" action="${config.actionRoot}">
 
 <function MediaList (module)>
 
-<table>
-
-  <tr class="darkgrey" >
-    <td class="table-head">
-  <b>${lang("media.icon")}</b></td>
-  <td class="table-head">
-  <b>${lang("media.title")}</b></td>
-    <td class="table-head">
-  <b>${lang("media.format")}</b></td>
-    <td class="table-head">
-  <b>${lang("media.size")}</b></td>
-    <td class="table-head">
-  <b>${lang("media.mediafolder")}</b></td>
-    <td class="table-head">
-  <b>${lang("media.creator")}</b></td>
-    <td class="table-head">
-  &nbsp;</td>
-
-  </tr>
+  <call showAddOrBack("1", module, "Admin", "start")>
     <if medialist>
-    <assign grey="0">
-    <list medialist as entry>
-    <tr <if grey=="1"><assign grey="0">class="listrow1"<else>class="listrow2"<assign grey="1"> </if>>
-    <td>
-        <a href="${config.actionRoot}?module=${module}&do=getMedia&id=${entry.id}">
-<if module=="Images">
-        <img src="${config.actionRoot}?module=${module}&do=getIcon&id=${entry.id}" border=0></a>        
-<else>
-        <img src="${config.docRoot}/img/${entry.big_icon}" border=0></a>
-</if>
-    </td>
-      <td>
-      ${entry.title}&nbsp;
-          <if entry.description><br>${entry.description}</if>
-    </td>
-      <td>
-      ${entry.media_descr}&nbsp;
-    </td>
-      <td>
-      ${entry.human_readable_size}&nbsp;
-    </td>
-      <td>
-       <if entry.mediafolder>
-          ${entry.mediafolder.name}
-       </if>&nbsp;
-    </td>
-      <td>
-      ${entry.creator}&nbsp;
-    </td>
-      <td>&nbsp;
-      <if articleid>
-        <a href="${config.actionRoot}?module=Content&do=attach&mid=${entry.id}&articleid=${articleid}">${lang("attach")}</a>
-      <else>
-        <if commentid>
-          <a href="${config.actionRoot}?module=Comment&do=attach&mid=${entry.id}&commentid=${commentid}">${lang("attach")}</a>
-        <else>
-          <a href="${config.actionRoot}?module=${module}&do=delete&id=${entry.id}&okurl=${utility.encodeURI(thisurl)}&cancelurl=${utility.encodeURI(thisurl)}">${lang("delete")}</a>
-          | 
-          <a href="${config.actionRoot}?module=${module}&do=edit&id=${entry.id}">${lang("edit")}</a>
-        </if>
-      </if>
-    </td>
-    </tr>
-  </list>
-  <tr>
-    <td colspan="7" class="table-foot">
-      ${count} ${lang("records")} / ${lang("show_from_to", from, to)}
-    </td>
-  </tr>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
 
-  <tr>
-    <td>
-      <if prevurl>
-        <a href="${config.actionRoot}?${prevurl}">${lang("list.previous")}</a>&nbsp;
-      </if>
-      <if nexturl>
-        <a href="${config.actionRoot}?${nexturl}">${lang("list.next")}</a>
+      <table>
+      
+        <tr class="darkgrey" >
+          <td class="table-head">
+        <b>${lang("media.icon")}</b></td>
+        <td class="table-head">
+        <b>${lang("media.title")}</b></td>
+          <td class="table-head">
+        <b>${lang("media.format")}</b></td>
+          <td class="table-head">
+        <b>${lang("media.size")}</b></td>
+          <td class="table-head">
+        <b>${lang("media.mediafolder")}</b></td>
+          <td class="table-head">
+        <b>${lang("media.creator")}</b></td>
+          <td class="table-head">
+        &nbsp;</td>
+      
+        </tr>
+          <assign grey="0">
+          <list medialist as entry>
+          <tr <if grey=="1"><assign grey="0">class="listrow1"<else>class="listrow2"<assign grey="1"> </if>>
+          <td>
+              <a href="${config.actionRoot}?module=${module}&do=getMedia&id=${entry.id}">
+      <if module=="Images">
+              <img src="${config.actionRoot}?module=${module}&do=getIcon&id=${entry.id}" border=0></a>        
+      <else>
+              <img src="${config.docRoot}/img/${entry.big_icon}" border=0></a>
       </if>
-    </td>
-  </tr>
-
-<else>
-  <tr><td align="center" class="box" colspan="7">${lang("no_matches_found")}</td></tr>
-</if>
-</table>
+          </td>
+            <td>
+            ${entry.title}&nbsp;
+                <if entry.description><br>${entry.description}</if>
+          </td>
+            <td>
+            ${entry.media_descr}&nbsp;
+          </td>
+            <td>
+            ${entry.human_readable_size}&nbsp;
+          </td>
+            <td>
+             <if entry.mediafolder>
+                ${entry.mediafolder.name}
+             </if>&nbsp;
+          </td>
+            <td>
+            ${entry.creator}&nbsp;
+          </td>
+            <td>&nbsp;
+            <if articleid>
+              <a href="${config.actionRoot}?module=Content&do=attach&mid=${entry.id}&articleid=${articleid}">${lang("attach")}</a>
+            <else>
+              <if commentid>
+                <a href="${config.actionRoot}?module=Comment&do=attach&mid=${entry.id}&commentid=${commentid}">${lang("attach")}</a>
+              <else>
+                <a href="${config.actionRoot}?module=${module}&do=delete&id=${entry.id}&okurl=${utility.encodeURI(thisurl)}&cancelurl=${utility.encodeURI(thisurl)}">${lang("delete")}</a>
+                | 
+                <a href="${config.actionRoot}?module=${module}&do=edit&id=${entry.id}">${lang("edit")}</a>
+              </if>
+            </if>
+          </td>
+          </tr>
+        </list>
+        <tr>
+          <td colspan="7" class="table-foot">
+            ${count} ${lang("records")} / ${lang("show_from_to", from, to)}
+          </td>
+        </tr>
+      </table>
+      
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "start")>
+  
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
+    </if>
 
 </function>
index f80a939..73882a5 100755 (executable)
@@ -23,7 +23,7 @@
       <assign grey="0">      
       <list log as l>
         <if grey=="1"><assign grey="0"><tr class="listrow1"><else><tr class="listrow2"><assign grey="1"> </if>
-          <td>${l.timestamp.format("yyyy-MM-dd  HH:mm")}</td>
+          <td>${l.timestamp.format(config["Mir.DefaultDateTimeFormat"])}</td>
           <td>${l.ip}</td>
           <td>
             <if l.type=="content">
index 5d7c98f..2a21ed1 100755 (executable)
@@ -4,46 +4,36 @@
     <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
 <head>
 <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "FUNCTIONS.template">  
-<include "head.template">
-<form action="${config.actionRoot}" method="post">
-
-  <input type="hidden" name="module" value="ArticleType">
-  <input type="hidden" name="id" value="${data.id}">
-  <if data.new>
-    <input type="hidden" name="do" value="insert">
-  <else>
-    <input type="hidden" name="do" value="update">
-  </if>
-    
-  <table border="0">
-    <tr>
-      <td align="right" class="table-left">
-        <B>${lang("articletype.id")}: </B>
-      </td>
-      <td class="listrow2">
-        ${data.id}
-      </td>
-    </tr>
-
-    <call TextInputTableRow (lang("articletype.name"), 40, 255, "name", data.name)>
-
-
-    <tr>
-      <td colspan="2" align="right" class="table-foot">
-        <if data.new>
-          <input type="submit" name="save" value="${lang("insert")}">
+    <include "FUNCTIONS.template">
+    <include "head.template">
+  
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
+      
+      <call EditStart(
+         ["module", "id", "do"],
+         [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("articletype.id"), entity.id)>
+        <call EditTextNormal(lang("articletype.name"), 40, 255, "name", entity.name)>
+      
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
         <else>
-          <input type="submit" name="save" value="${lang("save")}">
+          <call EditSubmitButtonNormal(lang("save"), "save")>
         </if> 
-      </td>
-    </tr>
-  </table>
-
-</form>
 
-<p><a class="link-box" href="${config.actionRoot}?module=ArticleType&do=list">[&lt;] ${lang("back")} </a> &nbsp;</p>
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module="+module+"&amp;do=list")>
+      </if>
 
-<include "foot.template">
+    <include "foot.template">
 </body>
 </html>
index 937896c..4361cfa 100755 (executable)
@@ -7,26 +7,14 @@
     
     <include "FUNCTIONS.template">
     <include "head.template">
+    
+    <call showAddOrBack("1", module, "Admin", "superusermenu")>
 
-    <assign contentlist = data.contentlist>
-    <assign column_nr = 3>
-    <assign data_keys = ["id","name"]>
-    <assign column_head_texts = [lang("articletype.id"), lang("articletype.name")]>
-    <assign column_head_CSS = "table_head">
-    <assign listrow1CSS = "listrow1">
-    <assign listrow2CSS = "listrow2">
-    <assign footer_css = "table_foot">
-    <assign module_name = "ArticleType">
-    <assign module_jumpback = "Admin">
-    <assign do_jumpback = "superusermenu">
-  
-    <include "templates/admin/head.template">
-  
-    <call AddOrBack(module_name, module_jumpback, do_jumpback)>
-
-    <if data.contentlist>
-      <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>
-      <call AddOrBack(module_name, module_jumpback, do_jumpback)>
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, ["id","name"], [lang("articletype.id"), lang("articletype.name")], from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "superusermenu")>
     <else>
       <P align="center">${lang("no_matches_found")}</p>
     </if>
index 3ec1243..e84c0a8 100755 (executable)
@@ -1,52 +1,42 @@
 <html>
-<head>
-        <title>${config["Mir.Name"]} | ${lang("breaking.htmltitle")}</title>
-        <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-<head>
+  <head>
+    <title>${config["Mir.Name"]} | ${lang("breaking.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+  <head>
 
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "head.template">
-<include "FUNCTIONS.template">
-
-
-<form action="${config.actionRoot}" method="post">
-  <input type="hidden" name="module" value="Breaking">
-  <input type="hidden" name="id" value="${data.id}">
-  <if data.new><input type="hidden" name="do" value="insert">
-  <else><input type="hidden" name="do" value="update"></if>
-<table border="0">
+  <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+    <include "FUNCTIONS.template">
+    <include "head.template">
   
-  <tr>
-    <td align="right" class="table-left">
-   <B>${lang("breaking.date")}:</B>
-  </td>
-    <td class="listrow2">
-      ${data.webdb_create_formatted}
-    </td>
-  </tr>
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
+      
+      <call EditStart(["module", "id", "do"], [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("breaking.id"), entity.id)>
+        
+        <if new!="">
+          <call EditReadonlyTextNormal(lang("breaking.date"), entity.creationdate.format(config["Mir.DefaultDateTimeFormat"]))>
+        </if>
+        <call EditTextAreaNormal(lang("breaking.text"), lang("breaking.textinfo"), "50", "5", "text", entity.text)>\r
+      
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
 
-  
-  
-  <tr>
-    <td align="right" class="table-left">
-  <B>${lang("breaking.text")}:</B><br> ${lang("breaking.textinfo")}</td>
-    <td class="listrow2">
-   <textarea cols="50" rows="5" name="text" wrap=virtual>${data.text}</textarea>
-    </td>
-  </tr>
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module="+module+"&amp;do=list")>
+      </if>
 
-  <tr>
-    <td colspan="2" align="right" class="table-foot">
-    <if data.new>
-      <input type="submit" name="save" value="${lang("insert")}">
-    <else>
-      <input type="submit" name="save" value="${lang("save")}">
-    </if> 
-    </td>
-</table>
-</form>
-<p><a class="link-box" href="${config.actionRoot}?module=Breaking&do=list">[&lt;] ${lang("back")}</a></p>
-<include "foot.template">
-</body>
+    <include "foot.template">
+  </body>
 </html>
index 9b2cef8..7fe2f46 100755 (executable)
@@ -1,50 +1,26 @@
 <html>
-<head>
-  <title>${config["Mir.Name"]} | ${lang("breakinglist.htmltitle")}</title>
-        <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-</head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+  <head>
+    <title>${config["Mir.Name"]} | ${lang("breakinglist.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+  </head>
 
+  <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
     <include "FUNCTIONS.template">
-  
     <include "head.template">
-
-    <comment>configure this template here</comment>
-    <assign contentlist =
-     data.contentlist>
-    <assign column_nr = 3>
-    <assign column_head_texts = [lang("breaking.date"), lang("breaking.text")]>
-    <assign data_keys = ["webdb_create_formatted", "text",]>
-    <assign column_head_CSS = "table_head">
-    <assign listrow1CSS = "listrow1">
-    <assign listrow2CSS = "listrow2">
-    <assign footer_css = "table_foot">
-    <assign module_name = "Breaking">
-    <assign module_jumpback = "Admin">
-    <assign do_jumpback = "">
-
-    <if data.contentlist>
-  
-  <p>
-      <a class="link-box" href="${config.actionRoot}?module=Breaking&do=add">[+] ${lang("add")}</a> &nbsp;
-      <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-  </p>
     
-    <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>   
-    <call PrevNextPage(module_name)>    
-   <else>
-    <P align="center" class="box">${lang("no_matches_found")}</p>
+    <call showAddOrBack("1", module, "Admin", "start")>
+
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, ["webdb_create_formatted", "text"], [lang("breaking.date"), lang("breaking.text")], from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "start")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
     </if>
-    
-   <p>
-      <a class="link-box" href="${config.actionRoot}?module=Breaking&do=add">[+] ${lang("add")}</a> &nbsp;
-      <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-  </p>
-
 
     <include "foot.template">
-</body>
+  </body>
 </html>
 
 
index a8ef160..229f756 100755 (executable)
@@ -98,7 +98,7 @@
   <list comments as entry>
     <tr <if grey=="1"><assign grey="0">class="listrow1"<else><assign grey="1">class="listrow2"</if>>
       <td valign="top" class="small">
-        ${entry.creationdate.formatted["dd.MM.yyyy HH:mm"]}<br>
+        ${entry.creationdate.format(config["Mir.DefaultDateTimeFormat"])}<br>
         <if entry.is_published=="0"><b>${lang("commentlist.hidden")}</b><else>-</if><br>
         <br>
         ${lang("comment.status")}: <br>
index bb77827..7f0b593 100755 (executable)
@@ -4,43 +4,36 @@
     <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
   <head>
   <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-  <include "FUNCTIONS.template">
+    <include "FUNCTIONS.template">
     <include "head.template">
-    <form action="${config.actionRoot}" method="post">
+  
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
+      
+      <call EditStart(
+         ["module", "id", "do"],
+         [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("commentstatus.id"), entity.id)>
+        <call EditTextNormal(lang("commentstatus.name"), 40, 255, "name", entity.name)>
+      
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
 
-      <input type="hidden" name="module" value="CommentStatus">
-      <input type="hidden" name="id" value="${data.id}">
-      <if data.new>
-        <input type="hidden" name="do" value="insert">
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
       <else>
-        <input type="hidden" name="do" value="update">
+        <call showBack("module="+module+"&amp;do=list")>
       </if>
-    
-      <table border="0">
-        <tr>
-          <td align="right" class="table-left">
-          <B>${lang("commentstatus.id")}:</B></td>
-          <td class="listrow2">
-            ${data.id}
-          </td>
-        </tr>
-        
-    <call TextInputTableRow (lang("commentstatus.name"), 40, 255, "name", data.name)>
-        <tr>
-          <td colspan="2" align="right" class="table-foot">
-            <span class="witetext">
-              <if data.new>
-                <input type="submit" name="save" value="${lang("insert")}">
-              <else>
-                <input type="submit" name="save" value="${lang("save")}">
-              </if> 
-            </span>
-          </td>
-        </tr>
-      </table>
 
-    </form>
-  <p><a class="link-box" href="${config.actionRoot}?module=CommentStatus&do=list">[&lt;] ${lang("back")} </a> &nbsp;</p>
     <include "foot.template">
   </body>
 </html>
index 8944f9b..d137d28 100755 (executable)
@@ -5,35 +5,21 @@
   </head>
   <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
   
-  <include "FUNCTIONS.template">
-  
+    <include "FUNCTIONS.template">
     <include "head.template">
+    
+    <call showAddOrBack("1", module, "Admin", "superusermenu")>
 
-    <comment>configure this template here</comment>
-    <assign contentlist = data.contentlist>
-    <assign column_nr = 3>
-    <assign data_keys = ["id","name"]>
-    <assign column_head_texts = [lang("commentstatus.id"), lang("commentstatus.name")]>
-    <assign column_head_CSS = "table_head">
-    <assign listrow1CSS = "listrow1">
-    <assign listrow2CSS = "listrow2">
-    <assign footer_css = "table_foot">
-    <assign module_name = "CommentStatus">
-    <assign module_jumpback = "Admin">
-    <assign do_jumpback = "superusermenu">
-
-    <if data.contentlist>
-    <call AddOrBack(module_name, module_jumpback, do_jumpback)>
-    <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>   
-    <call PrevNextPage(module_name)>    
-   <else>
-    <P align="center">${lang("no_matches_found")}</p>
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, ["id","name"], [lang("commentstatus.id"), lang("commentstatus.name")], from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "superusermenu")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
     </if>
-    
-  <call AddOrBack(module_name, module_jumpback, do_jumpback)>
 
     <include "foot.template">
-  
   </body>
 </html>
 
index 2079caf..665ae7b 100755 (executable)
@@ -63,7 +63,7 @@
       ${lang("content.lastchange_date")}:
     </td>
     <td class="listrow2">
-      ${utility.encodeHTML(article.changedate.format("yyyy-MM-dd HH:mm"))}<br>
+      ${utility.encodeHTML(article.changedate.format(config["Mir.DefaultDateTimeFormat"]))}<br>
     </td>
   </tr>
 
@@ -72,7 +72,7 @@
       ${lang("content.create_date")}:
     </td>
     <td class="listrow2">
-      ${utility.encodeHTML(article.creationdate.format("yyyy-MM-dd HH:mm"))}<br>${lang("edit")}:
+      ${utility.encodeHTML(article.creationdate.format(config["Mir.DefaultDateTimeFormat"]))}<br>${lang("edit")}:
       <input type="text" size="10" maxlength="16" name="webdb_create" value=""> &nbsp; <span class="small">(yyyy-mm-dd [HH:mm])</span>
     </td>
   </tr>
index 00d39d6..e580010 100755 (executable)
@@ -63,8 +63,8 @@
   <list articles as entry>
     <tr <if grey=="1"><assign grey="0">class="listrow1"<else>class="listrow2"<assign grey="1"></if>>
       <td class="x-small">
-          ${entry.creationdate.formatted["dd.MM.yyyy HH:mm"]}<br>
-          ${entry.changedate.formatted["dd.MM.yyyy HH:mm"]}<br>
+          ${entry.creationdate.format(config["Mir.DefaultDateTimeFormat"])}<br>
+          ${entry.changedate.format(config["Mir.DefaultDateTimeFormat"])}<br>
           <if entry.is_published!="0">Pub.<else>-</if> <if entry.is_html!="0">HTML<else>-</if>
       </td>
       <td>
index 288e156..65f7d00 100755 (executable)
@@ -1,20 +1,20 @@
 <html>
-<head>
+  <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">
+  </head>
+  <body>
+    <include "head.template">
 
-<table width="70%" align="center"><tr><td>
+    <table width="70%" align="center"><tr><td>
 
-<p class="box-head" align="center"><font size="+2"><b>${lang("error.title")}</b></font></p>
-<p align="center">${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
-<p align="center" class="bg-neutral"><br><font color="red">${data.date} -- ${data.errorstring}</font><br><br></p>
-<p align="center">${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
+      <p class="box-head" align="center"><font size="+2"><b>${lang("error.title")}</b></font></p>
+      <p align="center">${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
+      <p align="center" class="bg-neutral"><br><font color="red">${date.format(config["Mir.DefaultDateTimeFormat"])} -- ${errorstring}</font><br><br></p>
+      <p align="center">${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
 
-</td></tr></table>
+    </td></tr></table>
 
-<include "foot.template">
-</body>
+    <include "foot.template">
+  </body>
 </html>
index e1432d3..d67fe76 100755 (executable)
@@ -1,5 +1,5 @@
 <hr>  
-<table width="99%" cellspacing="0">
+<table width="100%" cellspacing="0">
   <tbody>
   <tr>
     <td align="left" class="table-head">
index e9ed39c..0c942f7 100755 (executable)
@@ -4,7 +4,7 @@
   <tr>
     <td><img src="${config.docRoot}/img/logo_small.gif" border="0" align="left"></td>
     <td>
-      ${config["Mir.Name"]} &nbsp; | &nbsp; ${config.now.format("yyyy-MM-dd HH:mm z")} 
+      ${config["Mir.Name"]} &nbsp; | &nbsp; ${config.now.format(config["Mir.DefaultDateTimeFormat"])} 
     </td>
     <td class="table-head" align="right">
       <a href="${config.actionRoot}?module=Users&amp;do=changepassword&amp;id=${login_user.id}&amp;returnurl="><span class="table-head">${lang("head.changepassword")}</span></a> &nbsp; | &nbsp;
index 8850bb7..2238ae5 100755 (executable)
@@ -4,7 +4,7 @@
   <tr>
     <td><img src="${config.docRoot}/img/logo_small.gif" border="0" align="left"></td>
     <td>
-      ${config["Mir.Name"]} &nbsp; | &nbsp; ${config.now.format("yyyy-MM-dd HH:mm z")} 
+      ${config["Mir.Name"]} 
     </td>
   </tr>
 </table>
index 4708b16..cd2191b 100755 (executable)
@@ -68,7 +68,7 @@
 <table cellpadding="6" width="98%" class="litegrey">
 <tr>
   <td>
-  <p>${lang("start.content.hidden")} | ${lang("month")}: ${data.month} , ${lang("year")}:${data.year}</p>
+  <p>${lang("start.content.hidden")} | ${lang("month")}: ${month} , ${lang("year")}:${year}</p>
   </td>
 </tr>
 </table>
@@ -77,7 +77,7 @@
   <p style='background: #FFFFFF; padding: 8px;'>
     ${lang("content.title")}: <b>${i.title}</b><br>
     ${lang("content.creator")}: ${i.creator}<br>
-    ${lang("message.date")}: ${i.creationdate.formatted["dd.MM.yyyy HH:mm"]}<br>
+    ${lang("message.date")}: ${i.creationdate.format(config["Mir.DefaultDateTimeFormat"])}<br>
     <br>
     <if i.to_media_audio>additional media, type: audio<br></if>
     <if i.to_media_video>additional media, type: video<br></if>
index de733de..1c20ece 100755 (executable)
@@ -1,33 +1,41 @@
 <html>
-<head>
-        <title>${config["Mir.Name"]} | ${lang("language.htmltitle")}</title>
-        <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-<head>
+  <head>
+    <title>${config["Mir.Name"]} | ${lang("language.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+  <head>
+  <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
 
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "FUNCTIONS.template">
-<include "head.template">
+    <include "FUNCTIONS.template">
+    <include "head.template">
+  
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
+      
+      <call EditStart(
+         ["module", "id", "do"],
+         [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("language.id"), entity.id)>
+        <call EditTextNormal(lang("language.name"), 40, 255, "name", entity.name)>
+        <call EditTextNormal(lang("language.code"), 2, 2, "code", entity.code)>
+      
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
 
-<form action="${config.actionRoot}" method="post">
-  <input type="hidden" name="module" value="Language">
-  <input type="hidden" name="id" value="${data.id}">
-  <if data.new><input type="hidden" name="do" value="insert">
-  <else><input type="hidden" name="do" value="update"></if>
-<table border="0">
-    <call TextInputTableRow (lang("language.name"), 30, 255, "name", data.name)>
-    <call TextInputTableRow (lang("language.code"), 2, 2,"code", data.code)>
-  <tr>
-    <td class="table-foot" colspan="2" align="right"> 
-  <if data.new>
-      <input type="submit" name="save" value="${lang("insert")}">
-    <else>
-      <input type="submit" name="save" value="${lang("save")}">
-    </if>
-  </td>
-  </tr>
-</table>
-</form>
-<p><a class="link-box" href="${config.actionRoot}?module=Language&do=list">[&lt;] ${lang("back")} </a> &nbsp;</p>
-<include "foot.template">
-</body>
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module="+module+"&amp;do=list")>
+      </if>
+
+    <include "foot.template">
+  </body>
 </html>
index 5ee774f..58a2eae 100755 (executable)
@@ -4,33 +4,20 @@
     <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
   </head>
   <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
     <include "FUNCTIONS.template">
-  
     <include "head.template">
+    
+    <call showAddOrBack("1", module, "Admin", "superusermenu")>
 
-    <comment>configure this template here</comment>
-    <assign contentlist = data.contentlist>
-    <assign column_nr = 3>
-    <assign data_keys = ["name","code"]>
-    <assign column_head_texts = [lang("language.name"), lang("language.code")]>
-    <assign column_head_CSS = "table_head">
-    <assign listrow1CSS = "listrow1">
-    <assign listrow2CSS = "listrow2">
-    <assign footer_css = "table_foot">
-    <assign module_name = "Language">
-    <assign module_jumpback = "Admin">
-    <assign do_jumpback = "superusermenu">
-
-    <if data.contentlist>
-    <call AddOrBack(module_name, module_jumpback, do_jumpback)>
-    <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>   
-    <call PrevNextPage(module_name)>    
-   <else>
-    <P align="center">${lang("no_matches_found")}</p>
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, ["id", "name","code"], [lang("language.id"), lang("language.name"), lang("language.code")], from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "superusermenu")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
     </if>
-    
-  <call AddOrBack(module_name, module_jumpback, do_jumpback)>
+
     <include "foot.template">
   </body>
 </html>
diff --git a/templates/admin/linksimcs.template b/templates/admin/linksimcs.template
deleted file mode 100755 (executable)
index ab40ab1..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<html>
-<head>
-        <title>${config["Mir.Name"]} | ${lang("linkimcs.htmltitle")}</title>
-        <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-<head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "head.template">
-<form action="${config.actionRoot}" method="post">
-  <input type=hidden name=module value=LinksImcs>
-  <input type="hidden" name="id" value="${data.entity.id}">
-  <if data.new><input type="hidden" name="do" value="insert">
-  <else><input type="hidden" name="do" value="update"></if>
-<table border="0">
-  <tr>
-    <td align="right" class="darkgrey"><span class="witesmall>
-    <B>${lang("linkimcs.name")}:</B></span></td>
-    <td>
-        <input type="text" size="40" name="title" value="${data.entity.title}">
-    </td>
-  </tr>
-  <tr>
-    <td align="right" class="darkgrey"><span class="witesmall>
-    <B>${lang("linkimcs.continent")}:</B></span></td>
-    <td>
-    <if data.parentlist>
-      <select name="to_parent_id" size="1">
-      <option value=NULL> ${lang("linkimcs.new_parent")}
-      <list data.parentlist as entry><option value="${entry.id}"<if entry.id == data.entity.to_parent_id> selected</if>> ${entry.title}</list>
-    </select>
-    </if>
-    </td>
-  </tr>
-  <tr>
-    <td align="right" class="darkgrey"><span class="witetext"><B>${lang("linkimcs.url")}:</B></span></td>
-    <td>
-      <input type="text" size="40" name="url" value="${data.entity.url}">
-    </td>
-  </tr>
-  <tr>
-    <td align="right" class="darkgrey"><span class="witetext"><B>${lang("linkimcs.sort-by")}:</B></span></td>
-    <td>
-      <select name="sortpriority" size="1">
-    <option value="1"<if data.entity.sortpriority == 1> selected</if>> 1
-    <option value="2"<if data.entity.sortpriority == 2> selected</if>> 2
-    <option value="3"<if data.entity.sortpriority == 3> selected</if>> 3
-    <option value="4"<if data.entity.sortpriority == 4> selected</if>> 4
-    </select>
-    </td>
-  </tr>
-  <tr>
-    <td align="right" class="darkgrey"><span class="witetext"><B>${lang("linkimcs.language")}:</B></span></td>
-    <td>
-      <select name="to_language" size="1">
-      <list data.languagelist as language>
-      <option value="${language.id}"<if data.entity.to_language == language.id> selected</if>> ${language.name}
-    </list>
-    </select>
-    </td>
-  </tr>
-  <tr>
-    <td colspan="2" align="right"><span class="witetext">
-    <if data.new>
-          <input type="submit" name="save" value="${lang("insert")}">
-      <else>
-        <input type="submit" name="save" value="${lang("save")}">
-      </if> </span></form></span>
-    </td>
-  </tr>
-</table>
-<include "foot.template">
-</body>
-</html>
index 279f8c6..0fd062c 100755 (executable)
@@ -50,8 +50,8 @@
       <td align="right">${lang("login.language")}:</td>
       <td align="left">  
         <select name="language">
-        <list data.languages as l>
-          <option value="${l.code}" <if l.code==data.defaultlanguage>selected</if> >${l.name}</option>
+        <list languages as l>
+          <option value="${l.code}" <if l.code==defaultlanguage>selected</if> >${l.name}</option>
         </list>
         </select>
       </td>
index 0389eb9..61ec50c 100755 (executable)
@@ -5,39 +5,40 @@
 <head>
 
 <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "FUNCTIONS.template">  
-<include "head.template">
-
-<form method="post" action="${config.actionRoot}">
-  <input type=hidden name=module value=Mediafolder>
-  <input type="hidden" name="id" value="${data.id}">
-  <if data.new> <input type="hidden" name="do" value="insert">
-  <else>   <input type="hidden" name="do" value="update"></if>
-
-<table border="0" cellspacing="2" cellpadding="2">
-<call TextInputTableRow (lang("mediafolder.date"), 8, 8, "date", data.date)>
-<call TextInputTableRow (lang("mediafolder.name"), 40, 80, "name", data.name)>  
-<call TextInputTableRow (lang("mediafolder.location"), 40, 80, "place", data.place)>  
-<call TextAreaTableRow (lang("mediafolder.comment"), "", 40, 5, "comment", data.comment)>  
-<call TextAreaTableRow (lang("mediafolder.keywords"), "", 40, 4, "keywords", data.keywords)>  
-
-
-  <tr>
-    <td colspan="4" align="right" class="table-foot"> 
-    <if data.new> <input type="submit" name="save" value="${lang("insert")}">
-      <else>   <input type="submit" name="save" value="${lang("save")}"></if>
-    
-    </td>
-  </tr>
-</table>
-
-</form>
-    <p>      
-      <a class="link-box" href="${config.actionRoot}?module=Mediafolder&do=list">[&lt;] ${lang("list")} </a> &nbsp;
-      <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-  </p>
-
-<include "foot.template">
+    <include "FUNCTIONS.template">
+    <include "head.template">
+  
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
+      
+      <call EditStart( ["module", "id", "do"], [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("mediafolder.id"), entity.id)>
+        
+        <call EditTextNormal(lang("mediafolder.date"), 8, 8, "date", entity.date)>
+        <call EditTextNormal(lang("mediafolder.name"), 40, 80, "name", entity.name)>
+        <call EditTextNormal(lang("mediafolder.location"), 40, 80, "place", entity.place)>
+
+        <call EditTextAreaNormal(lang("mediafolder.comment"), "", 40, 5, "comment", entity.comment)>\r
+        <call EditTextAreaNormal(lang("mediafolder.keywords"), "", 40,5, "keywords", entity.keywords)>\r
+        
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
+
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module="+module+"&amp;do=list")>
+      </if>
+
+    <include "foot.template">
 </body>
 </html>
index 06b3a31..62787b7 100755 (executable)
@@ -5,53 +5,24 @@
 </head>
 
 <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+    <include "FUNCTIONS.template">
+    <include "head.template">
+    
+    <call showAddOrBack("1", module, "Admin", "superusermenu")>
 
-<include "head.template">
-<if data.contentlist>
-  <table border="0">
-      <tr class="darkgrey">
-        <td class="table-head">${lang("mediafolder.date")}</td>
-        <td class="table-head">${lang("mediafolder.name")}</td>
-        <td class="table-head">${lang("mediafolder.location")}</td>
-      <td class="table-head">${lang("mediafolder.comment")}</td>
-      <td class="table-head">${lang("mediafolder.keywords")}</td>
-      <td class="table-head">&nbsp;</td>
-     </tr>
-    <list data.contentlist as entry>
-      <tr <if grey=="1"><assign grey="0">class="listrow1"<else>class="listrow2"<assign grey="1"> </if>>
-      <td>${entry.date}&nbsp;</td>
-        <td><b>${entry.name}</b>&nbsp;</td>
-        <td>${entry.place}&nbsp;</td>
-        <td>${entry.comment}&nbsp;</td>
-        <td>${entry.keywords}&nbsp;</td>
-        <td><a href="${config.actionRoot}?module=Mediafolder&do=delete&id=${entry.id}">${lang("delete")}</a>
-          | <a href="${config.actionRoot}?module=Mediafolder&do=edit&id=${entry.id}">${lang("edit")}</a>
-        | <a href="${config.actionRoot}?module=Images&do=list&query_media_folder=${entry.id}">${lang("list")}</a></td>
-      </tr>
-      </list>
-      <tr>
-      <td colspan="6" class="table-foot">${data.count} ${lang("records")} /
-        ${lang("show_from_to", data.from, data.to)}</td>
-      <td>&nbsp;</td>
-      </tr>
-  </table>
-      <P>
-  <if data.prev>
-  <a href="${config.actionRoot}?module=Mediafolder&do=list&where=${data.where}&prevoffset=${data.prev}&prev=zur&uuml;ck">${lang("list.previous")}</a>&nbsp;
-  </if>
-  <if data.next>
-  <a href="${config.actionRoot}?module=Mediafolder&do=list&where=${data.where}&nextoffset=${data.next}&next=weiter">${lang("list.next")}</a>
-  </if>
-<else>
-  <P align="center" class="box">${lang("no_matches_found")}</p>
-</if>
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, ["name", "place","comment"], 
+         [ lang("mediafolder.name"), 
+           lang("mediafolder.location"),
+           lang("mediafolder.comment")], from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "start")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
+    </if>
 
-    <p>
-      <a class="link-box" href="${config.actionRoot}?module=Mediafolder&do=add">[+] ${lang("add")}</a> &nbsp;
-      <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-  </p>
-
-<include "foot.template">
+    <include "foot.template">
 </body>
 </html>
 
index 244b290..d203287 100755 (executable)
@@ -1,63 +1,43 @@
 <html>
-<head>
-        <title>${config["Mir.Name"]} | ${lang("message.htmltitle")}</title>
-        <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-<head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "FUNCTIONS.template">
-<include "head.template">
-
-
-<form action="${config.actionRoot}" method="post">
-  <input type="hidden" name="module" value="Message">
-  <input type="hidden" name="id" value="${data.id}">
-  <if data.new>
-    <input type="hidden" name="do" value="insert">
-  <else>
-    <input type="hidden" name="do" value="update">
-  </if>
-  
-<table border="0">
+  <head>
+    <title>${config["Mir.Name"]} | ${lang("message.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+  <head>
+
+  <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+    <include "FUNCTIONS.template">
+    <include "head.template">
   
-  <tr>
-    <td align="right" class="table-left">
-  ${lang("message.date")}:</td>
-    <td>
-      ${data.date}
-    </td>
-  </tr>
-
-  
-  <call TextInputTableRow (lang("message.title"), 30, 30, "title", data.title)> 
-  <call TextInputTableRow (lang("message.creator"), 12, 30, "creator", data.creator)> 
-  <call TextAreaTableRow  (lang("message.text"), "", 50, 5, "description", data.description)> 
-  
-
-
-  <tr>
-    <td class="table-foot">
-  ${lang("message.textinfo")}
-  </td>
-  
-  <td align="right" class="table-foot"> 
-  <if new>
-    <input type="submit" name="save" value="${lang("insert")}">
-    <else>
-    <input type="submit" name="save" value="${lang("save")}">
-    </if> 
-    </td>
-  </tr>
-</table>
-
-</form>
-    <p>
+      <if new=="1">
+        <assign method="insert">
+      <else>
+        <assign method="update">
+      </if>
       
-      <a class="link-box" href="${config.actionRoot}?module=Message&do=list">[&lt;] ${lang("back")} </a> &nbsp;
-      <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-  </p>
-
+      
+      <call EditStart(["module", "id", "do"], [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("message.id"), entity.id)>
+        <call EditReadonlyTextNormal(lang("message.date"), entity.creationdate.format(config["Mir.DefaultDateTimeFormat"]))>
+        <call EditTextNormal(lang("message.title"), 30, 30, "title", entity.title)>
+        <call EditTextNormal(lang("message.creator"), 30, 30, "creator", entity.creator)>
+
+        <call EditTextAreaNormal(lang("message.text"), "", "50", "5", "description", entity.description)>\r
+      
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
 
-<include "foot.template">
-</body>
+      <call EditEnd()>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module="+module+"&amp;do=list")>
+      </if>
+
+    <include "foot.template">
+  </body>
 </html>
index b151b25..0782eac 100755 (executable)
@@ -6,69 +6,24 @@
 
 <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
 
-<include "head.template">
-<include "FUNCTIONS.template">
-
-<p>
-  <a class="link-box" href="${config.actionRoot}?module=Message&do=add">[+] ${lang("add")}</a> &nbsp;
-  <a class="link-box" href="${config.actionRoot}">[&lt;&lt;&lt;] ${lang("head.start")}</a>
-</p>
-
-<if data.contentlist>
-  <assign prevurl="">
-  <assign nexturl="">
-  <if data.prev>
-    <assign prevurl="module=Message&amp;do=list&amp;where="+data.where+"&amp;offset="+data.prev>
-  </if>
-  <if data.next>
-    <assign nexturl="module=Message&amp;do=list&amp;where="+data.where+"&amp;offset="+data.next>
-  </if>
-
-  <call showPrevNextLinks (prevurl, nexturl, "left")>
-  
-<table border="0" cellpadding="2" cellspacing="1">
-  <tr>
-    <td class="table-head">
-    ${lang("message.date")}</td>
-    <td class="table-head">
-    ${lang("message.title")} /<br>${lang("message.creator")}</td>
-    <td colspan="2" class="table-head">
-    ${lang("message.text")}</td>
-  </tr>
-
-  <list data.contentlist as entry>
-  <tr
-    <if grey=="1">
-      <assign grey="0">class="listrow1"
-    <else>class="listrow2"
-      <assign grey="1"> 
-    </if> >
-  <td class="x-small" valign="top">${entry.webdb_create}&nbsp;</td>
-  <td valign="top"><span class="small"><b>${entry.title}</b></span><br>
-     <span class="x-small">${lang("by")}: ${entry.creator}</span></td>
-  <td>${entry.description}&nbsp;</td>
-  <td valign="top">
-      <a class="listcommand" href="${config.actionRoot}?module=Message&do=delete&id=${entry.id}">[&nbsp;${lang("delete")}&nbsp;]</a><br>
-    <a class="listcommand" href="${config.actionRoot}?module=Message&do=edit&id=${entry.id}">[&nbsp;${lang("edit")}&nbsp;]</a>
-  </td>
-  </tr>
-  </list>
-  
-  <tr>
-    <td colspan="4" class="table-foot">${data.count} ${lang("records")} /
-        ${lang("show_from_to", data.from, data.to)}</td>
+    <include "FUNCTIONS.template">
+    <include "head.template">
     
-  </tr>
-
-</table>
-
-<P>
-  <call showPrevNextLinks (prevurl, nexturl, "left")>
-
-<else>
-  <P align="center">${lang("no_matches_found")}</p>
-</if>
+    <call showAddOrBack("1", module, "Admin", "start")>
+
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, [
+           "id", "title", "creator", "description"], 
+           [ lang("message.id"), lang("message.title"), lang("message.creator"), lang("message.text")], 
+          from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "start")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
+    </if>
+
+    <include "foot.template">
 
-<include "foot.template">
 </body>
 </html>
index 2b4bdb4..fd89391 100755 (executable)
             <if m.title><b>${m.title}</b><br></if>
             ${m.description}<br>
             <span class="x-small">
-              <if m.creator><i>by: ${m.creator}</i> / </if>${m.webdb_create}<br>
+              <if m.creator><i>by: ${m.creator}</i> / </if>${m.creationdate.format(config["Mir.DefaultDateTimeFormat"])}}<br>
             </span>
           </p>
         </list>
       <div class="box">
         <call ContentSearch ("")>
       </div>
-      
+
+<comment>      
       <!-- HELP -DEMO -->
       <p class="box">
         <b>HELP-Demo:</b><br>
         popup small-link: <call Help ("../help/content_datum.html", "1", "" )>&nbsp;&nbsp;  popup big-link: <call Help ("../help/content_datum.html", "1", "1" )><br><br>
         newwin small-link: <call Help ("../help/content_datum.html", "", "" )>&nbsp;&nbsp; newwin big-link: <call Help ("../help/content_datum.html", "", "1" )>
       </p>
-      
+</comment>      
       
     </td>
-    <td>&nbsp;</td>
   </tr>
   
 </table>
index 1c90b7d..3fae6b8 100755 (executable)
@@ -8,32 +8,40 @@
     <include "FUNCTIONS.template">
     <include "head.template">
   
-      <if data.new>
+      <if new=="1">
         <assign method="insert">
       <else>
         <assign method="update">
       </if>
+      
       <call EditStart(
          ["module", "id", "do"],
-         ["Topics", data.id, method])>
+         [module, entity.id, method])>
+         
+        <call EditReadonlyTextNormal(lang("topic.id"), entity.id)>
          
-        <call EditTextNormal(lang("topic.title"), 40, 255, "title", data.title)>
-        <call EditTextAreaNormal(lang("topic.description"), "", 40, 3, "description", data.description)>
-        <call EditTextNormal(lang("topic.filename"), 20, 255, "filename", data.filename)>
-        <call EditTextNormal(lang("topic.main_url"), 40, 255, "main_url", data.main_url)>
-        <call EditTextNormal(lang("topic.archive_url"), 40, 255, "archiv_url", data.archiv_url)>
+        <call EditTextNormal(lang("topic.title"), 40, 255, "title", entity.title)>
+        <call EditTextAreaNormal(lang("topic.description"), "", 40, 3, "description", entity.description)>
+        <call EditTextNormal(lang("topic.filename"), 20, 255, "filename", entity.filename)>
+        <call EditTextNormal(lang("topic.main_url"), 40, 255, "main_url", entity.main_url)>
+        <call EditTextNormal(lang("topic.archive_url"), 40, 255, "archiv_url", entity.archiv_url)>
+        
+        
       
-        <tr>
-          <td class="table-foot" colspan="2" align="right"> 
-          <if data.new>
-            <input type="submit" name="save" value="${lang("insert")}">
-          <else>
-            <input type="submit" name="save" value="${lang("save")}">
-          </if> 
-          </td>
-        </tr>
+        <if new=="1">
+          <call EditSubmitButtonNormal(lang("insert"), "save")>
+        <else>
+          <call EditSubmitButtonNormal(lang("save"), "save")>
+        </if> 
+
       <call EditEnd()>
-  <p><a class="link-box" href="${config.actionRoot}?module=Topics&do=list">[&lt;] ${lang("back")} </a> &nbsp;</p>
+      
+      <if returnurl>
+        <call showBack(returnurl)>
+      <else>
+        <call showBack("module=Topics&do=list")>
+      </if>
+
     <include "foot.template">
   </body>
 </html>
index 21a3c58..6a08c89 100755 (executable)
@@ -6,36 +6,32 @@
 
   <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
 
-
     <include "FUNCTIONS.template">
-  
     <include "head.template">
-
-    <comment>configure this template here</comment>
-    <assign contentlist = data.contentlist>
-    <assign column_nr = 5>
-    <assign column_head_texts = [lang("topic.title"), lang("topic.description"), lang("topic.main_url"), lang("topic.archive_url")]>
-    <assign data_keys = ["title", "description", "main_url", "archiv_url"]>
-    <assign column_head_CSS = "table_head">
-    <assign listrow1CSS = "listrow1">
-    <assign listrow2CSS = "listrow2">
-    <assign footer_css = "table_foot">
-    <assign module_name = "Topics">
-    <assign module_jumpback = "Admin">
-    <assign do_jumpback = "superusermenu">
-
-    <if data.contentlist>
-    <call AddOrBack(module_name, module_jumpback, do_jumpback)>
-    <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>   
-    <call PrevNextPage(module_name)>    
-   <else>
-    <P align="center">${lang("no_matches_found")}</p>
-    </if>
     
-  <call AddOrBack(module_name, module_jumpback, do_jumpback)>
+    <call showAddOrBack("1", module, "Admin", "superusermenu")>
+
+    <if entities>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call EntityTable(entities, [
+           "title", 
+           "filename", 
+           "main_url", 
+           "archiv_url",
+           "description"], 
+           [ lang("topic.title"), 
+             lang("topic.filename"), 
+             lang("topic.main_url"), 
+             lang("topic.archive_url"), 
+             lang("topic.description")], 
+          from, to, count, "1", "1", module)>
+      <call showPrevNextLinks(prevurl, nexturl, "left")>
+      <call showAddOrBack("1", module, "Admin", "superusermenu")>
+    <else>
+      <P align="center">${lang("no_matches_found")}</p>
+    </if>
 
     <include "foot.template">
-  
   </body>
 </html>
 
index ffcd623..ddef833 100755 (executable)
@@ -53,7 +53,7 @@
   <if passwordonly>
     <call showBack("")>
   <else>
-    <call showBack("?module=Users&amp;do=list")>
+    <call showBack("module=Users&amp;do=list")>
   </if>
 
   <include "foot.template">