1 31 32 package com.opencms.legacy; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.importexport.CmsImportExportException; 36 import org.opencms.importexport.I_CmsImportExportHandler; 37 import org.opencms.report.I_CmsReport; 38 import org.opencms.xml.CmsXmlException; 39 40 import java.util.Arrays ; 41 import java.util.List ; 42 43 import org.dom4j.Document; 44 import org.dom4j.Element; 45 46 55 public class CmsCosImportExportHandler extends Object implements I_CmsImportExportHandler { 56 57 58 private String m_description; 59 60 61 private String m_fileName; 62 63 64 private List m_exportChannels; 65 66 67 private List m_exportModules; 68 69 72 public CmsCosImportExportHandler() { 73 super(); 74 m_description = org.opencms.importexport.Messages.get().getBundle().key( 75 org.opencms.importexport.Messages.GUI_CMSIMPORTHANDLER_DEFAULT_DESC_0); 76 } 77 78 81 protected void finalize() throws Throwable { 82 try { 83 if (m_exportChannels != null) { 84 m_exportChannels.clear(); 85 } 86 m_exportChannels = null; 87 88 if (m_exportModules != null) { 89 m_exportModules.clear(); 90 } 91 m_exportModules = null; 92 } catch (Exception e) { 93 } finally { 95 super.finalize(); 96 } 97 } 98 99 102 public void exportData(CmsObject cms, I_CmsReport report) throws CmsImportExportException { 103 report.println(org.opencms.importexport.Messages.get().container( 104 org.opencms.importexport.Messages.RPT_EXPORT_DB_BEGIN_0), I_CmsReport.FORMAT_HEADLINE); 105 new CmsExportModuledata(cms, getFileName(), getExportChannels(), getExportModules(), report); 106 report.println(org.opencms.importexport.Messages.get().container( 107 org.opencms.importexport.Messages.RPT_EXPORT_DB_END_0), I_CmsReport.FORMAT_HEADLINE); 108 } 109 110 113 public synchronized void importData(CmsObject cms, String importFile, String importPath, I_CmsReport report) throws CmsXmlException, CmsImportExportException { 114 report.println(org.opencms.importexport.Messages.get().container( 115 org.opencms.importexport.Messages.RPT_IMPORT_DB_BEGIN_0), I_CmsReport.FORMAT_HEADLINE); 116 CmsImportModuledata cosImport = new CmsImportModuledata(cms, importFile, importPath, report); 117 cosImport.importResources(); 118 report.println(org.opencms.importexport.Messages.get().container( 119 org.opencms.importexport.Messages.RPT_IMPORT_DB_END_0), I_CmsReport.FORMAT_HEADLINE); 120 } 121 122 127 public String [] getExportChannels() { 128 return (String []) m_exportChannels.toArray(); 129 } 130 131 136 public List getExportChannelsAsList() { 137 return m_exportChannels; 138 } 139 140 145 public String [] getExportModules() { 146 return (String []) m_exportModules.toArray(); 147 } 148 149 154 public List getExportModulesAsList() { 155 return m_exportModules; 156 } 157 158 163 public String getFileName() { 164 return m_fileName; 165 } 166 167 172 public void setExportChannels(String [] exportChannels) { 173 m_exportChannels = Arrays.asList(exportChannels); 174 } 175 176 181 public void setExportModules(String [] exportModules) { 182 m_exportModules = Arrays.asList(exportModules); 183 } 184 185 190 public void setFileName(String fileName) { 191 m_fileName = fileName; 192 } 193 194 197 public String getDescription() { 198 return m_description; 199 } 200 201 204 public void setDescription(String description) { 205 m_description = description; 206 } 207 208 211 public boolean matches(Document manifest) { 212 Element rootElement = manifest.getRootElement(); 213 214 boolean hasModuleExportNode = (com.opencms.core.I_CmsConstants.C_EXPORT_TAG_MODULEXPORT.equalsIgnoreCase(rootElement.getName())); 215 boolean hasChannelNodes = (rootElement.selectNodes("./channels/file").size() > 0); 216 217 return (hasModuleExportNode && hasChannelNodes); 218 } 219 220 } 221 222
| Popular Tags
|