replaced some gnu RE's with the much faster jakarta ORO
authorzapata <zapata>
Thu, 1 Jun 2006 17:57:20 +0000 (17:57 +0000)
committerzapata <zapata>
Thu, 1 Jun 2006 17:57:20 +0000 (17:57 +0000)
lib/oro-2.0.8.jar [new file with mode: 0644]
source/mir/misc/StringUtil.java
source/mir/util/FileRoutines.java
source/mir/util/HTMLStripper.java [new file with mode: 0644]
source/mir/util/ShellRoutines.java
source/mircoders/global/MirGlobal.java
source/mircoders/localizer/LocalizerCache.java [new file with mode: 0755]
source/mircoders/localizer/MirCachingLocalizerDecorator.java [deleted file]
source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java
source/mircoders/servlet/ServletModuleFileEdit.java

diff --git a/lib/oro-2.0.8.jar b/lib/oro-2.0.8.jar
new file mode 100644 (file)
index 0000000..23488d2
Binary files /dev/null and b/lib/oro-2.0.8.jar differ
index fc9b84a..a468697 100755 (executable)
@@ -40,18 +40,13 @@ import java.util.TimeZone;
 public final class StringUtil {
 
   private static TimeZone UTC = TimeZone.getTimeZone("UTC");
 public final class StringUtil {
 
   private static TimeZone UTC = TimeZone.getTimeZone("UTC");
-  private static RE   re_newline2br, re_brbr2p, re_mail, re_url, re_tags,
-                      re_tables, re_forbiddenTags;
+  private static RE   re_tags, re_tables, re_forbiddenTags;
 
   private StringUtil() { }  // this avoids contruction
 
   static {
     try {
       //precompile regex
 
   private StringUtil() { }  // this avoids contruction
 
   static {
     try {
       //precompile regex
-      re_newline2br = new RE("(\r?\n){1}");
-      re_brbr2p     = new RE("(<br>\r?\n<br>){1,}");
-      re_mail       = new RE("\\b([a-zA-Z0-9_.-]+)@([a-zA-Z0-9_-]+)\\.([a-zA-Z0-9_.-]+)\\b");
-      re_url        = new RE("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])");
       re_tags       = new RE("<[^>]*>",RE.REG_ICASE);
       re_tables = new RE("<[ \t\r\n/]*(table|td|tr)[ \t\r\n]*>",RE.REG_ICASE);
       re_forbiddenTags = new RE("<[ \t\r\n/]*(html|meta|body|head|script)[ \t\r\n]*>",RE.REG_ICASE);
       re_tags       = new RE("<[^>]*>",RE.REG_ICASE);
       re_tables = new RE("<[ \t\r\n/]*(table|td|tr)[ \t\r\n]*>",RE.REG_ICASE);
       re_forbiddenTags = new RE("<[ \t\r\n/]*(html|meta|body|head|script)[ \t\r\n]*>",RE.REG_ICASE);
@@ -89,23 +84,6 @@ public final class StringUtil {
   }
 
   /**
   }
 
   /**
-   * Wandelt Calendar in einen 12-ziffrigen String um (yyyymmddhhmm)
-   * @param theDate
-   * @return 12-ziffriger String (yyyymmdd)
-   */
-
-  public static final String date2webdbDateTime (GregorianCalendar theDate) {
-    StringBuffer webdbDate = new StringBuffer();
-    webdbDate.append(String.valueOf(theDate.get(Calendar.YEAR)));
-    webdbDate.append(pad2(theDate.get(Calendar.MONTH) + 1));
-    webdbDate.append(pad2(theDate.get(Calendar.DATE)));
-    webdbDate.append(pad2(theDate.get(Calendar.HOUR)));
-    webdbDate.append(pad2(theDate.get(Calendar.MINUTE)));
-
-    return  webdbDate.toString();
-  }
-
-  /**
    * Return a http://www.w3.org/TR/NOTE-datetime formatted date (yyyy-mm-ddThh:mm:ssTZ)
    * @param theDate
    * @return w3approved datetime
    * Return a http://www.w3.org/TR/NOTE-datetime formatted date (yyyy-mm-ddThh:mm:ssTZ)
    * @param theDate
    * @return w3approved datetime
@@ -157,22 +135,6 @@ public final class StringUtil {
   }
 
   /**
   }
 
   /**
-  *  deleteForbiddenTags
-  *  this method deletes all <script>, <body> and <head>-tags
-  */
-  public static final String deleteForbiddenTags(String haystack) {
-    return re_forbiddenTags.substituteAll(haystack,"");
-  }
-
-  /**
-   *  deleteHTMLTableTags
-   *  this method deletes all <table>, <tr> and <td>-tags
-   */
-  public static final String deleteHTMLTableTags(String haystack) {
-    return re_tables.substituteAll(haystack,"");
-  }
-
-  /**
    * wandelt eine Datum in einen 8-buchstabigen String, der durch <code>/</code>
    * getrennt ist.
    *
    * wandelt eine Datum in einen 8-buchstabigen String, der durch <code>/</code>
    * getrennt ist.
    *
@@ -190,22 +152,6 @@ public final class StringUtil {
   }
 
   /**
   }
 
   /**
-   * Replaces in <code>haystack</code> matching <code>pattern</code> by <code>substitute</code>
-   * @param haystack
-   * @param pattern
-   * @param substitute
-   * @return String with replacements.
-   */
-  public static String regexpReplace(String haystack, String pattern, String substitute) {
-    try {
-      RE regex = new RE(pattern);
-      return regex.substituteAll(haystack,substitute);
-    } catch(REException ex){
-      return null;
-    }
-  }
-
-  /**
    * L?scht <code>/</code> am Ende des Strings, falls vorhanden
    * @param path
    * @return String ohne <code>/</code> am Ende
    * L?scht <code>/</code> am Ende des Strings, falls vorhanden
    * @param path
    * @return String ohne <code>/</code> am Ende
@@ -251,117 +197,6 @@ public final class StringUtil {
 
 
   /**
 
 
   /**
-   *  convertNewline2P ist eine regex-routine zum umwandeln von 2 oder mehr newlines (\n)
-   *  in den html-tag <p>
-   *  nur sinnvoll, wenn text nicht im html-format eingegeben
-   */
-  private static String convertNewline2P(String haystack) {
-    return re_brbr2p.substituteAll(haystack,"\n</p><p>");
-  }
-
-  /**
-   *  convertNewline2Break ist eine regex-routine zum umwandeln von 1 newline (\n)
-   *  in den html-tag <br>
-   *  nur sinnvoll, wenn text nicht im html-format eingegeben
-   */
-  private static String convertNewline2Break(String haystack) {
-    return re_newline2br.substituteAll(haystack,"$0<br />");
-  }
-
-  /**
-   *  createMailLinks wandelt text im email-adressenformat
-   *  in einen klickbaren link um
-   *  nur sinnvoll, wenn text nicht im html-format eingegeben
-   */
-  private static String createMailLinks(String haystack) {
-    return re_mail.substituteAll(haystack,"<a href=\"mailto:$0\">$0</a>");
-  }
-
-
-  /**
-   *  createMailLinks wandelt text im email-adressenformat
-   *  in einen klickbaren link um
-   *  nur sinnvoll, wenn text nicht im html-format eingegeben
-   */
-  private static String createMailLinks(String haystack, String imageRoot, String mailImage) {
-    return re_mail.substituteAll(haystack,"<img src=\""+imageRoot+"/"+mailImage+"\" border=\"0\"/>&#160;<a href=\"mailto:$0\">$0</a>");
-  }
-
-
-  /**
-   *  createURLLinks wandelt text im url-format
-   *  in einen klickbaren link um
-   *  nur sinnvoll, wenn text nicht im html-format eingegeben
-   */
-  private static String createURLLinks(String haystack) {
-    return re_url.substituteAll(haystack,"<a href=\"$0\">$0</a>");
-  }
-
-  /**
-   * this routine takes text in url format and makes
-   * a clickaeble "<href>" link removing any "illegal" html tags
-   * @param haystack  the url
-   * @param title  the href link text
-   * @param imageRoot  the place to find icons
-   * @param extImage  the url of the icon to show next to the link
-   * @return a String containing the url
-   */
-  private static String createURLLinks(String haystack, String title, String imageRoot,String extImage) {
-    if (title == null) {
-      return re_url.substituteAll(haystack,"<img src=\""+imageRoot+"/"+extImage+"\" border=\"0\"/>&#160;<a href=\"$0\">$0</a>");
-    }
-               title = removeHTMLTags(title);
-               return re_url.substituteAll(haystack,"<img src=\""+imageRoot+"/"+extImage+"\" border=\"0\"/>&#160;<a href=\"$0\">"+title+"</a>");
-  }
-
-  /**
-   * this routine takes text in url format and makes
-   * a clickaeble "<href>" link removing any "illegal" html tags
-   * @param haystack the url
-   * @param imageRoot the place to find icons
-   * @param extImage the url of the icon to show next to the link
-   * @param intImage unused
-   * @return a String containing the url
-   */
-  private static String createURLLinks(String haystack, String title, String imageRoot,String extImage,String intImage) {
-    return createURLLinks(haystack, title, imageRoot, extImage);
-  }
-
-  /**
-   * this method deletes all html tags
-   */
-  public static String removeHTMLTags(String haystack){
-    return re_tags.substituteAll(haystack,"");
-  }
-
-
-  /**
-   *  createHTML ruft alle regex-methoden zum unwandeln eines nicht
-   *  htmlcodierten string auf und returnt einen htmlcodierten String
-   */
-  public static String createHTML(String content){
-    content=convertNewline2Break(content);
-    content=convertNewline2P(content);
-    content=createMailLinks(content);
-    content=createURLLinks(content);
-    return content;
-  }
-
-
-  /**
-   *  createHTML ruft alle regex-methoden zum unwandeln eines nicht
-   *  htmlcodierten string auf und returnt einen htmlcodierten String
-   */
-  public static String createHTML(String content,String producerDocRoot,String mailImage,String extImage,String intImage){
-    content=convertNewline2Break(content);
-    content=convertNewline2P(content);
-    content=createMailLinks(content, producerDocRoot,mailImage);
-    content=createURLLinks(content, null, producerDocRoot, extImage, intImage);
-
-    return content;
-  }
-
-  /**
    * Converts mir's horrible internal date format (yyyy-MM-dd HH:mm:ss+zz) into a java Date
    *
    * @param anInternalDate
    * Converts mir's horrible internal date format (yyyy-MM-dd HH:mm:ss+zz) into a java Date
    *
    * @param anInternalDate
index 32a964a..d42ab16 100755 (executable)
@@ -241,8 +241,8 @@ public class FileRoutines {
   /**
    * Reads the content of a file into an array of bytes
    */
   /**
    * Reads the content of a file into an array of bytes
    */
-  public static byte[] readFileIntoByteArray(String fileName) throws IOException {
-    InputStream input = new FileInputStream(fileName);
+  public static byte[] readFileIntoByteArray(File aFile) throws IOException {
+    InputStream input = new FileInputStream(aFile);
     ByteArrayOutputStream result = new ByteArrayOutputStream();
 
     IORoutines.copyStream(input, result);
     ByteArrayOutputStream result = new ByteArrayOutputStream();
 
     IORoutines.copyStream(input, result);
@@ -250,6 +250,28 @@ public class FileRoutines {
     return result.toByteArray();
   }
 
     return result.toByteArray();
   }
 
+       /**
+        * Reads the content of a file into an array of bytes
+        */
+       public static void writeByteArrayIntoFile(byte[] anArray, File aFile) throws IOException {
+         OutputStream output = new FileOutputStream(aFile);
+
+         try {
+               ByteArrayInputStream input = new ByteArrayInputStream(anArray);
+               try {
+                 IORoutines.copyStream(input, output);
+               }
+               finally {
+                       input.close();
+               }
+         }
+         finally {
+               output.close();
+         }
+       }
+
+
+
   /**
    * Creates all parent directories of a file if they do not exist
    */
   /**
    * Creates all parent directories of a file if they do not exist
    */
diff --git a/source/mir/util/HTMLStripper.java b/source/mir/util/HTMLStripper.java
new file mode 100644 (file)
index 0000000..92fca33
--- /dev/null
@@ -0,0 +1,164 @@
+/*\r
+ * Copyright (C) 2006 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.util;\r
+\r
+import org.apache.oro.text.regex.Pattern;\r
+import org.apache.oro.text.regex.Perl5Compiler;\r
+import org.apache.oro.text.regex.Perl5Matcher;\r
+import org.apache.oro.text.regex.Perl5Substitution;\r
+import org.apache.oro.text.regex.Util;\r
+\r
+/**\r
+ * Class used to enrich text-based content with HTML links\r
+ * according to a set of rules\r
+ */\r
+public class HTMLStripper {\r
+\r
+  private Pattern newLineExpression;\r
+       private Pattern doubleBRExpression;\r
+       private Pattern emailAddressExpression;\r
+       private Pattern urlExpression;\r
+       private Pattern htmlTagExpression;\r
+\r
+  public HTMLStripper() {\r
+         Perl5Compiler compiler = new Perl5Compiler();\r
+\r
+         try {\r
+                               newLineExpression =\r
+                                               compiler.compile("(\r?\n){1}", Perl5Compiler.READ_ONLY_MASK);\r
+                               doubleBRExpression =\r
+                                               compiler.compile("(<br>\r?\n<br>){1,}", Perl5Compiler.READ_ONLY_MASK);\r
+                               emailAddressExpression =\r
+                                               compiler.compile("\\b([a-zA-Z0-9_.-]+)@([a-zA-Z0-9_-]+)\\.([a-zA-Z0-9_.-]+)\\b", Perl5Compiler.READ_ONLY_MASK);\r
+                               urlExpression =\r
+                                               compiler.compile("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])", Perl5Compiler.READ_ONLY_MASK);\r
+                               htmlTagExpression =\r
+                                               compiler.compile("<[^>]*>", Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK);\r
+         }\r
+         catch (Exception e) {\r
+                 throw new RuntimeException(e.getMessage());\r
+         }\r
+  }\r
+\r
+  /**\r
+   * this routine takes text in url format and makes\r
+   * a clickaeble "<href>" link removing any "illegal" html tags\r
+   * @param haystack  the url\r
+   * @param title  the href link text\r
+   * @param imageRoot  the place to find icons\r
+   * @param extImage  the url of the icon to show next to the link\r
+   * @return a String containing the url\r
+   */\r
+  private String createURLLinks(String haystack, String title, String imageRoot, String extImage) {\r
+               if (title == null) {\r
+      return substituteAll(haystack, urlExpression,\r
+                               "<img src=\"" + imageRoot + "/" + extImage + "\" border=\"0\"/>&#160;<a href=\"$0\">$0</a>");\r
+    }\r
+\r
+    title = removeHTMLTags(title);\r
+\r
+               return substituteAll(haystack, urlExpression,\r
+        "<img src=\"" + imageRoot + "/" + extImage + "\" border=\"0\"/>&#160;<a href=\"$0\">" + title + "</a>");\r
+  }\r
+\r
+  private String substituteAll(String anInput, Pattern anExpression, String aReplacement) {\r
+    Perl5Matcher matcher = new Perl5Matcher();\r
+\r
+    return Util.substitute(\r
+      matcher, anExpression,\r
+      new Perl5Substitution(aReplacement), anInput,\r
+      Util.SUBSTITUTE_ALL);\r
+  }\r
+\r
+  /**\r
+        * Remove all HTML tags\r
+        */\r
+       public String removeHTMLTags(String haystack){\r
+    return substituteAll(haystack, htmlTagExpression, "");\r
+       }\r
+\r
+\r
+  /**\r
+   *  convertNewline2P ist eine regex-routine zum umwandeln von 2 oder mehr newlines (\n)\r
+   *  in den html-tag <p>\r
+   *  nur sinnvoll, wenn text nicht im html-format eingegeben\r
+   */\r
+  private String convertNewline2P(String haystack) {\r
+    return substituteAll(haystack, doubleBRExpression, "\n</p><p>");\r
+  }\r
+\r
+  /**\r
+   *  convertNewline2Break ist eine regex-routine zum umwandeln von 1 newline (\n)\r
+   *  in den html-tag <br>\r
+   *  nur sinnvoll, wenn text nicht im html-format eingegeben\r
+   */\r
+  private  String convertNewline2Break(String haystack) {\r
+    return substituteAll(haystack, newLineExpression, "$0<br />");\r
+  }\r
+\r
+\r
+       /**\r
+        *  createMailLinks wandelt text im email-adressenformat\r
+        *  in einen klickbaren link um\r
+        *  nur sinnvoll, wenn text nicht im html-format eingegeben\r
+        */\r
+       private  String createMailLinks(String haystack, String imageRoot, String mailImage) {\r
+         return substituteAll(haystack, emailAddressExpression,\r
+                         "<img src=\"" + imageRoot + "/" + mailImage + "\" border=\"0\"/>&#160;<a href=\"mailto:$0\">$0</a>");\r
+       }\r
+\r
+\r
+  /**\r
+   * this routine takes text in url format and makes\r
+   * a clickaeble "<href>" link removing any "illegal" html tags\r
+   * @param haystack the url\r
+   * @param imageRoot the place to find icons\r
+   * @param extImage the url of the icon to show next to the link\r
+   * @param intImage unused\r
+   * @return a String containing the url\r
+   */\r
+  private  String createURLLinks(String haystack, String title, String imageRoot,String extImage, String intImage) {\r
+       return createURLLinks(haystack, title, imageRoot, extImage);\r
+  }\r
+\r
+  /**\r
+   */\r
+  public  String createHTML(String content, String producerDocRoot, String mailImage, String extImage, String intImage){\r
+    content = convertNewline2Break(content);\r
+    content = convertNewline2P(content);\r
+    content = createMailLinks(content, producerDocRoot, mailImage);\r
+    content = createURLLinks(content, null, producerDocRoot,\r
+      extImage, intImage);\r
+\r
+    return content;\r
+  }\r
+\r
+\r
+}\r
index f92cefc..4dbd67a 100644 (file)
@@ -78,7 +78,7 @@ public class ShellRoutines {
       throw new IOException("command exit satus:" + exitStatus);
     }
     byte[] result = FileRoutines.readFileIntoByteArray
       throw new IOException("command exit satus:" + exitStatus);
     }
     byte[] result = FileRoutines.readFileIntoByteArray
-        (commandOutput.getAbsolutePath());
+        (commandOutput.getAbsoluteFile());
     commandOutput.delete();
     return result;
   }
     commandOutput.delete();
     return result;
   }
index cd486ad..9601f05 100755 (executable)
@@ -43,7 +43,7 @@ import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityUsers;
 import mircoders.localizer.MirAdminInterfaceLocalizer;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityUsers;
 import mircoders.localizer.MirAdminInterfaceLocalizer;
-import mircoders.localizer.MirCachingLocalizerDecorator;
+import mircoders.localizer.LocalizerCache;
 import mircoders.localizer.MirLocalizer;
 import mircoders.localizer.MirLocalizerExc;
 import mircoders.localizer.MirLocalizerFailure;
 import mircoders.localizer.MirLocalizer;
 import mircoders.localizer.MirLocalizerExc;
 import mircoders.localizer.MirLocalizerFailure;
@@ -66,7 +66,9 @@ public class MirGlobal {
   static private final Map loggedInUserIds = new HashMap();
   static private LoggerWrapper logger = new LoggerWrapper("Global");
   static private LoggerWrapper adminUsageLogger = new LoggerWrapper("AdminUsage");
   static private final Map loggedInUserIds = new HashMap();
   static private LoggerWrapper logger = new LoggerWrapper("Global");
   static private LoggerWrapper adminUsageLogger = new LoggerWrapper("AdminUsage");
-//  static private ChangeEngine changeEngine = new ChangeEngine();
+
+  static private ChangeEngine changeEngine = new ChangeEngine();
+
   static private DatabaseEngine databaseEngine;
 
   static private BundleFactory bundleFactory =
   static private DatabaseEngine databaseEngine;
 
   static private BundleFactory bundleFactory =
@@ -99,7 +101,7 @@ public class MirGlobal {
       }
 
       try {
       }
 
       try {
-        localizer = new MirCachingLocalizerDecorator((MirLocalizer) localizerClass.newInstance());
+        localizer = new LocalizerCache((MirLocalizer) localizerClass.newInstance());
       }
       catch (Throwable t) {
         throw new MirLocalizerFailure("localizer class '" +
       }
       catch (Throwable t) {
         throw new MirLocalizerFailure("localizer class '" +
@@ -140,9 +142,9 @@ public class MirGlobal {
   /**
    * returns the global change engine (used to track changed files)
    */
   /**
    * returns the global change engine (used to track changed files)
    */
-//  public static ChangeEngine getChangeEngine() {
-//    return changeEngine;
-//  }
+  public static ChangeEngine getChangeEngine() {
+    return changeEngine;
+  }
 
   public static MirPropertiesConfiguration config() {
     return MirPropertiesConfiguration.instance();
 
   public static MirPropertiesConfiguration config() {
     return MirPropertiesConfiguration.instance();
diff --git a/source/mircoders/localizer/LocalizerCache.java b/source/mircoders/localizer/LocalizerCache.java
new file mode 100755 (executable)
index 0000000..647e1e5
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * 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;
+
+import mir.entity.adapter.EntityAdapterModel;
+import mir.generator.Generator;
+import mir.generator.WriterEngine;
+
+/**
+ * This was used to prevent localizers from being created
+ * all the time.
+ * 
+ */
+public class LocalizerCache implements MirLocalizer {
+  private MirLocalizer localizer;
+  private MirProducerLocalizer producerLocalizer;
+  private MirGeneratorLocalizer generatorLocalizer;
+  private MirOpenPostingLocalizer openPostingsLocalizer;
+  private MirProducerAssistantLocalizer producerAssistantLocalizer;
+  private MirDataModelLocalizer dataModelLocalizer;
+  private MirAdminInterfaceLocalizer adminInterfaceLocalizer;
+  private MirMediaLocalizer mediaLocalizer;
+
+  public LocalizerCache(MirLocalizer aLocalizer) {
+    localizer = aLocalizer;
+  }
+
+  public MirProducerLocalizer producers() throws MirLocalizerFailure {
+    if (producerLocalizer==null) {
+      producerLocalizer = localizer.producers();
+    }
+
+    return producerLocalizer;
+  }
+
+  public MirGeneratorLocalizer generators() throws MirLocalizerFailure {
+    if (generatorLocalizer==null) {
+      generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());
+    }
+
+    return generatorLocalizer;
+  }
+
+  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure {
+    if (openPostingsLocalizer==null) {
+      openPostingsLocalizer = localizer.openPostings();
+    }
+
+    return openPostingsLocalizer;
+  }
+
+  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure {
+    if (producerAssistantLocalizer==null) {
+      producerAssistantLocalizer = localizer.producerAssistant();
+    }
+
+    return producerAssistantLocalizer;
+  }
+
+  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure {
+    if (dataModelLocalizer==null) {
+      dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());
+    }
+
+    return dataModelLocalizer;
+  }
+
+  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure {
+    if (adminInterfaceLocalizer==null) {
+      adminInterfaceLocalizer = localizer.adminInterface();
+    }
+
+    return adminInterfaceLocalizer;
+  }
+
+  public MirMediaLocalizer media() throws MirLocalizerFailure {
+    if (mediaLocalizer==null) {
+      mediaLocalizer = localizer.media();
+    }
+
+    return mediaLocalizer;
+  }
+
+  private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {
+    private MirDataModelLocalizer master;
+    private EntityAdapterModel adapterModel;
+
+    public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {
+      master = aMaster;
+      adapterModel = null;
+    }
+
+    public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {
+      if (adapterModel==null) {
+        adapterModel = master.adapterModel();
+      }
+
+      return adapterModel;
+    }
+
+  }
+
+  private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {
+    private MirGeneratorLocalizer master;
+    private WriterEngine writerEngine;
+    private Generator.Library producerGeneratorLibrary;
+    private Generator.Library adminGeneratorLibrary;
+    private Generator.Library openPostingGeneratorLibrary;
+
+    public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {
+      master = aMaster;
+    }
+
+    public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
+      if (writerEngine==null) {
+        writerEngine = master.makeWriterEngine();
+      }
+
+      return writerEngine;
+    }
+
+    public Generator.Library makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+      if (producerGeneratorLibrary==null) {
+        producerGeneratorLibrary = master.makeProducerGeneratorLibrary();
+      }
+
+      return producerGeneratorLibrary;
+    }
+
+    public Generator.Library makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+      if (adminGeneratorLibrary==null) {
+        adminGeneratorLibrary = master.makeAdminGeneratorLibrary();
+      }
+
+      return adminGeneratorLibrary;
+    }
+
+    public Generator.Library makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+      if (openPostingGeneratorLibrary==null) {
+        openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();
+      }
+
+      return openPostingGeneratorLibrary;
+    }
+  }
+
+}
\ No newline at end of file
diff --git a/source/mircoders/localizer/MirCachingLocalizerDecorator.java b/source/mircoders/localizer/MirCachingLocalizerDecorator.java
deleted file mode 100755 (executable)
index 68ce0d3..0000000
+++ /dev/null
@@ -1,175 +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.localizer;
-
-import mir.entity.adapter.EntityAdapterModel;
-import mir.generator.Generator;
-import mir.generator.WriterEngine;
-
-/**
- * This was used to prevent localizers from being created
- * all the time. It might be obsolete.
- * 
- */
-public class MirCachingLocalizerDecorator implements MirLocalizer {
-  private MirLocalizer localizer;
-  private MirProducerLocalizer producerLocalizer;
-  private MirGeneratorLocalizer generatorLocalizer;
-  private MirOpenPostingLocalizer openPostingsLocalizer;
-  private MirProducerAssistantLocalizer producerAssistantLocalizer;
-  private MirDataModelLocalizer dataModelLocalizer;
-  private MirAdminInterfaceLocalizer adminInterfaceLocalizer;
-  private MirMediaLocalizer mediaLocalizer;
-
-  public MirCachingLocalizerDecorator(MirLocalizer aLocalizer) {
-    localizer = aLocalizer;
-  }
-
-  public MirProducerLocalizer producers() throws MirLocalizerFailure {
-    if (producerLocalizer==null) {
-      producerLocalizer = localizer.producers();
-    }
-
-    return producerLocalizer;
-  }
-
-  public MirGeneratorLocalizer generators() throws MirLocalizerFailure {
-    if (generatorLocalizer==null) {
-      generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());
-    }
-
-    return generatorLocalizer;
-  }
-
-  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure {
-    if (openPostingsLocalizer==null) {
-      openPostingsLocalizer = localizer.openPostings();
-    }
-
-    return openPostingsLocalizer;
-  }
-
-  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure {
-    if (producerAssistantLocalizer==null) {
-      producerAssistantLocalizer = localizer.producerAssistant();
-    }
-
-    return producerAssistantLocalizer;
-  }
-
-  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure {
-    if (dataModelLocalizer==null) {
-      dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());
-    }
-
-    return dataModelLocalizer;
-  }
-
-  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure {
-    if (adminInterfaceLocalizer==null) {
-      adminInterfaceLocalizer = localizer.adminInterface();
-    }
-
-    return adminInterfaceLocalizer;
-  }
-
-  public MirMediaLocalizer media() throws MirLocalizerFailure {
-    if (mediaLocalizer==null) {
-      mediaLocalizer = localizer.media();
-    }
-
-    return mediaLocalizer;
-  }
-
-  private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {
-    private MirDataModelLocalizer master;
-    private EntityAdapterModel adapterModel;
-
-    public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {
-      master = aMaster;
-      adapterModel = null;
-    }
-
-    public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {
-      if (adapterModel==null) {
-        adapterModel = master.adapterModel();
-      }
-
-      return adapterModel;
-    }
-
-  }
-
-  private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {
-    private MirGeneratorLocalizer master;
-    private WriterEngine writerEngine;
-    private Generator.Library producerGeneratorLibrary;
-    private Generator.Library adminGeneratorLibrary;
-    private Generator.Library openPostingGeneratorLibrary;
-
-    public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {
-      master = aMaster;
-    }
-
-    public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
-      if (writerEngine==null) {
-        writerEngine = master.makeWriterEngine();
-      }
-
-      return writerEngine;
-    }
-
-    public Generator.Library makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
-      if (producerGeneratorLibrary==null) {
-        producerGeneratorLibrary = master.makeProducerGeneratorLibrary();
-      }
-
-      return producerGeneratorLibrary;
-    }
-
-    public Generator.Library makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
-      if (adminGeneratorLibrary==null) {
-        adminGeneratorLibrary = master.makeAdminGeneratorLibrary();
-      }
-
-      return adminGeneratorLibrary;
-    }
-
-    public Generator.Library makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
-      if (openPostingGeneratorLibrary==null) {
-        openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();
-      }
-
-      return openPostingGeneratorLibrary;
-    }
-  }
-
-}
\ No newline at end of file
index db4bdf6..e408c09 100755 (executable)
  */
 package mircoders.localizer.basic;
 
  */
 package mircoders.localizer.basic;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import gnu.regexp.RE;
 import gnu.regexp.RE;
