001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/threads/CmsDatabaseImportThread.java,v $
003: * Date : $Date: 2008-02-27 12:05:43 $
004: * Version: $Revision: 1.13 $
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.threads;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.importexport.CmsImportParameters;
036: import org.opencms.main.CmsLog;
037: import org.opencms.main.OpenCms;
038: import org.opencms.report.A_CmsReportThread;
039:
040: import org.apache.commons.logging.Log;
041:
042: /**
043: * Imports an OpenCms export file into the VFS.<p>
044: *
045: * @author Alexander Kandzior
046: * @author Thomas Weckert
047: *
048: * @version $Revision: 1.13 $
049: *
050: * @since 6.0.0
051: */
052: public class CmsDatabaseImportThread extends A_CmsReportThread {
053:
054: /** The log object for this class. */
055: private static final Log LOG = CmsLog
056: .getLog(CmsDatabaseImportThread.class);
057:
058: /** The import file name. */
059: private String m_importFile;
060:
061: /** The keep permissions flag. */
062: private boolean m_keepPermissions;
063:
064: /**
065: * Imports an OpenCms export file into the VFS.<p>
066: *
067: * @param cms the current OpenCms context object
068: * @param importFile the file to import
069: * @param keepPermissions if set, the permissions set on existing resources will not be modified
070: */
071: public CmsDatabaseImportThread(CmsObject cms, String importFile,
072: boolean keepPermissions) {
073:
074: super (cms, Messages.get().getBundle().key(
075: Messages.GUI_DB_IMPORT_THREAD_NAME_1, importFile));
076: m_importFile = importFile;
077: m_keepPermissions = keepPermissions;
078: initHtmlReport(cms.getRequestContext().getLocale());
079: }
080:
081: /**
082: * @see org.opencms.report.A_CmsReportThread#getReportUpdate()
083: */
084: public String getReportUpdate() {
085:
086: return getReport().getReportUpdate();
087: }
088:
089: /**
090: * @see java.lang.Runnable#run()
091: */
092: public void run() {
093:
094: CmsImportParameters parameters = new CmsImportParameters(
095: m_importFile, "/", m_keepPermissions);
096:
097: try {
098: OpenCms.getImportExportManager().importData(getCms(),
099: getReport(), parameters);
100: } catch (Throwable e) {
101: getReport().println(e);
102: if (LOG.isErrorEnabled()) {
103: LOG.error(Messages.get().getBundle().key(
104: Messages.ERR_DB_IMPORT_0), e);
105: }
106: }
107: }
108: }
|