KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsSearchIndexSourceControlList.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.CmsLog;
38 import org.opencms.main.OpenCms;
39 import org.opencms.search.CmsSearchDocumentType;
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 import org.apache.commons.logging.Log;
69
70 /**
71  * A list that displays information about the <code>{@link org.opencms.search.CmsSearchIndexSource}</code>
72  * that are members of the <code>{@link org.opencms.search.CmsSearchIndex}</code>
73  * in the current request scope (param "searchindex").<p>
74  *
75  * Unlike <code>{@link org.opencms.workplace.tools.searchindex.CmsSearchIndexSourceList}</code>
76  * this list is stand-alone displayable (not to embed in another dialog) and
77  * offers single actions within the rows related to the current selected indexsource
78  * which has to be found by the <b>request parameter <code></code></b>.
79  *
80  * @author Achim Westermann
81  *
82  * @version $Revision: 1.2 $
83  *
84  * @since 6.0.0
85  */

86 public class CmsSearchIndexSourceControlList extends A_CmsListDialog {
87
88     /** list action dummy id constant. */
89     public static final String JavaDoc LIST_ACTION_DELETE = "ade";
90
91     /** list action dummy id constant. */
92     public static final String JavaDoc LIST_ACTION_DOCUMENTS = "ado";
93
94     /** list action dummy id constant. */
95     public static final String JavaDoc LIST_ACTION_EDIT = "ae";
96
97     /** list action dummy id constant. */
98     public static final String JavaDoc LIST_ACTION_OVERVIEW_INDEXSOURCE = "aois";
99
100     /**
101      * List action dummy id constant. <p>
102      *
103      * This is meant to be used for the same action as
104      * <code>{@link #LIST_ACTION_OVERVIEW_INDEXSOURCE}</code> but has to be used if
105      * within one list two columns shall trigger the same action...<p>
106      **/

107     public static final String JavaDoc LIST_ACTION_OVERVIEW_INDEXSOURCE2 = "aois2";
108
109     /** list action dummy id constant. */
110     public static final String JavaDoc LIST_ACTION_RESOURCES = "ar";
111
112     /** list column id constant. */
113     public static final String JavaDoc LIST_COLUMN_DELETE = "cde";
114
115     /** list item detail id constant. */
116     public static final String JavaDoc LIST_COLUMN_DOCUMENTS = "cdo";
117
118     /** list column id constant. */
119     public static final String JavaDoc LIST_COLUMN_EDIT = "ce";
120
121     /** list column id constant. */
122     public static final String JavaDoc LIST_COLUMN_INDEXER = "ca";
123
124     /** list column id constant. */
125     public static final String JavaDoc LIST_COLUMN_NAME = "cn";
126
127     /** list column id constant. */
128     public static final String JavaDoc LIST_COLUMN_RESOURCES = "cr";
129
130     /** list item detail id constant. */
131     public static final String JavaDoc LIST_DETAIL_DOCTYPES = "dd";
132
133     /** list item detail id constant. */
134     public static final String JavaDoc LIST_DETAIL_RESOURCES = "dr";
135
136     /** list id constant. */
137     public static final String JavaDoc LIST_ID = "lssisc";
138
139     /** list action id constant. */
140     public static final String JavaDoc LIST_MACTION_DELETESOURCE = "mad";
141
142     /** The list icon for a folder resource of a indexsource-documenttype. **/
143     protected static final String JavaDoc ICON_FOLDER = "tools/searchindex/icons/small/indexsource-resources.png";
144
145     /** The log object for this class. */
146     private static final Log LOG = CmsLog.getLog(CmsSearchIndexSourceControlList.class);
147
148     /**
149      * Public constructor.<p>
150      *
151      * @param jsp an initialized JSP action element
152      */

153     public CmsSearchIndexSourceControlList(CmsJspActionElement jsp) {
154
155         this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_INDEXSOURCES_NAME_0));
156     }
157
158     /**
159      * Public constructor.<p>
160      *
161      * @param jsp an initialized JSP action element
162      * @param listId the id of the list
163      * @param listName the list name
164      */

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

