001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckReport.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.collectors.I_CmsResourceCollector;
035: import org.opencms.jsp.CmsJspActionElement;
036: import org.opencms.report.I_CmsReportThread;
037: import org.opencms.workplace.list.A_CmsListReport;
038:
039: import java.util.Hashtable;
040: import java.util.Map;
041:
042: import javax.servlet.http.HttpServletRequest;
043: import javax.servlet.http.HttpServletResponse;
044: import javax.servlet.jsp.JspException;
045: import javax.servlet.jsp.PageContext;
046:
047: /**
048: * Provides a report for checking the content of resources in the OpenCms VFS.<p>
049: *
050: * @author Michael Emmerich
051: *
052: * @version $Revision: 1.5 $
053: *
054: * @since 6.1.2
055: */
056: public class CmsContentCheckReport extends A_CmsListReport {
057:
058: /** The object edited with this widget dialog. */
059: protected Object m_dialogObject;
060:
061: /** The Content Check object. */
062: private CmsContentCheck m_contentCheck;
063:
064: /** Request parameter for the class name to get the dialog object from. */
065: private String m_paramClassname;
066:
067: /**
068: * Public constructor with JSP action element.<p>
069: *
070: * @param jsp an initialized JSP action element
071: */
072: public CmsContentCheckReport(CmsJspActionElement jsp) {
073:
074: super (jsp);
075: }
076:
077: /**
078: * Public constructor with JSP variables.<p>
079: *
080: * @param context the JSP page context
081: * @param req the JSP request
082: * @param res the JSP response
083: */
084: public CmsContentCheckReport(PageContext context,
085: HttpServletRequest req, HttpServletResponse res) {
086:
087: this (new CmsJspActionElement(context, req, res));
088: }
089:
090: /**
091: * Performs the dialog actions depending on the initialized action.<p>
092: *
093: * @throws JspException if dialog actions fail
094: */
095: public void displayReport() throws JspException {
096:
097: // save initialized instance of this class in request attribute for included sub-elements
098: getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS,
099: this );
100: switch (getAction()) {
101: case ACTION_REPORT_END:
102: // set the results of the content check
103: m_contentCheck = (CmsContentCheck) ((Map) getSettings()
104: .getDialogObject()).get(getParamClassname());
105: I_CmsResourceCollector collector = new CmsContentCheckCollector(
106: null, m_contentCheck.getResults());
107: getSettings().setCollector(collector);
108: try {
109: getToolManager().jspForwardTool(this ,
110: "/contenttools/check/result", null);
111: } catch (Exception e) {
112: actionCloseDialog();
113: }
114: break;
115: case ACTION_CANCEL:
116: actionCloseDialog();
117: break;
118: case ACTION_REPORT_UPDATE:
119: setParamAction(REPORT_UPDATE);
120: getJsp().include(FILE_REPORT_OUTPUT);
121: break;
122: case ACTION_REPORT_BEGIN:
123: case ACTION_CONFIRMED:
124: case ACTION_DEFAULT:
125: default:
126: I_CmsReportThread m_thread = initializeThread();
127: m_thread.start();
128: setParamAction(REPORT_BEGIN);
129: setParamThread(m_thread.getUUID().toString());
130: getJsp().include(FILE_REPORT_OUTPUT);
131: }
132: }
133:
134: /**
135: * Returns the request parameter value for the class name to get the dialog object from.<p>
136: *
137: * @return the request parameter value for the class name to get the dialog object from
138: */
139: public String getParamClassname() {
140:
141: return m_paramClassname;
142: }
143:
144: /**
145: *
146: * @see org.opencms.workplace.list.A_CmsListReport#initializeThread()
147: */
148: public I_CmsReportThread initializeThread() {
149:
150: m_contentCheck = (CmsContentCheck) ((Map) getSettings()
151: .getDialogObject()).get(getParamClassname());
152:
153: I_CmsReportThread contentCheckThread = new CmsContentCheckThread(
154: getCms(), m_contentCheck);
155:
156: return contentCheckThread;
157: }
158:
159: /**
160: * Stores the given object as "dialog object" for this widget dialog in the current users session.<p>
161: *
162: * @param dialogObject the object to store
163: */
164: public void setDialogObject(Object dialogObject) {
165:
166: m_dialogObject = dialogObject;
167: if (dialogObject == null) {
168: // null object: remove the entry from the map
169: getDialogObjectMap().remove(getClass().getName());
170: } else {
171: getDialogObjectMap()
172: .put(getClass().getName(), dialogObject);
173: }
174: }
175:
176: /**
177: * Sets the request parameter value for the class name to get the dialog object from.<p>
178: *
179: * @param className the request parameter value for the class name to get the dialog object from
180: */
181: public void setParamClassname(String className) {
182:
183: m_paramClassname = className;
184: }
185:
186: /**
187: * Returns the (internal use only) map of dialog objects.<p>
188: *
189: * @return the (internal use only) map of dialog objects
190: */
191: private Map getDialogObjectMap() {
192:
193: Map objects = (Map) getSettings().getDialogObject();
194: if (objects == null) {
195: // using hashtable as most efficient version of a synchronized map
196: objects = new Hashtable();
197: getSettings().setDialogObject(objects);
198: }
199: return objects;
200: }
201:
202: }
|