KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsRebuildReport.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.jsp.CmsJspActionElement;
35 import org.opencms.main.CmsIllegalArgumentException;
36 import org.opencms.main.CmsRuntimeException;
37 import org.opencms.report.I_CmsReportThread;
38 import org.opencms.util.CmsStringUtil;
39 import org.opencms.workplace.CmsWorkplaceSettings;
40 import org.opencms.workplace.list.A_CmsListReport;
41 import org.opencms.workplace.tools.CmsToolManager;
42
43 import java.util.ArrayList JavaDoc;
44 import java.util.HashMap JavaDoc;
45 import java.util.List JavaDoc;
46 import java.util.Map JavaDoc;
47 import java.util.StringTokenizer JavaDoc;
48
49 import javax.servlet.http.HttpServletRequest JavaDoc;
50 import javax.servlet.http.HttpServletResponse JavaDoc;
51 import javax.servlet.jsp.PageContext JavaDoc;
52
53 /**
54  * A report for displaying the rebuild process of the corresponding
55  * <code>{@link org.opencms.workplace.tools.searchindex.CmsIndexingReportThread}</code>.<p>
56  *
57  * @author Achim Westermann
58  *
59  * @version $Revision: 1.2 $
60  *
61  * @since 6.0.0
62  */

63 public class CmsRebuildReport extends A_CmsListReport {
64
65     /** Indexes parameter: Value is a list of comma separated search index name. */
66     public static final String JavaDoc PARAM_INDEXES = "indexes";
67
68     /** The request parameter value for search indexes: comma-separated names. **/
69     private String JavaDoc m_paramIndexes;
70
71     /**
72      * Public constructor with JSP action element.<p>
73      *
74      * @param jsp an initialized JSP action element
75      */

76     public CmsRebuildReport(CmsJspActionElement jsp) {
77
78         super(jsp);
79
80     }
81
82     /**
83      * Public constructor with JSP variables.<p>
84      *
85      * @param context the JSP page context
86      * @param req the JSP request
87      * @param res the JSP response
88      */

89     public CmsRebuildReport(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
90
91         super(context, req, res);
92
93     }
94
95     /**
96      * Returns the comma-separated String of index names of the indexes that have to be rebuilt.<p>
97      *
98      * @return the comma-separated String of index names of the indexes that have to be rebuilt
99      */

100     public String JavaDoc getParamIndexes() {
101
102         return m_paramIndexes;
103     }
104
105     /**
106      * Returns the <b>unstarted</b> <code>Thread</code> that will do the work of rebuilding the indexes
107      * provided by the request parameter "indexes" value (comma-separated List).<p>
108      *
109      * @throws CmsRuntimeException if the request parameter "indexes" is missing.
110      *
111      * @return the <b>unstarted</b> <code>Thread</code> that will do the work of rebuilding the indexes
112      * provided by the request parameter "indexes" value (comma-separated List)
113      *
114      * @see org.opencms.workplace.list.A_CmsListReport#initializeThread()
115      */

116     public I_CmsReportThread initializeThread() throws CmsRuntimeException {
117
118         if (getParamIndexes() == null) {
119             throw new CmsIllegalArgumentException(Messages.get().container(
120                 Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
121                 PARAM_INDEXES));
122         }
123         List JavaDoc indexes = extractIndexNames();
124         CmsIndexingReportThread thread = new CmsIndexingReportThread(getCms(), indexes);
125         return thread;
126     }
127
128     /**
129      * Sets the comma-separated String of index names of the indexes that that have to be rebuilt.<p>
130      *
131      * @param paramIndexes the comma-separated String of index names of the indexes that have to be rebuilt
132      */

133     public void setParamIndexes(String JavaDoc paramIndexes) {
134
135         m_paramIndexes = paramIndexes;
136     }
137
138     /**
139      *
140      * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
141      */

142     protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest JavaDoc request) {
143
144         super.initWorkplaceRequestValues(settings, request);
145         // closelink is a bit complicated: If a forward from a single searchindex overview page
146
// was made, go back to that searchindex-overview. If more indexes are in the given
147
// parameter "indexes" go back to the search management entry page...
148
List JavaDoc indexes = extractIndexNames();
149         if (indexes.size() == 1) {
150             // back to index overview
151
Map JavaDoc params = new HashMap JavaDoc();
152             params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, indexes.get(0));
153             setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), "/searchindex/singleindex", params));
154         } else {
155             // back to search entry page
156
setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), "/searchindex"));
157         }
158     }
159
160     /**
161      * Extracts all modules to deelte form the module parameter.<p>
162      * @return list of module names
163      */

164     private List JavaDoc extractIndexNames() {
165
166         List JavaDoc modules = new ArrayList JavaDoc();
167
168         if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamIndexes())) {
169             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(getParamIndexes(), ",");
170             while (tok.hasMoreTokens()) {
171                 String JavaDoc module = tok.nextToken();
172                 modules.add(module);
173             }
174         }
175         return modules;
176     }
177 }
178
Popular Tags