KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsTaskContentDialogMsg.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.CmsUser;
34 import org.opencms.main.CmsException;
35 import org.opencms.main.CmsLog;
36 import org.opencms.workflow.CmsTask;
37 import org.opencms.workflow.CmsTaskService;
38
39 import com.opencms.core.I_CmsSession;
40 import com.opencms.legacy.CmsXmlTemplateLoader;
41
42 import java.util.Hashtable JavaDoc;
43
44 /**
45  * Template class for displaying OpenCms workplace task content screens.
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 CmsTaskContentDialogMsg 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, Hashtable JavaDoc parameters,
70             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         CmsXmlWpTemplateFile xmlTemplateDocument = (CmsXmlWpTemplateFile)getOwnTemplateFile(cms,
77                 templateFile, elementName, parameters, templateSelector);
78         I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
79         
80         // the recipient of the message
81
String JavaDoc userName = "";
82         try {
83             String JavaDoc taskidstr = (String JavaDoc)parameters.get("taskid");
84             int taskid;
85             if(taskidstr == null || taskidstr == "") {
86                 Integer JavaDoc sessionTaskid = (Integer JavaDoc)session.getValue("taskid");
87                 taskid = sessionTaskid.intValue();
88             }
89             else {
90                 Integer JavaDoc taskidInt = new Integer JavaDoc(taskidstr);
91                 taskid = taskidInt.intValue();
92                 session.putValue("taskid", taskidInt);
93             }
94             CmsTaskService taskService = cms.getTaskService();
95             CmsTask task = taskService.readTask(taskid);
96             CmsUser user = null;
97             if("query".equals(parameters.get("action"))) {
98                 
99                 // this is the query-dialog
100
user = taskService.readOwner(task);
101                 templateSelector = "query";
102             }
103             else {
104                 
105                 // this is the message-dialog
106
user = taskService.readAgent(task);
107             }
108             userName = CmsUser.getFullName(user);
109         }
110         catch(Exception JavaDoc exc) {
111             
112         
113         // unexpected exception - ignoring
114
}
115         xmlTemplateDocument.setData("user", userName);
116         
117         // Now load the template file and start the processing
118
return startProcessing(cms, xmlTemplateDocument, elementName, parameters, templateSelector);
119     }
120     
121     /**
122      * Indicates if the results of this class are cacheable.
123      *
124      * @param cms CmsObject Object for accessing system resources
125      * @param templateFile Filename of the template file
126      * @param elementName Element name of this template in our parent template.
127      * @param parameters Hashtable with all template class parameters.
128      * @param templateSelector template section that should be processed.
129      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
130      */

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