KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > searchindex > CmsSearchIndexList


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsSearchIndexList.java,v $
3  * Date : $Date: 2006/03/27 14:52:21 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.searchindex;
33
34 import org.opencms.configuration.CmsSearchConfiguration;
35 import org.opencms.i18n.CmsMessageContainer;
36 import org.opencms.jsp.CmsJspActionElement;
37 import org.opencms.main.CmsRuntimeException;
38 import org.opencms.main.OpenCms;
39 import org.opencms.search.CmsSearchIndex;
40 import org.opencms.search.CmsSearchIndexSource;
41 import org.opencms.search.CmsSearchManager;
42 import org.opencms.workplace.list.A_CmsListDialog;
43 import org.opencms.workplace.list.CmsListColumnAlignEnum;
44 import org.opencms.workplace.list.CmsListColumnDefinition;
45 import org.opencms.workplace.list.CmsListDefaultAction;
46 import org.opencms.workplace.list.CmsListDirectAction;
47 import org.opencms.workplace.list.CmsListItem;
48 import org.opencms.workplace.list.CmsListItemDetails;
49 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
50 import org.opencms.workplace.list.CmsListMetadata;
51 import org.opencms.workplace.list.CmsListMultiAction;
52 import org.opencms.workplace.list.CmsListOrderEnum;
53 import org.opencms.workplace.tools.CmsToolDialog;
54
55 import java.io.IOException JavaDoc;
56 import java.util.ArrayList JavaDoc;
57 import java.util.HashMap JavaDoc;
58 import java.util.Iterator JavaDoc;
59 import java.util.LinkedList JavaDoc;
60 import java.util.List JavaDoc;
61 import java.util.Map JavaDoc;
62
63 import javax.servlet.ServletException JavaDoc;
64 import javax.servlet.http.HttpServletRequest JavaDoc;
65 import javax.servlet.http.HttpServletResponse JavaDoc;
66 import javax.servlet.jsp.PageContext JavaDoc;
67
68 /**
69  * A list that displays all search indexes of the OpenCms installation and offers
70  * operations on them.<p>
71  *
72  * @author Achim Westermann
73  *
74  * @version $Revision: 1.2 $
75  *
76  * @since 6.0.0
77  */

