KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsErrorpage.java,v $
3 * Date : $Date: 2005/06/27 23:22:07 $
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 import org.opencms.workplace.CmsWorkplace;
35
36 import com.opencms.legacy.CmsXmlTemplateLoader;
37 import com.opencms.template.A_CmsXmlContent;
38
39 import java.util.Hashtable JavaDoc;
40
41 import org.w3c.dom.Element JavaDoc;
42 import org.w3c.dom.NodeList JavaDoc;
43
44 /**
45  * Class for building workplace error pages. <BR>
46  * Called by CmsXmlTemplateFile for handling the special XML tag <code>&lt;ERRORPAGE&gt;</code>.
47  *
48  * @author Michael Emmerich
49  * @version $Revision: 1.2 $ $Date: 2005/06/27 23:22:07 $
50  *
51  * @deprecated Will not be supported past the OpenCms 6 release.
52  */

53
54 public class CmsErrorpage extends A_CmsWpElement {
55
56     /**
57      * Handling of the <CODE>&lt;ERRORPAGEBOX&gt;</CODE> tags.
58      * <P>
59      * Reads the code of a error page box from the errors definition file
60      * and returns the processed code with the actual elements.
61      * <P>
62      * Error page boxes can be referenced in any workplace template by <br>
63      * <CODE>&lt;ERRORPAGEBOX name="..." action="..." alt="..."/&gt;</CODE>
64      *
65      * @param cms CmsObject Object for accessing resources.
66      * @param n XML element containing the <code>&lt;ERRORPAGEBOX&gt;</code> tag.
67      * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document.
68      * @param callingObject reference to the calling object.
69      * @param parameters Hashtable containing all user parameters.
70      * @param lang CmsXmlLanguageFile conataining the currently valid language file.
71      * @return Processed button.
72      * @throws CmsException
73      */

74
75     public Object JavaDoc handleSpecialWorkplaceTag(CmsObject cms, Element JavaDoc n, A_CmsXmlContent doc,
76             Object JavaDoc callingObject, Hashtable JavaDoc parameters, CmsXmlLanguageFile lang) throws CmsException {
77
78         // collect all required data
79
String JavaDoc errorTitle = n.getAttribute(CmsWorkplaceDefault.C_ERROR_TITLE);
80         String JavaDoc errorMessage = n.getAttribute(CmsWorkplaceDefault.C_ERROR_MESSAGE);
81         String JavaDoc errorReason = n.getAttribute(CmsWorkplaceDefault.C_ERROR_REASON);
82         String JavaDoc errorSuggestion = n.getAttribute(CmsWorkplaceDefault.C_ERROR_SUGGESTION);
83         String JavaDoc errorLink = n.getAttribute(CmsWorkplaceDefault.C_ERROR_LINK);
84         if ("explorer_files.html".equals(errorLink)) {
85             errorLink = CmsWorkplaceAction.getExplorerFileUri(CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest());
86         }
87         String JavaDoc details = "no details";
88         if(n.hasChildNodes()) {
89             details = n.getFirstChild().getNodeValue();
90         }
91         // try to read the processed lasturl
92
NodeList JavaDoc nlist = n.getChildNodes();
93         if(nlist.getLength() > 1){
94             String JavaDoc theLasturl = nlist.item(1).getNodeValue();
95             // if the lasturl is given set the errorLink to lasturl
96
if(theLasturl != null && !"".equals(theLasturl.trim())){
97                 errorLink = theLasturl;
98             }
99         }
100         String JavaDoc reason;
101         String JavaDoc button;
102         CmsXmlWpTemplateFile errordef = getErrorDefinitions(cms);
103
104         // get the data from the language file
105
errorTitle = lang.getLanguageValue(errorTitle);
106         errorMessage = lang.getLanguageValue(errorMessage);
107         errorReason = lang.getLanguageValue(errorReason);
108         errorSuggestion = lang.getLanguageValue(errorSuggestion);
109         reason = lang.getLanguageValue("message.reason");
110         button = lang.getLanguageValue("button.ok");
111         errordef.setData("stylesheetpath", CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl() + CmsWorkplace.VFS_PATH_RESOURCES);
112         errordef.setData("jspath", CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl() + CmsWorkplaceDefault.C_VFS_PATH_SCRIPTS);
113         errordef.setData(CmsWorkplaceDefault.C_ERROR_MSG_BUTTON, button);
114         errordef.setData(CmsWorkplaceDefault.C_ERROR_TITLE, errorTitle);
115         errordef.setData(CmsWorkplaceDefault.C_ERROR_MESSAGE, errorMessage);
116         errordef.setData(CmsWorkplaceDefault.C_ERROR_REASON, errorReason);
117         errordef.setData(CmsWorkplaceDefault.C_ERROR_SUGGESTION, errorSuggestion);
118         errordef.setData(CmsWorkplaceDefault.C_ERROR_LINK, errorLink);
119         errordef.setData(CmsWorkplaceDefault.C_ERROR_MSG_REASON, reason);
120         errordef.setData(CmsWorkplaceDefault.C_ERROR_MSG_DETAILS, details);
121
122         // build errorpage
123
String JavaDoc result = errordef.getProcessedDataValue(CmsWorkplaceDefault.C_TAG_ERRORPAGE, callingObject, null);
124         return result;
125     }
126
127     /**
128      * Indicates if the results of this class are cacheable.
129      *
130      * @param cms CmsObject Object for accessing system resources
131      * @param templateFile Filename of the template file
132      * @param elementName Element name of this template in our parent template.
133      * @param parameters Hashtable with all template class parameters.
134      * @param templateSelector template section that should be processed.
135      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
136      */

137
138     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
139             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
140         return false;
141     }
142 }
143
Popular Tags