KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > PortletBrowseAction


1 /*
2  * Copyright 2000-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.modules.actions.portlets;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.jetspeed.om.registry.MediaTypeRegistry;
23 import org.apache.jetspeed.portal.Portlet;
24 import org.apache.jetspeed.services.Registry;
25 import org.apache.jetspeed.util.PortletSessionState;
26 import org.apache.turbine.util.RunData;
27 import org.apache.velocity.context.Context;
28
29 /**
30  * This action extends the RegistryBrowseAction to provide filtering for portlets
31  * and add extra information into the context
32  *
33  * @author <a HREF="mailto:jford@apache.org">Jeremy Ford</a>
34  * @version $Id: PortletBrowseAction.java,v 1.2 2004/02/23 02:56:58 jford Exp $
35  */

36 public class PortletBrowseAction extends RegistryBrowseAction
37 {
38     /**
39     * Subclasses must override this method to provide default behavior
40     * for the portlet action
41     */

42     /**
43     * Build the normal state content for this portlet.
44     *
45     * @param portlet The velocity-based portlet that is being built.
46     * @param context The velocity context for this request.
47     * @param rundata The turbine rundata context for this request.
48     */

49     protected void buildNormalContext(
50         Portlet portlet,
51         Context context,
52         RunData rundata)
53     {
54         super.buildNormalContext(portlet, context, rundata);
55
56         List JavaDoc portlets =
57             (List JavaDoc) PortletSessionState.getAttribute(portlet, rundata, RESULTS);
58
59         List JavaDoc categories = PortletFilter.buildCategoryList(portlets);
60         context.put("categories", categories);
61
62         MediaTypeRegistry mediaTypeReg =
63             (MediaTypeRegistry) Registry.get(Registry.MEDIA_TYPE);
64
65         ArrayList JavaDoc collection = new ArrayList JavaDoc();
66         Iterator JavaDoc iter = mediaTypeReg.listEntryNames();
67         while (iter.hasNext())
68         {
69             collection.add(iter.next());
70         }
71
72         context.put("media_types", collection);
73
74         context.put("parents", PortletFilter.buildParentList(portlets));
75     }
76
77     /**
78      * Filter portlets by using the PortletFilter helper class
79      *
80      * @see org.apache.jetspeed.modules.actions.portlets.RegistryBrowseAction#filter(java.util.List, java.lang.String[], java.lang.String[])
81      */

82     protected List JavaDoc filter(List JavaDoc entries, String JavaDoc[] fields, String JavaDoc[] values)
83     {
84         return PortletFilter.filterPortlets(entries, fields, values);
85     }
86 }
87
Popular Tags