1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.portal.portlets.viewprocessor;
17
18
19 import org.apache.jetspeed.portal.Portlet;
20 import org.apache.jetspeed.portal.PortletException;
21
22
23 import org.w3c.dom.Node;
24 import org.w3c.dom.NodeList;
25
26 /***
27 * <p>Portlet which renders RDF Site Summary.</p>
28 * <p>This portlet uses XML stylesheet for transforming the RSS
29 * content into display markup depending on the MimeType requested
30 * by the user-agent</p>
31 * <p>It accepts the following parameters :
32 * <dl>
33 * <dt>itemDisplayed</dt>
34 * <dd>The number of items from the RSS file to display on screen. Default 15 for HTML, 5 for WML</dd>
35 * <dt>showDescription</dt>
36 * <dd>Should the portlet show the item descriptions. Must be true or false. Default: true for HTML, false for WML</dd>
37 * <dt>showTitle</dt>
38 * <dd>Should the portlet show the channel description. Must be true or false. Default: true for HTML, false for WML</dd>
39 * <dt>stylesheet[.<mime>]</dt>
40 * <dd>The stylesheet URL. If a mime-type is specified, the stylesheet
41 * is only used for this mime-type</dd>
42 * </dl>
43 *
44 * @author <A HREF="mailto:raphael@apache.org">Raphaël Luta</A>
45 * @version $Id: $
46 * @since 1.4b4
47 */
48 public class RSSViewProcessor extends XSLViewProcessor
49 {
50
51 /***
52 * This method loads the init parameters and
53 * parse the document tied to this portlet
54 *
55 * @param portlet
56 * @exception PortletException
57 */
58 public void init(Portlet portlet)
59 throws PortletException
60 {
61
62 super.init(portlet);
63
64
65 String title = null;
66 String description = null;
67
68
69 Node channel = null;
70 NodeList list = this.document.getElementsByTagName("channel");
71
72 if (list.getLength() != 1)
73 {
74 throw new PortletException(ERROR_NOT_VALID);
75 }
76
77 channel = list.item(0);
78
79 Node tn = getNode( channel, "title" );
80
81 if ( tn == null ) {
82 throw new PortletException( ERROR_NOT_VALID );
83 }
84 else
85 {
86 Node fc = tn.getFirstChild();
87 if (fc != null)
88 {
89 title = fc.getNodeValue();
90 }
91 }
92
93 Node dn = getNode( channel, "description" );
94
95 if ( dn != null )
96 {
97 Node fc = dn.getFirstChild();
98 if (fc != null)
99 {
100 description = fc.getNodeValue();
101 }
102 }
103
104 portlet.setTitle(title);
105 portlet.setDescription(description);
106 }
107
108 }