78 public class CmsSearchIndexList extends A_CmsListDialog {
79
80     /** list action id constant. */
81     public static final String JavaDoc LIST_ACTION_DELETE = "ad";
82
83     /** list action id constant. */
84     public static final String JavaDoc LIST_ACTION_EDIT = "ae";
85
86     /** list action id constant. */
87     public static final String JavaDoc LIST_ACTION_INDEXSOURCES = "ais";
88
89     /** list action id constant. */
90     public static final String JavaDoc LIST_ACTION_REBUILD = "ar";
91
92     /** list action id constant. */
93     public static final String JavaDoc LIST_ACTION_SEARCH = "as";
94
95     /** list action id constant. */
96     public static final String JavaDoc LIST_ACTION_SEARCHINDEX_OVERVIEW = "asio";
97
98     /** list column id constant. */
99     public static final String JavaDoc LIST_COLUMN_DELETE = "cad";
100
101     /** list column id constant. */
102     public static final String JavaDoc LIST_COLUMN_EDIT = "cae";
103
104     /** list column id constant. */
105     public static final String JavaDoc LIST_COLUMN_INDEX_SOURCE = "cai";
106
107     /** list column id constant. */
108     public static final String JavaDoc LIST_COLUMN_INDEXSOURCES = "cis";
109
110     /** list column id constant. */
111     public static final String JavaDoc LIST_COLUMN_LOCALE = "cl";
112
113     /** list column id constant. */
114     public static final String JavaDoc LIST_COLUMN_NAME = "cn";
115
116     /** list column id constant. */
117     public static final String JavaDoc LIST_COLUMN_PROJECT = "cp";
118
119     /** list column id constant. */
120     public static final String JavaDoc LIST_COLUMN_REBUILD = "car";
121
122     /** list column id constant. */
123     public static final String JavaDoc LIST_COLUMN_REBUILDMODE = "cr";
124
125     /** list column id constant. */
126     public static final String JavaDoc LIST_COLUMN_SEARCH = "cas";
127
128     /** list item detail id constant. */
129     public static final String JavaDoc LIST_DETAIL_INDEXSOURCE = "di";
130     /** list id constant. */
131     public static final String JavaDoc LIST_ID = "lssi";
132
133     /** list action id constant. */
134     public static final String JavaDoc LIST_MACTION_DELETE = "mad";
135
136     /** list action id constant. */
137     public static final String JavaDoc LIST_MACTION_REBUILD = "mar";
138
139     /** The path to the searchindex list icon (edit column). */
140     protected static final String JavaDoc LIST_ICON_INDEX = "tools/searchindex/icons/small/searchindex.png";
141
142     /** The path to the indexsource list icon. */
143     protected static final String JavaDoc LIST_ICON_INDEXSOURCE = "tools/searchindex/icons/small/indexsource.png";
144
145     /** The path to the rebuild multiple indexes icon. */
146     protected static final String JavaDoc LIST_ICON_REBUILD_MULTI = "tools/searchindex/icons/small/multi-rebuild.png";
147
148     /** The path to the rebuild single indexes icon. */
149     protected static final String JavaDoc LIST_ICON_REBUILD_SINGLE = "tools/searchindex/icons/small/rebuild.png";
150
151     /** The path to the search (within indexsource) list icon. */
152     protected static final String JavaDoc LIST_ICON_SEARCH = "buttons/preview.png";
153
154     /**
155      * Public constructor.<p>
156      *
157      * @param jsp an initialized JSP action element
158      */

159     public CmsSearchIndexList(CmsJspActionElement jsp) {
160
161         this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_NAME_0));
162     }
163
164     /**
165      * Public constructor.<p>
166      *
167      * @param jsp an initialized JSP action element
168      * @param listId the id of the list
169      * @param listName the list name
170      */

171     public CmsSearchIndexList(CmsJspActionElement jsp, String JavaDoc listId, CmsMessageContainer listName) {
172
173         this(jsp, listId, listName, LIST_COLUMN_NAME, CmsListOrderEnum.ORDER_ASCENDING, null);
174     }
175
176     /**
177      * Public constructor.<p>
178      *
179      * @param jsp an initialized JSP action element
180      * @param listId the id of the displayed list
181      * @param listName the name of the list
182      * @param sortedColId the a priory sorted column
183      * @param sortOrder the order of the sorted column
184      * @param searchableColId the column to search into
185      */

186     public CmsSearchIndexList(
187         CmsJspActionElement jsp,
188         String JavaDoc listId,
189         CmsMessageContainer listName,
190         String JavaDoc sortedColId,
191         CmsListOrderEnum sortOrder,
192         String JavaDoc searchableColId) {
193
194         super(jsp, listId, listName, sortedColId, sortOrder, searchableColId);
195
196     }
197
198     /**
199      * Public constructor.<p>
200      *
201      * Public constructor with JSP variables.<p>
202      *
203      * @param context the JSP page context
204      * @param req the JSP request
205      * @param res the JSP response
206      */

207     public CmsSearchIndexList(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
208
209         this(new CmsJspActionElement(context, req, res));
210     }
211
212     /**
213      * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
214      */