180     public CmsSearchIndexSourceControlList(
181         CmsJspActionElement jsp,
182         String JavaDoc listId,
183         CmsMessageContainer listName,
184         String JavaDoc sortedColId,
185         CmsListOrderEnum sortOrder,
186         String JavaDoc searchableColId) {
187
188         super(jsp, listId, listName, sortedColId, sortOrder, searchableColId);
189
190     }
191
192     /**
193      * Public constructor.<p>
194      *
195      * Public constructor with JSP variables.<p>
196      *
197      * @param context the JSP page context
198      * @param req the JSP request
199      * @param res the JSP response
200      */

201     public CmsSearchIndexSourceControlList(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
202
203         this(new CmsJspActionElement(context, req, res));
204     }
205
206     /**
207      * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
208      */

209     public void executeListMultiActions() {
210
211         CmsSearchManager searchManager = OpenCms.getSearchManager();
212         if (getParamListAction().equals(LIST_MACTION_DELETESOURCE)) {
213             // execute the delete multiaction
214
Iterator JavaDoc itItems = getSelectedItems().iterator();
215             CmsListItem listItem;
216             CmsSearchIndexSource idxsource;
217             while (itItems.hasNext()) {
218                 listItem = (CmsListItem)itItems.next();
219                 idxsource = searchManager.getIndexSource((String JavaDoc)listItem.get(LIST_COLUMN_NAME));
220                 searchManager.removeSearchIndexSource(idxsource);
221                 getList().removeItem(listItem.getId(), getLocale());
222             }
223             refreshList();
224             writeConfiguration(false);
225         }
226         listSave();
227     }
228
229     /**
230      * @throws ServletException
231      * @throws IOException
232      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
233      */

234     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc {
235
236         String JavaDoc indexSource = getSelectedItem().getId();
237         Map JavaDoc params = new HashMap JavaDoc();
238         String JavaDoc action = getParamListAction();
239         if (action.equals(LIST_ACTION_EDIT)) {
240             // forward to the edit indexsource screen
241
params.put(A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE, indexSource);
242             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
243             getToolManager().jspForwardTool(this, "/searchindex/indexsources/indexsource/edit", params);
244         } else if (action.equals(LIST_ACTION_DELETE)) {
245             // forward to the delete indexsource screen
246
params.put(A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE, indexSource);
247             params.put(PARAM_ACTION, DIALOG_INITIAL);
248             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
249             getToolManager().jspForwardTool(this, "/searchindex/indexsources/indexsource/delete", params);
250         } else if (action.equals(LIST_ACTION_RESOURCES)) {
251             // forward to the assign resources to indexsource screen
252
params.put(A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE, indexSource);
253             params.put(PARAM_ACTION, DIALOG_INITIAL);
254             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
255             getToolManager().jspForwardTool(this, "/searchindex/indexsources/indexsource/resources", params);
256         } else if (action.equals(LIST_ACTION_DOCUMENTS)) {
257             // forward to the assign document types to indexsource screen
258
params.put(A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE, indexSource);
259             params.put(PARAM_ACTION, DIALOG_INITIAL);
260             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
261             getToolManager().jspForwardTool(this, "/searchindex/indexsources/indexsource/doctypes", params);
262         } else if (action.equals(LIST_ACTION_OVERVIEW_INDEXSOURCE)) {
263             // forward to the index overview screen
264
params.put(A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE, indexSource);
265             params.put(PARAM_ACTION, DIALOG_INITIAL);
266             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
267             getToolManager().jspForwardTool(this, "/searchindex/indexsources/indexsource", params);
268         }
269         listSave();
270     }
271
272     /**
273      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
274      */

