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, 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.setup; 029 030import org.opencms.main.CmsLog; 031import org.opencms.main.CmsShell; 032import org.opencms.ui.report.CmsStreamReportWidget; 033 034import java.io.File; 035import java.io.FileInputStream; 036import java.io.FileNotFoundException; 037import java.io.PipedOutputStream; 038import java.io.PrintStream; 039 040public class CmsVaadinUpdateThread extends Thread { 041 042 /** System.out and System.err are redirected to this stream. */ 043 private PipedOutputStream m_pipedOut; 044 045 /** The cms shell to import the workplace with. */ 046 private CmsShell m_shell; 047 048 /** The report widget. */ 049 private CmsStreamReportWidget m_reportWidget; 050 051 /** The output stream for the CmsShell. */ 052 private PrintStream m_out; 053 054 /** The additional shell commands, i.e. the setup bean. */ 055 private CmsUpdateBean m_updateBean; 056 057 /** 058 * Constructor.<p> 059 * 060 * @param updateBean the initialized update bean 061 */ 062 public CmsVaadinUpdateThread(CmsUpdateBean updateBean, CmsStreamReportWidget reportWidget) { 063 064 super("OpenCms: Workplace update"); 065 066 // store setup bean 067 m_updateBean = updateBean; 068 m_out = reportWidget.getStream(); 069 m_reportWidget = reportWidget; 070 } 071 072 /** 073 * @see java.lang.Runnable#run() 074 */ 075 @Override 076 public void run() { 077 078 try { 079 080 // create a shell that will start importing the workplace 081 m_shell = new CmsShell( 082 m_updateBean.getWebAppRfsPath() + "WEB-INF" + File.separator, 083 m_updateBean.getServletMapping(), 084 m_updateBean.getDefaultWebApplication(), 085 "${user}@${project}>", 086 m_updateBean, 087 m_out, 088 m_out, 089 false); 090 091 try { 092 try { 093 if (CmsLog.INIT.isInfoEnabled()) { 094 // log welcome message, the full package name is required because 095 // two different Message classes are used 096 CmsLog.INIT.info( 097 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 098 CmsLog.INIT.info( 099 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 100 CmsLog.INIT.info( 101 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 102 CmsLog.INIT.info( 103 org.opencms.setup.Messages.get().getBundle().key( 104 org.opencms.setup.Messages.INIT_WELCOME_UPDATE_0)); 105 CmsLog.INIT.info( 106 org.opencms.setup.Messages.get().getBundle().key( 107 org.opencms.setup.Messages.INIT_UPDATE_WORKPLACE_START_0)); 108 CmsLog.INIT.info( 109 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 110 CmsLog.INIT.info( 111 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 112 for (int i = 0; i < org.opencms.main.Messages.COPYRIGHT_BY_ALKACON.length; i++) { 113 CmsLog.INIT.info(". " + org.opencms.main.Messages.COPYRIGHT_BY_ALKACON[i]); 114 } 115 CmsLog.INIT.info( 116 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 117 CmsLog.INIT.info( 118 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_DOT_0)); 119 CmsLog.INIT.info( 120 org.opencms.main.Messages.get().getBundle().key(org.opencms.main.Messages.INIT_LINE_0)); 121 122 } 123 m_shell.execute( 124 new FileInputStream( 125 new File(m_updateBean.getWebAppRfsPath() + CmsUpdateBean.FOLDER_UPDATE + "cmsupdate.txt"))); 126 if (CmsLog.INIT.isInfoEnabled()) { 127 CmsLog.INIT.info( 128 org.opencms.setup.Messages.get().getBundle().key( 129 org.opencms.setup.Messages.INIT_UPDATE_WORKPLACE_FINISHED_0)); 130 } 131 } catch (FileNotFoundException e) { 132 e.printStackTrace(); 133 } 134 135 m_pipedOut.close(); 136 } catch (Throwable t) { 137 // ignore 138 } 139 } finally { 140 m_reportWidget.finish(); 141 } 142 } 143}