KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > legacy > CmsCosImportExportHandler


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/legacy/CmsCosImportExportHandler.java,v $
3  * Date : $Date: 2006/03/27 14:53:03 $
4  * Version: $Revision: 1.9 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

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 JavaDoc;
41 import java.util.List JavaDoc;
42
43 import org.dom4j.Document;
44 import org.dom4j.Element;
45
46 /**
47  * Import/export handler implementation for COS data.<p>
48  *
49  * @author Thomas Weckert (t.weckert@alkacon.com)
50  * @version $Revision: 1.9 $ $Date: 2006/03/27 14:53:03 $
51  * @since 5.3
52  *
53  * @deprecated Will not be supported past the OpenCms 6 release.
54  */

55 public class CmsCosImportExportHandler extends Object JavaDoc implements I_CmsImportExportHandler {
56     
57     /** The description of this import/export handler.<p> */
58     private String JavaDoc m_description;
59     
60     /** The name of the export file in the real file system.<p> */
61     private String JavaDoc m_fileName;
62     
63     /** The COS channels to be exported.<p> */
64     private List JavaDoc m_exportChannels;
65     
66     /** The COS modules to be exported.<p> */
67     private List JavaDoc m_exportModules;
68
69     /**
70      * Creates a new COS import/export handler.<p>
71      */

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     /**
79      * @see java.lang.Object#finalize()
80      */

81     protected void finalize() throws Throwable JavaDoc {
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 JavaDoc e) {
93             // noop
94
} finally {
95             super.finalize();
96         }
97     }
98
99     /**
100      * @see org.opencms.importexport.I_CmsImportExportHandler#exportData(org.opencms.file.CmsObject, org.opencms.report.I_CmsReport)
101      */

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     /**
111      * @see org.opencms.importexport.I_CmsImportExportHandler#importData(org.opencms.file.CmsObject, java.lang.String, java.lang.String, org.opencms.report.I_CmsReport)
112      */

113     public synchronized void importData(CmsObject cms, String JavaDoc importFile, String JavaDoc 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     /**
123      * Returns the COS channels to be exported.<p>
124      *
125      * @return the COS channels to be exported
126      */

127     public String JavaDoc[] getExportChannels() {
128         return (String JavaDoc[]) m_exportChannels.toArray();
129     }
130     
131     /**
132      * Returns the COS channels to be exported as a list.<p>
133      *
134      * @return the COS channels to be exported as a list
135      */

136     public List JavaDoc getExportChannelsAsList() {
137         return m_exportChannels;
138     }
139
140     /**
141      * Returns the COS modules to be exported.<p>
142      *
143      * @return the COS modules to be exported
144      */

145     public String JavaDoc[] getExportModules() {
146         return (String JavaDoc[]) m_exportModules.toArray();
147     }
148     
149     /**
150      * Returns the COS modules to be exported as a list.<p>
151      *
152      * @return the COS modules to be exported as a list
153      */

154     public List JavaDoc getExportModulesAsList() {
155         return m_exportModules;
156     }
157
158     /**
159      * Returns the name of the export file in the real file system.<p>
160      *
161      * @return the name of the export file in the real file system
162      */

163     public String JavaDoc getFileName() {
164         return m_fileName;
165     }
166
167     /**
168      * Sets the COS channels to be exported.<p>
169      *
170      * @param exportChannels the COS channels to be exported
171      */

172     public void setExportChannels(String JavaDoc[] exportChannels) {
173         m_exportChannels = Arrays.asList(exportChannels);
174     }
175
176     /**
177      * Sets the COS modules to be exported.<p>
178      *
179      * @param exportModules the COS modules to be exported
180      */

181     public void setExportModules(String JavaDoc[] exportModules) {
182         m_exportModules = Arrays.asList(exportModules);
183     }
184
185     /**
186      * Sets the name of the export file in the real file system.<p>
187      *
188      * @param fileName the name of the export file in the real file system
189      */

190     public void setFileName(String JavaDoc fileName) {
191         m_fileName = fileName;
192     }
193     
194     /**
195      * @see org.opencms.importexport.I_CmsImportExportHandler#getDescription()
196      */

197     public String JavaDoc getDescription() {
198         return m_description;
199     }
200
201     /**
202      * @see org.opencms.importexport.I_CmsImportExportHandler#setDescription(java.lang.String)
203      */

204     public void setDescription(String JavaDoc description) {
205         m_description = description;
206     }
207
208     /**
209      * @see org.opencms.importexport.I_CmsImportExportHandler#matches(org.dom4j.Document)
210      */

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