275     protected void fillDetails(String JavaDoc detailId) {
276
277         // get content
278
List JavaDoc items = getList().getAllContent();
279         Iterator JavaDoc itItems = items.iterator();
280         CmsListItem item;
281         if (detailId.equals(LIST_DETAIL_DOCTYPES)) {
282             while (itItems.hasNext()) {
283                 item = (CmsListItem)itItems.next();
284                 fillDetailDocTypes(item, detailId);
285
286             }
287         }
288         if (detailId.equals(LIST_DETAIL_RESOURCES)) {
289             while (itItems.hasNext()) {
290                 item = (CmsListItem)itItems.next();
291                 fillDetailResources(item, detailId);
292
293             }
294
295         }
296
297     }
298
299     /**
300      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
301      */

302     protected List JavaDoc getListItems() {
303
304         List JavaDoc result = new ArrayList JavaDoc();
305         // get content
306
List JavaDoc sources = searchIndexSources();
307         Iterator JavaDoc itSources = sources.iterator();
308         CmsSearchIndexSource source;
309         String JavaDoc value;
310         while (itSources.hasNext()) {
311             try {
312                 source = (CmsSearchIndexSource)itSources.next();
313                 // use "null" String and avoid list exception in gui.
314
CmsListItem item = getList().newItem(source.getName());
315                 item.set(LIST_COLUMN_NAME, source.getName());
316                 try {
317                     value = source.getIndexer().getClass().getName();
318                 } catch (Throwable JavaDoc f) {
319                     value = "null";
320                 }
321                 item.set(LIST_COLUMN_INDEXER, value);
322                 result.add(item);
323             } catch (Throwable JavaDoc g) {
324                 CmsMessageContainer msg = Messages.get().container(
325                     Messages.LOG_ERR_LIST_ITEM_SKIPPED_2,
326                     getList().getName().key(getLocale()),
327                     "Name");
328                 if (LOG.isWarnEnabled()) {
329                     LOG.warn(msg.key(getLocale()));
330                 }
331             }
332         }
333         return result;
334     }
335
336     /**
337      * @see org.opencms.workplace.CmsWorkplace#initMessages()
338      */

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

