1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.modules.actions.portlets;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
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 portlets =
57 (List) PortletSessionState.getAttribute(portlet, rundata, RESULTS);
58
59 List categories = PortletFilter.buildCategoryList(portlets);
60 context.put("categories", categories);
61
62 MediaTypeRegistry mediaTypeReg =
63 (MediaTypeRegistry) Registry.get(Registry.MEDIA_TYPE);
64
65 ArrayList collection = new ArrayList();
66 Iterator 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 filter(List entries, String[] fields, String[] values)
83 {
84 return PortletFilter.filterPortlets(entries, fields, values);
85 }
86 }