001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.workplace.tools.content.check; 029 030import org.opencms.file.CmsResource; 031import org.opencms.jsp.CmsJspActionElement; 032import org.opencms.workplace.list.A_CmsListExplorerDialog; 033import org.opencms.workplace.list.CmsListItem; 034import org.opencms.workplace.list.CmsListItemDetails; 035import org.opencms.workplace.list.CmsListItemDetailsFormatter; 036import org.opencms.workplace.list.CmsListMetadata; 037import org.opencms.workplace.list.I_CmsListResourceCollector; 038 039import java.util.Iterator; 040import java.util.List; 041import java.util.Map; 042 043import javax.servlet.http.HttpServletRequest; 044import javax.servlet.http.HttpServletResponse; 045import javax.servlet.jsp.PageContext; 046 047/** 048 * Result List Dialog.<p> 049 * 050 * @since 6.1.2 051 */ 052public class CmsContentCheckFilesDialog extends A_CmsListExplorerDialog { 053 054 /** List detail error. */ 055 public static final String LIST_DETAIL_ERROR = "de"; 056 057 /** List detail warning. */ 058 public static final String LIST_DETAIL_WARNING = "dw"; 059 060 /** list id constant. */ 061 public static final String LIST_ID = "checkcontent"; 062 063 /** The results of the content check. */ 064 CmsContentCheckResult m_results; 065 066 /** The internal collector instance. */ 067 private I_CmsListResourceCollector m_collector; 068 069 /** 070 * Public constructor.<p> 071 * 072 * @param jsp an initialized JSP action element 073 */ 074 public CmsContentCheckFilesDialog(CmsJspActionElement jsp) { 075 076 super(jsp, LIST_ID, Messages.get().container(Messages.GUI_CHECKCONTENT_LIST_NAME_0)); 077 } 078 079 /** 080 * Public constructor with JSP variables.<p> 081 * 082 * @param context the JSP page context 083 * @param req the JSP request 084 * @param res the JSP response 085 */ 086 public CmsContentCheckFilesDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) { 087 088 this(new CmsJspActionElement(context, req, res)); 089 } 090 091 /** 092 * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions() 093 */ 094 @Override 095 public void executeListMultiActions() { 096 097 throwListUnsupportedActionException(); 098 } 099 100 /** 101 * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() 102 */ 103 @Override 104 public void executeListSingleActions() { 105 106 throwListUnsupportedActionException(); 107 } 108 109 /** 110 * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getCollector() 111 */ 112 @Override 113 public I_CmsListResourceCollector getCollector() { 114 115 if (m_collector == null) { 116 // get the content check result object 117 Map objects = (Map)getSettings().getDialogObject(); 118 Object o = objects.get(CmsContentCheckDialog.class.getName()); 119 if ((o != null) && (o instanceof CmsContentCheck)) { 120 m_results = ((CmsContentCheck)o).getResults(); 121 } else { 122 m_results = new CmsContentCheckResult(); 123 } 124 m_collector = new CmsContentCheckCollector(this, m_results); 125 } 126 return m_collector; 127 } 128 129 /** 130 * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) 131 */ 132 @Override 133 protected void fillDetails(String detailId) { 134 135 // get content 136 List resourceNames = getList().getAllContent(); 137 Iterator i = resourceNames.iterator(); 138 while (i.hasNext()) { 139 CmsListItem item = (CmsListItem)i.next(); 140 CmsResource res = getCollector().getResource(getCms(), item); 141 // check if errors are enabled 142 StringBuffer html = new StringBuffer(); 143 // error detail is enabled 144 if (detailId.equals(LIST_DETAIL_ERROR)) { 145 // get all errors for this resource and show them 146 List errors = m_results.getErrors(res.getRootPath()); 147 if (errors != null) { 148 Iterator j = errors.iterator(); 149 while (j.hasNext()) { 150 String errorMessage = (String)j.next(); 151 html.append(errorMessage); 152 html.append("<br>"); 153 } 154 item.set(detailId, html.toString()); 155 } 156 } 157 // warning detail is enabled 158 if (detailId.equals(LIST_DETAIL_WARNING)) { 159 // get all warnings for this resource and show them 160 List warnings = m_results.getWarnings(res.getRootPath()); 161 if (warnings != null) { 162 Iterator j = warnings.iterator(); 163 while (j.hasNext()) { 164 String warningsMessage = (String)j.next(); 165 html.append(warningsMessage); 166 html.append("<br>"); 167 } 168 item.set(detailId, html.toString()); 169 } 170 } 171 } 172 } 173 174 /** 175 * @see org.opencms.workplace.CmsWorkplace#initMessages() 176 */ 177 @Override 178 protected void initMessages() { 179 180 // add specific dialog resource bundle 181 addMessages(org.opencms.workplace.tools.content.Messages.get().getBundleName()); 182 addMessages(Messages.get().getBundleName()); 183 super.initMessages(); 184 } 185 186 /** 187 * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata) 188 */ 189 @Override 190 protected void setIndependentActions(CmsListMetadata metadata) { 191 192 // create list item detail for errors 193 CmsListItemDetails errorDetails = new CmsListItemDetails(LIST_DETAIL_ERROR); 194 errorDetails.setAtColumn(LIST_COLUMN_NAME); 195 //errorDetails.setVisible(false); 196 errorDetails.setShowActionName( 197 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_ERRORINFO_NAME_0)); 198 errorDetails.setShowActionHelpText( 199 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_ERRORINFO_HELP_0)); 200 errorDetails.setHideActionName( 201 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_HIDE_ERRORINFO_NAME_0)); 202 errorDetails.setHideActionHelpText( 203 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_HIDE_ERRORINFO_HELP_0)); 204 errorDetails.setFormatter( 205 new CmsListItemDetailsFormatter(Messages.get().container(Messages.GUI_CHECKCONTENT_LABEL_ERROR_0))); 206 207 // add error info item detail to meta data 208 metadata.addItemDetails(errorDetails); 209 210 // create list item detail for warnings 211 CmsListItemDetails warningDetails = new CmsListItemDetails(LIST_DETAIL_WARNING); 212 warningDetails.setAtColumn(LIST_COLUMN_NAME); 213 //warningDetails.setVisible(false); 214 warningDetails.setShowActionName( 215 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0)); 216 warningDetails.setShowActionHelpText( 217 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0)); 218 warningDetails.setHideActionName( 219 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0)); 220 warningDetails.setHideActionHelpText( 221 Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_HIDE_WARNINGINFO_HELP_0)); 222 warningDetails.setFormatter( 223 new CmsListItemDetailsFormatter(Messages.get().container(Messages.GUI_CHECKCONTENT_LABEL_WARNING_0))); 224 225 // add warning info item detail to meta data 226 metadata.addItemDetails(warningDetails); 227 228 super.setIndependentActions(metadata); 229 } 230 231 /** 232 * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata) 233 */ 234 @Override 235 protected void setMultiActions(CmsListMetadata metadata) { 236 237 // no LMA 238 } 239 240}