350     protected void setColumns(CmsListMetadata metadata) {
351
352         // create column for edit
353
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
354         editCol.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_EDIT_NAME_0));
355         editCol.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_EDIT_NAME_HELP_0));
356         editCol.setWidth("5");
357         editCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
358         editCol.setSorteable(false);
359         // add dummy icon
360
CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
361         editAction.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_ACTION_EDIT_NAME_0));
362         editAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_EDIT_NAME_HELP_0));
363         editAction.setIconPath(CmsSearchIndexList.LIST_ICON_INDEXSOURCE);
364         editCol.addDirectAction(editAction);
365         // add it to the list definition
366
metadata.addColumn(editCol);
367
368         // create column for resource assignment
369
CmsListColumnDefinition resCol = new CmsListColumnDefinition(LIST_COLUMN_RESOURCES);
370         resCol.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_RESOURCES_NAME_0));
371         resCol.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_RESOURCES_NAME_HELP_0));
372         resCol.setWidth("5");
373         resCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
374         resCol.setSorteable(false);
375         // add resource icon
376
CmsListDirectAction resAction = new CmsListDirectAction(LIST_ACTION_RESOURCES);
377         resAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_RESOURCES_NAME_0));
378         resAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_RESOURCES_NAME_HELP_0));
379         resAction.setIconPath(ICON_FOLDER);
380         resCol.addDirectAction(resAction);
381         // add it to the list definition
382
metadata.addColumn(resCol);
383
384         // create column for document type assignment
385
CmsListColumnDefinition docCol = new CmsListColumnDefinition(LIST_COLUMN_DOCUMENTS);
386         docCol.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_DOCUMENTS_NAME_0));
387         docCol.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_DOCUMENTS_NAME_HELP_0));
388         docCol.setWidth("5");
389         docCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
390         docCol.setSorteable(false);
391         // add document type icon
392
CmsListDirectAction docAction = new CmsListDirectAction(LIST_ACTION_DOCUMENTS);
393         docAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DOCUMENTS_NAME_0));
394         docAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_DOCUMENTS_NAME_HELP_0));
395         docAction.setIconPath(CmsDocumentTypeList.ICON_DOCTYPE);
396         docCol.addDirectAction(docAction);
397         // add it to the list definition
398
metadata.addColumn(docCol);
399
400         // create column for deletion
401
CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
402         deleteCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_NAME_0));
403         deleteCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_HELP_0));
404         deleteCol.setWidth("10");
405         deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
406         deleteCol.setSorteable(false);
407         // add delete action
408
CmsListDirectAction deleteAction = new CmsListDirectAction(LIST_ACTION_DELETE);
409         deleteAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_NAME_0));
410         deleteAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_HELP_0));
411         // skipped as the following page will have to ask for confirmation again (and additionally check a constraint)
412
// deleteAction.setConfirmationMessage(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_ACTION_DELETE_CONF_0));
413
deleteAction.setIconPath(ICON_DELETE);
414         deleteCol.addDirectAction(deleteAction);
415         // add it to the list definition
416
metadata.addColumn(deleteCol);
417
418         // add column for name
419
CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
420         nameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
421         nameCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_NAME_0));
422         nameCol.setWidth("50%");
423         // add overview action
424
CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_ACTION_OVERVIEW_INDEXSOURCE);
425         defEditAction.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_OVERVIEW_NAME_0));
426         defEditAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_OVERVIEW_NAME_HELP_0));
427         nameCol.addDefaultAction(defEditAction);
428         metadata.addColumn(nameCol);
429
430         // add column for analyzer
431
CmsListColumnDefinition analyzerCol = new CmsListColumnDefinition(LIST_COLUMN_INDEXER);
432         analyzerCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
433         analyzerCol.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_INDEXER_0));
434         analyzerCol.setWidth("45%");
435         metadata.addColumn(analyzerCol);
436
437     }
438
439     /**
440      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
441      */

442     protected void setIndependentActions(CmsListMetadata metadata) {
443
444         // add document types of index source detail help
445
CmsListItemDetails doctypeDetails = new CmsListItemDetails(LIST_DETAIL_DOCTYPES);
446         doctypeDetails.setAtColumn(LIST_COLUMN_NAME);
447         doctypeDetails.setVisible(false);
448         doctypeDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_SHOW_0));
449         doctypeDetails.setShowActionHelpText(Messages.get().container(
450             Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_SHOW_HELP_0));
451         doctypeDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_HIDE_0));
452         doctypeDetails.setHideActionHelpText(Messages.get().container(
453             Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_HIDE_HELP_0));
454         doctypeDetails.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_NAME_0));
455         doctypeDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
456             Messages.GUI_LIST_INDEXSOURCE_DETAIL_DOCTYPE_NAME_0)));
457         metadata.addItemDetails(doctypeDetails);
458
459         // add resources of index source detail help
460
CmsListItemDetails resourceDetails = new CmsListItemDetails(LIST_DETAIL_RESOURCES);
461         resourceDetails.setAtColumn(LIST_COLUMN_NAME);
462         resourceDetails.setVisible(false);
463         resourceDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_SHOW_0));
464         resourceDetails.setShowActionHelpText(Messages.get().container(
465             Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_SHOW_HELP_0));
466         resourceDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_HIDE_0));
467         resourceDetails.setHideActionHelpText(Messages.get().container(
468             Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_HIDE_HELP_0));
469         resourceDetails.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_NAME_0));
470         resourceDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
471             Messages.GUI_LIST_INDEXSOURCE_DETAIL_RESOURCE_NAME_0)));
472         metadata.addItemDetails(resourceDetails);
473
474     }
475
476     /**
477      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
478      */

