Source Code Cross Referenced for CmsImportExportManager.java in  » Content-Management-System » opencms » org » opencms » importexport » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » opencms » org.opencms.importexport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/importexport/CmsImportExportManager.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:48 $
004:         * Version: $Revision: 1.38 $
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.importexport;
033:
034:        import org.opencms.configuration.CmsConfigurationException;
035:        import org.opencms.db.CmsUserExportSettings;
036:        import org.opencms.file.CmsObject;
037:        import org.opencms.i18n.CmsMessageContainer;
038:        import org.opencms.main.CmsEvent;
039:        import org.opencms.main.CmsException;
040:        import org.opencms.main.CmsLog;
041:        import org.opencms.main.I_CmsEventListener;
042:        import org.opencms.main.OpenCms;
043:        import org.opencms.report.I_CmsReport;
044:        import org.opencms.security.CmsRole;
045:        import org.opencms.security.CmsRoleViolationException;
046:        import org.opencms.security.I_CmsPrincipal;
047:        import org.opencms.xml.CmsXmlException;
048:
049:        import java.io.InputStream;
050:        import java.util.ArrayList;
051:        import java.util.Collections;
052:        import java.util.HashMap;
053:        import java.util.List;
054:        import java.util.Map;
055:
056:        import org.apache.commons.logging.Log;
057:
058:        import org.dom4j.Document;
059:        import org.dom4j.io.SAXReader;
060:
061:        /**
062:         * Provides information about how to handle imported resources.<p>
063:         * 
064:         * @author Thomas Weckert  
065:         * 
066:         * @version $Revision: 1.38 $ 
067:         * 
068:         * @since 6.0.0 
069:         * 
070:         * @see OpenCms#getImportExportManager()
071:         */
072:        public class CmsImportExportManager {
073:
074:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userinfo/entry@name" attribute, contains the additional user info entry name. 
075:             * @deprecated Use the appropriate tag from latest import class instead*/
076:            public static final String A_NAME = A_CmsImport.A_NAME;
077:
078:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userinfo/entry@type" attribute, contains the additional user info entry data type name. 
079:             * @deprecated Use the appropriate tag from latest import class instead*/
080:            public static final String A_TYPE = A_CmsImport.A_TYPE;
081:
082:            /** The name of the XML manifest file used for the description of exported OpenCms VFS properties and attributes. */
083:            public static final String EXPORT_MANIFEST = "manifest.xml";
084:
085:            /** The current version of the OpenCms export (appears in the {@link #EXPORT_MANIFEST} header). */
086:            public static final String EXPORT_VERSION = ""
087:                    + CmsImportVersion7.IMPORT_VERSION7;
088:
089:            /** 
090:             * The name of the XML manifest file used for the description of exported OpenCms VFS properties and attributes.<p>
091:             * 
092:             * @deprecated use {@link #EXPORT_MANIFEST} instead
093:             */
094:            public static final String EXPORT_XMLFILENAME = EXPORT_MANIFEST;
095:
096:            /** Tag in the {@link #EXPORT_MANIFEST} for the "access" node. 
097:             * @deprecated Use the appropriate tag from latest import class instead*/
098:            public static final String N_ACCESS = A_CmsImport.N_ACCESS;
099:
100:            /** Tag in the {@link #EXPORT_MANIFEST} for the "allowed" node, to identify allowed user permissions. 
101:             * @deprecated Use the appropriate tag from latest import class instead*/
102:            public static final String N_ACCESSCONTROL_ALLOWEDPERMISSIONS = A_CmsImport.N_ACCESSCONTROL_ALLOWEDPERMISSIONS;
103:
104:            /** Tag in the {@link #EXPORT_MANIFEST} for the "denied" node, to identify denied user permissions. 
105:             * @deprecated Use the appropriate tag from latest import class instead*/
106:            public static final String N_ACCESSCONTROL_DENIEDPERMISSIONS = A_CmsImport.N_ACCESSCONTROL_DENIEDPERMISSIONS;
107:
108:            /** Tag in the {@link #EXPORT_MANIFEST} for the "accesscontrol" node, to identify access control entries. 
109:             * @deprecated Use the appropriate tag from latest import class instead*/
110:            public static final String N_ACCESSCONTROL_ENTRIES = A_CmsImport.N_ACCESSCONTROL_ENTRIES;
111:
112:            /** Tag in the {@link #EXPORT_MANIFEST} for the "accessentry" node, to identify a single access control entry. 
113:             * @deprecated Use the appropriate tag from latest import class instead*/
114:            public static final String N_ACCESSCONTROL_ENTRY = A_CmsImport.N_ACCESSCONTROL_ENTRY;
115:
116:            /** Tag in the {@link #EXPORT_MANIFEST} for the "permissionset" node, to identify a permission set. 
117:             * @deprecated Use the appropriate tag from latest import class instead*/
118:            public static final String N_ACCESSCONTROL_PERMISSIONSET = A_CmsImport.N_ACCESSCONTROL_PERMISSIONSET;
119:
120:            /** Tag in the {@link #EXPORT_MANIFEST} for the "uuidprincipal" node, to identify a principal UUID. 
121:             * @deprecated Use the appropriate tag from latest import class instead*/
122:            public static final String N_ACCESSCONTROL_PRINCIPAL = A_CmsImport.N_ACCESSCONTROL_PRINCIPAL;
123:
124:            /** Tag for the "creator" node (appears in the {@link #EXPORT_MANIFEST} header). */
125:            public static final String N_CREATOR = "creator";
126:
127:            /** Tag for the "createdate" node (appears in the {@link #EXPORT_MANIFEST} header). */
128:            public static final String N_DATE = "createdate";
129:
130:            /** Tag in the {@link #EXPORT_MANIFEST} for the "datecreated" node, contains the date created VFS file attribute. 
131:             * @deprecated Use the appropriate tag from latest import class instead*/
132:            public static final String N_DATECREATED = A_CmsImport.N_DATECREATED;
133:
134:            /** Tag in the {@link #EXPORT_MANIFEST} for the "dateexpired" node, contains the expiration date VFS file attribute. 
135:             * @deprecated Use the appropriate tag from latest import class instead*/
136:            public static final String N_DATEEXPIRED = A_CmsImport.N_DATEEXPIRED;
137:
138:            /** Tag in the {@link #EXPORT_MANIFEST} for the "datelastmodified" node, contains the date last modified VFS file attribute. 
139:             * @deprecated Use the appropriate tag from latest import class instead*/
140:            public static final String N_DATELASTMODIFIED = A_CmsImport.N_DATELASTMODIFIED;
141:
142:            /** Tag in the {@link #EXPORT_MANIFEST} for the "datereleased" node, contains the release date VFS file attribute. 
143:             * @deprecated Use the appropriate tag from latest import class instead*/
144:            public static final String N_DATERELEASED = A_CmsImport.N_DATERELEASED;
145:
146:            /** Tag in the {@link #EXPORT_MANIFEST} for the "defaultgroup" node, for backward compatibility with OpenCms 5.x. 
147:             * @deprecated Use the appropriate tag from latest import class instead*/
148:            public static final String N_DEFAULTGROUP = A_CmsImport.N_DEFAULTGROUP;
149:
150:            /** Tag in the {@link #EXPORT_MANIFEST} for the "description" node, contains a users description test. 
151:             * @deprecated Use the appropriate tag from latest import class instead*/
152:            public static final String N_DESCRIPTION = A_CmsImport.N_DESCRIPTION;
153:
154:            /** Tag in the {@link #EXPORT_MANIFEST} for the "destination" node, contains target VFS file name. 
155:             * @deprecated Use the appropriate tag from latest import class instead*/
156:            public static final String N_DESTINATION = A_CmsImport.N_DESTINATION;
157:
158:            /** Tag in the {@link #EXPORT_MANIFEST} for the "email" node, contains a users email. 
159:             * @deprecated Use the appropriate tag from latest import class instead*/
160:            public static final String N_EMAIL = A_CmsImport.N_EMAIL;
161:
162:            /** Tag in the {@link #EXPORT_MANIFEST} for the "export" node. */
163:            public static final String N_EXPORT = "export";
164:
165:            /** Tag in the {@link #EXPORT_MANIFEST} for the "file" node, container node for all VFS resources. 
166:             * @deprecated Use the appropriate tag from latest import class instead*/
167:            public static final String N_FILE = A_CmsImport.N_FILE;
168:
169:            /** Tag in the {@link #EXPORT_MANIFEST} for the "firstname" node, contains a users first name. 
170:             * @deprecated Use the appropriate tag from latest import class instead*/
171:            public static final String N_FIRSTNAME = A_CmsImport.N_FIRSTNAME;
172:
173:            /** Tag in the {@link #EXPORT_MANIFEST} for the "flags" node, contains the flags of a VFS resource. 
174:             * @deprecated Use the appropriate tag from latest import class instead*/
175:            public static final String N_FLAGS = A_CmsImport.N_FLAGS;
176:
177:            /** Tag in the {@link #EXPORT_MANIFEST} for the "groupdata" node, contains a users group data. 
178:             * @deprecated Use the appropriate tag from latest import class instead*/
179:            public static final String N_GROUPDATA = A_CmsImport.N_GROUPDATA;
180:
181:            /** Tag in the {@link #EXPORT_MANIFEST} for the "groupname" node, contains a groups name. 
182:             * @deprecated Use the appropriate tag from latest import class instead*/
183:            public static final String N_GROUPNAME = A_CmsImport.N_GROUPNAME;
184:
185:            /** Tag in the {@link #EXPORT_MANIFEST} for the "id" node, only required for backward compatibility with import version 2. 
186:             * @deprecated Use the appropriate tag from latest import class instead*/
187:            public static final String N_ID = A_CmsImport.N_ID;
188:
189:            /** Tag in the {@link #EXPORT_MANIFEST}, starts the manifest info header. */
190:            public static final String N_INFO = "info";
191:
192:            /** Tag in the {@link #EXPORT_MANIFEST} for the "lastmodified" node, only required for backward compatibility with import version 2. 
193:             * @deprecated Use the appropriate tag from latest import class instead*/
194:            public static final String N_LASTMODIFIED = A_CmsImport.N_LASTMODIFIED;
195:
196:            /** Tag in the {@link #EXPORT_MANIFEST} for the "lastname" node, contains a users last name. 
197:             * @deprecated Use the appropriate tag from latest import class instead*/
198:            public static final String N_LASTNAME = A_CmsImport.N_LASTNAME;
199:
200:            /** Tag in the {@link #EXPORT_MANIFEST} for the "name" node, contains a users login name. 
201:             * @deprecated Use the appropriate tag from latest import class instead*/
202:            public static final String N_NAME = A_CmsImport.N_NAME;
203:
204:            /** Tag in the {@link #EXPORT_MANIFEST} for the "opencms_version" node, appears in the manifest info header. */
205:            public static final String N_OC_VERSION = "opencms_version";
206:
207:            /** Tag in the {@link #EXPORT_MANIFEST} for the "parentgroup" node, contains a groups parent group name. 
208:             * @deprecated Use the appropriate tag from latest import class instead*/
209:            public static final String N_PARENTGROUP = A_CmsImport.N_PARENTGROUP;
210:
211:            /** Tag in the {@link #EXPORT_MANIFEST} for the "password" node, contains a users encrypted password. 
212:             * @deprecated Use the appropriate tag from latest import class instead*/
213:            public static final String N_PASSWORD = A_CmsImport.N_PASSWORD;
214:
215:            /** Tag in the {@link #EXPORT_MANIFEST} for the "infoproject" node, appears in the manifest info header. */
216:            public static final String N_INFO_PROJECT = "infoproject";
217:
218:            /** Tag in the {@link #EXPORT_MANIFEST} for the "properties" node, starts the list of properties of a VFS resource. 
219:             * @deprecated Use the appropriate tag from latest import class instead*/
220:            public static final String N_PROPERTIES = A_CmsImport.N_PROPERTIES;
221:
222:            /** Tag in the {@link #EXPORT_MANIFEST} for the "property" node, starts a property for a VFS resource. 
223:             * @deprecated Use the appropriate tag from latest import class instead*/
224:            public static final String N_PROPERTY = A_CmsImport.N_PROPERTY;
225:
226:            /** Tag in the {@link #EXPORT_MANIFEST} for the "type" property attribute, contains a property type. 
227:             * @deprecated Use the appropriate tag from latest import class instead*/
228:            public static final String N_PROPERTY_ATTRIB_TYPE = A_CmsImport.N_PROPERTY_ATTRIB_TYPE;
229:
230:            /** Tag in the {@link #EXPORT_MANIFEST} for the "shared" property type attribute value. 
231:             * @deprecated Use the appropriate tag from latest import class instead*/
232:            public static final String N_PROPERTY_ATTRIB_TYPE_SHARED = A_CmsImport.N_PROPERTY_ATTRIB_TYPE_SHARED;
233:
234:            /** Tag in the [@link #EXPORT_MANIFEST} for the "relation" node, starts a relation for a VFS resource. 
235:             * @deprecated Use the appropriate tag from latest import class instead*/
236:            public static final String N_RELATION = A_CmsImport.N_RELATION;
237:
238:            /** Tag in the {@link #EXPORT_MANIFEST} for the "id" relation attribute, contains the structure id of the target resource of the relation. 
239:             * @deprecated Use the appropriate tag from latest import class instead*/
240:            public static final String N_RELATION_ATTRIBUTE_ID = A_CmsImport.N_RELATION_ATTRIBUTE_ID;
241:
242:            /** Tag in the {@link #EXPORT_MANIFEST} for the "path" relation attribute, contains the path to the target resource of the relation. 
243:             * @deprecated Use the appropriate tag from latest import class instead*/
244:            public static final String N_RELATION_ATTRIBUTE_PATH = A_CmsImport.N_RELATION_ATTRIBUTE_PATH;
245:
246:            /** Tag in the {@link #EXPORT_MANIFEST} for the "type" relation attribute, contains the type of relation. 
247:             * @deprecated Use the appropriate tag from latest import class instead*/
248:            public static final String N_RELATION_ATTRIBUTE_TYPE = A_CmsImport.N_RELATION_ATTRIBUTE_TYPE;
249:
250:            /** Tag in the {@link #EXPORT_MANIFEST} for the "relations" node, starts the list of relations of a VFS resources. 
251:             * @deprecated Use the appropriate tag from latest import class instead*/
252:            public static final String N_RELATIONS = A_CmsImport.N_RELATIONS;
253:
254:            /** Tag in the {@link #EXPORT_MANIFEST} for the "source" node, contains the source path of a VFS resource in the import zip (or folder). 
255:             * @deprecated Use the appropriate tag from latest import class instead*/
256:            public static final String N_SOURCE = A_CmsImport.N_SOURCE;
257:
258:            /** Tag in the {@link #EXPORT_MANIFEST} for the "address" node, contains a users address. 
259:             * @deprecated Use the appropriate tag from latest import class instead*/
260:            public static final String N_TAG_ADDRESS = A_CmsImport.N_TAG_ADDRESS;
261:
262:            /** Tag in the {@link #EXPORT_MANIFEST} for the "type" node, the resource type name of a VFS resource. 
263:             * @deprecated Use the appropriate tag from latest import class instead*/
264:            public static final String N_TYPE = A_CmsImport.N_TYPE;
265:
266:            /** Tag in the {@link #EXPORT_MANIFEST} for the "user" node, starts the user data. 
267:             * @deprecated Use the appropriate tag from latest import class instead*/
268:            public static final String N_USER = A_CmsImport.N_USER;
269:
270:            /** Tag in the {@link #EXPORT_MANIFEST} for the "usercreated" node, contains the name of the user who created the VFS resource. 
271:             * @deprecated Use the appropriate tag from latest import class instead*/
272:            public static final String N_USERCREATED = A_CmsImport.N_USERCREATED;
273:
274:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userdata" node, starts the list of users. 
275:             * @deprecated Use the appropriate tag from latest import class instead*/
276:            public static final String N_USERDATA = A_CmsImport.N_USERDATA;
277:
278:            /** Tag in the {@link #EXPORT_MANIFEST} for the "usergroupdatas" node, starts the users group data. 
279:             * @deprecated Use the appropriate tag from latest import class instead*/
280:            public static final String N_USERGROUPDATA = A_CmsImport.N_USERGROUPDATA;
281:
282:            /** Tag in the {@link #EXPORT_MANIFEST} for the "orgunitdatas" node, starts the organizational unit data. 
283:             * @deprecated Use the appropriate tag from latest import class instead*/
284:            public static final String N_ORGUNITDATA = A_CmsImport.N_ORGUNITDATA;
285:
286:            /** Tag in the {@link #EXPORT_MANIFEST} for the "usergroups" node, starts the users group data. 
287:             * @deprecated Use the appropriate tag from latest import class instead*/
288:            public static final String N_USERGROUPS = A_CmsImport.N_USERGROUPS;
289:
290:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userinfo" node, contains the additional user info. 
291:             * @deprecated Use the appropriate tag from latest import class instead*/
292:            public static final String N_USERINFO = A_CmsImport.N_USERINFO;
293:
294:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userinfo/entry" node, contains the additional user info entry value. 
295:             * @deprecated Use the appropriate tag from latest import class instead*/
296:            public static final String N_USERINFO_ENTRY = A_CmsImport.N_USERINFO_ENTRY;
297:
298:            /** Tag in the {@link #EXPORT_MANIFEST} for the "userlastmodified" node, contains the name of the user who last modified the VFS resource. 
299:             * @deprecated Use the appropriate tag from latest import class instead*/
300:            public static final String N_USERLASTMODIFIED = A_CmsImport.N_USERLASTMODIFIED;
301:
302:            /** Tag in the {@link #EXPORT_MANIFEST} for the "uuidresource" node, contains a the resource UUID of a VFS resource. 
303:             * @deprecated Use the appropriate tag from latest import class instead*/
304:            public static final String N_UUIDRESOURCE = A_CmsImport.N_UUIDRESOURCE;
305:
306:            /** Tag in the {@link #EXPORT_MANIFEST} for the "uuidstructure" node, only required for backward compatibility with import version 2. 
307:             * @deprecated Use the appropriate tag from latest import class instead*/
308:            public static final String N_UUIDSTRUCTURE = A_CmsImport.N_UUIDSTRUCTURE;
309:
310:            /** Tag in the {@link #EXPORT_MANIFEST} for the "value" node, contains the value of a property. 
311:             * @deprecated Use the appropriate tag from latest import class instead*/
312:            public static final String N_VALUE = A_CmsImport.N_VALUE;
313:
314:            /** Tag in the {@link #EXPORT_MANIFEST} for the "export_version" node, appears in the manifest info header. */
315:            public static final String N_VERSION = "export_version";
316:
317:            /** The log object for this class. */
318:            private static final Log LOG = CmsLog
319:                    .getLog(CmsImportExportManager.class);
320:
321:            /** Boolean flag whether imported pages should be converted into XML pages. */
322:            private boolean m_convertToXmlPage;
323:
324:            /** The default values of the HTML->OpenCms Template converter. */
325:            private CmsExtendedHtmlImportDefault m_extendedHtmlImportDefault;
326:
327:            /** List of property keys that should be removed from imported resources. */
328:            private List m_ignoredProperties;
329:
330:            /** List of immutable resources that should remain unchanged when resources are imported. */
331:            private List m_immutableResources;
332:
333:            /** The initialized import/export handlers. */
334:            private List m_importExportHandlers;
335:
336:            /** Import principal group translations. */
337:            private Map m_importGroupTranslations;
338:
339:            /** Import principal user translations. */
340:            private Map m_importUserTranslations;
341:
342:            /** The configured import versions class names. */
343:            private List m_importVersionClasses;
344:
345:            /** Boolean flag whether colliding resources should be overwritten during the import. */
346:            private boolean m_overwriteCollidingResources;
347:
348:            /** The user export settings. */
349:            private CmsUserExportSettings m_userExportSettings;
350:
351:            /** The URL of a 4.x OpenCms application to import content correct into 5.x OpenCms application. */
352:            private String m_webAppUrl;
353:
354:            /**
355:             * Creates a new instance for the import/export manager, will be called by the import/export configuration manager.
356:             */
357:            public CmsImportExportManager() {
358:
359:                if (LOG.isInfoEnabled()) {
360:                    LOG.info(Messages.get().getBundle().key(
361:                            Messages.INIT_IMPORTEXPORT_INITIALIZING_0));
362:                }
363:
364:                m_importExportHandlers = new ArrayList();
365:                m_immutableResources = new ArrayList();
366:                m_ignoredProperties = new ArrayList();
367:                m_convertToXmlPage = true;
368:                m_importGroupTranslations = new HashMap();
369:                m_importUserTranslations = new HashMap();
370:                m_overwriteCollidingResources = true;
371:                m_importVersionClasses = new ArrayList();
372:            }
373:
374:            /**
375:             * Adds a property name to the list of properties that should be removed from imported resources.<p>
376:             * 
377:             * @param propertyName a property name
378:             */
379:            public void addIgnoredProperty(String propertyName) {
380:
381:                if (LOG.isDebugEnabled()) {
382:                    LOG.debug(Messages.get().getBundle().key(
383:                            Messages.LOG_IMPORTEXPORT_IGNORING_PROPERTY_1,
384:                            propertyName));
385:                }
386:                m_ignoredProperties.add(propertyName);
387:            }
388:
389:            /**
390:             * Adds a resource to the list of immutable resources that should remain 
391:             * unchanged when resources are imported.<p>
392:             * 
393:             * @param immutableResource a resources uri in the OpenCms VFS
394:             */
395:            public void addImmutableResource(String immutableResource) {
396:
397:                if (LOG.isDebugEnabled()) {
398:                    LOG
399:                            .debug(Messages
400:                                    .get()
401:                                    .getBundle()
402:                                    .key(
403:                                            Messages.LOG_IMPORTEXPORT_ADDED_IMMUTABLE_RESOURCE_1,
404:                                            immutableResource));
405:                }
406:                m_immutableResources.add(immutableResource);
407:            }
408:
409:            /**
410:             * Adds an import/export handler to the list of configured handlers.<p>
411:             * 
412:             * @param handler the import/export handler to add
413:             */
414:            public void addImportExportHandler(I_CmsImportExportHandler handler) {
415:
416:                if (LOG.isDebugEnabled()) {
417:                    LOG
418:                            .debug(Messages
419:                                    .get()
420:                                    .getBundle()
421:                                    .key(
422:                                            Messages.LOG_IMPORTEXPORT_ADDED_IMPORTEXPORT_HANDLER_1,
423:                                            handler));
424:                }
425:                m_importExportHandlers.add(handler);
426:            }
427:
428:            /**
429:             * Adds an import princial translation to the configuration.<p>
430:             * 
431:             * @param type the princial type ("USER" or "GROUP")
432:             * @param from the "from" translation source
433:             * @param to the "to" translation target
434:             */
435:            public void addImportPrincipalTranslation(String type, String from,
436:                    String to) {
437:
438:                if (LOG.isDebugEnabled()) {
439:                    LOG
440:                            .debug(Messages
441:                                    .get()
442:                                    .getBundle()
443:                                    .key(
444:                                            Messages.LOG_IMPORTEXPORT_ADDED_PRINCIPAL_TRANSLATION_3,
445:                                            type, from, to));
446:                }
447:                if (I_CmsPrincipal.PRINCIPAL_GROUP.equalsIgnoreCase(type)) {
448:                    m_importGroupTranslations.put(from, to);
449:                    if (LOG.isInfoEnabled()) {
450:                        LOG
451:                                .info(Messages
452:                                        .get()
453:                                        .getBundle()
454:                                        .key(
455:                                                Messages.INIT_IMPORTEXPORT_ADDED_GROUP_TRANSLATION_2,
456:                                                from, to));
457:                    }
458:                } else if (I_CmsPrincipal.PRINCIPAL_USER.equalsIgnoreCase(type)) {
459:                    m_importUserTranslations.put(from, to);
460:                    if (LOG.isInfoEnabled()) {
461:                        LOG
462:                                .info(Messages
463:                                        .get()
464:                                        .getBundle()
465:                                        .key(
466:                                                Messages.INIT_IMPORTEXPORT_ADDED_USER_TRANSLATION_2,
467:                                                from, to));
468:                    }
469:                }
470:            }
471:
472:            /**
473:             * Adds a import version class name to the configuration.<p>
474:             * 
475:             * @param importVersionClass the import version class name to add
476:             */
477:            public void addImportVersionClass(I_CmsImport importVersionClass) {
478:
479:                if (LOG.isDebugEnabled()) {
480:                    LOG.debug(Messages.get().getBundle().key(
481:                            Messages.LOG_IMPORTEXPORT_ADDED_IMPORT_VERSION_1,
482:                            importVersionClass));
483:                }
484:                m_importVersionClasses.add(importVersionClass);
485:            }
486:
487:            /**
488:             * Checks if imported pages should be converted into XML pages.<p>
489:             * 
490:             * @return true, if imported pages should be converted into XML pages
491:             */
492:            public boolean convertToXmlPage() {
493:
494:                return m_convertToXmlPage;
495:            }
496:
497:            /**
498:             * Checks if the current user has permissions to export Cms data of a specified export handler,
499:             * and if so, triggers the handler to write the export.<p>
500:             * 
501:             * @param cms the cms context
502:             * @param handler handler containing the export data
503:             * @param report the output report
504:             * 
505:             * @throws CmsRoleViolationException if the current user is not a allowed to export the OpenCms database
506:             * @throws CmsImportExportException if operation was not successful
507:             * @throws CmsConfigurationException if something goes wrong
508:             * 
509:             * @see I_CmsImportExportHandler
510:             */
511:            public void exportData(CmsObject cms,
512:                    I_CmsImportExportHandler handler, I_CmsReport report)
513:                    throws CmsConfigurationException, CmsImportExportException,
514:                    CmsRoleViolationException {
515:
516:                OpenCms.getRoleManager().checkRole(cms,
517:                        CmsRole.DATABASE_MANAGER);
518:                handler.exportData(cms, report);
519:            }
520:
521:            /**
522:             * Returns the extendedHtmlImportDefault.<p>
523:             *
524:             * @return the extendedHtmlImportDefault
525:             */
526:            public CmsExtendedHtmlImportDefault getExtendedHtmlImportDefault() {
527:
528:                return getExtendedHtmlImportDefault(false);
529:            }
530:
531:            /**
532:             * Returns the extendedHtmlImportDefault.<p>
533:             *
534:             *@param withNull returns the extendenHtmlImport as null if its null, 
535:             *                otherwise a new CmsExtendedHtmlImportDefault Object is generated
536:             *
537:             * @return the extendedHtmlImportDefault
538:             */
539:            public CmsExtendedHtmlImportDefault getExtendedHtmlImportDefault(
540:                    boolean withNull) {
541:
542:                return (withNull || (m_extendedHtmlImportDefault != null) ? m_extendedHtmlImportDefault
543:                        : new CmsExtendedHtmlImportDefault());
544:            }
545:
546:            /**
547:             * Returns the list of property keys that should be removed from imported resources.<p>
548:             * 
549:             * @return the list of property keys that should be removed from imported resources, or Collections.EMPTY_LIST
550:             */
551:            public List getIgnoredProperties() {
552:
553:                return m_ignoredProperties;
554:            }
555:
556:            /**
557:             * Returns the list of immutable resources that should remain unchanged when resources are 
558:             * imported.<p>
559:             * 
560:             * Certain system resources should not be changed during import. This is the case for the main 
561:             * folders in the /system/ folder. Changes to these folders usually should not be imported to 
562:             * another system.<p>
563:             * 
564:             * @return the list of immutable resources, or {@link Collections#EMPTY_LIST}
565:             */
566:            public List getImmutableResources() {
567:
568:                return m_immutableResources;
569:            }
570:
571:            /**
572:             * Returns an instance of an import/export handler implementation that is able to import
573:             * a specified resource.<p>
574:             * 
575:             * @param parameters the import parameters
576:             * 
577:             * @return an instance of an import/export handler implementation
578:             * 
579:             * @throws CmsImportExportException if something goes wrong
580:             */
581:            public I_CmsImportExportHandler getImportExportHandler(
582:                    CmsImportParameters parameters)
583:                    throws CmsImportExportException {
584:
585:                Document manifest;
586:                InputStream stream = null;
587:                CmsImportHelper helper = new CmsImportHelper(parameters);
588:                try {
589:                    helper.openFile();
590:                    stream = helper
591:                            .getFileStream(CmsImportExportManager.EXPORT_MANIFEST);
592:                    SAXReader reader = new SAXReader(false);
593:                    reader.setValidation(false);
594:                    reader
595:                            .setFeature(
596:                                    "http://apache.org/xml/features/nonvalidating/load-external-dtd",
597:                                    false);
598:                    manifest = reader.read(stream);
599:                } catch (Throwable e) {
600:                    throw new CmsImportExportException(Messages.get()
601:                            .container(
602:                                    Messages.ERR_IMPORTEXPORT_FILE_NOT_FOUND_1,
603:                                    EXPORT_MANIFEST), e);
604:                } finally {
605:                    try {
606:                        if (stream != null) {
607:                            stream.close();
608:                        }
609:                    } catch (Exception e) {
610:                        // noop
611:                    }
612:                    helper.closeFile();
613:                }
614:                for (int i = 0; i < m_importExportHandlers.size(); i++) {
615:                    I_CmsImportExportHandler handler = (I_CmsImportExportHandler) m_importExportHandlers
616:                            .get(i);
617:                    if (handler.matches(manifest)) {
618:                        return handler;
619:                    }
620:                }
621:
622:                CmsMessageContainer message = Messages.get().container(
623:                        Messages.ERR_IMPORTEXPORT_ERROR_NO_HANDLER_FOUND_1,
624:                        EXPORT_MANIFEST);
625:                if (LOG.isDebugEnabled()) {
626:                    LOG.debug(message.key());
627:                }
628:
629:                throw new CmsImportExportException(message);
630:            }
631:
632:            /**
633:             * Returns the list of configured import/export handlers.<p>
634:             * 
635:             * @return the list of configured import/export handlers
636:             */
637:            public List getImportExportHandlers() {
638:
639:                return m_importExportHandlers;
640:            }
641:
642:            /**
643:             * Returns the configured principal group translations.<p>
644:             * 
645:             * @return the configured principal group translations
646:             */
647:            public Map getImportGroupTranslations() {
648:
649:                return m_importGroupTranslations;
650:            }
651:
652:            /**
653:             * Returns the configured principal user translations.<p>
654:             * 
655:             * @return the configured principal user translations
656:             */
657:            public Map getImportUserTranslations() {
658:
659:                return m_importUserTranslations;
660:            }
661:
662:            /**
663:             * Returns the configured import version class names.<p>
664:             * 
665:             * @return the configured import version class names
666:             */
667:            public List getImportVersionClasses() {
668:
669:                return m_importVersionClasses;
670:            }
671:
672:            /**
673:             * Returns the URL of a 4.x OpenCms app. (e.g. http://localhost:8080/opencms/opencms/)
674:             * from which content was exported.<p>
675:             * 
676:             * This setting is required to import content of 4.x OpenCms apps. correct into 5.x OpenCms apps.<p>
677:             * 
678:             * @return the webAppUrl.
679:             */
680:            public String getOldWebAppUrl() {
681:
682:                return m_webAppUrl;
683:            }
684:
685:            /**
686:             * Returns the user settings for export.<p>
687:             * 
688:             * @return the user settings for export
689:             */
690:            public CmsUserExportSettings getUserExportSettings() {
691:
692:                return m_userExportSettings;
693:            }
694:
695:            /**
696:             * Checks if the current user has permissions to import data into the Cms,
697:             * and if so, creates a new import handler instance that imports the data.<p>
698:             * 
699:             * @param cms the current OpenCms context object
700:             * @param report a Cms report to print log messages
701:             * @param parameters the import parameters
702:             * 
703:             * @throws CmsRoleViolationException if the current user is not allowed to import the OpenCms database
704:             * @throws CmsImportExportException if operation was not successful
705:             * @throws CmsXmlException if the manifest of the import could not be unmarshalled
706:             * @throws CmsException in case of errors accessing the VFS
707:             * 
708:             * @see I_CmsImportExportHandler
709:             * @see #importData(CmsObject, String, String, I_CmsReport)
710:             */
711:            public void importData(CmsObject cms, I_CmsReport report,
712:                    CmsImportParameters parameters)
713:                    throws CmsImportExportException, CmsXmlException,
714:                    CmsRoleViolationException, CmsException {
715:
716:                // check the required role permissions
717:                OpenCms.getRoleManager().checkRole(cms,
718:                        CmsRole.DATABASE_MANAGER);
719:
720:                try {
721:                    OpenCms.fireCmsEvent(new CmsEvent(
722:                            I_CmsEventListener.EVENT_CLEAR_CACHES,
723:                            Collections.EMPTY_MAP));
724:                    I_CmsImportExportHandler handler = getImportExportHandler(parameters);
725:                    handler.setImportParameters(parameters);
726:                    handler.importData(cms, report);
727:                } finally {
728:                    OpenCms.fireCmsEvent(new CmsEvent(
729:                            I_CmsEventListener.EVENT_CLEAR_CACHES,
730:                            Collections.EMPTY_MAP));
731:                }
732:            }
733:
734:            /**
735:             * Checks if the current user has permissions to import data into the Cms,
736:             * and if so, creates a new import handler instance that imports the data.<p>
737:             * 
738:             * @param cms the current OpenCms context object
739:             * @param importFile the name (absolute path) of the resource (zipfile or folder) to be imported
740:             * @param importPath the name (absolute path) of the destination folder in the Cms if required, or null
741:             * @param report a Cms report to print log messages
742:             * 
743:             * @throws CmsRoleViolationException if the current user is not allowed to import the OpenCms database
744:             * @throws CmsImportExportException if operation was not successful
745:             * @throws CmsXmlException if the manifest of the import could not be unmarshalled
746:             * @throws CmsException in case of errors accessing the VFS
747:             * 
748:             * @see I_CmsImportExportHandler
749:             * @see #importData(CmsObject, I_CmsReport, CmsImportParameters)
750:             * 
751:             * @deprecated use {@link #importData(CmsObject, I_CmsReport, CmsImportParameters)} instead
752:             */
753:            public void importData(CmsObject cms, String importFile,
754:                    String importPath, I_CmsReport report)
755:                    throws CmsImportExportException, CmsXmlException,
756:                    CmsRoleViolationException, CmsException {
757:
758:                CmsImportParameters parameters = new CmsImportParameters(
759:                        importFile, importPath, false);
760:                importData(cms, report, parameters);
761:            }
762:
763:            /**
764:             * Checks if colliding resources should be overwritten during the import.<p>
765:             * 
766:             * @return true, if colliding resources should be overwritten during the import
767:             * @see #setOverwriteCollidingResources(boolean)
768:             */
769:            public boolean overwriteCollidingResources() {
770:
771:                return m_overwriteCollidingResources;
772:            }
773:
774:            /**
775:             * Sets if imported pages should be converted into XML pages.<p>
776:             * 
777:             * @param convertToXmlPage true, if imported pages should be converted into XML pages.
778:             */
779:            public void setConvertToXmlPage(boolean convertToXmlPage) {
780:
781:                if (LOG.isDebugEnabled()) {
782:                    LOG.debug(Messages.get().getBundle().key(
783:                            Messages.LOG_IMPORTEXPORT_SET_CONVERT_PARAMETER_1,
784:                            Boolean.toString(convertToXmlPage)));
785:                }
786:                m_convertToXmlPage = convertToXmlPage;
787:            }
788:
789:            /**
790:             * Sets if imported pages should be converted into XML pages.<p>
791:             * 
792:             * @param convertToXmlPage <code>"true"</code>, if imported pages should be converted into XML pages.
793:             */
794:            public void setConvertToXmlPage(String convertToXmlPage) {
795:
796:                setConvertToXmlPage(Boolean.valueOf(convertToXmlPage)
797:                        .booleanValue());
798:            }
799:
800:            /**
801:             * Sets the extendedHtmlImportDefault.<p>
802:             *
803:             * @param extendedHtmlImportDefault the extendedHtmlImportDefault to set
804:             */
805:            public void setExtendedHtmlImportDefault(
806:                    CmsExtendedHtmlImportDefault extendedHtmlImportDefault) {
807:
808:                m_extendedHtmlImportDefault = extendedHtmlImportDefault;
809:            }
810:
811:            /**
812:             * Sets the URL of a 4.x OpenCms app. (e.g. http://localhost:8080/opencms/opencms/)
813:             * from which content was exported.<p>
814:             * 
815:             * This setting is required to import content of 4.x OpenCms apps. correct into 5.x OpenCms apps.<p>
816:             * 
817:             * @param webAppUrl a URL of the a OpenCms app. (e.g. http://localhost:8080/opencms/opencms/)
818:             */
819:            public void setOldWebAppUrl(String webAppUrl) {
820:
821:                if (LOG.isDebugEnabled()) {
822:                    LOG.debug(Messages.get().getBundle().key(
823:                            Messages.LOG_IMPORTEXPORT_SET_OLD_WEBAPP_URL_1,
824:                            webAppUrl));
825:                }
826:                m_webAppUrl = webAppUrl;
827:            }
828:
829:            /**
830:             * Sets whether colliding resources should be overwritten during the import for a
831:             * specified import implementation.<p>
832:             * 
833:             * v1 and v2 imports (without resource UUIDs in the manifest) *MUST* overwrite colliding 
834:             * resources. Don't forget to set this flag back to it's original value in v1 and v2
835:             * import implementations!<p>
836:             * 
837:             * This flag must be set to false to force imports > v2 to move colliding resources to 
838:             * /system/lost-found/.<p>
839:             * 
840:             * The import implementation has to take care to set this flag correct!<p>
841:             * 
842:             * @param overwriteCollidingResources true if colliding resources should be overwritten during the import
843:             */
844:            public void setOverwriteCollidingResources(
845:                    boolean overwriteCollidingResources) {
846:
847:                if (LOG.isDebugEnabled()) {
848:                    LOG
849:                            .debug(Messages
850:                                    .get()
851:                                    .getBundle()
852:                                    .key(
853:                                            Messages.LOG_IMPORTEXPORT_SET_OVERWRITE_PARAMETER_1,
854:                                            Boolean
855:                                                    .toString(overwriteCollidingResources)));
856:                }
857:                m_overwriteCollidingResources = overwriteCollidingResources;
858:            }
859:
860:            /**
861:             * @see CmsImportExportManager#setOverwriteCollidingResources(boolean)
862:             * 
863:             * @param overwriteCollidingResources <code>"true"</code> if colliding resources should be overwritten during the import
864:             */
865:            public void setOverwriteCollidingResources(
866:                    String overwriteCollidingResources) {
867:
868:                setOverwriteCollidingResources(Boolean.valueOf(
869:                        overwriteCollidingResources).booleanValue());
870:            }
871:
872:            /**
873:             * Sets the user export settings.<p>
874:             *
875:             * @param userExportSettings the user export settings to set
876:             */
877:            public void setUserExportSettings(
878:                    CmsUserExportSettings userExportSettings) {
879:
880:                m_userExportSettings = userExportSettings;
881:            }
882:
883:            /**
884:             * Returns the translated name for the given group name.<p>
885:             * 
886:             * If no matching name is found, the given group name is returned.<p>
887:             * 
888:             * @param name the group name to translate
889:             * @return the translated name for the given group name
890:             */
891:            public String translateGroup(String name) {
892:
893:                if (m_importGroupTranslations == null) {
894:                    return name;
895:                }
896:                String match = (String) m_importGroupTranslations.get(name);
897:                if (match != null) {
898:                    return match;
899:                } else {
900:                    return name;
901:                }
902:            }
903:
904:            /**
905:             * Returns the translated name for the given user name.<p>
906:             * 
907:             * If no matching name is found, the given user name is returned.<p>
908:             * 
909:             * @param name the user name to translate
910:             * @return the translated name for the given user name
911:             */
912:            public String translateUser(String name) {
913:
914:                if (m_importUserTranslations == null) {
915:                    return name;
916:                }
917:                String match = (String) m_importUserTranslations.get(name);
918:                if (match != null) {
919:                    return match;
920:                } else {
921:                    return name;
922:                }
923:            }
924:
925:            /**
926:             * @see java.lang.Object#finalize()
927:             */
928:            protected void finalize() throws Throwable {
929:
930:                try {
931:                    if (m_immutableResources != null) {
932:                        m_immutableResources.clear();
933:                    }
934:                    if (m_ignoredProperties != null) {
935:                        m_ignoredProperties.clear();
936:                    }
937:                } catch (Throwable t) {
938:                    // noop
939:                }
940:                super.finalize();
941:            }
942:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.