KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminProjectResent.java,v $
3 * Date : $Date: 2005/05/31 15:51:19 $
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.file.CmsProject;
34 import org.opencms.main.CmsException;
35 import org.opencms.main.CmsLog;
36
37 import com.opencms.core.I_CmsSession;
38 import com.opencms.legacy.CmsXmlTemplateLoader;
39 import com.opencms.template.CmsXmlTemplateFile;
40
41 import java.util.Hashtable JavaDoc;
42 import java.util.Vector JavaDoc;
43
44 /**
45  * Template class for displaying OpenCms workplace admin project resent.
46  * <P>
47  *
48  * @author Andreas Schouten
49  * @version $Revision: 1.2 $ $Date: 2005/05/31 15:51:19 $
50  * @see com.opencms.workplace.CmsXmlWpTemplateFile
51  *
52  * @deprecated Will not be supported past the OpenCms 6 release.
53  */

54
55 public class CmsAdminProjectResent 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      */

68     
69     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
70             Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
71         if(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
72             CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
73             CmsLog.getLog(this).debug("Template file is: " + templateFile);
74             CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
75         }
76         CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile,
77                 elementName, parameters, templateSelector);
78         xmlTemplateDocument.setData("proId", ""+ cms.getRequestContext().currentProject().getId());
79         // delete the oldProjectId
80
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
81         session.removeValue("oldProjectId");
82         
83         // Now load the template file and start the processing
84
return startProcessing(cms, xmlTemplateDocument, elementName, parameters,
85                 templateSelector);
86     }
87     
88     /**
89      * Indicates if the results of this class are cacheable.
90      *
91      * @param cms CmsObject Object for accessing system resources
92      * @param templateFile Filename of the template file
93      * @param elementName Element name of this template in our parent template.
94      * @param parameters Hashtable with all template class parameters.
95      * @param templateSelector template section that should be processed.
96      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
97      */

98     
99     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
100             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
101         return false;
102     }
103     
104     /**
105      * Gets the projects.
106      * <P>
107      *
108      * @param cms CmsObject Object for accessing system resources.
109      * @param names Vector to be filled with the appropriate values in this method.
110      * @param values Vector to be filled with the appropriate values in this method.
111      * @return Vector representing the current projects.
112      * @throws CmsException
113      */

114     
115     // public Vector projectList(CmsObject cms, CmsXmlLanguageFile lang)
116
// throws CmsException {
117
// get the manageable projects
118
// return cms.getAllManageableProjects();
119
// }
120

121     public Vector JavaDoc projectList(CmsObject cms, CmsXmlLanguageFile lang) throws CmsException {
122         Vector JavaDoc list = new Vector JavaDoc();
123         
124         // get the manageable projects
125
Vector JavaDoc mp = new Vector JavaDoc(cms.getAllManageableProjects());
126         Hashtable JavaDoc temp = new Hashtable JavaDoc();
127         for(int i = 0;i < mp.size();i++) {
128             temp.put("" + ((CmsProject)mp.elementAt(i)).getId(), mp.elementAt(i));
129         }
130         
131         //
132
Vector JavaDoc ap = new Vector JavaDoc(cms.getAllAccessibleProjects());
133         for(int i = 0;i < ap.size();i++) {
134             if(temp.containsKey("" + ((CmsProject)ap.elementAt(i)).getId())) {
135                 list.addElement(ap.elementAt(i));
136             }
137         }
138         
139         //
140
return list;
141     }
142 }
143
Popular Tags