479     protected void setMultiActions(CmsListMetadata metadata) {
480
481         // add add multi action
482
CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETESOURCE);
483         deleteMultiAction.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_MACTION_DELETESOURCE_NAME_0));
484         deleteMultiAction.setHelpText(Messages.get().container(
485             Messages.GUI_LIST_INDEXSOURCE_MACTION_DELETESOURCE_NAME_HELP_0));
486         deleteMultiAction.setConfirmationMessage(Messages.get().container(
487             Messages.GUI_LIST_INDEXSOURCE_MACTION_DELETESOURCE_CONF_0));
488         deleteMultiAction.setIconPath(ICON_MULTI_MINUS);
489         metadata.addMultiAction(deleteMultiAction);
490
491     }
492
493     /**
494      * Writes the updated search configuration back to the XML
495      * configuration file and refreshes the complete list.<p>
496      *
497      * @param refresh if true, the list items are refreshed
498      */

499     protected void writeConfiguration(boolean refresh) {
500
501         // update the XML configuration
502
OpenCms.writeConfiguration(CmsSearchConfiguration.class);
503         if (refresh) {
504             refreshList();
505         }
506     }
507
508     /**
509      * Fills details about document types of the index source into the given item. <p>
510      *
511      * @param item the list item to fill
512      * @param detailId the id for the detail to fill
513      *
514      */

515     private void fillDetailDocTypes(CmsListItem item, String JavaDoc detailId) {
516
517         CmsSearchManager searchManager = OpenCms.getSearchManager();
518         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
519
520         // search for the corresponding CmsSearchIndexSource:
521
String JavaDoc idxSourceName = (String JavaDoc)item.get(LIST_COLUMN_NAME);
522         CmsSearchIndexSource idxSource = searchManager.getIndexSource(idxSourceName);
523
524         // get the index sources doc types
525
List JavaDoc docTypes = idxSource.getDocumentTypes();
526         // output of found index sources
527
Iterator JavaDoc itDocTypes = docTypes.iterator();
528         CmsSearchDocumentType docType;
529         html.append("<ul>\n");
530         while (itDocTypes.hasNext()) {
531             // get the instance (instead of plain name) for more detail in future...
532
docType = searchManager.getDocumentTypeConfig(itDocTypes.next().toString());
533             // harden against unconfigured doctypes that are refferred to by indexsource nodes
534
if (docType != null) {
535
536                 html.append(" <li>\n").append(" ").append(docType.getName()).append("\n");
537                 html.append(" </li>");
538             }
539         }
540
541         html.append("</ul>\n");
542         item.set(detailId, html.toString());
543     }
544
545     /**
546      * Fills details about resource paths of the index source into the given item. <p>
547      *
548      * @param item the list item to fill
549      * @param detailId the id for the detail to fill
550      *
551      */

552     private void fillDetailResources(CmsListItem item, String JavaDoc detailId) {
553
554         CmsSearchManager searchManager = OpenCms.getSearchManager();
555         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
556
557         // search for the corresponding CmsSearchIndexSource:
558
String JavaDoc idxSourceName = (String JavaDoc)item.get(LIST_COLUMN_NAME);
559         CmsSearchIndexSource idxSource = searchManager.getIndexSource(idxSourceName);
560
561         // get the index sources resource strings
562
List JavaDoc resources = idxSource.getResourcesNames();
563         // output of found index sources
564
Iterator JavaDoc itResources = resources.iterator();
565         html.append("<ul>\n");
566         while (itResources.hasNext()) {
567
568             html.append(" <li>\n").append(" ").append(itResources.next().toString()).append("\n");
569             html.append(" </li>");
570         }
571
572         html.append("</ul>\n");
573
574         item.set(detailId, html.toString());
575     }
576
577     /**
578      * Returns the available search indexes of this installation.
579      *
580      * @return the available search indexes of this installation
581      */

582     private List JavaDoc searchIndexSources() {
583
584         CmsSearchManager manager = OpenCms.getSearchManager();
585         return new LinkedList JavaDoc(manager.getSearchIndexSources().values());
586
587     }
588 }
589
Popular Tags