001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/database/CmsStaticExportThread.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.12 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.database;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.main.CmsEvent;
036: import org.opencms.main.I_CmsEventListener;
037: import org.opencms.main.OpenCms;
038: import org.opencms.report.A_CmsReportThread;
039: import org.opencms.report.I_CmsReport;
040:
041: import java.util.HashMap;
042: import java.util.Map;
043:
044: /**
045: * Does a full static export of all system resources in the current site.<p>
046: *
047: * @author Michael Emmerich
048: *
049: * @version $Revision: 1.12 $
050: *
051: * @since 6.0.0
052: */
053: public class CmsStaticExportThread extends A_CmsReportThread {
054:
055: /**
056: * Creates a static export Thread.<p>
057: *
058: * @param cms the current cms context
059: */
060: public CmsStaticExportThread(CmsObject cms) {
061:
062: super (cms, Messages.get().getBundle().key(
063: Messages.GUI_STATEXP_THREAD_NAME_0));
064: initHtmlReport(cms.getRequestContext().getLocale());
065: }
066:
067: /**
068: * @see org.opencms.report.A_CmsReportThread#getReportUpdate()
069: */
070: public String getReportUpdate() {
071:
072: return getReport().getReportUpdate();
073: }
074:
075: /**
076: * @see java.lang.Runnable#run()
077: */
078: public void run() {
079:
080: getReport()
081: .println(
082: org.opencms.staticexport.Messages
083: .get()
084: .container(
085: org.opencms.staticexport.Messages.RPT_STATICEXPORT_BEGIN_0),
086: I_CmsReport.FORMAT_HEADLINE);
087: try {
088: OpenCms.getStaticExportManager().exportFullStaticRender(
089: true, getReport());
090: Map eventData = new HashMap();
091: eventData.put("purge", Boolean.TRUE);
092: eventData.put(I_CmsEventListener.KEY_REPORT, getReport());
093: OpenCms.fireCmsEvent(new CmsEvent(
094: I_CmsEventListener.EVENT_FULLSTATIC_EXPORT,
095: eventData));
096: } catch (Exception e) {
097: getReport().println(e);
098: }
099:
100: // append runtime statistics to report
101: getReport().print(
102: org.opencms.report.Messages.get().container(
103: org.opencms.report.Messages.RPT_STAT_0));
104: getReport()
105: .println(
106: org.opencms.report.Messages
107: .get()
108: .container(
109: org.opencms.report.Messages.RPT_STAT_DURATION_1,
110: getReport().formatRuntime()));
111: getReport()
112: .println(
113: org.opencms.staticexport.Messages
114: .get()
115: .container(
116: org.opencms.staticexport.Messages.RPT_STATICEXPORT_END_0),
117: I_CmsReport.FORMAT_HEADLINE);
118: }
119: }
|