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 */1617packageorg.apache.jetspeed.modules.actions.portlets;
1819// Java APIs20import java.util.Iterator;
21import java.util.Collection;
22import java.util.ArrayList;
2324// Turbine Modules25import org.apache.turbine.util.RunData;
26import org.apache.jetspeed.services.search.Search;
2728// Jetspeed Stuff29import org.apache.jetspeed.om.registry.PortletEntry;
30import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31import org.apache.jetspeed.services.logging.JetspeedLogger;
32import org.apache.jetspeed.services.Registry;
33import org.apache.jetspeed.portal.Portlet;
343536/***37 * This class is responsible for indexing the registry.38 * 39 * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>40 * @version $Id: IndexPortletRegistry.java,v 1.6 2004/03/31 04:49:10 morciuch Exp $41 */42publicclassIndexPortletRegistryextendsSecureGenericMVCAction43 {
4445/***46 * Static initialization of the logger for this class47 */48privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(IndexPortletRegistry.class.getName());
4950/***51 * Build the normal state content for this portlet.52 *53 * @param portlet The jsp-based portlet that is being built.54 * @param rundata The turbine rundata context for this request.55 */56protectedvoid buildNormalContext(Portlet portlet, RunData rundata)
57 {
58// Do nothing59 }
6061/***62 * Continue event handler.63 *64 * @param portlet The jsp-based portlet that is being built.65 * @param rundata The turbine rundata context for this request.66 */67publicvoid doIndex(RunData rundata, Portlet portlet)
68 {
69if (portlet == null)
70 {
71return;
72 }
7374 Collection c = new ArrayList();
7576for (Iterator i = Registry.get(Registry.PORTLET).listEntryNames(); i.hasNext();)
77 {
78PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, (String) i.next());
79if (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT) && !entry.isHidden())
80 {
81 c.add(entry);
82//System.out.println("Will index [" + entry.getTitle() + "]");83 }
84 }
8586try87 {
88// Delete all entries from index89 Search.remove(c);
90 }
91catch (Throwable e)
92 {
93 logger.error("Throwable", e);
94 }
9596try97 {
98// Add all entries to index99 Search.add(c);
100 }
101catch (Throwable e)
102 {
103 logger.error("Throwable", e);
104 }
105 }
106107 }