-
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.adapter.EntityAdapter;
 import mir.entity.adapter.EntityIteratorAdapter;
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.adapter.EntityAdapter;
 import mir.entity.adapter.EntityIteratorAdapter;
@@ -47,16 +37,15 @@ import mir.generator.Generator;
 import mir.generator.GeneratorExc;
 import mir.generator.GeneratorFailure;
 import mir.log.LoggerWrapper;
 import mir.generator.GeneratorExc;
 import mir.generator.GeneratorFailure;
 import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
 import mir.util.GeneratorDateTimeFunctions;
 import mir.util.GeneratorFormatAdapters;
 import mir.util.GeneratorDateTimeFunctions;
 import mir.util.GeneratorFormatAdapters;
-import mir.util.generator.ReflectionGeneratorFunctionsAdapter;
+import mir.util.HTMLStripper;
 import mir.util.StringRoutines;
 import mir.util.StringRoutines;
+import mir.util.generator.ReflectionGeneratorFunctionsAdapter;
 import mircoders.global.MirGlobal;
 import mircoders.localizer.MirLocalizerExc;
 import mircoders.localizer.MirLocalizerFailure;
 import mircoders.localizer.MirProducerAssistantLocalizer;
 import mircoders.global.MirGlobal;
 import mircoders.localizer.MirLocalizerExc;
 import mircoders.localizer.MirLocalizerFailure;
 import mircoders.localizer.MirProducerAssistantLocalizer;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -64,15 +53,28 @@ import org.w3c.dom.NodeList;
 import org.w3c.tidy.Configuration;
 import org.w3c.tidy.Tidy;
 
 import org.w3c.tidy.Configuration;
 import org.w3c.tidy.Tidy;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {
   protected LoggerWrapper logger;
 
 public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {
   protected LoggerWrapper logger;
 
+  private HTMLStripper stripper;
   private RE regularExpressionLT;
   private RE regularExpressionGT;
   private RE regularExpressionWhitespace;
 
   private RE regularExpressionLT;
   private RE regularExpressionGT;
   private RE regularExpressionWhitespace;
 
+
   public MirBasicProducerAssistantLocalizer() throws MirLocalizerFailure {
     try {
   public MirBasicProducerAssistantLocalizer() throws MirLocalizerFailure {
     try {
+      stripper = new HTMLStripper();
+
       regularExpressionLT = new RE("<");
       regularExpressionGT = new RE(">");
       regularExpressionWhitespace = new RE("\\s+");
       regularExpressionLT = new RE("<");
       regularExpressionGT = new RE(">");
       regularExpressionWhitespace = new RE("\\s+");
@@ -206,8 +208,8 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
     logger.debug("about to filter non HTML Text of length " + aText.length());
     try {
       String result =
     logger.debug("about to filter non HTML Text of length " + aText.length());
     try {
       String result =
-          StringUtil.createHTML(
-              StringUtil.removeHTMLTags(aText),
+          stripper.createHTML(
+              stripper.removeHTMLTags(aText),
               MirGlobal.config().getString("Producer.ImageRoot"),
               MirGlobal.config().getString("Producer.MailLinkName"),
               MirGlobal.config().getString("Producer.ExtLinkName"),
               MirGlobal.config().getString("Producer.ImageRoot"),
               MirGlobal.config().getString("Producer.MailLinkName"),
               MirGlobal.config().getString("Producer.ExtLinkName"),
index 52bf4be..1018868 100755 (executable)
 
 package mircoders.servlet;
 
 
 package mircoders.servlet;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import mir.servlet.AdminServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
 import mir.servlet.AdminServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
@@ -53,6 +37,12 @@ import mir.util.FileRoutines;
 import mir.util.HTTPRequestParser;
 import mir.util.StringRoutines;
 import mir.util.URLBuilder;
 import mir.util.HTTPRequestParser;
 import mir.util.StringRoutines;
 import mir.util.URLBuilder;
+import mircoders.global.MirGlobal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.*;
 
 /*
  *  ServletModuleFileEdit -
 
 /*
  *  ServletModuleFileEdit -
@@ -60,7 +50,7 @@ import mir.util.URLBuilder;
  *  in the config file.
  *
  * @author $Author: zapata $
  *  in the config file.
  *
  * @author $Author: zapata $
- * @version $Revision: 1.13.2.11 $ $Date: 2005/10/01 18:40:41 $
+ * @version $Revision: 1.13.2.12 $ $Date: 2006/06/01 17:57:21 $
  *
  */
 
  *
  */
 
@@ -184,9 +174,9 @@ public class ServletModuleFileEdit extends AdminServletModule {
         }
 
         logAdminUsage(aRequest, f.getAbsolutePath(), "object modified");
         }
 
         logAdminUsage(aRequest, f.getAbsolutePath(), "object modified");
-/*
+
         MirGlobal.getChangeEngine().getTracker().addChange(f.getCanonicalPath());
         MirGlobal.getChangeEngine().getTracker().addChange(f.getCanonicalPath());
-*/
+
         editFile(directory, filename, subDirectory, aRequest, aResponse);
       }
     }
         editFile(directory, filename, subDirectory, aRequest, aResponse);
       }
     }