KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > content > check > CmsContentCheckReport


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckReport.java,v $
3  * Date : $Date: 2006/03/27 14:52:54 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.content.check;
33
34 import org.opencms.file.collectors.I_CmsResourceCollector;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.report.I_CmsReportThread;
37 import org.opencms.workplace.list.A_CmsListReport;
38
39 import java.util.Hashtable JavaDoc;
40 import java.util.Map JavaDoc;
41
42 import javax.servlet.http.HttpServletRequest JavaDoc;
43 import javax.servlet.http.HttpServletResponse JavaDoc;
44 import javax.servlet.jsp.JspException JavaDoc;
45 import javax.servlet.jsp.PageContext JavaDoc;
46
47 /**
48  * Provides a report for checking the content of resources in the OpenCms VFS.<p>
49  *
50  * @author Michael Emmerich
51  *
52  * @version $Revision: 1.2 $
53  *
54  * @since 6.1.2
55  */

56 public class CmsContentCheckReport extends A_CmsListReport {
57
58     /** The object edited with this widget dialog. */
59     protected Object JavaDoc m_dialogObject;
60
61     /** The Content Check object. */
62     private CmsContentCheck m_contentCheck;
63
64     /** Request parameter for the class name to get the dialog object from. */
65     private String JavaDoc m_paramClassname;
66
67     /**
68      * Public constructor with JSP action element.<p>
69      *
70      * @param jsp an initialized JSP action element
71      */

72     public CmsContentCheckReport(CmsJspActionElement jsp) {
73
74         super(jsp);
75     }
76
77     /**
78      * Public constructor with JSP variables.<p>
79      *
80      * @param context the JSP page context
81      * @param req the JSP request
82      * @param res the JSP response
83      */

84     public CmsContentCheckReport(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
85
86         this(new CmsJspActionElement(context, req, res));
87     }
88
89     /**
90      * Performs the dialog actions depending on the initialized action.<p>
91      *
92      * @throws JspException if dialog actions fail
93      */

94     public void displayReport() throws JspException JavaDoc {
95
96         // save initialized instance of this class in request attribute for included sub-elements
97
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
98         switch (getAction()) {
99             case ACTION_REPORT_END:
100                 // set the results of the content check
101
m_contentCheck = (CmsContentCheck)((Map JavaDoc)getSettings().getDialogObject()).get(getParamClassname());
102                 I_CmsResourceCollector collector = new CmsContentCheckCollector(m_contentCheck.getResults());
103                 getSettings().setCollector(collector);
104                 try {
105                     getToolManager().jspForwardTool(this, "/contenttools/check/result", null);
106                 } catch (Exception JavaDoc e) {
107                     actionCloseDialog();
108                 }
109                 break;
110             case ACTION_CANCEL:
111                 actionCloseDialog();
112                 break;
113             case ACTION_REPORT_UPDATE:
114                 setParamAction(REPORT_UPDATE);
115                 getJsp().include(FILE_REPORT_OUTPUT);
116                 break;
117             case ACTION_REPORT_BEGIN:
118             case ACTION_CONFIRMED:
119             case ACTION_DEFAULT:
120             default:
121                 I_CmsReportThread m_thread = initializeThread();
122                 m_thread.start();
123                 setParamAction(REPORT_BEGIN);
124                 setParamThread(m_thread.getUUID().toString());
125                 getJsp().include(FILE_REPORT_OUTPUT);
126         }
127     }
128
129     /**
130      * Returns the request parameter value for the class name to get the dialog object from.<p>
131      *
132      * @return the request parameter value for the class name to get the dialog object from
133      */

134     public String JavaDoc getParamClassname() {
135
136         return m_paramClassname;
137     }
138
139     /**
140      *
141      * @see org.opencms.workplace.list.A_CmsListReport#initializeThread()
142      */

143     public I_CmsReportThread initializeThread() {
144
145         m_contentCheck = (CmsContentCheck)((Map JavaDoc)getSettings().getDialogObject()).get(getParamClassname());
146
147         I_CmsReportThread contentCheckThread = new CmsContentCheckThread(getCms(), m_contentCheck);
148
149         return contentCheckThread;
150     }
151
152     /**
153      * Stores the given object as "dialog object" for this widget dialog in the current users session.<p>
154      *
155      * @param dialogObject the object to store
156      */

157     public void setDialogObject(Object JavaDoc dialogObject) {
158
159         m_dialogObject = dialogObject;
160         if (dialogObject == null) {
161             // null object: remove the entry from the map
162
getDialogObjectMap().remove(getClass().getName());
163         } else {
164             getDialogObjectMap().put(getClass().getName(), dialogObject);
165         }
166     }
167
168     /**
169      * Sets the request parameter value for the class name to get the dialog object from.<p>
170      *
171      * @param className the request parameter value for the class name to get the dialog object from
172      */

173     public void setParamClassname(String JavaDoc className) {
174
175         m_paramClassname = className;
176     }
177
178     /**
179      * Returns the (internal use only) map of dialog objects.<p>
180      *
181      * @return the (internal use only) map of dialog objects
182      */

183     private Map JavaDoc getDialogObjectMap() {
184
185         Map JavaDoc objects = (Map JavaDoc)getSettings().getDialogObject();
186         if (objects == null) {
187             // using hashtable as most efficient version of a synchronized map
188
objects = new Hashtable JavaDoc();
189             getSettings().setDialogObject(objects);
190         }
191         return objects;
192     }
193
194 }
Popular Tags