bolivian setup seems to work now...
[mir.git] / source / mircoders / localizer / basic / MirBasicProducerToolLocalizer.java
index 8a5eb8c..9d99449 100755 (executable)
@@ -11,11 +11,13 @@ import mircoders.localizer.*;
 import mircoders.global.*;
 
 public class MirBasicProducerToolLocalizer implements MirProducerToolLocalizer {
+  protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
 
   public void initializeGenerationValueSet(Map aValueSet) {
     // ML: these config settings will be included more beautifully as soon as the new config system is in place
 
     Map configMap = new HashMap();
+    Map utilityMap = new HashMap();
 
                configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
                configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
@@ -28,35 +30,46 @@ public class MirBasicProducerToolLocalizer implements MirProducerToolLocalizer {
                configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
                configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
                configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
-               configMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
                configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
 
+               utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+
     aValueSet.put("config", configMap);
+    aValueSet.put("utility", utilityMap);
 
     EntityList topicList=null;
     EntityList entityList=null;
     EntityList parentList=null;
+    EntityList languageList=null;
 
     try {
       ModuleLinksImcs linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
       ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
+      ModuleLanguage languageModule = new ModuleLanguage(DatabaseLanguage.getInstance());
 
       topicList = topicsModule.getTopicsList();
       entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
       parentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
-
+      languageList = languageModule.getByWhereClause("", "id", -1);
     }
     catch (Throwable t) {
-      System.out.println("initializeGenerationValueSet: Exception "+t.getMessage());
-      t.printStackTrace(System.out);
+      logger.printError("initializeGenerationValueSet: Exception "+t.getMessage());
     }
 
     aValueSet.put("topics", topicList);
     aValueSet.put("imclist", entityList);
     aValueSet.put("parentlist", parentList);
+
+    Map articleTypeMap = new HashMap();
+    articleTypeMap.put("openposting", "0");
+    articleTypeMap.put("newswire", "1");
+    articleTypeMap.put("feature", "2");
+    articleTypeMap.put("topicspecial", "3");
+    articleTypeMap.put("startspecial", "4");
+    aValueSet.put("articletype", articleTypeMap);
   };
 
-  public PrintWriter openWriter(String anIdentifier) throws MirLocalizerException {
+  public PrintWriter openWriter(String anIdentifier) throws MirLocalizerFailure {
     File file;
     File dir;
 
@@ -74,11 +87,21 @@ public class MirBasicProducerToolLocalizer implements MirProducerToolLocalizer {
       );
     }
     catch (Throwable t) {
-      throw new MirLocalizerException(t);
+      throw new MirLocalizerFailure("Failure while opening a PrintWriter",t);
     }
   };
 
   public void closeWriter(PrintWriter aWriter) {
     aWriter.close();
   };
+
+  public String filterText(String aText) {
+    return StringUtil.createHTML(
+        StringUtil.deleteForbiddenTags(aText),
+        MirGlobal.getConfigProperty("Producer.ImageRoot"),
+        MirGlobal.getConfigProperty("Producer.MailLinkName"),
+        MirGlobal.getConfigProperty("Producer.ExtLinkName"),
+        MirGlobal.getConfigProperty("Producer.IntLinkName")
+    );
+  }
 }