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