Index: applications/rss/project.xml
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed-2/applications/rss/project.xml,v
retrieving revision 1.2
diff -u -r1.2 project.xml
--- applications/rss/project.xml 2 Dec 2004 05:22:12 -0000 1.2
+++ applications/rss/project.xml 14 Jan 2005 22:20:20 -0000
@@ -3,150 +3,141 @@
$Id: project.xml,v 1.2 2004/12/02 05:22:12 taylor Exp $
-->
- ${basedir}/./../project.xml
- rss
- Jetspeed-2 Language Selector Portlet
- Jetspeed-2 Language Selector Portlet
- Language Selector Portlet
-
-
- scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-jetspeed-2/applications/rss
- http://cvs.apache.org/viewcvs/jakarta-jetspeed-2/applications/rss/
-
-
-
-
- portlet-api
- portlet-api
- 1.0
-
- false
-
-
-
- servletapi
- 2.3
-
- false
-
-
-
-
- springframework:spring-core
- 1.1.1
-
- true
-
-
-
- jdom
- jdom
- 1.0
-
- true
-
-
-
- commons-digester
- commons-digester
- 1.5
- jar
- http://jakarta.apache.org/commons/digester.html
-
- true
-
-
-
- commons-beanutils
- commons-beanutils
- 1.6.1
- jar
- http://jakarta.apache.org/commons/beanutils.html
-
- true
-
-
-
-
- rome
- rome
- 0.4
- jar
-
- true
-
-
-
-
- portals-bridges
- portals-bridges-common
- 0.1
-
- true
-
-
-
-
- velocity
- 1.4
-
- true
-
-
-
- velocity-tools
- 1.1
- http://jakarta.apache.org/velocity
-
- true
-
-
-
- portals-bridges
- portals-bridges-velocity
- 0.1
-
- true
-
-
-
- xml-apis
- 2.0.2
-
- true
-
-
-
-
-
-
-
-
- src/java
-
-
- ${basedir}/src/java/
-
- **/*.properties
-
-
-
-
-
-
- maven-jdepend-plugin
-
- maven-pmd-plugin
- maven-changelog-plugin
- maven-file-activity-plugin
- maven-developer-activity-plugin
- maven-license-plugin
- maven-javadoc-plugin
- maven-jxr-plugin
- maven-junit-report-plugin
- maven-linkcheck-plugin
- maven-tasklist-plugin
-
-
+ maven-pmd-plugin
+ maven-changelog-plugin
+ maven-file-activity-plugin
+ maven-developer-activity-plugin
+ maven-license-plugin
+ maven-javadoc-plugin
+ maven-jxr-plugin
+ maven-junit-report-plugin
+ maven-linkcheck-plugin
+ maven-tasklist-plugin
+
+
\ No newline at end of file
Index: applications/rss/src/java/org/apache/portals/applications/rss/RomeRSSPortlet.java
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed-2/applications/rss/src/java/org/apache/portals/applications/rss/RomeRSSPortlet.java,v
retrieving revision 1.2
diff -u -r1.2 RomeRSSPortlet.java
--- applications/rss/src/java/org/apache/portals/applications/rss/RomeRSSPortlet.java 19 Nov 2004 21:59:09 -0000 1.2
+++ applications/rss/src/java/org/apache/portals/applications/rss/RomeRSSPortlet.java 14 Jan 2005 22:20:21 -0000
@@ -15,100 +15,106 @@
*/
package org.apache.portals.applications.rss;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-import org.apache.portals.applications.transform.TransformCacheEntry;
-import org.apache.portals.applications.util.Streams;
-import org.w3c.dom.Document;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
+
+import org.apache.velocity.context.Context;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
-import com.sun.syndication.io.SyndFeedOutput;
import com.sun.syndication.io.XmlReader;
/**
* Rome RSS Portlet
*
* @author David Sean Taylor
- * @version $Id: RomeRSSPortlet.java,v 1.2 2004/11/19 21:59:09 taylor Exp $
+ * @version $Id: Exp $
*/
-public class RomeRSSPortlet extends AbstractRssPortlet
+public class RomeRSSPortlet extends GenericVelocityPortlet
{
+
+ protected Log log = LogFactory.getLog(RomeRSSPortlet.class);
+
+ /**
+ * @see javax.portlet.Portlet#init(javax.portlet.PortletConfig)
+ */
public void init(PortletConfig config) throws PortletException
{
super.init(config);
+
}
-
- /*
- * (non-Javadoc)
- *
- * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
- * javax.portlet.RenderResponse)
+
+ /**
+ * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
{
+
response.setContentType("text/html");
-
- PortletPreferences prefs = request.getPreferences();
+ Context velocityContext = this.getContext(request);
+ PortletPreferences prefs = request.getPreferences();
String url = prefs.getValue("url", "http://www.npr.org/rss/rss.php?topicId=4");
- String stylesheet = getPortletConfig().getInitParameter("stylesheet");
- String realStylesheet = getPortletConfig().getPortletContext().getRealPath(stylesheet);
+ try
+ {
+ URL feedUrl = new URL(url);
+ SyndFeedInput input = new SyndFeedInput();
+
+ SyndFeed feed = input.build(new XmlReader(feedUrl));
+
+ RssInfo rssInfo = new RssInfo(feed, new Integer(prefs.getValue("itemdisplayed", "15")).intValue(), new Boolean(prefs
+ .getValue("openinpopup", "true")).booleanValue(), new Boolean(prefs.getValue("showdescription", "true"))
+ .booleanValue(), new Boolean(prefs.getValue("showtitle", "true")).booleanValue(), new Boolean(prefs.getValue(
+ "showtextinput", "true")).booleanValue());
- URL xslt = getPortletConfig().getPortletContext().getResource(stylesheet);
-
- String key = cache.constructKey(url, stylesheet); // TODO: use the entire parameter list
- TransformCacheEntry entry = cache.get(key);
- if (entry != null)
+ velocityContext.put("rssInfo", rssInfo);
+
+ super.doView(request, response);
+
+ }
+ catch (Exception e)
{
- byte[] bytes = (byte[])entry.getDocument();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- Streams.drain(bais, response.getPortletOutputStream());
- bais.close();
+ throw new PortletException(new String("Failed to process RSS Feed: " + url + ", " + e));
}
- else
- {
- try
- {
- URL feedUrl = new URL(url);
- SyndFeedInput input = new SyndFeedInput();
- SyndFeed feed = input.build(new XmlReader(feedUrl));
- SyndFeedOutput output = new SyndFeedOutput();
- //output.output(feed, response.getWriter());
- Document document = output.outputW3CDom(feed);
-
- Map parameters = new HashMap();
-
- parameters.put("itemdisplayed", prefs.getValue("itemdisplayed", "15"));
- parameters.put("openinpopup", prefs.getValue("openinpopup", "true"));
- parameters.put("showdescription", prefs.getValue("showdescription", "true"));
- parameters.put("showtitle", prefs.getValue("showtitle", "true"));
- parameters.put("showtextinput", prefs.getValue("showtextinput", "true"));
-
-
- // TODO: don't use a transform, instead use Velocity template and populate via Rome model
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- transform.transform(realStylesheet, document, baos, parameters);
- byte[] bytes = baos.toByteArray();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- Streams.drain(bais, response.getPortletOutputStream());
- cache.put(key, bytes, 15);
- }
- catch (Exception e)
- {
- response.getPortletOutputStream().write(new String("Failed to process RSS Feed: " + url + ", " + e).getBytes());
- }
+
+ }
+
+ /**
+ *
+ * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
+ */
+ public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
+ response.setContentType("text/html");
+ doPreferencesEdit(request, response);
+ }
+
+ /**
+ *
+ * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
+ */
+ public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, java.io.IOException
+ {
+ String add = request.getParameter("Save");
+ if (add != null)
+ {
+ processPreferencesAction(request, actionResponse);
}
}
+
}
Index: applications/rss/src/webapp/WEB-INF/portlet.xml
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed-2/applications/rss/src/webapp/WEB-INF/portlet.xml,v
retrieving revision 1.1
diff -u -r1.1 portlet.xml
--- applications/rss/src/webapp/WEB-INF/portlet.xml 15 Nov 2004 06:06:41 -0000 1.1
+++ applications/rss/src/webapp/WEB-INF/portlet.xml 14 Jan 2005 22:20:21 -0000
@@ -92,6 +92,14 @@
Index: applications/rss/src/webapp/WEB-INF/view/edit-prefs.vm
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed-2/applications/rss/src/webapp/WEB-INF/view/edit-prefs.vm,v
retrieving revision 1.2
diff -u -r1.2 edit-prefs.vm
--- applications/rss/src/webapp/WEB-INF/view/edit-prefs.vm 15 Nov 2004 18:40:44 -0000 1.2
+++ applications/rss/src/webapp/WEB-INF/view/edit-prefs.vm 14 Jan 2005 22:20:21 -0000
@@ -1,10 +1,33 @@
+#*
+Copyright 2004 The Apache Software Foundation
+
+Licensed 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.
+*#
+
+#**
+
+@author Christophe Lombart
+@version $Id: Exp $
+
+*#
+
+ #end
+#end