001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/scheduler/jobs/CmsStaticExportJob.java,v $
003: * Date : $Date: 2008-02-27 12:05:38 $
004: * Version: $Revision: 1.11 $
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.scheduler.jobs;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.main.CmsEvent;
036: import org.opencms.main.CmsException;
037: import org.opencms.main.I_CmsEventListener;
038: import org.opencms.main.OpenCms;
039: import org.opencms.report.CmsLogReport;
040: import org.opencms.report.I_CmsReport;
041: import org.opencms.scheduler.I_CmsScheduledJob;
042: import org.opencms.staticexport.Messages;
043:
044: import java.io.IOException;
045: import java.util.HashMap;
046: import java.util.Map;
047:
048: import javax.servlet.ServletException;
049:
050: /**
051: * A schedulable OpenCms job to write a complete static export (e.g. nightly exports).<p>
052: *
053: * This job does not have any parameters.<p>
054: *
055: * @author Thomas Weckert
056: *
057: * @version $Revision: 1.11 $
058: *
059: * @since 6.0.0
060: */
061: public class CmsStaticExportJob implements I_CmsScheduledJob {
062:
063: /**
064: * @see org.opencms.scheduler.I_CmsScheduledJob#launch(CmsObject, Map)
065: */
066: public String launch(CmsObject cms, Map parameters)
067: throws Exception {
068:
069: I_CmsReport report = null;
070:
071: try {
072: report = new CmsLogReport(cms.getRequestContext()
073: .getLocale(), CmsStaticExportJob.class);
074: OpenCms.getStaticExportManager().exportFullStaticRender(
075: true, report);
076: Map eventData = new HashMap();
077: eventData.put("purge", Boolean.TRUE);
078: eventData.put(I_CmsEventListener.KEY_REPORT, report);
079: OpenCms.fireCmsEvent(new CmsEvent(
080: I_CmsEventListener.EVENT_FULLSTATIC_EXPORT,
081: eventData));
082: } catch (CmsException e) {
083: if (report != null) {
084: report.println(e);
085: }
086: } catch (IOException e) {
087: if (report != null) {
088: report.println(e);
089: }
090: } catch (ServletException e) {
091: if (report != null) {
092: report.println(e);
093: }
094: } finally {
095: // append runtime statistics to the report
096: if (report != null) {
097: report
098: .print(org.opencms.report.Messages
099: .get()
100: .container(
101: org.opencms.report.Messages.RPT_STAT_0));
102: report
103: .println(org.opencms.report.Messages
104: .get()
105: .container(
106: org.opencms.report.Messages.RPT_STAT_DURATION_1,
107: report.formatRuntime()));
108: report.println(Messages.get().container(
109: Messages.RPT_STATICEXPORT_END_0),
110: I_CmsReport.FORMAT_HEADLINE);
111: }
112: }
113:
114: return null;
115: }
116: }
|