KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminProjectResentFiles.java,v $
3 * Date : $Date: 2005/05/19 08:57:22 $
4 * Version: $Revision: 1.2 $
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
30 package com.opencms.workplace;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.main.CmsException;
34
35 import com.opencms.core.I_CmsSession;
36 import com.opencms.legacy.CmsLegacyException;
37 import com.opencms.legacy.CmsXmlTemplateLoader;
38
39 import java.io.IOException JavaDoc;
40 import java.util.Hashtable JavaDoc;
41
42 /**
43  * News administration template class
44  * <p>
45  * Used both for displaying news administration overviews and
46  * editing news.
47  *
48  * @author Alexander Lucas
49  * @version $Revision: 1.2 $ $Date: 2005/05/19 08:57:22 $
50  * @see com.opencms.workplace.CmsXmlWpTemplateFile
51  *
52  * @deprecated Will not be supported past the OpenCms 6 release.
53  */

54
55 public class CmsAdminProjectResentFiles extends CmsWorkplaceDefault {
56
57     /**
58      * Gets the content of a defined section in a given template file and its subtemplates
59      * with the given parameters.
60      *
61      * @see #getContent(CmsObject, String, String, Hashtable, String)
62      * @param cms CmsObject Object for accessing system resources.
63      * @param templateFile Filename of the template file.
64      * @param elementName Element name of this template in our parent template.
65      * @param parameters Hashtable with all template class parameters.
66      * @param templateSelector template section that should be processed.
67      * @throws CmsException if something goes wrong
68      * @return byte array with the processed content
69      */

70
71     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
72             Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
73         // get the session
74
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
75         // load the template file
76
CmsXmlWpTemplateFile xmlTemplateDocument = (CmsXmlWpTemplateFile)getOwnTemplateFile(cms,
77                 templateFile, elementName, parameters, templateSelector);
78         String JavaDoc filter = (String JavaDoc)parameters.get("projectfilter");
79         String JavaDoc projectId = (String JavaDoc)parameters.get("projectid");
80         if (projectId == null || "".equalsIgnoreCase(projectId)) {
81             projectId = (String JavaDoc)session.getValue("projectid");
82             if (projectId == null || "".equalsIgnoreCase(projectId)) {
83                 projectId = ""+cms.getRequestContext().currentProject().getId();
84             }
85         }
86         xmlTemplateDocument.setData("projectid", projectId);
87         String JavaDoc action = (String JavaDoc)parameters.get("action");
88         if (filter == null || "".equalsIgnoreCase(filter)) {
89             filter=(String JavaDoc)session.getValue("projectfilter");
90             if (filter == null || "".equalsIgnoreCase(filter)) {
91                 filter = "all";
92             }
93             xmlTemplateDocument.setData("filter", filter);
94             xmlTemplateDocument.setData("loadheader", xmlTemplateDocument.getProcessedDataValue("LOADHEADER", this));
95         } else {
96             xmlTemplateDocument.setData("filter", filter);
97             xmlTemplateDocument.setData("loadheader", xmlTemplateDocument.getProcessedDataValue("NOTLOADHEADER", this));
98         }
99
100         // store the chosen filter and projectid into the session
101
session.putValue("projectfilter", filter);
102         session.putValue("projectid", projectId);
103
104         if (action != null && "restoreproject".equalsIgnoreCase(action)) {
105             session.removeValue("projectid");
106             session.removeValue("projectfilter");
107             //redirect to the needed headfile
108
try {
109                 CmsXmlTemplateLoader.getResponse(cms.getRequestContext()).sendCmsRedirect(getConfigFile(cms).getWorkplaceActionPath()
110                     +"empty.html");
111             } catch (IOException JavaDoc exc) {
112                 throw new CmsLegacyException("Could not redirect to empty.html", exc);
113             }
114         }
115         // Finally start the processing
116
return startProcessing(cms, xmlTemplateDocument, elementName, parameters, templateSelector);
117     }
118
119     /**
120      * Indicates if the results of this class are cacheable.
121      *
122      * @param cms CmsObject Object for accessing system resources
123      * @param templateFile Filename of the template file
124      * @param elementName Element name of this template in our parent template.
125      * @param parameters Hashtable with all template class parameters.
126      * @param templateSelector template section that should be processed.
127      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
128      */

129
130     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
131             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
132         return false;
133     }
134 }
135
Popular Tags