KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminLinkCheckViewer.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 package com.opencms.workplace;
30
31 import org.opencms.file.CmsObject;
32 import org.opencms.i18n.CmsEncoder;
33 import org.opencms.main.CmsException;
34
35 import com.opencms.defaults.CmsLinkCheck;
36 import com.opencms.template.CmsXmlTemplateFile;
37
38 import java.util.Enumeration JavaDoc;
39 import java.util.Hashtable JavaDoc;
40
41 /**
42  * Template class for displaying OpenCms workplace administration synchronisation properties.
43  *
44  * @version $Revision: 1.2 $ $Date: 2005/06/27 23:22:07 $
45  * @author Edna Falkenhan
46  *
47  * @deprecated Will not be supported past the OpenCms 6 release.
48  */

49 public class CmsAdminLinkCheckViewer extends CmsWorkplaceDefault {
50
51     /**
52      * Gets the content of a defined section in a given template file and its subtemplates
53      * with the given parameters.
54      *
55      * @see #getContent(CmsObject, String, String, Hashtable, String)
56      * @param cms CmsObject Object for accessing system resources.
57      * @param templateFile Filename of the template file.
58      * @param elementName Element name of this template in our parent template.
59      * @param parameters Hashtable with all template class parameters.
60      * @param templateSelector template section that should be processed.
61      */

62     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
63
64         CmsXmlTemplateFile templateDocument = getOwnTemplateFile(cms, templateFile, elementName, parameters, templateSelector);
65         long length = 0;
66
67         if("ok".equalsIgnoreCase((String JavaDoc)parameters.get("step"))){
68             templateSelector = "done";
69         } else {
70             String JavaDoc linkcheckdate = "";
71             StringBuffer JavaDoc linkcheckcontent = new StringBuffer JavaDoc();
72             try {
73                 Hashtable JavaDoc linkchecktable = CmsLinkCheck.readLinkCheckTable();
74                 Enumeration JavaDoc keys = linkchecktable.keys();
75                 while(keys.hasMoreElements()) {
76                     String JavaDoc curKey = (String JavaDoc)keys.nextElement();
77                     String JavaDoc curValue = (String JavaDoc) linkchecktable.get(curKey);
78                     if(curKey.equals(CmsLinkCheck.C_LINKCHECKTABLE_DATE)){
79                         linkcheckdate = curValue;
80                     } else {
81                         linkcheckcontent.append(curKey+", failed checks: "+curValue+"\n");
82                         length++;
83                     }
84                 }
85             } catch(Exception JavaDoc exc) {
86                 linkcheckcontent.append(CmsException.getStackTraceAsString(exc));
87             }
88             templateDocument.setData("logfiledate", linkcheckdate);
89             templateDocument.setData("logfile", CmsEncoder.escape(linkcheckcontent.toString(),
90                 cms.getRequestContext().getEncoding()));
91             templateDocument.setData("logfilesize", length + "");
92         }
93         // Now load the template file and start the processing
94
return startProcessing(cms, templateDocument, elementName, parameters, templateSelector);
95     }
96 }
Popular Tags