215     public void executeListMultiActions() throws IOException JavaDoc, ServletException JavaDoc, CmsRuntimeException {
216
217         CmsSearchManager searchManager = OpenCms.getSearchManager();
218         if (getParamListAction().equals(LIST_MACTION_DELETE)) {
219             // execute the delete multiaction
220
List JavaDoc removedItems = new ArrayList JavaDoc();
221             Iterator JavaDoc itItems = getSelectedItems().iterator();
222             while (itItems.hasNext()) {
223                 CmsListItem listItem = (CmsListItem)itItems.next();
224                 searchManager.removeSearchIndex(searchManager.getIndex((String JavaDoc)listItem.get(LIST_COLUMN_NAME)));
225                 removedItems.add(listItem.getId());
226                 getList().removeItem(listItem.getId(), getLocale());
227             }
228             writeConfiguration(false);
229         } else if (getParamListAction().equals(LIST_MACTION_REBUILD)) {
230             // execute the rebuild multiaction
231
StringBuffer JavaDoc items = new StringBuffer JavaDoc();
232             Iterator JavaDoc itItems = getSelectedItems().iterator();
233             while (itItems.hasNext()) {
234                 CmsListItem listItem = (CmsListItem)itItems.next();
235                 items.append(listItem.getId());
236                 if (itItems.hasNext()) {
237                     items.append(',');
238                 }
239             }
240             Map JavaDoc params = new HashMap JavaDoc();
241             params.put(CmsRebuildReport.PARAM_INDEXES, items.toString());
242             params.put(PARAM_ACTION, DIALOG_INITIAL);
243             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
244             getToolManager().jspForwardTool(this, "/searchindex/singleindex/rebuildreport", params);
245         }
246         listSave();
247     }
248
249     /**
250      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
251      */

252     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc, CmsRuntimeException {
253
254         CmsSearchManager searchManager = OpenCms.getSearchManager();
255         String JavaDoc index = getSelectedItem().getId();
256         Map JavaDoc params = new HashMap JavaDoc();
257         String JavaDoc action = getParamListAction();
258         if (action.equals(LIST_ACTION_DELETE)) {
259             searchManager.removeSearchIndex(searchManager.getIndex(index));
260             getList().removeItem(index, getLocale());
261             writeConfiguration(false);
262         } else if (action.equals(LIST_ACTION_REBUILD)) {
263             // forward to the rebuild index screen
264
params.put(CmsRebuildReport.PARAM_INDEXES, index);
265             params.put(PARAM_ACTION, DIALOG_INITIAL);
266             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
267             getToolManager().jspForwardTool(this, "/searchindex/singleindex/rebuildreport", params);
268         } else if (action.equals(LIST_ACTION_SEARCH)) {
269             // forward to the edit index screen
270
params.put(PARAM_ACTION, DIALOG_INITIAL);
271             params.put(CmsRebuildReport.PARAM_INDEXES, index);
272             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
273             params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
274             getToolManager().jspForwardTool(this, "/searchindex/singleindex/search", params);
275         } else if (action.equals(LIST_ACTION_EDIT)) {
276             // forward to the edit index screen
277
params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
278             params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
279             getToolManager().jspForwardTool(this, "/searchindex/singleindex/edit", params);
280         } else if (action.equals(LIST_ACTION_SEARCHINDEX_OVERVIEW)) {
281             // forward to the index overview screen
282
params.put(PARAM_ACTION, DIALOG_INITIAL);
283             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
284             params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
285             getToolManager().jspForwardTool(this, "/searchindex/singleindex", params);
286         } else if (action.equals(LIST_ACTION_INDEXSOURCES)) {
287             // forward to the index source assignment screen
288
params.put(PARAM_ACTION, DIALOG_INITIAL);
289             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
290             params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
291             getToolManager().jspForwardTool(this, "/searchindex/singleindex/indexsources", params);
292         }
293
294         listSave();
295     }
296
297     /**
298      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
299      */

300     protected void fillDetails(String JavaDoc detailId) {
301
302         // get content
303
List JavaDoc items = getList().getAllContent();
304         Iterator JavaDoc itItems = items.iterator();
305         CmsListItem item;
306         while (itItems.hasNext()) {
307             item = (CmsListItem)itItems.next();
308             if (detailId.equals(LIST_DETAIL_INDEXSOURCE)) {
309                 fillDetailIndexSource(item, detailId);
310             }
311
312         }
313
314     }
315
316     /**
317      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
318      */

