KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsIndexingReportThread.java,v $
3  * Date : $Date: 2006/03/27 14:52:21 $
4  * Version: $Revision: 1.11 $
5  *
6  * This program is part of the Alkacon OpenCms Software library.
7  *
8  * This license applies to all programs, pages, Java classes, parts and
9  * modules of the Alkacon OpenCms Software library published by
10  * Alkacon Software GmbH, unless otherwise noted.
11  *
12  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com) (http://www.alkacon.com)
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or (at
17  * your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  * For further information about Alkacon Software GmbH, please see the
29  * companys website: http://www.alkacon.com.
30  *
31  * For further information about OpenCms, please see the OpenCms project
32  * website: http://www.opencms.org.
33  *
34  * The names "Alkacon", "Alkacon Software GmbH" and "OpenCms" must not be used
35  * to endorse or promote products derived from this software without prior
36  * written permission. For written permission, please contact info@alkacon.com.
37  *
38  * Products derived from this software may not be called "Alkacon",
39  * "Alkacon Software GmbH" or "OpenCms", nor may "Alkacon", "Alkacon Software GmbH"
40  * or "OpenCms" appear in their name, without prior written permission of
41  * Alkacon Software GmbH.
42  *
43  * This program is also available under a commercial non-GPL license. For
44  * pricing and ordering information, please inquire at sales@alkacon.com.
45  */

46
47 package org.opencms.workplace.tools.searchindex;
48
49 import org.opencms.file.CmsObject;
50 import org.opencms.file.CmsVfsResourceNotFoundException;
51 import org.opencms.main.CmsException;
52 import org.opencms.main.OpenCms;
53 import org.opencms.report.A_CmsReportThread;
54 import org.opencms.report.I_CmsReport;
55
56 import java.util.List JavaDoc;
57
58 /**
59  * Implements methods to utilize a report thread for <code>CmsIndexingReport</code>.<p>
60  *
61  * @author Carsten Weinholz
62  *
63  * @version $Revision: 1.11 $
64  *
65  * @since 6.0.0
66  */

67 public class CmsIndexingReportThread extends A_CmsReportThread {
68
69     /** The last error occured. */
70     private Throwable JavaDoc m_error;
71
72     /** A list of names of the indexes to refresh or null for all indexes. */
73     private List JavaDoc m_indexNames;
74
75     /**
76      * Creates an indexing Thread for full update.<p>
77      *
78      * @param cms the current OpenCms context object
79      * @param indexNames a list of names of the indexes to refresh or null for all indexes
80      */

81     public CmsIndexingReportThread(CmsObject cms, List JavaDoc indexNames) {
82
83         super(cms, Messages.get().getBundle().key(Messages.GUI_INDEXING_THREAD_NAME_0));
84         initHtmlReport(cms.getRequestContext().getLocale());
85
86         m_indexNames = indexNames;
87     }
88
89     /**
90      * Returns the last error.<p>
91      *
92      * @see org.opencms.report.A_CmsReportThread#getError()
93      */

94     public Throwable JavaDoc getError() {
95
96         return m_error;
97     }
98
99     /**
100      * Updates the report.<p>
101      *
102      * @see org.opencms.report.A_CmsReportThread#getReportUpdate()
103      */

104     public String JavaDoc getReportUpdate() {
105
106         return getReport().getReportUpdate();
107     }
108
109     /**
110      * Starts the indexing report thread.<p>
111      *
112      * @see java.lang.Runnable#run()
113      */

114     public void run() {
115
116         getReport().println(
117             Messages.get().container(Messages.RPT_REBUILD_SEARCH_INDEXES_BEGIN_0),
118             I_CmsReport.FORMAT_HEADLINE);
119         try {
120
121             if (m_indexNames == null) {
122                 OpenCms.getSearchManager().rebuildAllIndexes(getReport());
123             } else {
124                 OpenCms.getSearchManager().rebuildIndexes(m_indexNames, getReport());
125             }
126             getReport().println(
127                 Messages.get().container(Messages.RPT_REBUILD_SEARCH_INDEXES_END_0),
128                 I_CmsReport.FORMAT_HEADLINE);
129         } catch (CmsVfsResourceNotFoundException e) {
130
131             getReport().println(
132                 Messages.get().container(Messages.RPT_SEARCH_CONFIG_NOT_FOUND_0),
133                 I_CmsReport.FORMAT_NOTE);
134             m_error = e;
135         } catch (CmsException exc) {
136             getReport().println(
137                 org.opencms.search.Messages.get().container(org.opencms.search.Messages.RPT_SEARCH_INDEXING_FAILED_0),
138                 I_CmsReport.FORMAT_WARNING);
139             getReport().println(exc);
140             m_error = exc;
141         }
142     }
143
144 }
Popular Tags