KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > portlets > viewprocessor > RSSViewProcessor


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.jetspeed.portal.portlets.viewprocessor;
17
18 // Jetspeed apis
19
import org.apache.jetspeed.portal.Portlet;
20 import org.apache.jetspeed.portal.PortletException;
21
22 // XML stuff
23
import org.w3c.dom.Node JavaDoc;
24 import org.w3c.dom.NodeList JavaDoc;
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         //Determine title and description for this portlet
65
String JavaDoc title = null;
66         String JavaDoc description = null;
67
68         //now find the channel node.
69
Node JavaDoc channel = null;
70         NodeList JavaDoc 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 JavaDoc tn = getNode( channel, "title" );
80
81         if ( tn == null ) {
82             throw new PortletException( ERROR_NOT_VALID );
83         }
84         else
85         {
86             Node JavaDoc fc = tn.getFirstChild();
87             if (fc != null)
88             {
89                 title = fc.getNodeValue();
90             }
91         }
92
93         Node JavaDoc dn = getNode( channel, "description" );
94
95         if ( dn != null )
96         {
97             Node JavaDoc 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 }
109
Popular Tags