319     protected List JavaDoc getListItems() {
320
321         List JavaDoc result = new ArrayList JavaDoc();
322         // get content
323
List JavaDoc indexes = searchIndexes();
324         Iterator JavaDoc itIndexes = indexes.iterator();
325         CmsSearchIndex index;
326         while (itIndexes.hasNext()) {
327             index = (CmsSearchIndex)itIndexes.next();
328             CmsListItem item = getList().newItem(index.getName());
329             item.set(LIST_COLUMN_NAME, index.getName());
330             item.set(LIST_COLUMN_REBUILDMODE, index.getRebuildMode());
331             item.set(LIST_COLUMN_PROJECT, index.getProject());
332             item.set(LIST_COLUMN_LOCALE, index.getLocale());
333             result.add(item);
334         }
335         return result;
336     }
337
338     /**
339      * @see org.opencms.workplace.CmsWorkplace#initMessages()
340      */

341     protected void initMessages() {
342
343         // add specific dialog resource bundle
344
addMessages(Messages.get().getBundleName());
345         // add default resource bundles
346
super.initMessages();
347     }
348
349     /**
350      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
351      */

352     protected void setColumns(CmsListMetadata metadata) {
353
354         // create column for edit
355
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
356         editCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_EDIT_NAME_0));
357         editCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_EDIT_HELP_0));
358         editCol.setWidth("5");
359         editCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
360         editCol.setSorteable(false);
361         // add edit action
362
CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
363         editAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_EDIT_NAME_0));
364         editAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_EDIT_HELP_0));
365         editAction.setIconPath(LIST_ICON_INDEX);
366         editCol.addDirectAction(editAction);
367         // add it to the list definition
368
metadata.addColumn(editCol);
369
370         // create column for indexsource assignment
371
CmsListColumnDefinition sourceCol = new CmsListColumnDefinition(LIST_COLUMN_INDEXSOURCES);
372         sourceCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_0));
373         sourceCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_HELP_0));
374         sourceCol.setWidth("5");
375         sourceCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
376         sourceCol.setSorteable(false);
377         // add assign indexsource action
378
CmsListDirectAction sourceAction = new CmsListDirectAction(LIST_ACTION_INDEXSOURCES);
379         sourceAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_INDEXSOURCES_NAME_0));
380         sourceAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_HELP_0));
381         sourceAction.setIconPath(LIST_ICON_INDEXSOURCE);
382         sourceCol.addDirectAction(sourceAction);
383         // add it to the list definition
384
metadata.addColumn(sourceCol);
385
386         // create column for deletion
387
CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
388         deleteCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_NAME_0));
389         deleteCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_HELP_0));
390         deleteCol.setWidth("5");
391         deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
392         deleteCol.setSorteable(false);
393         // add delete action
394
CmsListDirectAction deleteAction = new CmsListDirectAction(LIST_ACTION_DELETE);
395         deleteAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_NAME_0));
396         deleteAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_HELP_0));
397         deleteAction.setConfirmationMessage(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_CONF_0));
398         deleteAction.setIconPath(ICON_DELETE);
399         deleteCol.addDirectAction(deleteAction);
400         // add it to the list definition
401
metadata.addColumn(deleteCol);
402
403         // rebuild column
404
CmsListColumnDefinition rebuildCol = new CmsListColumnDefinition(LIST_COLUMN_REBUILD);
405         rebuildCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILD_NAME_0));
406         rebuildCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILD_HELP_0));
407         rebuildCol.setWidth("5");
408         rebuildCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
409         rebuildCol.setSorteable(false);
410         // add search action
411
CmsListDirectAction rebuildAction = new CmsListDirectAction(LIST_ACTION_REBUILD);
412         rebuildAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_NAME_0));
413         rebuildAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_HELP_0));
414         rebuildAction.setConfirmationMessage(Messages.get().container(
415             Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_CONF_0));
416         rebuildAction.setIconPath(LIST_ICON_REBUILD_SINGLE);
417         rebuildCol.addDirectAction(rebuildAction);
418         // add it to the list definition
419
metadata.addColumn(rebuildCol);
420
421         // search column
422
CmsListColumnDefinition searchCol = new CmsListColumnDefinition(LIST_COLUMN_SEARCH);
423         searchCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_SEARCH_NAME_0));
424         searchCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_SEARCH_HELP_0));
425         searchCol.setWidth("5");
426         searchCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
427         searchCol.setSorteable(false);
428         // add search action
429
CmsListDirectAction searchAction = new CmsListDirectAction(LIST_ACTION_SEARCH);
430         searchAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_SEARCH_NAME_0));
431         searchAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_SEARCH_HELP_0));
432         searchAction.setIconPath(LIST_ICON_SEARCH);
433         searchCol.addDirectAction(searchAction);
434         // add it to the list definition
435
metadata.addColumn(searchCol);
436
437         // add column for name
438
CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
439         nameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
440         nameCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_NAME_0));
441         nameCol.setWidth("45%");
442         // a default action for the link to overview
443
CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_ACTION_SEARCHINDEX_OVERVIEW);
444         defEditAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_OVERVIEW_NAME_0));
445         defEditAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_OVERVIEW_HELP_0));
446         nameCol.addDefaultAction(defEditAction);
447         metadata.addColumn(nameCol);
448
449         // add column for rebuild mode
450
CmsListColumnDefinition rebuildModeCol = new CmsListColumnDefinition(LIST_COLUMN_REBUILDMODE);
451         rebuildModeCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
452         rebuildModeCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILDMODE_0));
453         rebuildModeCol.setWidth("15%");
454         metadata.addColumn(rebuildModeCol);
455
456         // add column for project
457
CmsListColumnDefinition projectCol = new CmsListColumnDefinition(LIST_COLUMN_PROJECT);
458         projectCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
459         projectCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_PROJECT_0));
460         projectCol.setWidth("30%");
461         metadata.addColumn(projectCol);
462
463         // add column for locale
464
CmsListColumnDefinition localeCol = new CmsListColumnDefinition(LIST_COLUMN_LOCALE);
465         localeCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
466         localeCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_LOCALE_0));
467         localeCol.setWidth("10%");
468         metadata.addColumn(localeCol);
469     }
470
471     /**
472      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
473      */

