1 31 32 package org.opencms.workplace.tools.content.check; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.CmsIllegalArgumentException; 36 import org.opencms.util.CmsStringUtil; 37 import org.opencms.widgets.CmsCheckboxWidget; 38 import org.opencms.widgets.CmsVfsFileWidget; 39 import org.opencms.workplace.CmsDialog; 40 import org.opencms.workplace.CmsWidgetDialog; 41 import org.opencms.workplace.CmsWidgetDialogParameter; 42 import org.opencms.workplace.CmsWorkplaceSettings; 43 import org.opencms.workplace.tools.CmsToolDialog; 44 import org.opencms.workplace.tools.database.CmsDatabaseExportReport; 45 46 import java.util.ArrayList ; 47 import java.util.HashMap ; 48 import java.util.Iterator ; 49 import java.util.List ; 50 import java.util.Map ; 51 52 import javax.servlet.http.HttpServletRequest ; 53 import javax.servlet.http.HttpServletResponse ; 54 import javax.servlet.jsp.PageContext ; 55 56 65 public class CmsContentCheckDialog extends CmsWidgetDialog { 66 67 68 public static final String DIALOG_TYPE = "contentcheck"; 69 70 71 public static final String [] PAGES = {"page1"}; 72 73 74 protected static final String CONTENT_CHECK_REPORT = PATH_WORKPLACE + "admin/contenttools/check/report.jsp"; 75 76 77 protected static final String CONTENT_CHECK_RESULT = PATH_WORKPLACE + "admin/contenttools/check/result.jsp"; 78 79 80 private CmsContentCheck m_contentCheck; 81 82 87 public CmsContentCheckDialog(CmsJspActionElement jsp) { 88 89 super(jsp); 90 91 } 92 93 100 public CmsContentCheckDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) { 101 102 this(new CmsJspActionElement(context, req, res)); 103 } 104 105 108 public void actionCommit() { 109 110 List errors = new ArrayList (); 111 try { 112 List paths = m_contentCheck.getPaths(); 114 if (paths.size() == 0) { 115 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_NO_VFSPATH_0)); 116 } else { 117 Iterator i = paths.iterator(); 118 while (i.hasNext()) { 119 String path = (String )i.next(); 120 if (!getCms().existsResource(path)) { 121 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_NO_VFSPATH_0)); 122 } 123 } 124 } 125 126 boolean isActive = false; 128 List plugins = m_contentCheck.getPlugins(); 129 Iterator i = plugins.iterator(); 130 while (i.hasNext()) { 131 I_CmsContentCheck plugin = (I_CmsContentCheck)i.next(); 132 if (plugin.isActive()) { 133 isActive = true; 134 } 135 } 136 if (!isActive) { 137 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_NO_TEST_0)); 138 } 139 140 setDialogObject(m_contentCheck); 143 Map params = new HashMap (); 144 params.put(CmsDatabaseExportReport.PARAM_CLASSNAME, this.getClass().getName()); 146 params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW); 148 params.put(PARAM_CLOSELINK, getJsp().link(CONTENT_CHECK_RESULT)); 150 getToolManager().jspForwardPage(this, CONTENT_CHECK_REPORT, params); 152 153 } catch (Throwable t) { 154 errors.add(t); 155 } 156 setCommitErrors(errors); 158 } 159 160 166 protected String createDialogHtml(String dialog) { 167 168 StringBuffer result = new StringBuffer (1024); 169 170 result.append(createWidgetTableStart()); 172 173 result.append(createWidgetErrorHeader()); 175 176 if (dialog.equals(PAGES[0])) { 177 result.append(dialogBlockStart(key("label.vfsresources"))); 178 result.append(createWidgetTableStart()); 179 result.append(createDialogRowsHtml(0, 0)); 180 result.append(createWidgetTableEnd()); 181 result.append(dialogBlockEnd()); 182 result.append(dialogBlockStart(key("label.contentcheck"))); 183 result.append(createWidgetTableStart()); 184 result.append(createDialogRowsHtml(1, m_contentCheck.getPluginsCount())); 185 result.append(createWidgetTableEnd()); 186 result.append(dialogBlockEnd()); 187 } 188 189 result.append(createWidgetTableEnd()); 191 192 return result.toString(); 193 } 194 195 198 protected void defineWidgets() { 199 200 initContentCheck(); 201 addWidget(new CmsWidgetDialogParameter(m_contentCheck, "paths", PAGES[0], new CmsVfsFileWidget())); 202 List plugins = m_contentCheck.getPlugins(); 204 for (int i = 0; i < plugins.size(); i++) { 205 I_CmsContentCheck plugin = (I_CmsContentCheck)plugins.get(i); 206 addWidget(new CmsWidgetDialogParameter( 207 plugin, 208 I_CmsContentCheck.PARAMETER, 209 plugin.getDialogParameterName(), 210 PAGES[0], 211 new CmsCheckboxWidget())); 212 } 213 214 } 215 216 219 protected String [] getPageArray() { 220 221 return new String [] {"page1"}; 222 } 223 224 227 protected void initContentCheck() { 228 229 Object o; 230 if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) { 231 o = null; 233 } else { 234 o = getDialogObject(); 236 } 237 238 if (!(o instanceof CmsContentCheck)) { 239 m_contentCheck = new CmsContentCheck(getCms()); 241 242 } else { 243 m_contentCheck = (CmsContentCheck)o; 245 } 246 } 247 248 251 protected void initMessages() { 252 253 addMessages(org.opencms.workplace.tools.content.Messages.get().getBundleName()); 255 addMessages("org.opencms.workplace.workplace"); 256 addMessages(Messages.get().getBundleName()); 257 258 CmsContentCheck dummy = new CmsContentCheck(getCms()); 260 List plugins = dummy.getPlugins(); 261 Iterator i = plugins.iterator(); 262 while (i.hasNext()) { 263 I_CmsContentCheck plugin = (I_CmsContentCheck)i.next(); 264 List bundles = plugin.getMessageBundles(); 265 Iterator j = bundles.iterator(); 266 while (j.hasNext()) { 267 String bundle = (String )j.next(); 268 addMessages(bundle); 269 } 270 } 271 272 super.initMessages(); 274 } 275 276 279 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 280 281 setParamDialogtype(DIALOG_TYPE); 283 284 super.initWorkplaceRequestValues(settings, request); 285 286 setDialogObject(m_contentCheck); 288 } 289 290 } 291 | Popular Tags |