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.ui.apps.dbmanager; 029 030import org.opencms.configuration.CmsConfigurationException; 031import org.opencms.main.OpenCms; 032import org.opencms.module.CmsModule; 033import org.opencms.module.CmsModuleDependency; 034import org.opencms.module.CmsModuleImportExportHandler; 035import org.opencms.module.CmsModuleManager; 036 037import java.util.List; 038 039/** 040 * 041 */ 042public class CmsImportFile { 043 044 /**Path of the file (on the server).*/ 045 private String m_path; 046 047 /**Module in OpenCms.*/ 048 private CmsModule m_module; 049 050 /** 051 * public constructor.<p> 052 * 053 * @param path of the file 054 */ 055 public CmsImportFile(String path) { 056 m_path = path; 057 } 058 059 /** 060 * Gets the module to import.<p> 061 * 062 * @return the CmsModule 063 */ 064 public CmsModule getModule() { 065 066 return m_module; 067 } 068 069 /** 070 * Gets the path of the file.<p> 071 * 072 * @return the server path 073 */ 074 public String getPath() { 075 076 return m_path; 077 } 078 079 /** 080 * 081 *Class to load and validate import module file.<p> 082 * 083 * @throws CmsConfigurationException gets thrown when validation fails 084 */ 085 public void loadAndValidate() throws CmsConfigurationException { 086 087 CmsModule module = CmsModuleImportExportHandler.readModuleFromImport(m_path); 088 m_module = module; 089 List<CmsModuleDependency> dependencies = OpenCms.getModuleManager().checkDependencies( 090 module, 091 CmsModuleManager.DEPENDENCY_MODE_IMPORT); 092 if (!dependencies.isEmpty()) { 093 StringBuffer dep = new StringBuffer(32); 094 for (int i = 0; i < dependencies.size(); i++) { 095 CmsModuleDependency dependency = dependencies.get(i); 096 dep.append("\n - "); 097 dep.append(dependency.getName()); 098 dep.append(" (Version: "); 099 dep.append(dependency.getVersion()); 100 dep.append(")"); 101 } 102 // throw new CmsConfigurationException( 103 // org.opencms.ui.apps.Messages.get().container( 104 // org.opencms.ui.apps.Messages.ERR_MODULEMANAGER_ACTION_MODULE_DEPENDENCY_2, 105 // m_path, 106 // new String(dep))); 107 } 108 } 109 110}