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 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.modules.actions.portlets;
1718import java.util.ArrayList;
19import java.util.Iterator;
20import java.util.List;
2122import org.apache.jetspeed.om.registry.MediaTypeRegistry;
23import org.apache.jetspeed.portal.Portlet;
24import org.apache.jetspeed.services.Registry;
25import org.apache.jetspeed.util.PortletSessionState;
26import org.apache.turbine.util.RunData;
27import org.apache.velocity.context.Context;
2829/***30 * This action extends the RegistryBrowseAction to provide filtering for portlets31 * 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 */36publicclassPortletBrowseActionextendsRegistryBrowseAction37 {
38/***39 * Subclasses must override this method to provide default behavior40 * for the portlet action41 */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 */49protectedvoid buildNormalContext(
50Portlet portlet,
51 Context context,
52 RunData rundata)
53 {
54super.buildNormalContext(portlet, context, rundata);
5556 List portlets =
57 (List) PortletSessionState.getAttribute(portlet, rundata, RESULTS);
5859 List categories = PortletFilter.buildCategoryList(portlets);
60 context.put("categories", categories);
6162MediaTypeRegistry mediaTypeReg =
63 (MediaTypeRegistry) Registry.get(Registry.MEDIA_TYPE);
6465 ArrayList collection = new ArrayList();
66 Iterator iter = mediaTypeReg.listEntryNames();
67while (iter.hasNext())
68 {
69 collection.add(iter.next());
70 }
7172 context.put("media_types", collection);
7374 context.put("parents", PortletFilter.buildParentList(portlets));
75 }
7677/***78 * Filter portlets by using the PortletFilter helper class79 * 80 * @see org.apache.jetspeed.modules.actions.portlets.RegistryBrowseAction#filter(java.util.List, java.lang.String[], java.lang.String[])81 */82protected List filter(List entries, String[] fields, String[] values)
83 {
84return PortletFilter.filterPortlets(entries, fields, values);
85 }
86 }