You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/02/26 17:53:09 UTC

svn commit: r511889 - in /tiles/examples/trunk/tiles-showcase/src/main/java/org/apache: commons/ commons/tiles/ commons/tiles/showcase/ commons/tiles/showcase/digester/ commons/tiles/showcase/digester/rss/ tiles/showcase/portal/ tiles/showcase/rssChannel/

Author: apetrelli
Date: Mon Feb 26 08:53:08 2007
New Revision: 511889

URL: http://svn.apache.org/viewvc?view=rev&rev=511889
Log:
TILESSHOW-8
Some bug fixing and update.
Added the RSS digester example, removed from Commons-Digester since version 1.6.

Added:
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java   (with props)
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java   (with props)
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java   (with props)
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java   (with props)
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java   (with props)
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html   (with props)
Modified:
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/PortalCatalog.java
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/UserMenuAction.java
    tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/rssChannel/RssChannelsAction.java

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java Mon Feb 26 08:53:08 2007
@@ -0,0 +1,616 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.tiles.showcase.digester.rss;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+
+
+/**
+ * <p>Implementation object representing a <strong>channel</strong> in the
+ * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
+ * to further specialize its behavior.</p>
+ */
+
+public class Channel implements Serializable {
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * The set of items associated with this Channel.
+     */
+    protected ArrayList items = new ArrayList();
+
+
+    /**
+     * The set of skip days for this channel.
+     */
+    protected ArrayList skipDays = new ArrayList();
+
+
+    /**
+     * The set of skip hours for this channel.
+     */
+    protected ArrayList skipHours = new ArrayList();
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * The channel copyright (1-100 characters).
+     */
+    protected String copyright = null;
+
+    public String getCopyright() {
+        return (this.copyright);
+    }
+
+    public void setCopyright(String copyright) {
+        this.copyright = copyright;
+    }
+
+
+    /**
+     * The channel description (1-500 characters).
+     */
+    protected String description = null;
+
+    public String getDescription() {
+        return (this.description);
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+
+    /**
+     * The channel description file URL (1-500 characters).
+     */
+    protected String docs = null;
+
+    public String getDocs() {
+        return (this.docs);
+    }
+
+    public void setDocs(String docs) {
+        this.docs = docs;
+    }
+
+
+    /**
+     * The image describing this channel.
+     */
+    protected Image image = null;
+
+    public Image getImage() {
+        return (this.image);
+    }
+
+    public void setImage(Image image) {
+        this.image = image;
+    }
+
+
+    /**
+     * The channel language (2-5 characters).
+     */
+    protected String language = null;
+
+    public String getLanguage() {
+        return (this.language);
+    }
+
+    public void setLanguage(String language) {
+        this.language = language;
+    }
+
+
+    /**
+     * The channel last build date (1-100 characters).
+     */
+    protected String lastBuildDate = null;
+
+    public String getLastBuildDate() {
+        return (this.lastBuildDate);
+    }
+
+    public void setLastBuildDate(String lastBuildDate) {
+        this.lastBuildDate = lastBuildDate;
+    }
+
+
+    /**
+     * The channel link (1-500 characters).
+     */
+    protected String link = null;
+
+    public String getLink() {
+        return (this.link);
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+
+    /**
+     * The managing editor (1-100 characters).
+     */
+    protected String managingEditor = null;
+
+    public String getManagingEditor() {
+        return (this.managingEditor);
+    }
+
+    public void setManagingEditor(String managingEditor) {
+        this.managingEditor = managingEditor;
+    }
+
+
+    /**
+     * The channel publication date (1-100 characters).
+     */
+    protected String pubDate = null;
+
+    public String getPubDate() {
+        return (this.pubDate);
+    }
+
+    public void setPubDate(String pubDate) {
+        this.pubDate = pubDate;
+    }
+
+
+    /**
+     * The channel rating (20-500 characters).
+     */
+    protected String rating = null;
+
+    public String getRating() {
+        return (this.rating);
+    }
+
+    public void setRating(String rating) {
+        this.rating = rating;
+    }
+
+
+    /**
+     * The text input description for this channel.
+     */
+    protected TextInput textInput = null;
+
+    public TextInput getTextInput() {
+        return (this.textInput);
+    }
+
+    public void setTextInput(TextInput textInput) {
+        this.textInput = textInput;
+    }
+
+
+    /**
+     * The channel title (1-100 characters).
+     */
+    protected String title = null;
+
+    public String getTitle() {
+        return (this.title);
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+
+    /**
+     * The RSS specification version number used to create this Channel.
+     */
+    protected double version = 0.91;
+
+    public double getVersion() {
+        return (this.version);
+    }
+
+    public void setVersion(double version) {
+        this.version = version;
+    }
+
+
+    /**
+     * The webmaster email address (1-100 characters).
+     */
+    protected String webMaster = null;
+
+    public String getWebMaster() {
+        return (this.webMaster);
+    }
+
+    public void setWebMaster(String webMaster) {
+        this.webMaster = webMaster;
+    }
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Add an additional item.
+     *
+     * @param item The item to be added
+     */
+    public void addItem(Item item) {
+        synchronized (items) {
+            items.add(item);
+        }
+    }
+
+
+    /**
+     * Add an additional skip day name.
+     *
+     * @param skipDay The skip day to be added
+     */
+    public void addSkipDay(String skipDay) {
+        synchronized (skipDays) {
+            skipDays.add(skipDay);
+        }
+    }
+
+
+    /**
+     * Add an additional skip hour name.
+     *
+     * @param skipHour The skip hour to be added
+     */
+    public void addSkipHour(String skipHour) {
+        synchronized (skipHours) {
+            skipHours.add(skipHour);
+        }
+    }
+
+
+    /**
+     * Return the items for this channel.
+     */
+    public Item[] findItems() {
+        synchronized (items) {
+            Item items[] = new Item[this.items.size()];
+            return ((Item[]) this.items.toArray(items));
+        }
+    }
+
+
+    /**
+     * Return the items for this channel.
+     */
+    public Item[] getItems() {
+        return findItems();
+    }
+
+
+    /**
+     * Return the skip days for this channel.
+     */
+    public String[] findSkipDays() {
+        synchronized (skipDays) {
+            String skipDays[] = new String[this.skipDays.size()];
+            return ((String[]) this.skipDays.toArray(skipDays));
+        }
+    }
+
+
+    /**
+     * Return the skip hours for this channel.
+     */
+    public String[] getSkipHours() {
+        return findSkipHours();
+    }
+
+
+    /**
+     * Return the skip hours for this channel.
+     */
+    public String[] findSkipHours() {
+        synchronized (skipHours) {
+            String skipHours[] = new String[this.skipHours.size()];
+            return ((String[]) this.skipHours.toArray(skipHours));
+        }
+    }
+
+
+    /**
+     * Return the skip days for this channel.
+     */
+    public String[] getSkipDays() {
+        return findSkipDays();
+    }
+
+
+    /**
+     * Remove an item for this channel.
+     *
+     * @param item The item to be removed
+     */
+    public void removeItem(Item item) {
+        synchronized (items) {
+            items.remove(item);
+        }
+    }
+
+
+    /**
+     * Remove a skip day for this channel.
+     *
+     * @param skipDay The skip day to be removed
+     */
+    public void removeSkipDay(String skipDay) {
+        synchronized (skipDays) {
+            skipDays.remove(skipDay);
+        }
+    }
+
+
+    /**
+     * Remove a skip hour for this channel.
+     *
+     * @param skipHour The skip hour to be removed
+     */
+    public void removeSkipHour(String skipHour) {
+        synchronized (skipHours) {
+            skipHours.remove(skipHour);
+        }
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified output stream, with no indication of character
+     * encoding.
+     *
+     * @param stream The output stream to write to
+     */
+    public void render(OutputStream stream) {
+
+        try {
+            render(stream, null);
+        } catch (UnsupportedEncodingException e) {
+            ; // Can not happen
+        }
+
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified output stream, with the specified character encoding.
+     *
+     * @param stream The output stream to write to
+     * @param encoding The character encoding to declare, or <code>null</code>
+     *  for no declaration
+     *
+     * @exception UnsupportedEncodingException if the named encoding
+     *  is not supported
+     */
+    public void render(OutputStream stream, String encoding)
+            throws UnsupportedEncodingException {
+
+        PrintWriter pw = null;
+        if (encoding == null) {
+            pw = new PrintWriter(stream);
+        } else {
+            pw = new PrintWriter(new OutputStreamWriter(stream, encoding));
+        }
+        render(pw, encoding);
+        pw.flush();
+
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer, with no indication of character encoding.
+     *
+     * @param writer The writer to render output to
+     */
+    public void render(Writer writer) {
+
+        render(writer, null);
+
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer, indicating the specified character encoding.
+     *
+     * @param writer The writer to render output to
+     * @param encoding The character encoding to declare, or <code>null</code>
+     *  for no declaration
+     */
+    public void render(Writer writer, String encoding) {
+
+        PrintWriter pw = new PrintWriter(writer);
+        render(pw, encoding);
+        pw.flush();
+
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer, with no indication of character encoding.
+     *
+     * @param writer The writer to render output to
+     */
+    public void render(PrintWriter writer) {
+
+        render(writer, null);
+
+    }
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer, indicating the specified character encoding.
+     *
+     * @param writer The writer to render output to
+     * @param encoding The character encoding to declare, or <code>null</code>
+     *  for no declaration
+     */
+    public void render(PrintWriter writer, String encoding) {
+
+        writer.print("<?xml version=\"1.0\"");
+        if (encoding != null) {
+            writer.print(" encoding=\"");
+            writer.print(encoding);
+            writer.print("\"");
+        }
+        writer.println("?>");
+        writer.println();
+
+        writer.println("<!DOCTYPE rss PUBLIC");
+        writer.println("  \"-//Netscape Communications//DTD RSS 0.91//EN\"");
+        writer.println("  \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">");
+        writer.println();
+
+        writer.println("<rss version=\"0.91\">");
+        writer.println();
+
+        writer.println("  <channel>");
+        writer.println();
+
+        writer.print("    <title>");
+        writer.print(title);
+        writer.println("</title>");
+
+        writer.print("    <description>");
+        writer.print(description);
+        writer.println("</description>");
+
+        writer.print("    <link>");
+        writer.print(link);
+        writer.println("</link>");
+
+        writer.print("    <language>");
+        writer.print(language);
+        writer.println("</language>");
+
+        if (rating != null) {
+            writer.print("    <rating>");
+            writer.print(rating);
+            writer.println("</rating>");
+        }
+
+        if (copyright != null) {
+            writer.print("    <copyright>");
+            writer.print(copyright);
+            writer.print("</copyright>");
+        }
+
+
+        if (pubDate != null) {
+            writer.print("    <pubDate>");
+            writer.print(pubDate);
+            writer.println("</pubDate>");
+        }
+
+        if (lastBuildDate != null) {
+            writer.print("    <lastBuildDate>");
+            writer.print(lastBuildDate);
+            writer.println("</lastBuildDate>");
+        }
+
+        if (docs != null) {
+            writer.print("    <docs>");
+            writer.print(docs);
+            writer.println("</docs>");
+        }
+
+        if (managingEditor != null) {
+            writer.print("    <managingEditor>");
+            writer.print(managingEditor);
+            writer.println("</managingEditor>");
+        }
+
+        if (webMaster != null) {
+            writer.print("    <webMaster>");
+            writer.print(webMaster);
+            writer.println("</webMaster>");
+        }
+
+        writer.println();
+
+        if (image != null) {
+            image.render(writer);
+            writer.println();
+        }
+
+        if (textInput != null) {
+            textInput.render(writer);
+            writer.println();
+        }
+
+        String skipDays[] = findSkipDays();
+        if (skipDays.length > 0) {
+            writer.println("    <skipDays>");
+            for (int i = 0; i < skipDays.length; i++) {
+                writer.print("      <skipDay>");
+                writer.print(skipDays[i]);
+                writer.println("</skipDay>");
+            }
+            writer.println("    </skipDays>");
+        }
+
+        String skipHours[] = findSkipHours();
+        if (skipHours.length > 0) {
+            writer.println("    <skipHours>");
+            for (int i = 0; i < skipHours.length; i++) {
+                writer.print("      <skipHour>");
+                writer.print(skipHours[i]);
+                writer.println("</skipHour>");
+            }
+            writer.println("    </skipHours>");
+            writer.println();
+        }
+
+        Item items[] = findItems();
+        for (int i = 0; i < items.length; i++) {
+            items[i].render(writer);
+            writer.println();
+        }
+
+        writer.println("  </channel>");
+        writer.println();
+
+        writer.println("</rss>");
+
+    }
+
+
+}

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Channel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java Mon Feb 26 08:53:08 2007
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.tiles.showcase.digester.rss;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+
+/**
+ * <p>Implementation object representing an <strong>image</strong> in the
+ * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
+ * to further specialize its behavior.</p>
+ */
+
+public class Image implements Serializable {
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * The image description (1-100 characters).
+     */
+    protected String description = null;
+
+    public String getDescription() {
+        return (this.description);
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+
+    /**
+     * The image height in pixels (1-400).
+     */
+    protected int height = 31;
+
+    public int getHeight() {
+        return (this.height);
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+
+    /**
+     * The image link (1-500 characters).
+     */
+    protected String link = null;
+
+    public String getLink() {
+        return (this.link);
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+
+    /**
+     * The image alternate text (1-100 characters).
+     */
+    protected String title = null;
+
+    public String getTitle() {
+        return (this.title);
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+
+    /**
+     * The image location URL (1-500 characters).
+     */
+    protected String url = null;
+
+    public String getURL() {
+        return (this.url);
+    }
+
+    public void setURL(String url) {
+        this.url = url;
+    }
+
+
+    /**
+     * The image width in pixels (1-400).
+     */
+    protected int width = 31;
+
+    public int getWidth() {
+        return (this.width);
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+
+    // -------------------------------------------------------- Package Methods
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer.
+     *
+     * @param writer The writer to render output to
+     */
+    void render(PrintWriter writer) {
+
+        writer.println("    <image>");
+
+        writer.print("      <title>");
+        writer.print(title);
+        writer.println("</title>");
+
+        writer.print("      <url>");
+        writer.print(url);
+        writer.println("</url>");
+
+        if (link != null) {
+            writer.print("      <link>");
+            writer.print(link);
+            writer.println("</link>");
+        }
+
+        writer.print("      <width>");
+        writer.print(width);
+        writer.println("</width>");
+
+        writer.print("      <height>");
+        writer.print(height);
+        writer.println("</height>");
+
+        if (description != null) {
+            writer.print("      <description>");
+            writer.print(description);
+            writer.println("</description>");
+        }
+
+        writer.println("    </image>");
+
+    }
+
+
+}

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Image.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java Mon Feb 26 08:53:08 2007
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.tiles.showcase.digester.rss;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+
+/**
+ * <p>Implementation object representing an <strong>item</strong> in the
+ * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
+ * to further specialize its behavior.</p>
+ */
+
+public class Item implements Serializable {
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * The item description (1-500 characters).
+     */
+    protected String description = null;
+
+    public String getDescription() {
+        return (this.description);
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+
+    /**
+     * The item link (1-500 characters).
+     */
+    protected String link = null;
+
+    public String getLink() {
+        return (this.link);
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+
+    /**
+     * The item title (1-100 characters).
+     */
+    protected String title = null;
+
+    public String getTitle() {
+        return (this.title);
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+
+    // -------------------------------------------------------- Package Methods
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer.
+     *
+     * @param writer The writer to render output to
+     */
+    void render(PrintWriter writer) {
+
+        writer.println("    <item>");
+
+        writer.print("      <title>");
+        writer.print(title);
+        writer.println("</title>");
+
+        writer.print("      <link>");
+        writer.print(link);
+        writer.println("</link>");
+
+        if (description != null) {
+            writer.print("      <description>");
+            writer.print(description);
+            writer.println("</description>");
+        }
+
+        writer.println("    </item>");
+
+    }
+
+
+}

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/Item.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java Mon Feb 26 08:53:08 2007
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.tiles.showcase.digester.rss;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+/**
+ * <p>Implementation of <strong>org.apache.commons.digester.Digester</strong>
+ * designed to process input streams that conform to the <em>Rich Site
+ * Summary</em> DTD, version 0.91.  For more information about this format,
+ * see the <a href="http://my.netscape.com/publish/">My Netscape</a> site.</p>
+ *
+ * <p>The default implementation object returned by calling
+ * <code>parse()</code> (an instance of
+ * <code>org.apache.commons.tiles.showcase.digester.rss.Channel</code>)
+ * knows how to render itself in XML format via the <code>render()</code>
+ * method.  See the test <code>main()</code> method below for an
+ * example of using these classes.</p>
+ */
+
+public class RSSDigester extends Digester {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * Have we been configured yet?
+     */
+    protected boolean configured = false;
+
+
+    /**
+     * The set of public identifiers, and corresponding resource names,
+     * for the versions of the DTDs that we know about.
+     */
+    protected static final String registrations[] = {
+        "-//Netscape Communications//DTD RSS 0.9//EN",
+        "/org/apache/commons/digester/rss/rss-0.9.dtd",
+        "-//Netscape Communications//DTD RSS 0.91//EN",
+        "/org/apache/commons/digester/rss/rss-0.91.dtd",
+    };
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * The fully qualified class name of the <code>Channel</code>
+     * implementation class.
+     */
+    protected String channelClass = "org.apache.commons.tiles.showcase.digester.rss.Channel";
+
+    public String getChannelClass() {
+        return (this.channelClass);
+    }
+
+    public void setChannelClass(String channelClass) {
+        this.channelClass = channelClass;
+    }
+
+
+    /**
+     * The fully qualified class name of the <code>Image</code>
+     * implementation class.
+     */
+    protected String imageClass = "org.apache.commons.tiles.showcase.digester.rss.Image";
+
+    public String getImageClass() {
+        return (this.imageClass);
+    }
+
+    public void setImageClass(String imageClass) {
+        this.imageClass = imageClass;
+    }
+
+
+    /**
+     * The fully qualified class name of the <code>Item</code>
+     * implementation class.
+     */
+    protected String itemClass = "org.apache.commons.tiles.showcase.digester.rss.Item";
+
+    public String getItemClass() {
+        return (this.itemClass);
+    }
+
+    public void setItemClass(String itemClass) {
+        this.itemClass = itemClass;
+    }
+
+
+    /**
+     * The fully qualified class name of the <code>TextInput</code>
+     * implementation class.
+     */
+    protected String textInputClass =
+            "org.apache.commons.tiles.showcase.digester.rss.TextInput";
+
+    public String getTextInputClass() {
+        return (this.textInputClass);
+    }
+
+    public void setTextInputClass(String textInputClass) {
+        this.textInputClass = textInputClass;
+    }
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Parse the content of the specified file using this Digester.  Returns
+     * the root element from the object stack (which will be the Channel).
+     *
+     * @param file File containing the XML data to be parsed
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing exception occurs
+     */
+    public Object parse(File file) throws IOException, SAXException {
+
+        configure();
+        return (super.parse(file));
+
+    }
+
+
+    /**
+     * Parse the content of the specified input source using this Digester.
+     * Returns the root element from the object stack (which will be the
+     * Channel).
+     *
+     * @param input Input source containing the XML data to be parsed
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing exception occurs
+     */
+    public Object parse(InputSource input) throws IOException, SAXException {
+
+        configure();
+        return (super.parse(input));
+
+    }
+
+
+    /**
+     * Parse the content of the specified input stream using this Digester.
+     * Returns the root element from the object stack (which will be
+     * the Channel).
+     *
+     * @param input Input stream containing the XML data to be parsed
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing exception occurs
+     */
+    public Object parse(InputStream input) throws IOException, SAXException {
+
+        configure();
+        return (super.parse(input));
+
+    }
+
+
+    /**
+     * Parse the content of the specified URI using this Digester.
+     * Returns the root element from the object stack (which will be
+     * the Channel).
+     *
+     * @param uri URI containing the XML data to be parsed
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing exception occurs
+     */
+    public Object parse(String uri) throws IOException, SAXException {
+
+        configure();
+        return (super.parse(uri));
+
+    }
+
+
+    // -------------------------------------------------------- Package Methods
+
+
+
+    // ------------------------------------------------------ Protected Methods
+
+
+    /**
+     * Configure the parsing rules that will be used to process RSS input.
+     */
+    protected void configure() {
+
+        if (configured) {
+            return;
+        }
+
+        // Register local copies of the DTDs we understand
+        for (int i = 0; i < registrations.length; i += 2) {
+            URL url = this.getClass().getResource(registrations[i + 1]);
+            if (url != null) {
+                register(registrations[i], url.toString());
+            }
+        }
+
+        // FIXME - validate the "version" attribute of the rss element?
+
+        // Add the rules for the Channel object
+        addObjectCreate("rss/channel", channelClass);
+        addCallMethod("rss/channel/copyright", "setCopyright", 0);
+        addCallMethod("rss/channel/description", "setDescription", 0);
+        addCallMethod("rss/channel/docs", "setDocs", 0);
+        addCallMethod("rss/channel/language", "setLanguage", 0);
+        addCallMethod("rss/channel/lastBuildDate", "setLastBuildDate", 0);
+        addCallMethod("rss/channel/link", "setLink", 0);
+        addCallMethod("rss/channel/managingEditor", "setManagingEditor", 0);
+        addCallMethod("rss/channel/pubDate", "setPubDate", 0);
+        addCallMethod("rss/channel/rating", "setRating", 0);
+        addCallMethod("rss/channel/skipDays/day", "addSkipDay", 0);
+        addCallMethod("rss/channel/skipHours/hour", "addSkipHour", 0);
+        addCallMethod("rss/channel/title", "setTitle", 0);
+        addCallMethod("rss/channel/webMaster", "setWebMaster", 0);
+
+        // Add the rules for the Image object
+        addObjectCreate("rss/channel/image", imageClass);
+        addSetNext("rss/channel/image", "setImage",
+                "org.apache.commons.tiles.showcase.digester.rss.Image");
+        addCallMethod("rss/channel/image/description", "setDescription", 0);
+        addCallMethod("rss/channel/image/height", "setHeight", 0,
+                new Class[]{ Integer.TYPE });
+        addCallMethod("rss/channel/image/link", "setLink", 0);
+        addCallMethod("rss/channel/image/title", "setTitle", 0);
+        addCallMethod("rss/channel/image/url", "setURL", 0);
+        addCallMethod("rss/channel/image/width", "setWidth", 0,
+                new Class[]{ Integer.TYPE });
+
+        // Add the rules for the Item object
+        addObjectCreate("rss/channel/item", itemClass);
+        addSetNext("rss/channel/item", "addItem",
+                "org.apache.commons.tiles.showcase.digester.rss.Item");
+        addCallMethod("rss/channel/item/description", "setDescription", 0);
+        addCallMethod("rss/channel/item/link", "setLink", 0);
+        addCallMethod("rss/channel/item/title", "setTitle", 0);
+
+        // Add the rules for the TextInput object
+        addObjectCreate("rss/channel/textinput", textInputClass);
+        addSetNext("rss/channel/textinput", "setTextInput",
+                "org.apache.commons.tiles.showcase.digester.rss.TextInput");
+        addCallMethod("rss/channel/textinput/description",
+                "setDescription", 0);
+        addCallMethod("rss/channel/textinput/link", "setLink", 0);
+        addCallMethod("rss/channel/textinput/name", "setName", 0);
+        addCallMethod("rss/channel/textinput/title", "setTitle", 0);
+
+        // Mark this digester as having been configured
+        configured = true;
+
+    }
+
+
+    // ------------------------------------------------------ Test Main Program
+
+
+    /**
+     * Test main program that parses the channel description included in this
+     * package as a static resource.
+     *
+     * @param args The command line arguments (ignored)
+     */
+    public static void main(String args[]) {
+
+        try {
+            System.out.println("RSSDigester Test Program");
+            System.out.println("Opening input stream ...");
+            InputStream is = RSSDigester.class.getResourceAsStream
+                    ("/org/apache/commons/digester/rss/rss-example.xml");
+            System.out.println("Creating new digester ...");
+            RSSDigester digester = new RSSDigester();
+            if ((args.length > 0) && (args[0].equals("-debug"))) {
+                digester.setLogger(LogFactory.getLog("RSSDigester"));
+            }
+            System.out.println("Parsing input stream ...");
+            Channel channel = (Channel) digester.parse(is);
+            System.out.println("Closing input stream ...");
+            is.close();
+            System.out.println("Dumping channel info ...");
+            channel.render(System.out);
+        } catch (Exception e) {
+            System.out.println("-->Exception");
+            e.printStackTrace(System.out);
+        }
+
+    }
+
+
+}

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/RSSDigester.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java Mon Feb 26 08:53:08 2007
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.tiles.showcase.digester.rss;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+
+/**
+ * <p>Implementation object representing a <strong>textinput</strong> in the
+ * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
+ * to further specialize its behavior.</p>
+ */
+
+public class TextInput implements Serializable {
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * The text input description (1-100 characters).
+     */
+    protected String description = null;
+
+    public String getDescription() {
+        return (this.description);
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+
+    /**
+     * The text input link (1-500 characters).
+     */
+    protected String link = null;
+
+    public String getLink() {
+        return (this.link);
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+
+    /**
+     * The text input field name (1-100 characters).
+     */
+    protected String name = null;
+
+    public String getName() {
+        return (this.name);
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    /**
+     * The text input submit button label (1-100 characters).
+     */
+    protected String title = null;
+
+    public String getTitle() {
+        return (this.title);
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+
+    // -------------------------------------------------------- Package Methods
+
+
+    /**
+     * Render this channel as XML conforming to the RSS 0.91 specification,
+     * to the specified writer.
+     *
+     * @param writer The writer to render output to
+     */
+    void render(PrintWriter writer) {
+
+        writer.println("    <textinput>");
+
+        writer.print("      <title>");
+        writer.print(title);
+        writer.println("</title>");
+
+        writer.print("      <description>");
+        writer.print(description);
+        writer.println("</description>");
+
+        writer.print("      <name>");
+        writer.print(name);
+        writer.println("</name>");
+
+        writer.print("      <link>");
+        writer.print(link);
+        writer.println("</link>");
+
+        writer.println("    </textinput>");
+
+    }
+
+
+}

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/TextInput.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html?view=auto&rev=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html (added)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html Mon Feb 26 08:53:08 2007
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Package Documentation for org.apache.commons.digester.rss Package</title>
+</head>
+<body bgcolor="white">
+<p>Example usage of Digester to parse XML documents compatible with the
+<em>Rich Site Summary</em> format used by many newsfeeds.</p>
+</body>
+</html>

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/commons/tiles/showcase/digester/rss/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/PortalCatalog.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/PortalCatalog.java?view=diff&rev=511889&r1=511888&r2=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/PortalCatalog.java (original)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/PortalCatalog.java Mon Feb 26 08:53:08 2007
@@ -23,8 +23,10 @@
 package org.apache.tiles.showcase.portal;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.tiles.ComponentAttribute;
 import org.apache.tiles.showcase.channel.AttributeUtils;
@@ -43,6 +45,9 @@
      protected List tiles = new ArrayList();
        /** List of Tiles labels */
      protected List tileLabels = new ArrayList();
+     
+     protected Map<Object, Integer> key2index =
+         new HashMap<Object, Integer>();
 
        /**
         * Set list of tiles.
@@ -85,6 +90,12 @@
          throw new java.lang.ArrayIndexOutOfBoundsException( "List of tiles and list of labels must be of the same size" );
          }
        this.tiles = list;
+       key2index.clear();
+       int i = 0;
+       for (Object item: list) {
+           key2index.put(((ComponentAttribute) item).getValue(), i);
+           i++;
+       }
        tileLabels = labels;
        }
 
@@ -115,6 +126,11 @@
          throw new java.lang.ArrayIndexOutOfBoundsException( "List of tiles and list of labels must be of the same size" );
          }
        tiles.addAll(list);
+       int i = key2index.size();
+       for (Object item: list) {
+           key2index.put(((ComponentAttribute) item).getValue(), i);
+           i++;
+       }
        tileLabels.addAll(labels);
        }
 
@@ -186,9 +202,9 @@
          if( key.indexOf( '@' )>0 )
            { // special key
            }
-         if( tiles.contains( key ) )
+         if(key2index.containsKey(key))
            { // ok, add it
-           list.add( key );
+           list.add(tiles.get(key2index.get(key)));
            }
          } // end loop
        return list;

Modified: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/UserMenuAction.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/UserMenuAction.java?view=diff&rev=511889&r1=511888&r2=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/UserMenuAction.java (original)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/portal/UserMenuAction.java Mon Feb 26 08:53:08 2007
@@ -338,7 +338,9 @@
 			}
 
 			extractItems(result, attribute, context, container, tilesContext);
-
+        } else if (object instanceof ComponentAttribute) {
+            extractItems(result, ((ComponentAttribute) object).getValue(),
+                    context, container, tilesContext);
 		} else if (object instanceof MenuItem) {
 			result.add(object);
 		}

Modified: tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/rssChannel/RssChannelsAction.java
URL: http://svn.apache.org/viewvc/tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/rssChannel/RssChannelsAction.java?view=diff&rev=511889&r1=511888&r2=511889
==============================================================================
--- tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/rssChannel/RssChannelsAction.java (original)
+++ tiles/examples/trunk/tiles-showcase/src/main/java/org/apache/tiles/showcase/rssChannel/RssChannelsAction.java Mon Feb 26 08:53:08 2007
@@ -32,13 +32,17 @@
 //import org.apache.commons.digester.rss.RSSDigester;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.tiles.showcase.digester.rss.Channel;
+import org.apache.commons.tiles.showcase.digester.rss.RSSDigester;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
 import org.apache.struts.action.ActionMessages;
 import org.apache.struts.tiles2.actions.TilesAction;
 import org.apache.tiles.ComponentAttribute;
 import org.apache.tiles.ComponentContext;
+import org.apache.tiles.showcase.channel.AttributeUtils;
 
 /**
  * Read and parse RSS files found at on a given
@@ -116,31 +120,33 @@
 
         // -- Loop through channels --
         List channelBeans = new ArrayList(channels.size());
-//        try {
-//            for (int i = 0; i < channels.size(); i++) {
-//                RSSDigester digester = new RSSDigester();
-//                String url = (String) channels.get(i);
-//                // Add application path if needed
-//                if (url.startsWith("/")) {
-//                    url = toFullUrl(request, url);
-//                }
-//
-//                log.debug("Channel url=" + url);
-//
-//                Channel obj = (Channel) digester.parse(url);
-//
-//                log.debug("Channel:" + obj);
-//
-//                channelBeans.add(obj);
-//            }
-//            
-//        } catch (Throwable t) {
-//            errors.add(
-//                ActionMessages.GLOBAL_MESSAGE,
-//                new ActionMessage("rss.access.error"));
-//
-//            servlet.log(t.toString());
-//        }
+        try {
+            for (int i = 0; i < channels.size(); i++) {
+                RSSDigester digester = new RSSDigester();
+                String url = AttributeUtils
+                        .getAttributeValueAsString((ComponentAttribute) channels
+                                .get(i));
+                // Add application path if needed
+                if (url.startsWith("/")) {
+                    url = toFullUrl(request, url);
+                }
+
+                log.debug("Channel url=" + url);
+
+                Channel obj = (Channel) digester.parse(url);
+
+                log.debug("Channel:" + obj);
+
+                channelBeans.add(obj);
+            }
+            
+        } catch (Throwable t) {
+            errors.add(
+                ActionMessages.GLOBAL_MESSAGE,
+                new ActionMessage("rss.access.error"));
+
+            log.error("Error during getting RSS resource", t);
+        }
 
         // -- Handle Errors ---
         if (!errors.isEmpty()) {