first preliminary version of support for displaying RSS feeds
authorzapata <zapata>
Sun, 30 Mar 2003 13:16:19 +0000 (13:16 +0000)
committerzapata <zapata>
Sun, 30 Mar 2003 13:16:19 +0000 (13:16 +0000)
21 files changed:
source/mir/log/Log.java
source/mir/log/Logger.java
source/mir/log/LoggerToWriterAdapter.java
source/mir/log/LoggerWrapper.java
source/mir/log/TestFramework.java
source/mir/log/log4j/LoggerImpl.java
source/mir/misc/FileUtil.java
source/mir/producer/ExpandedAssignmentProducerNode.java
source/mir/producer/RSSProducerNode.java [new file with mode: 0755]
source/mir/producer/reader/DefaultProducerNodeBuilders.java
source/mir/producer/reader/ProducerConfigReader.java
source/mir/rss/RSSChannel.java [new file with mode: 0755]
source/mir/rss/RSSData.java [new file with mode: 0755]
source/mir/rss/RSSExc.java [new file with mode: 0755]
source/mir/rss/RSSFailure.java [new file with mode: 0755]
source/mir/rss/RSSItem.java [new file with mode: 0755]
source/mir/rss/RSSReader.java [new file with mode: 0755]
source/mir/rss/RSSToMapConverter.java [new file with mode: 0755]
source/mir/util/XMLReader.java
source/mir/util/XMLReaderTool.java
source/mircoders/localizer/basic/MirBasicProducerLocalizer.java

index 6e0db0c..2184f76 100755 (executable)
@@ -1,3 +1,34 @@
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
 package mir.log;\r
 \r
 import mir.config.MirPropertiesConfiguration;\r
index 9f1f4a1..5152b54 100755 (executable)
@@ -1,3 +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 the com.oreilly.servlet library, 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.log;
 
 
index a9dc294..91b5795 100755 (executable)
@@ -1,3 +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 the com.oreilly.servlet library, 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.log;
 
 import java.io.Writer;
index bf396ce..f8316b5 100755 (executable)
@@ -1,3 +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 the com.oreilly.servlet library, 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.log;
 
 import java.io.PrintWriter;