474     protected void setIndependentActions(CmsListMetadata metadata) {
475
476         // add index source details
477
CmsListItemDetails indexDetails = new CmsListItemDetails(LIST_DETAIL_INDEXSOURCE);
478         indexDetails.setAtColumn(LIST_COLUMN_NAME);
479         indexDetails.setVisible(false);
480         indexDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_SHOW_0));
481         indexDetails.setShowActionHelpText(Messages.get().container(
482             Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_SHOW_HELP_0));
483         indexDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_HIDE_0));
484         indexDetails.setHideActionHelpText(Messages.get().container(
485             Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_HIDE_HELP_0));
486         indexDetails.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_NAME_0));
487         indexDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
488             Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_NAME_0)));
489         metadata.addItemDetails(indexDetails);
490     }
491
492     /**
493      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
494      */

495     protected void setMultiActions(CmsListMetadata metadata) {
496
497         // add delete multi action
498
CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETE);
499         deleteMultiAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_NAME_0));
500         deleteMultiAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_HELP_0));
501         deleteMultiAction.setConfirmationMessage(Messages.get().container(
502             Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_CONF_0));
503         deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
504         metadata.addMultiAction(deleteMultiAction);
505
506         // add rebuild multi action
507
CmsListMultiAction rebuildMultiAction = new CmsListMultiAction(LIST_MACTION_REBUILD);
508         rebuildMultiAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_NAME_0));
509         rebuildMultiAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_HELP_0));
510         rebuildMultiAction.setConfirmationMessage(Messages.get().container(
511             Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_CONF_0));
512         rebuildMultiAction.setIconPath(LIST_ICON_REBUILD_MULTI);
513         metadata.addMultiAction(rebuildMultiAction);
514
515     }
516
517     /**
518      * Writes the updated search configuration back to the XML
519      * configuration file and refreshes the complete list.<p>
520      *
521      * @param refresh if true, the list items are refreshed
522      */

