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