index b7f924d..dcec4c1 100755 (executable)
@@ -1,14 +1,44 @@
-package mir.log;
+/*
+ * 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 the com.oreilly.servlet library, 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.log;
 
 
 public class TestFramework {
 
-    public static void main(String[] args) {
-        TestFramework t = new TestFramework();
+  public static void main(String[] args) {
+    TestFramework t = new TestFramework();
 
-        Log.info( TestFramework.class, "class");
-        Log.info( t, "object" );
-        Log.info( null, "lalala" );
-    }
+    Log.info( TestFramework.class, "class");
+    Log.info( t, "object" );
+    Log.info( null, "lalala" );
+  }
 }
index 3470bff..ede6069 100755 (executable)
@@ -1,3 +1,34 @@
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
 package mir.log.log4j;\r
 \r
 import java.util.HashMap;\r
index 017be8c..0d78ff7 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 the com.oreilly.servlet library, 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.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-
-/**
- * Hilfsklasse zum Mergen von Template und Daten
- */
-public final class FileUtil {
-
-  private static String producerStorageRoot;
-
-  //
-  // Initialisierung
-
-  static {
-    try {
-      producerStorageRoot = 
-       MirPropertiesConfiguration.instance().getString("Producer.StorageRoot");
-    } catch (PropertiesConfigExc e) {
-      e.printStackTrace();
-    } 
-  }
-
-  /**
-   * Privater Konstruktor, um versehentliche Instantiierung zu verhindern
-   */
-  private FileUtil () {
-  }
-
-  public static File getFile(String filename)
-    throws IOException {
-
-    try {
-      File f = null;
-      f = new File(filename);
-      File dir = new File(f.getParent());
-      dir.mkdirs();
-
-      return f;
-    } catch(Exception e) {
-      throw new IOException(e.toString());
-    }
-
-  }
-
-  public static long write(File f, InputStream in)
-    throws IOException {
-
-    long size = 0;
-
-               if (in!=null) {
-                       try {
-        FileOutputStream out = new FileOutputStream(f);
-
-        int read;
-        byte[] buf = new byte[8 * 1024];
-        while((read = in.read(buf)) != -1) {
-          out.write(buf, 0, read);
-          size += read;
-        }
-
-        in.close();
-                               out.close();
-                       } catch(IOException e) {
-        throw new IOException(e.toString());
-      }
-    }
-               return size;
-       }
-
-  public static long write(String filename, InputStream in)
-    throws IOException {
-
-    long size = 0;
-
-               if (in!=null) {
-                       try {
-        File f = getFile(filename);
-        size = write(f, in);
-                       } catch(IOException e) {
-        throw new IOException(e.toString());
-      }
-    }
-               return size;
-       }
-
-  public static long write(String filename, Reader in, String encoding)
-    throws IOException {
-
-    long size = 0;
-
-               if (in!=null) {
-                       try {
-        File f = getFile(filename);
-        FileOutputStream fOut = new FileOutputStream(f);
-        OutputStreamWriter out = new OutputStreamWriter(fOut, encoding);
-        int read;
-        char[] cbuf = new char[8*1024];
-        while((read = in.read(cbuf)) != -1) {
-          out.write(cbuf, 0, read);
-          size += read;
-        }
-
-                               out.close();
-        in.close();
-                       } catch(IOException e) {
-        throw new IOException(e.toString());
-      }
-    }
-               return size;
-       }
-
-  public static boolean read(String filename, byte out[])
-    throws IOException {
-
-    File f = null;
-    f = new File(filename);
-
-               if (f.exists()) {
-                       try {
-        if (out.length != f.length())
-          return false;
-                               FileInputStream inStream;
-                               inStream = new FileInputStream(f);
-                               inStream.read(out);
-                               inStream.close();
-                       } catch(IOException e) {
-        throw new IOException(e.toString());
-      }
-    } else {
-      return false;
-    }
-    return true;
-  }
-    
-  public static long getSize(String filename) {
-    File f = null;
-    f = new File(filename);
-    long l=0;
-
-    if (f.exists()) {
-      return f.length();
-    } else {
-      return -1;
-    }
-  }
-
-}
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.misc;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.OutputStreamWriter;\r
+import java.io.Reader;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+\r
+/**\r
+ * Hilfsklasse zum Mergen von Template und Daten\r
+ */\r
+public final class FileUtil {\r
+\r
+  private static String producerStorageRoot;\r
+\r
+  //\r
+  // Initialisierung\r
+\r
+  static {\r
+    try {\r
+      producerStorageRoot =\r
+          MirPropertiesConfiguration.instance().getString("Producer.StorageRoot");\r
+    }\r
+    catch (PropertiesConfigExc e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Privater Konstruktor, um versehentliche Instantiierung zu verhindern\r
+   */\r
+  private FileUtil() {\r
+  }\r
+\r
+  public static File getFile(String filename) throws IOException {\r
+\r
+    try {\r
+      File f = null;\r
+      f = new File(filename);\r
+      File dir = new File(f.getParent());\r
+      dir.mkdirs();\r
+\r
+      return f;\r
+    }\r
+    catch (Exception e) {\r
+      throw new IOException(e.toString());\r
+    }\r
+\r
+  }\r
+\r
+  public static long write(File f, InputStream in) throws IOException {\r
+\r
+    long size = 0;\r
+\r
+    if (in != null) {\r
+      try {\r
+        FileOutputStream out = new FileOutputStream(f);\r
+\r
+        int read;\r
+        byte[] buf = new byte[8 * 1024];\r
+        while ( (read = in.read(buf)) != -1) {\r
+          out.write(buf, 0, read);\r
+          size += read;\r
+        }\r
+\r
+        in.close();\r
+        out.close();\r
+      }\r
+      catch (IOException e) {\r
+        throw new IOException(e.toString());\r
+      }\r
+    }\r
+    return size;\r
+  }\r
+\r
+  public static long write(String filename, InputStream in) throws IOException {\r
+\r
+    long size = 0;\r
+\r
+    if (in != null) {\r
+      try {\r
+        File f = getFile(filename);\r
+        size = write(f, in);\r
+      }\r
+      catch (IOException e) {\r
+        throw new IOException(e.toString());\r
+      }\r
+    }\r
+    return size;\r
+  }\r
+\r
+  public static long write(String filename, Reader in, String encoding) throws IOException {\r
+\r
+    long size = 0;\r
+\r
+    if (in != null) {\r
+      try {\r
+        File f = getFile(filename);\r
+        FileOutputStream fOut = new FileOutputStream(f);\r
+        OutputStreamWriter out = new OutputStreamWriter(fOut, encoding);\r
+        int read;\r
+        char[] cbuf = new char[8 * 1024];\r
+        while ( (read = in.read(cbuf)) != -1) {\r
+          out.write(cbuf, 0, read);\r
+          size += read;\r
+        }\r
+\r
+        out.close();\r
+        in.close();\r
+      }\r
+      catch (IOException e) {\r
+        throw new IOException(e.toString());\r
+      }\r
+    }\r
+    return size;\r
+  }\r
+\r
+  public static boolean read(String filename, byte out[]) throws IOException {\r
+\r
+    File f = null;\r
+    f = new File(filename);\r
+\r
+    if (f.exists()) {\r
+      try {\r
+        if (out.length != f.length())\r
+          return false;\r
+        FileInputStream inStream;\r
+        inStream = new FileInputStream(f);\r
+        inStream.read(out);\r
+        inStream.close();\r
+      }\r
+      catch (IOException e) {\r
+        throw new IOException(e.toString());\r
+      }\r
+    }\r
+    else {\r
+      return false;\r
+    }\r
+    return true;\r
+  }\r
+\r
+  public static long getSize(String filename) {\r
+    File f = null;\r
+    f = new File(filename);\r
+    long l = 0;\r
+\r
+    if (f.exists()) {\r
+      return f.length();\r
+    }\r
+    else {\r
+      return -1;\r
+    }\r
+  }\r
+\r
+}\r
index de00c44..2e0b628 100755 (executable)
@@ -31,9 +31,9 @@
 
 package mir.producer;
 
-import java.util.Map;
-
-import mir.log.LoggerWrapper;
+import java.util.Map;\r
+\r
+import mir.log.LoggerWrapper;\r
 import mir.util.ParameterExpander;
 
 public class ExpandedAssignmentProducerNode implements ProducerNode {
diff --git a/source/mir/producer/RSSProducerNode.java b/source/mir/producer/RSSProducerNode.java
new file mode 100755 (executable)
index 0000000..fc1c442
--- /dev/null
@@ -0,0 +1,33 @@
+package mir.producer;
+
+import java.util.Map;\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.rss.RSSData;\r
+import mir.rss.RSSReader;\r
+import mir.rss.RSSToMapConverter;\r
+import mir.util.ParameterExpander;
+
+public class RSSProducerNode implements ProducerNode {
+  private String key;
+  private String url;
+
+  public RSSProducerNode(String aKey, String anURL) {
+    key = aKey;
+    url = anURL;
+  }
+
+  public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure {
+    try {
+      String expandedKey = ParameterExpander.expandExpression( aValueMap, key );
+      String expandedUrl = ParameterExpander.expandExpression( aValueMap, url );
+
+      RSSReader reader = new RSSReader();
+      RSSData rssData = reader.parseUrl(url);
+      ParameterExpander.setValueForKey(aValueMap, expandedKey, RSSToMapConverter.convertRSSData(rssData));
+    }
+    catch (Throwable t) {
+      aLogger.error("Error while processing RSS data: " + t.toString());
+    }
+  };
+}
\ No newline at end of file
index fcfc3b3..6252402 100755 (executable)
 
 package mir.producer.reader;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import mir.entity.adapter.EntityAdapterModel;
-import mir.generator.Generator;
-import mir.generator.WriterEngine;
-import mir.log.LoggerWrapper;
-import mir.producer.ConditionalProducerNode;
-import mir.producer.DirCopyingProducerNode;
-import mir.producer.EntityBatchingProducerNode;
-import mir.producer.EntityEnumeratingProducerNode;
-import mir.producer.EntityListProducerNode;
-import mir.producer.EvaluatedAssignmentProducerNode;
-import mir.producer.ExpandedAssignmentProducerNode;
-import mir.producer.FileDateSettingProducerNode;
-import mir.producer.FileDeletingProducerNode;
-import mir.producer.GeneratingProducerNode;
-import mir.producer.LoggingProducerNode;
-import mir.producer.LoopProducerNode;
-import mir.producer.ProducerNode;
-import mir.producer.ResourceBundleProducerNode;
-import mir.producer.ScriptCallingProducerNode;
-import mir.util.XMLReader;
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.generator.Generator;\r
+import mir.generator.WriterEngine;\r
+import mir.log.LoggerWrapper;\r
+import mir.producer.ConditionalProducerNode;\r
+import mir.producer.DirCopyingProducerNode;\r
+import mir.producer.EntityBatchingProducerNode;\r
+import mir.producer.EntityEnumeratingProducerNode;\r
+import mir.producer.EntityListProducerNode;\r
+import mir.producer.EvaluatedAssignmentProducerNode;\r
+import mir.producer.ExpandedAssignmentProducerNode;\r
+import mir.producer.FileDateSettingProducerNode;\r
+import mir.producer.FileDeletingProducerNode;\r
+import mir.producer.GeneratingProducerNode;\r
+import mir.producer.LoggingProducerNode;\r
+import mir.producer.LoopProducerNode;\r
+import mir.producer.ProducerNode;\r
+import mir.producer.RSSProducerNode;\r
+import mir.producer.ResourceBundleProducerNode;\r
+import mir.producer.ScriptCallingProducerNode;\r
+import mir.util.XMLReader;\r
 import mir.util.XMLReaderTool;
 
 public class DefaultProducerNodeBuilders {
@@ -78,6 +79,8 @@ public class DefaultProducerNodeBuilders {
     aBuilderLibrary.registerBuilder("If", ConditionalProducerNodeBuilder.class);
     aBuilderLibrary.registerBuilder("While", LoopProducerNodeBuilder.class);
 
+    aBuilderLibrary.registerBuilder("RSS", RSSProducerNodeBuilder.class);
+
     aBuilderLibrary.registerFactory("Enumerate", new EnumeratingProducerNodeBuilder.factory(aModel));
     aBuilderLibrary.registerFactory("List", new ListProducerNodeBuilder.factory(aModel));
     aBuilderLibrary.registerFactory("Batch", new BatchingProducerNodeBuilder.factory(aModel));
@@ -121,6 +124,7 @@ public class DefaultProducerNodeBuilders {
   public final static String   SKIP_ATTRIBUTE = "skip";
   public final static String   KEY_ATTRIBUTE = "key";
   public final static String   LIMIT_ATTRIBUTE = "limit";
+  public final static String   URL_ATTRIBUTE = "url";
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -690,6 +694,35 @@ public class DefaultProducerNodeBuilders {
 
 ////////////////////////////////////////////////////////////////////////////////
 
+  public static class RSSProducerNodeBuilder extends AbstractProducerNodeBuilder {
+    private final static String   RSS_KEY_ATTRIBUTE = KEY_ATTRIBUTE;
+    private final static String   RSS_URL_ATTRIBUTE = URL_ATTRIBUTE;
+
+    private final static String[] RSS_REQUIRED_ATTRIBUTES = { RSS_KEY_ATTRIBUTE, RSS_URL_ATTRIBUTE };
+    private final static String[] RSS_OPTIONAL_ATTRIBUTES = {  };
+    private final static String[] RSS_SUBNODES = {  };
+
+    private String key;
+    private String url;
+
+    public RSSProducerNodeBuilder() {
+      super(RSS_SUBNODES);
+    }
+
+    public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLReader.XMLReaderExc {
+      XMLReaderTool.checkAttributes(anAttributes, RSS_REQUIRED_ATTRIBUTES, RSS_OPTIONAL_ATTRIBUTES);
+
+      key = (String) anAttributes.get( RSS_KEY_ATTRIBUTE );
+      url = (String) anAttributes.get( RSS_URL_ATTRIBUTE );
+    };
+
+    public ProducerNode constructNode() {
+      return new RSSProducerNode(key, url);
+    };
+  }
+
+////////////////////////////////////////////////////////////////////////////////
+
   public static class ScriptedProducerParameterNodeBuilder implements ProducerNodeBuilder {
     private String parameterName;
     private String scriptedNodeName;
index 5e2d124..46249ef 100755 (executable)
@@ -31,6 +31,7 @@
 \r
 package  mir.producer.reader;\r
 \r
+import java.io.File;\r
 import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.Iterator;\r
@@ -61,11 +62,13 @@ public class ProducerConfigReader {
   public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, List aProducerFactories, List aUsedFiles) throws ProducerConfigFailure {\r
     try {\r
       XMLReader reader = new XMLReader();\r
+      aUsedFiles.add(new File(aFileName));\r
 \r
       builderLibrary = aBuilderLibrary;\r
       scriptedNodeBuilderLibrary = new ProducerNodeBuilderLibrary();\r
 \r
-      reader.parseFile(aFileName, new RootSectionHandler(aProducerFactories), aUsedFiles);\r
+      reader.parseFile(aFileName, new RootSectionHandler(aProducerFactories));\r
+\r
     }\r
     catch (Throwable e) {\r
       if ((e instanceof XMLReader.XMLReaderExc) && ((XMLReader.XMLReaderExc) e).getHasLocation()) {\r
diff --git a/source/mir/rss/RSSChannel.java b/source/mir/rss/RSSChannel.java
new file mode 100755 (executable)
index 0000000..54e1dec
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 the com.oreilly.servlet library, 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.rss;
+
+import java.util.*;
+
+public class RSSChannel {
+  private String title;
+  private String link;
+  private String description;
+  private String identifier;
+  private List items;
+
+  protected RSSChannel(String anIdentifier) {
+    items = new Vector();
+    identifier = anIdentifier;
+  }
+
+  protected void addItem(RSSItem anItem) {
+    items.add(anItem);
+  };
+
+  protected void setItems(List anItems) {
+    items.clear();
+    items.addAll(anItems);
+  };
+
+  public List getItems() {
+    return items;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String aTitle) {
+    title = aTitle;
+  }
+
+  public String getLink() {
+    return link;
+  }
+
+  public void setLink(String aLink) {
+    link = aLink;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String aDescription) {
+    description = aDescription;
+  }
+
+}
diff --git a/source/mir/rss/RSSData.java b/source/mir/rss/RSSData.java
new file mode 100755 (executable)
index 0000000..5f24399
--- /dev/null
@@ -0,0 +1,70 @@
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.rss;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+public class RSSData {\r
+  private List items;\r
+  private Map item;\r
+  private RSSChannel channel;\r
+\r
+  protected RSSData() {\r
+    items = new Vector();\r
+    item = new HashMap();\r
+    channel = null;\r
+  }\r
+\r
+  protected void addItem(RSSItem anItem) {\r
+    items.add(anItem);\r
+    item.put(anItem.getIdentifier(), anItem);\r
+  };\r
+\r
+  public void setChannel(RSSChannel aChannel) {\r
+    channel = aChannel;\r
+  }\r
+\r
+  public RSSChannel getChannel() {\r
+    return channel;\r
+  }\r
+\r
+  public List getItems() {\r
+    return items;\r
+  }\r
+\r
+  public Map getItem() {\r
+    return item;\r
+  }\r
+}\r
diff --git a/source/mir/rss/RSSExc.java b/source/mir/rss/RSSExc.java
new file mode 100755 (executable)
index 0000000..ee304ea
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 the com.oreilly.servlet library, 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.rss;
+
+import multex.Exc;
+
+public class RSSExc extends Exc {
+  public RSSExc(String aMessage) {
+    super(aMessage);
+  }
+}
diff --git a/source/mir/rss/RSSFailure.java b/source/mir/rss/RSSFailure.java
new file mode 100755 (executable)
index 0000000..1fae979
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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 the com.oreilly.servlet library, 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.rss;
+
+import multex.Failure;
+
+public class RSSFailure extends Failure {
+  public RSSFailure(String aMessage,Throwable aCause) {
+    super(aMessage, aCause);
+  }
+
+  public RSSFailure(Throwable aCause) {
+    this (aCause.getMessage(), aCause);
+  }
+}
diff --git a/source/mir/rss/RSSItem.java b/source/mir/rss/RSSItem.java
new file mode 100755 (executable)
index 0000000..eaf5c03
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 the com.oreilly.servlet library, 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.rss;
+
+import java.util.*;
+
+public class RSSItem {
+  private String title;
+  private String link;
+  private String description;
+  private String identifier;
+
+  protected RSSItem(String anIdentifier) {
+    identifier = anIdentifier;
+  }
+
+  public String getIdentifier() {
+    return identifier;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String aTitle) {
+    title = aTitle;
+  }
+
+  public String getLink() {
+    return link;
+  }
+
+  public void setLink(String aLink) {
+    link = aLink;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String aDescription) {
+    description = aDescription;
+  }
+
+}
+
diff --git a/source/mir/rss/RSSReader.java b/source/mir/rss/RSSReader.java
new file mode 100755 (executable)
index 0000000..45fbe4f
--- /dev/null
@@ -0,0 +1,389 @@
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.rss;\r
+\r
+import java.io.InputStream;\r
+import java.net.URL;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.util.XMLReader;\r
+import mir.util.XMLReaderTool;\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 RSSReader {\r
+  public RSSReader() {\r
+  }\r
+\r
+  public RSSData parseInputStream(InputStream aStream) throws RSSExc, RSSFailure {\r
+    try {\r
+      XMLReader xmlReader = new XMLReader();\r
+      RSSData result = new RSSData();\r
+      xmlReader.parseInputStream(aStream, new RootSectionHandler(result));\r
+\r
+      return result;\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RSSFailure(t);\r
+    }\r
+  }\r
+\r
+  public RSSData parseUrl(String anUrl) throws RSSExc, RSSFailure {\r
+    try {\r
+      InputStream inputStream = (InputStream) new URL(anUrl).getContent(new Class[] {InputStream.class});\r
+\r
+      if (inputStream==null)\r
+        throw new RSSExc("RSSChannel.parseUrl: Can't get url content");\r
+\r
+      return parseInputStream(inputStream);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RSSFailure(t);\r
+    }\r
+  }\r
+\r
+  private static class RootSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private RSSData data;\r
+\r
+    public RootSectionHandler(RSSData aData) {\r
+      data = aData;\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      if (XMLReaderTool.getLocalNameFromQualifiedName(aTag).equals("RDF")) {\r
+        return new RDFSectionHandler(data);\r
+      }\r
+      else\r
+        throw new XMLReader.XMLReaderFailure(new RSSExc("'RDF' tag expected"));\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      if (aCharacters.trim().length()>0)\r
+        throw new XMLReader.XMLReaderExc("No character data allowed here");\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+  }\r
+\r
+  private static class RDFSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private RSSData data;\r
+\r
+    public RDFSectionHandler(RSSData aData) {\r
+      data = aData;\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      String identifier = (String) anAttributes.get("rdf:about");\r
+\r
+      if (aTag.equals("channel")) {\r
+        if (identifier==null)\r
+          throw new XMLReader.XMLReaderFailure(new RSSExc("Missing rdf:about"));\r
+        else\r
+          return new ChannelSectionHandler(identifier);\r
+      }\r
+      else if (aTag.equals("item")) {\r
+        if (identifier==null)\r
+          throw new XMLReader.XMLReaderFailure(new RSSExc("Missing rdf:about"));\r
+        else\r
+          return new ItemSectionHandler(identifier);\r
+      }\r
+      else\r
+        return new DiscardingSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+      if (aHandler instanceof ItemSectionHandler) {\r
+        data.addItem(((ItemSectionHandler) aHandler).getItem());\r
+      }\r
+      else if (aHandler instanceof ChannelSectionHandler) {\r
+        data.setChannel(((ChannelSectionHandler) aHandler).getChannel());\r
+      }\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      if (aCharacters.trim().length()>0)\r
+        throw new XMLReader.XMLReaderExc("No character data allowed here");\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+  }\r
+\r
+  private static class ChannelSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private String image;\r
+    private String currentTag;\r
+    private RSSChannel channel;\r
+\r
+    public ChannelSectionHandler(String anIdentifier) {\r
+      channel = new RSSChannel(anIdentifier);\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      currentTag = aTag;\r
+      if (currentTag.equals("items")) {\r
+        return new ChannelItemsSectionHandler();\r
+      }\r
+      else if (currentTag.equals("description") ||\r
+               currentTag.equals("link") ||\r
+               currentTag.equals("title")) {\r
+        return new PCDATASectionHandler();\r
+      }\r
+\r
+      return new DiscardingSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+      if (currentTag.equals("items")) {\r
+        channel.setItems(((ChannelItemsSectionHandler) aHandler).getItems());\r
+      }\r
+      if (currentTag.equals("description")) {\r
+        channel.setDescription(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+      else if (currentTag.equals("title")) {\r
+        channel.setTitle(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+      else if (currentTag.equals("link")) {\r
+        channel.setLink(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      if (aCharacters.trim().length()>0)\r
+        throw new XMLReader.XMLReaderExc("No character data allowed here");\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public RSSChannel getChannel () {\r
+      return channel;\r
+    }\r
+  }\r
+\r
+  private static class ChannelItemsSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private List items;\r
+\r
+    public ChannelItemsSectionHandler() {\r
+      items = new Vector();\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      if (aTag.equals("rdf:Seq"))\r
+        return new RDFSequenceSectionHandler();\r
+      else\r
+        return new DiscardingSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+      if (aHandler instanceof RDFSequenceSectionHandler) {\r
+        items.addAll(((RDFSequenceSectionHandler) aHandler).getItems());\r
+      }\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      if (aCharacters.trim().length()>0)\r
+        throw new XMLReader.XMLReaderExc("No character data allowed here");\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public List getItems() {\r
+      return items;\r
+    }\r
+  }\r
+\r
+  private static class ItemSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private String currentTag;\r
+    private RSSItem item;\r
+\r
+    public ItemSectionHandler(String anIdentifier) {\r
+      item = new RSSItem(anIdentifier);\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      currentTag = aTag;\r
+\r
+      if (currentTag.equals("description") ||\r
+               currentTag.equals("link") ||\r
+               currentTag.equals("title")) {\r
+        return new PCDATASectionHandler();\r
+      }\r
+\r
+      return new DiscardingSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+      if (currentTag.equals("description")) {\r
+        item.setDescription(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+      else if (currentTag.equals("title")) {\r
+        item.setTitle(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+      else if (currentTag.equals("link")) {\r
+        item.setLink(((PCDATASectionHandler) aHandler).getData());\r
+      }\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      if (aCharacters.trim().length()>0)\r
+        throw new XMLReader.XMLReaderExc("No character data allowed here");\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public RSSItem getItem() {\r
+      return item;\r
+    };\r
+  }\r
+\r
+  private static class PCDATASectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private StringBuffer data;\r
+\r
+    public PCDATASectionHandler() {\r
+      data = new StringBuffer();\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      throw new XMLReader.XMLReaderFailure(new RSSExc("No subtags allowed here"));\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      data.append(aCharacters);\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public String getData() {\r
+      return data.toString();\r
+    }\r
+  }\r
+\r
+\r
+  private static class RDFSequenceSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private List items;\r
+\r
+    public RDFSequenceSectionHandler() {\r
+      items = new Vector();\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      if (aTag.equals("rdf:li")) {\r
+        String item = (String) anAttributes.get("rdf:resource");\r
+\r
+        if (item!=null)\r
+          items.add(item);\r
+      }\r
+\r
+      return new DiscardingSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public List getItems() {\r
+      return items;\r
+    }\r
+  }\r
+\r
+  private static class RDFLiteralSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    private StringBuffer data;\r
+    private String tag;\r
+\r
+    public RDFLiteralSectionHandler() {\r
+      data = new StringBuffer();\r
+    }\r
+\r
+    protected StringBuffer getData() {\r
+      return data;\r
+    }\r
+\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      tag=aTag;\r
+      data.append("<"+tag+">");\r
+\r
+      return new RDFLiteralSectionHandler();\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+      data.append(((RDFLiteralSectionHandler) aHandler).getData());\r
+      data.append("</"+tag+">");\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+      data.append(aCharacters);\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+  }\r
+\r
+  private static class DiscardingSectionHandler extends XMLReader.AbstractSectionHandler {\r
+    public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
+      return this;\r
+    };\r
+\r
+    public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
+    };\r
+\r
+    public void finishSection() throws XMLReader.XMLReaderExc {\r
+    };\r
+  }\r
+}\r
diff --git a/source/mir/rss/RSSToMapConverter.java b/source/mir/rss/RSSToMapConverter.java
new file mode 100755 (executable)
index 0000000..36b8461
--- /dev/null
@@ -0,0 +1,77 @@
+/*\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 the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.rss;\r
+\r
+import java.util.*;\r
+\r
+public class RSSToMapConverter {\r
+  private RSSToMapConverter() {\r
+  }\r
+\r
+  public static Map convertRSSItem(RSSItem anItem) {\r
+    Map result = new HashMap();\r
+\r
+    result.put("title", anItem.getTitle());\r
+    result.put("description", anItem.getDescription());\r
+    result.put("link", anItem.getLink());\r
+\r
+    return result;\r
+  }\r
+\r
+  public static Map convertRSSData(RSSData anRSSData) {\r
+    Map result = new HashMap();\r
+\r
+    Map channel = null;\r
+    if (anRSSData.getChannel()!=null) {\r
+      channel = new HashMap();\r
+      channel.put("title", anRSSData.getChannel().getTitle());\r
+      channel.put("description", anRSSData.getChannel().getDescription());\r
+      channel.put("link", anRSSData.getChannel().getLink());\r
+\r
+      List items = new Vector();\r
+      Iterator i = anRSSData.getChannel().getItems().iterator();\r
+\r
+      while (i.hasNext()) {\r
+        RSSItem item = (RSSItem) anRSSData.getItem().get(i.next());\r
+        if (item!=null) {\r
+          items.add(convertRSSItem(item));\r
+        }\r
+      }\r
+\r
+      channel.put("items", items);\r
+    }\r
+    result.put("channel", channel);\r
+    result.put("data", anRSSData);\r
+\r
+    return result;\r
+  }\r
+}
\ No newline at end of file
index 6f77dca..b8bc9e3 100755 (executable)
@@ -33,8 +33,11 @@ package mir.util;
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
+import java.io.StringReader;\r
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -57,23 +60,44 @@ import org.xml.sax.helpers.DefaultHandler;
 public class XMLReader {\r
   private Locator locator;\r
   private String filename;\r
+  private boolean namespaceAware;\r
+\r
+  public XMLReader() {\r
+    this(false);\r
+  }\r
+\r
+  public XMLReader(boolean aNameSpaceAware) {\r
+    namespaceAware = aNameSpaceAware;\r
+    filename="";\r
+  }\r
 \r
-  public void parseFile(String aFileName, SectionHandler aRootHandler, List aUsedFiles) throws XMLReaderFailure, XMLReaderExc {\r
+  public void parseFile(String aFileName, SectionHandler aRootHandler) throws XMLReaderFailure, XMLReaderExc {\r
+    filename= aFileName;\r
+    try {\r
+      parseInputStream(new FileInputStream(aFileName), aRootHandler);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new XMLReaderFailure(t);\r
+    }\r
+  }\r
+\r
+  public void parseInputStream(InputStream anInputStream, SectionHandler aRootHandler) throws XMLReaderFailure, XMLReaderExc {\r
     try {\r
       SAXParserFactory parserFactory = SAXParserFactory.newInstance();\r
 \r
-      parserFactory.setNamespaceAware(false);\r
+      parserFactory.setNamespaceAware(namespaceAware);\r
       parserFactory.setValidating(true);\r
 \r
-      XMLReaderHandler handler = new XMLReaderHandler(parserFactory, aRootHandler, aUsedFiles);\r
+      XMLReaderHandler handler = new XMLReaderHandler(parserFactory, aRootHandler);\r
 \r
-      handler.includeFile(aFileName);\r
+      handler.processInputStream(anInputStream);\r
     }\r
     catch (Throwable e) {\r
-      Throwable t = getRootCause(e);\r
+      Throwable t = ExceptionFunctions.traceCauseException(e);\r
 \r
       if (t instanceof XMLReaderExc) {\r
-        ((XMLReaderExc) t).setLocation(filename, locator.getLineNumber(), locator.getColumnNumber());\r
+        if (locator!=null && filename!=null)\r
+          ((XMLReaderExc) t).setLocation(filename, locator.getLineNumber(), locator.getColumnNumber());\r
         throw (XMLReaderExc) t;\r
       }\r
 \r
@@ -85,88 +109,35 @@ public class XMLReader {
     }\r
   }\r
 \r
-  private Throwable getRootCause(Throwable t) {\r
-    if (t instanceof SAXParseException && ((SAXParseException) t).getException()!=null) {\r
-      return getRootCause(((SAXParseException) t).getException());\r
-    }\r
-    else if (t instanceof Failure && ((Failure) t).getCause()!=null) {\r
-      return getRootCause(((Failure) t).getCause());\r
-    }\r
-    else return t;\r
-  }\r
-\r
   private class XMLReaderHandler extends DefaultHandler {\r
-    private Stack includeFileStack;\r
     private SAXParserFactory parserFactory;\r
     private SectionsManager manager;\r
-    private List usedFiles;\r
     private InputSource inputSource;\r
 \r
-    public XMLReaderHandler(SAXParserFactory aParserFactory, SectionHandler aRootHandler, List aUsedFiles) {\r
+    public XMLReaderHandler(SAXParserFactory aParserFactory, SectionHandler aRootHandler) {\r
       super();\r
 \r
-      includeFileStack=new Stack();\r
       parserFactory=aParserFactory;\r
-      includeFileStack = new Stack();\r
       manager = new SectionsManager();\r
-      usedFiles = aUsedFiles;\r
       manager.pushHandler(aRootHandler);\r
    }\r
 \r
-    public String getLocatorDescription(Locator aLocator) {\r
-      return aLocator.getPublicId()+" ("+aLocator.getLineNumber()+")";\r
-    }\r
-\r
     public void setDocumentLocator(Locator aLocator) {\r
       locator=aLocator;\r
     }\r
 \r
-    private void includeFile(String aFileName) throws XMLReaderExc, XMLReaderFailure, SAXParseException, SAXException {\r
-      File file;\r
-      SAXParser parser;\r
-\r
+    private void processInputStream(InputStream anInputStream) throws XMLReaderExc, XMLReaderFailure {\r
       try {\r
-        if (!includeFileStack.empty())\r
-          file = new File(new File((String) includeFileStack.peek()).getParent(), aFileName);\r
-        else\r
-          file = new File(aFileName);\r
-\r
-        if (includeFileStack.contains(file.getCanonicalPath())) {\r
-          throw new XMLReaderExc("recursive inclusion of file "+file.getCanonicalPath());\r
-        }\r
-\r
-        usedFiles.add(file);\r
+        SAXParser parser=parserFactory.newSAXParser();\r
 \r
-        parser=parserFactory.newSAXParser();\r
-\r
-        inputSource = new InputSource(new FileInputStream(file));\r
-        inputSource.setPublicId(file.getCanonicalPath());\r
-\r
-        includeFileStack.push(file.getCanonicalPath());\r
-        filename = file.getCanonicalPath();\r
-        try {\r
-          parser.parse(inputSource, this);\r
-        }\r
-        finally {\r
-          includeFileStack.pop();\r
-        }\r
-        if (!includeFileStack.empty())\r
-          filename = (String) includeFileStack.peek();\r
+        inputSource = new InputSource(anInputStream);\r
+        parser.parse(inputSource, this);\r
       }\r
       catch (ParserConfigurationException e) {\r
-        throw new XMLReaderExc("Internal exception while including \""+aFileName+"\": "+e.getMessage());\r
+        throw new XMLReaderExc("Internal exception: "+e.getMessage());\r
       }\r
-      catch (SAXParseException e) {\r
-        throw e;\r
-      }\r
-      catch (XMLReaderFailure e) {\r
-        throw e;\r
-      }\r
-      catch (FileNotFoundException e) {\r
-        throw new XMLReaderExc("Include file \""+aFileName+"\" not found: "+e.getMessage());\r
-      }\r
-      catch (IOException e) {\r
-        throw new XMLReaderExc("unable to open include file \""+aFileName+"\": "+e.getMessage());\r
+      catch (Throwable e) {\r
+        throw new XMLReaderFailure(e);\r
       }\r
     }\r
 \r
@@ -175,24 +146,13 @@ public class XMLReader {
       int i;\r
 \r
       try {\r
-        if (aQualifiedName.equals("include")) {\r
-          String fileName=anAttributes.getValue("file");\r
-\r
-          if (fileName==null) {\r
-            throw new XMLReaderExc("include has no file attribute");\r
-          }\r
-\r
-          includeFile(fileName);\r
-        }\r
-        else {\r
-          attributesMap = new HashMap();\r
-          for (i=0; i<anAttributes.getLength(); i++)\r
-            attributesMap.put(anAttributes.getQName(i), anAttributes.getValue(i));\r
+        attributesMap = new HashMap();\r
+        for (i=0; i<anAttributes.getLength(); i++)\r
+          attributesMap.put(anAttributes.getQName(i), anAttributes.getValue(i));\r
 \r
-          SectionHandler handler = manager.currentHandler().startElement(aQualifiedName, attributesMap);\r
+        SectionHandler handler = manager.currentHandler().startElement(aQualifiedName, attributesMap);\r
 \r
-          manager.pushHandler( handler );\r
-        }\r
+        manager.pushHandler( handler );\r
       }\r
       catch (XMLReaderExc e) {\r
         throw new SAXParseException(e.getMessage(), null, e);\r
index 95e4322..df4ba40 100755 (executable)
@@ -36,6 +36,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 
 public class XMLReaderTool {
 
@@ -95,4 +96,45 @@ public class XMLReaderTool {
     }
 
   }
+
+  /**
+   * Returns the namespace part of a qualified XML Tag name <br>
+   * Example:<br>
+   * <code>getNameSpaceFromQualifiedName("dc:creator");</code> <br>
+   * will return <code>"dc"</code>
+   *
+   * @param aQualifiedName
+   * @return
+   */
+
+  public static String getNameSpaceFromQualifiedName(String aQualifiedName) {
+    List parts = StringRoutines.splitString(aQualifiedName, ":");
+
+    if (parts.size()<=1)
+      return null;
+    else
+      return (String) parts.get(0);
+  }
+
+  /**
+   * Returns the localname part of a qualified XML Tag name <br>
+   * Example:<br>
+   * <code>getLocalNameFromQualifiedName("dc:creator");</code> <br>
+   * will return <code>"creator"</code>
+   *
+   * @param aQualifiedName
+   * @return
+   */
+
+  public static String getLocalNameFromQualifiedName(String aQualifiedName) {
+    List parts = StringRoutines.splitString(aQualifiedName, ":");
+
+    if (parts.size()<1)
+      return null;
+    if (parts.size()==1)
+      return (String) parts.get(0);
+    else
+      return (String) parts.get(1);
+  }
+
 }
index ad0be4c..423fe65 100755 (executable)
@@ -105,6 +105,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
       }
       catch (Throwable t) {
         logger.error("MirBasicProducerLocalizer.factories(): Unable to setup factories: "+t.getMessage());
+        t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));
       }
     }