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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16packageorg.apache.jetspeed.portal.portlets.viewprocessor;
1718// Jetspeed apis19import org.apache.jetspeed.portal.Portlet;
20import org.apache.jetspeed.portal.PortletException;
2122// XML stuff23import org.w3c.dom.Node;
24import org.w3c.dom.NodeList;
2526/***27 * <p>Portlet which renders RDF Site Summary.</p>28 * <p>This portlet uses XML stylesheet for transforming the RSS29 * content into display markup depending on the MimeType requested30 * 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 stylesheet41 * 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.4b447 */48publicclassRSSViewProcessorextendsXSLViewProcessor49 {
5051/***52 * This method loads the init parameters and53 * parse the document tied to this portlet54 * 55 * @param portlet56 * @exception PortletException57 */58publicvoid init(Portlet portlet)
59 throws PortletException60 {
6162super.init(portlet);
6364//Determine title and description for this portlet65 String title = null;
66 String description = null;
6768//now find the channel node.69 Node channel = null;
70 NodeList list = this.document.getElementsByTagName("channel");
7172if (list.getLength() != 1)
73 {
74thrownewPortletException(ERROR_NOT_VALID);
75 }
7677 channel = list.item(0);
7879 Node tn = getNode( channel, "title" );
8081if ( tn == null ) {
82thrownewPortletException( ERROR_NOT_VALID );
83 }
84else85 {
86 Node fc = tn.getFirstChild();
87if (fc != null)
88 {
89 title = fc.getNodeValue();
90 }
91 }
9293 Node dn = getNode( channel, "description" );
9495if ( dn != null )
96 {
97 Node fc = dn.getFirstChild();
98if (fc != null)
99 {
100 description = fc.getNodeValue();
101 }
102 }
103104 portlet.setTitle(title);
105 portlet.setDescription(description);
106 }
107108 }