KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > workplace > CmsAdminModuleDeleteWarning


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminModuleDeleteWarning.java,v $
3 * Date : $Date: 2005/06/27 23:22:07 $
4 * Version: $Revision: 1.3 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
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 OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.workplace;
30
31 import org.opencms.file.CmsObject;
32 import org.opencms.main.CmsException;
33 import org.opencms.main.CmsLog;
34
35 import com.opencms.core.I_CmsSession;
36 import com.opencms.legacy.CmsXmlTemplateLoader;
37
38 import java.util.Hashtable JavaDoc;
39 import java.util.Vector JavaDoc;
40
41 /**
42  * Template class for displaying the Warnings when deleting a module.
43  * Creation date: (15.09.00 10:21:25)
44  * @author Hanjo Riege
45  *
46  * @deprecated Will not be supported past the OpenCms 6 release.
47  */

48 public class CmsAdminModuleDeleteWarning extends CmsWorkplaceDefault {
49     
50     /**
51      * the different template tags.
52      */

53     private final String JavaDoc C_READY = "ready";
54     private final String JavaDoc C_WINCONTENT = "windowcontent";
55     private final String JavaDoc C_FILELISTENTRY = "filelist_entry";
56     private final String JavaDoc C_FILENAME = "filename";
57     private final String JavaDoc C_W_TITLE = "windowtitle";
58     private final String JavaDoc C_W_TEXT = "windowtext";
59     private final String JavaDoc C_CBENTRY = "checkbox_entry";
60     private final String JavaDoc C_STEP_0 = "0";
61     private final String JavaDoc C_STEP_CHECKSUM_2 = "checksum_2";
62     private final String JavaDoc C_STEP_PROPFILES_1 = "propfiles_1";
63     private final String JavaDoc C_STEP_PROPFILES_2 = "propjiles_2";
64     private final String JavaDoc C_STEP_INUSE = "inuse";
65     private final String JavaDoc C_STEP_MISSFILES = "missfiles";
66     
67     /**
68      * Gets the content of a defined section in a given template file and its subtemplates
69      * with the given parameters.
70      *
71      * @see #getContent(CmsObject, String, String, Hashtable, String)
72      * @param cms CmsObject Object for accessing system resources.
73      * @param templateFile Filename of the template file.
74      * @param elementName Element name of this template in our parent template.
75      * @param parameters Hashtable with all template class parameters.
76      * @param templateSelector template section that should be processed.
77      */

78     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
79         if(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
80             CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
81             CmsLog.getLog(this).debug("Template file is: " + templateFile);
82             CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
83         }
84         CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms, templateFile);
85         CmsXmlLanguageFile lang = xmlTemplateDocument.getLanguageFile();
86         
87         // CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile, elementName, parameters, templateSelector);
88
// CmsXmlLanguageFile lang=new CmsXmlLanguageFile(cms);
89
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
90         String JavaDoc step = (String JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_DELETE_STEP);
91         if(step != null) {
92             if(C_STEP_0.equals(step)) {
93                 
94                 // first call
95
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_CHECKSUM);
96                 if(files.isEmpty()) {
97                     step = C_STEP_PROPFILES_1;
98                 }
99                 else {
100                     
101                     // there are some files with wrong Checksum; fill the template and set the next step
102
xmlTemplateDocument.setData(C_W_TITLE, lang.getLanguageValue("module.error.deletetitle"));
103                     xmlTemplateDocument.setData(C_W_TEXT, lang.getLanguageValue("module.error.deletetext1"));
104                     String JavaDoc output = "";
105                     for(int i = 0;i < files.size();i++) {
106                         xmlTemplateDocument.setData(C_FILENAME, (String JavaDoc)files.elementAt(i));
107                         output += xmlTemplateDocument.getProcessedDataValue(C_CBENTRY);
108                     }
109                     xmlTemplateDocument.setData(C_WINCONTENT, output);
110                     session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_DELETE_STEP, C_STEP_CHECKSUM_2);
111                 }
112             }
113             if(C_STEP_CHECKSUM_2.equals(step)) {
114                 
115                 // ok, get the files that should not deleted and put them in the session.
116
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_CHECKSUM);
117                 Vector JavaDoc outFiles = new Vector JavaDoc();
118                 for(int i = 0;i < files.size();i++) {
119                     String JavaDoc file = (String JavaDoc)files.elementAt(i);
120                     String JavaDoc test = (String JavaDoc)parameters.get(file);
121                     if(test == null) {
122                         outFiles.addElement(file);
123                     }
124                 }
125                 session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_EXCLUSION, outFiles);
126                 step = C_STEP_PROPFILES_1;
127             }
128             if(C_STEP_PROPFILES_1.equals(step)) {
129                 
130                 // now we take care about the filesWithProperty vector.The same way like the wrong ChecksumVector.
131
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_PROPFILES);
132                 if(files.isEmpty()) {
133                     step = C_STEP_INUSE;
134                 }
135                 else {
136                     
137                     // we have some of these files, lets fill the template and set the next step.
138
xmlTemplateDocument.setData(C_W_TITLE, lang.getLanguageValue("module.error.deletetitle"));
139                     xmlTemplateDocument.setData(C_W_TEXT, lang.getLanguageValue("module.error.deletetext2"));
140                     String JavaDoc output = "";
141                     for(int i = 0;i < files.size();i++) {
142                         xmlTemplateDocument.setData(C_FILENAME, (String JavaDoc)files.elementAt(i));
143                         output += xmlTemplateDocument.getProcessedDataValue(C_CBENTRY);
144                     }
145                     xmlTemplateDocument.setData(C_WINCONTENT, output);
146                     session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_DELETE_STEP, C_STEP_PROPFILES_2);
147                 }
148             }
149             if(C_STEP_PROPFILES_2.equals(step)) {
150                 
151                 // ok, get the files that should not deleted and put them in the session.
152
// first look if there is already a exclusionVector in the session.
153
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_PROPFILES);
154                 Vector JavaDoc outFiles = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_EXCLUSION);
155                 if(outFiles == null) {
156                     outFiles = new Vector JavaDoc();
157                 }
158                 for(int i = 0;i < files.size();i++) {
159                     String JavaDoc file = (String JavaDoc)files.elementAt(i);
160                     String JavaDoc test = (String JavaDoc)parameters.get(file);
161                     if(test == null) {
162                         outFiles.addElement(file);
163                     }
164                 }
165                 session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_EXCLUSION, outFiles);
166                 step = C_STEP_INUSE;
167             }
168             if(C_STEP_INUSE.equals(step)) {
169                 
170                 // the files that are in use. if there are any, just show them to the user.
171
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_INUSE);
172                 if(files.isEmpty()) {
173                     step = C_STEP_MISSFILES;
174                 }
175                 else {
176                     xmlTemplateDocument.setData(C_W_TITLE, lang.getLanguageValue("module.error.deletetitle"));
177                     xmlTemplateDocument.setData(C_W_TEXT, lang.getLanguageValue("module.error.deletetext3"));
178                     String JavaDoc output = "";
179                     for(int i = 0;i < files.size();i++) {
180                         xmlTemplateDocument.setData(C_FILENAME, (String JavaDoc)files.elementAt(i));
181                         output += xmlTemplateDocument.getProcessedDataValue(C_FILELISTENTRY);
182                     }
183                     xmlTemplateDocument.setData(C_WINCONTENT, output);
184                     session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_DELETE_STEP, C_STEP_MISSFILES);
185                 }
186             }
187             if(C_STEP_MISSFILES.equals(step)) {
188                 
189                 // they are already gone, just inform the user
190
Vector JavaDoc files = (Vector JavaDoc)session.getValue(CmsWorkplaceDefault.C_SESSION_MODULE_MISSFILES);
191                 if(files.isEmpty()) {
192                     templateSelector = C_READY;
193                 }
194                 else {
195                     xmlTemplateDocument.setData(C_W_TITLE, lang.getLanguageValue("module.error.deletetitle"));
196                     xmlTemplateDocument.setData(C_W_TEXT, lang.getLanguageValue("module.error.deletetext4"));
197                     String JavaDoc output = "";
198                     for(int i = 0;i < files.size();i++) {
199                         xmlTemplateDocument.setData(C_FILENAME, (String JavaDoc)files.elementAt(i));
200                         output += xmlTemplateDocument.getProcessedDataValue(C_FILELISTENTRY);
201                     }
202                     xmlTemplateDocument.setData(C_WINCONTENT, output);
203                     session.putValue(CmsWorkplaceDefault.C_SESSION_MODULE_DELETE_STEP, C_READY);
204                 }
205             }
206             if(C_READY.equals(step)) {
207                 templateSelector = C_READY;
208             }
209         }
210         
211         // Now load the template file and start the processing
212
return startProcessing(cms, xmlTemplateDocument, elementName, parameters, templateSelector);
213     }
214     
215     /**
216      * Indicates if the results of this class are cacheable.
217      *
218      * @param cms CmsObject Object for accessing system resources
219      * @param templateFile Filename of the template file
220      * @param elementName Element name of this template in our parent template.
221      * @param parameters Hashtable with all template class parameters.
222      * @param templateSelector template section that should be processed.
223      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
224      */

225     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
226         return false;
227     }
228 }
229
Popular Tags