1 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 ; 44 import java.util.HashMap ; 45 import java.util.List ; 46 import java.util.Map ; 47 import java.util.StringTokenizer ; 48 49 import javax.servlet.http.HttpServletRequest ; 50 import javax.servlet.http.HttpServletResponse ; 51 import javax.servlet.jsp.PageContext ; 52 53 63 public class CmsRebuildReport extends A_CmsListReport { 64 65 66 public static final String PARAM_INDEXES = "indexes"; 67 68 69 private String m_paramIndexes; 70 71 76 public CmsRebuildReport(CmsJspActionElement jsp) { 77 78 super(jsp); 79 80 } 81 82 89 public CmsRebuildReport(PageContext context, HttpServletRequest req, HttpServletResponse res) { 90 91 super(context, req, res); 92 93 } 94 95 100 public String getParamIndexes() { 101 102 return m_paramIndexes; 103 } 104 105 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 indexes = extractIndexNames(); 124 CmsIndexingReportThread thread = new CmsIndexingReportThread(getCms(), indexes); 125 return thread; 126 } 127 128 133 public void setParamIndexes(String paramIndexes) { 134 135 m_paramIndexes = paramIndexes; 136 } 137 138 142 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 143 144 super.initWorkplaceRequestValues(settings, request); 145 List indexes = extractIndexNames(); 149 if (indexes.size() == 1) { 150 Map params = new HashMap (); 152 params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, indexes.get(0)); 153 setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), "/searchindex/singleindex", params)); 154 } else { 155 setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), "/searchindex")); 157 } 158 } 159 160 164 private List extractIndexNames() { 165 166 List modules = new ArrayList (); 167 168 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamIndexes())) { 169 StringTokenizer tok = new StringTokenizer (getParamIndexes(), ","); 170 while (tok.hasMoreTokens()) { 171 String module = tok.nextToken(); 172 modules.add(module); 173 } 174 } 175 return modules; 176 } 177 } 178 | Popular Tags |