523     protected void writeConfiguration(boolean refresh) {
524
525         // update the XML configuration
526
OpenCms.writeConfiguration(CmsSearchConfiguration.class);
527         if (refresh) {
528             refreshList();
529         }
530     }
531
532     /**
533      * Fills details of the index source into the given item. <p>
534      *
535      * @param item the list item to fill
536      * @param detailId the id for the detail to fill
537      *
538      */

539     private void fillDetailIndexSource(CmsListItem item, String JavaDoc detailId) {
540
541         CmsSearchManager searchManager = OpenCms.getSearchManager();
542         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
543         // search for the corresponding CmsSearchIndex:
544
String JavaDoc idxName = (String JavaDoc)item.get(LIST_COLUMN_NAME);
545         CmsSearchIndex idx = OpenCms.getSearchManager().getIndex(idxName);
546
547         // get the index sources (nice API)
548
List JavaDoc idxSources = new LinkedList JavaDoc();
549         Iterator JavaDoc itIdxSrcNames = idx.getSourceNames().iterator();
550         while (itIdxSrcNames.hasNext()) {
551             idxSources.add(searchManager.getIndexSource((String JavaDoc)itIdxSrcNames.next()));
552         }
553
554         // output of found index sources
555
Iterator JavaDoc itIdxSources = idxSources.iterator();
556         CmsSearchIndexSource idxSource;
557         List JavaDoc resources;
558         html.append("<ul>\n");
559         while (itIdxSources.hasNext()) {
560             idxSource = (CmsSearchIndexSource)itIdxSources.next();
561             html.append(" <li>\n").append(" ").append("name : ").append(idxSource.getName()).append("\n");
562             html.append(" </li>");
563
564             html.append(" <li>\n").append(" ").append("indexer : ").append(idxSource.getIndexerClassName()).append(
565                 "\n");
566             html.append(" </li>");
567
568             html.append(" <li>\n").append(" ").append("resources : ").append("\n");
569             html.append(" <ul>\n");
570             resources = idxSource.getResourcesNames();
571             Iterator JavaDoc itResources = resources.iterator();
572             while (itResources.hasNext()) {
573                 html.append(" <li>\n").append(" ").append((String JavaDoc)itResources.next()).append("\n");
574                 html.append(" </li>\n");
575             }
576             html.append(" </ul>\n");
577             html.append(" </li>");
578
579             html.append(" <li>\n").append(" ").append("doctypes : ").append("\n");
580             html.append(" <ul>\n");
581             resources = idxSource.getDocumentTypes();
582             itResources = resources.iterator();
583             while (itResources.hasNext()) {
584                 html.append(" <li>\n").append(" ").append((String JavaDoc)itResources.next()).append("\n");
585                 html.append(" </li>\n");
586             }
587             html.append(" </ul>\n");
588             html.append(" </li>");
589         }
590
591         html.append("</ul>\n");
592         item.set(detailId, html.toString());
593     }
594
595     /**
596      * Returns the available search indexes of this installation.
597      *
598      * @return the available search indexes of this installation
599      */

600     private List JavaDoc searchIndexes() {
601
602         CmsSearchManager manager = OpenCms.getSearchManager();
603         return manager.getSearchIndexes();
604     }
605 }
606
Popular Tags