Source Code Cross Referenced for CmsImportVersion7.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) 


0001:        /*
0002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/importexport/CmsImportVersion7.java,v $
0003:         * Date   : $Date: 2008-02-27 12:05:49 $
0004:         * Version: $Revision: 1.4 $
0005:         *
0006:         * This library is part of OpenCms -
0007:         * the Open Source Content Management System
0008:         *
0009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
0010:         *
0011:         * This library is free software; you can redistribute it and/or
0012:         * modify it under the terms of the GNU Lesser General Public
0013:         * License as published by the Free Software Foundation; either
0014:         * version 2.1 of the License, or (at your option) any later version.
0015:         *
0016:         * This library is distributed in the hope that it will be useful,
0017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0019:         * Lesser General Public License for more details.
0020:         *
0021:         * For further information about Alkacon Software GmbH, please see the
0022:         * company website: http://www.alkacon.com
0023:         *
0024:         * For further information about OpenCms, please see the
0025:         * project website: http://www.opencms.org
0026:         * 
0027:         * You should have received a copy of the GNU Lesser General Public
0028:         * License along with this library; if not, write to the Free Software
0029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0030:         */
0031:
0032:        package org.opencms.importexport;
0033:
0034:        import org.opencms.configuration.CmsConfigurationManager;
0035:        import org.opencms.db.CmsDbEntryNotFoundException;
0036:        import org.opencms.file.CmsDataAccessException;
0037:        import org.opencms.file.CmsFile;
0038:        import org.opencms.file.CmsObject;
0039:        import org.opencms.file.CmsProject;
0040:        import org.opencms.file.CmsProperty;
0041:        import org.opencms.file.CmsResource;
0042:        import org.opencms.file.CmsResourceFilter;
0043:        import org.opencms.file.CmsUser;
0044:        import org.opencms.file.CmsVfsResourceNotFoundException;
0045:        import org.opencms.file.types.CmsResourceTypePlain;
0046:        import org.opencms.file.types.I_CmsResourceType;
0047:        import org.opencms.i18n.CmsMessageContainer;
0048:        import org.opencms.loader.CmsLoaderException;
0049:        import org.opencms.lock.CmsLock;
0050:        import org.opencms.main.CmsException;
0051:        import org.opencms.main.CmsIllegalStateException;
0052:        import org.opencms.main.CmsLog;
0053:        import org.opencms.main.OpenCms;
0054:        import org.opencms.relations.CmsRelation;
0055:        import org.opencms.relations.CmsRelationType;
0056:        import org.opencms.relations.I_CmsLinkParseable;
0057:        import org.opencms.report.I_CmsReport;
0058:        import org.opencms.security.CmsAccessControlEntry;
0059:        import org.opencms.security.CmsOrganizationalUnit;
0060:        import org.opencms.security.CmsRole;
0061:        import org.opencms.security.I_CmsPasswordHandler;
0062:        import org.opencms.security.I_CmsPrincipal;
0063:        import org.opencms.util.CmsDataTypeUtil;
0064:        import org.opencms.util.CmsDateUtil;
0065:        import org.opencms.util.CmsStringUtil;
0066:        import org.opencms.util.CmsUUID;
0067:        import org.opencms.xml.CmsXmlEntityResolver;
0068:        import org.opencms.xml.CmsXmlErrorHandler;
0069:
0070:        import java.io.File;
0071:        import java.io.InputStream;
0072:        import java.text.ParseException;
0073:        import java.util.ArrayList;
0074:        import java.util.Collections;
0075:        import java.util.HashMap;
0076:        import java.util.Iterator;
0077:        import java.util.List;
0078:        import java.util.Map;
0079:        import java.util.Map.Entry;
0080:        import java.util.zip.ZipFile;
0081:
0082:        import org.apache.commons.codec.binary.Base64;
0083:        import org.apache.commons.digester.Digester;
0084:        import org.apache.commons.logging.Log;
0085:
0086:        import org.dom4j.Document;
0087:
0088:        /**
0089:         * Adds the XML handler rules for import and export of resources and accounts.<p>
0090:         * 
0091:         * @author Michael Moossen
0092:         * 
0093:         * @version $Revision: 1.4 $ 
0094:         * 
0095:         * @since 7.0.4
0096:         */
0097:        public class CmsImportVersion7 implements  I_CmsImport {
0098:
0099:            /** Tag for the "userinfo/entry@name" attribute, contains the additional user info entry name. */
0100:            public static final String A_NAME = "name";
0101:
0102:            /** Tag for the "type" attribute, contains the property type. */
0103:            public static final String A_TYPE = "type";
0104:
0105:            /** The version number of this import implementation.<p> */
0106:            public static final int IMPORT_VERSION7 = 7;
0107:
0108:            /** Tag for the "allowed" node, to identify allowed user permissions. */
0109:            public static final String N_ACCESSCONTROL_ALLOWEDPERMISSIONS = "allowed";
0110:
0111:            /** Tag for the "denied" node, to identify denied user permissions. */
0112:            public static final String N_ACCESSCONTROL_DENIEDPERMISSIONS = "denied";
0113:
0114:            /** Tag for the "accesscontrol" node, to identify access control entries. */
0115:            public static final String N_ACCESSCONTROL_ENTRIES = "accesscontrol";
0116:
0117:            /** Tag for the "accessentry" node, to identify a single access control entry. */
0118:            public static final String N_ACCESSCONTROL_ENTRY = "accessentry";
0119:
0120:            /** Tag for the "permissionset" node, to identify a permission set. */
0121:            public static final String N_ACCESSCONTROL_PERMISSIONSET = "permissionset";
0122:
0123:            /** Tag for the "uuidprincipal" node, to identify a principal UUID. */
0124:            public static final String N_ACCESSCONTROL_PRINCIPAL = "uuidprincipal";
0125:
0126:            /** Tag for the "accounts" node. */
0127:            public static final String N_ACCOUNTS = "accounts";
0128:
0129:            /** Tag for the "datecreated" node, contains the date created VFS file attribute. */
0130:            public static final String N_DATECREATED = "datecreated";
0131:
0132:            /** Tag for the "dateexpired" node, contains the expiration date VFS file attribute. */
0133:            public static final String N_DATEEXPIRED = "dateexpired";
0134:
0135:            /** Tag for the "datelastmodified" node, contains the date last modified VFS file attribute. */
0136:            public static final String N_DATELASTMODIFIED = "datelastmodified";
0137:
0138:            /** Tag for the "datereleased" node, contains the release date VFS file attribute. */
0139:            public static final String N_DATERELEASED = "datereleased";
0140:
0141:            /** Tag for the "description" node, contains a users description test. */
0142:            public static final String N_DESCRIPTION = "description";
0143:
0144:            /** Tag for the "destination" node, contains target VFS file name. */
0145:            public static final String N_DESTINATION = "destination";
0146:
0147:            /** Tag for the "email" node, contains a users email. */
0148:            public static final String N_EMAIL = "email";
0149:
0150:            /** Tag for the "file" node, container node for all VFS resources. */
0151:            public static final String N_FILE = "file";
0152:
0153:            /** Tag for the "files" node, container node for all VFS resources. */
0154:            public static final String N_FILES = "files";
0155:
0156:            /** Tag for the "firstname" node, contains a users first name. */
0157:            public static final String N_FIRSTNAME = "firstname";
0158:
0159:            /** Tag for the "flags" node, contains the flags of a VFS resource. */
0160:            public static final String N_FLAGS = "flags";
0161:
0162:            /** Tag for the "group" node, contains a group name. */
0163:            public static final String N_GROUP = "group";
0164:
0165:            /** Tag for the "groups" node, contains a users group data. */
0166:            public static final String N_GROUPS = "groups";
0167:
0168:            /** Tag for the "id" relation attribute, contains the structure id of the target resource of the relation. */
0169:            public static final String N_ID = "id";
0170:
0171:            /** Tag for the "lastname" node, contains a users last name. */
0172:            public static final String N_LASTNAME = "lastname";
0173:
0174:            /** Tag for the "managersgroup" node, contains name of the managers group of the project. */
0175:            public static final String N_MANAGERSGROUP = "managersgroup";
0176:
0177:            /** Tag for the "name" node, contains the name of a property. */
0178:            public static final String N_NAME = "name";
0179:
0180:            /** Tag for the "orgunit" node, starts the organizational unit data. */
0181:            public static final String N_ORGUNIT = "orgunit";
0182:
0183:            /** Tag for the "orgunits" node, starts the organizational unit data. */
0184:            public static final String N_ORGUNITS = "orgunits";
0185:
0186:            /** Tag for the "parentgroup" node, contains a groups parent group fqn. */
0187:            public static final String N_PARENTGROUP = "parentgroup";
0188:
0189:            /** Tag for the "password" node, contains a users encrypted password. */
0190:            public static final String N_PASSWORD = "password";
0191:
0192:            /** Tag for the "path" relation attribute, contains the path to the target resource of the relation. */
0193:            public static final String N_PATH = "path";
0194:
0195:            /** Tag for the "project" node, starts the project data. */
0196:            public static final String N_PROJECT = "project";
0197:
0198:            /** Tag for the "projects" node, starts the project data. */
0199:            public static final String N_PROJECTS = "projects";
0200:
0201:            /** Tag for the "properties" node, starts the list of properties of a VFS resource. */
0202:            public static final String N_PROPERTIES = "properties";
0203:
0204:            /** Tag for the "property" node, starts a property for a VFS resource. */
0205:            public static final String N_PROPERTY = "property";
0206:
0207:            /** Tag in the [@link #EXPORT_MANIFEST} for the "relation" node, starts a relation for a VFS resource. */
0208:            public static final String N_RELATION = "relation";
0209:
0210:            /** Tag for the "relations" node, starts the list of relations of a VFS resources. */
0211:            public static final String N_RELATIONS = "relations";
0212:
0213:            /** Tag for the "resource" node, contains the a organizational unit resource name. */
0214:            public static final String N_RESOURCE = "resource";
0215:
0216:            /** Tag for the "resources" node, contains the list of organizational unit resources. */
0217:            public static final String N_RESOURCES = "resources";
0218:
0219:            /** Tag for the "source" node, contains the source path of a VFS resource in the import zip (or folder). */
0220:            public static final String N_SOURCE = "source";
0221:
0222:            /** Tag for the "type" node, the resource type name of a VFS resource. */
0223:            public static final String N_TYPE = "type";
0224:
0225:            /** Tag for the "user" node, starts the user data. */
0226:            public static final String N_USER = "user";
0227:
0228:            /** Tag for the "usercreated" node, contains the name of the user who created the VFS resource. */
0229:            public static final String N_USERCREATED = "usercreated";
0230:
0231:            /** Tag for the "usergroup" node, the name of a users group. */
0232:            public static final String N_USERGROUP = "usergroup";
0233:
0234:            /** Tag for the "usergroups" node, starts the users group data. */
0235:            public static final String N_USERGROUPS = "usergroups";
0236:
0237:            /** Tag for the "userinfo" node, contains the additional user info. */
0238:            public static final String N_USERINFO = "userinfo";
0239:
0240:            /** Tag for the "userinfo/entry" node, contains the additional user info entry value. */
0241:            public static final String N_USERINFO_ENTRY = "entry";
0242:
0243:            /** Tag for the "userlastmodified" node, contains the name of the user who last modified the VFS resource. */
0244:            public static final String N_USERLASTMODIFIED = "userlastmodified";
0245:
0246:            /** Tag for the "userrole" node, contains an users role name. */
0247:            public static final String N_USERROLE = "userrole";
0248:
0249:            /** Tag for the "userroles" node, starts the users role data. */
0250:            public static final String N_USERROLES = "userroles";
0251:
0252:            /** Tag for the "users" node, starts the list of users. */
0253:            public static final String N_USERS = "users";
0254:
0255:            /** Tag for the "usersgroup" node, contains name of the users group of the project. */
0256:            public static final String N_USERSGROUP = "usersgroup";
0257:
0258:            /** Tag for the "uuidresource" node, contains a the resource UUID of a VFS resource. */
0259:            public static final String N_UUIDRESOURCE = "uuidresource";
0260:
0261:            /** Tag for the "uuidstructure" node, only required for backward compatibility with import version 2. */
0262:            public static final String N_UUIDSTRUCTURE = "uuidstructure";
0263:
0264:            /** Tag for the "value" node, contains the value of a property. */
0265:            public static final String N_VALUE = "value";
0266:
0267:            /** Value for the "shared" property type attribute value. */
0268:            public static final String PROPERTY_ATTRIB_TYPE_SHARED = "shared";
0269:
0270:            /** The log object for this class. */
0271:            private static final Log LOG = CmsLog
0272:                    .getLog(CmsImportVersion7.class);
0273:
0274:            /** The ACE flags value. */
0275:            private int m_aceFlags;
0276:
0277:            /** The ACE allowed permissions value. */
0278:            private int m_acePermissionsAllowed;
0279:
0280:            /** The ACE denied permissions value. */
0281:            private int m_acePermissionsDenied;
0282:
0283:            /** The ACE principal id value. */
0284:            private CmsUUID m_acePrincipalId;
0285:
0286:            /** The list of ACEs for the current imported resource. */
0287:            private List m_aces;
0288:
0289:            /** The cms object. */
0290:            private CmsObject m_cms;
0291:
0292:            /** The date created value. */
0293:            private long m_dateCreated;
0294:
0295:            /** The date expired value. */
0296:            private long m_dateExpired = CmsResource.DATE_EXPIRED_DEFAULT;
0297:
0298:            /** The date last modified value. */
0299:            private long m_dateLastModified;
0300:
0301:            /** The date released value. */
0302:            private long m_dateReleased = CmsResource.DATE_RELEASED_DEFAULT;
0303:
0304:            /** The destination value. */
0305:            private String m_destination;
0306:
0307:            /** The current file counter. */
0308:            private int m_fileCounter;
0309:
0310:            /** The flags value. */
0311:            private int m_flags;
0312:
0313:            /** The description of the current group to import. */
0314:            private String m_groupDescription;
0315:
0316:            /** The flags of the current group to import. */
0317:            private int m_groupFlags;
0318:
0319:            /** The name of the current group to import. */
0320:            private String m_groupName;
0321:
0322:            /** The parent of the current group to import. */
0323:            private String m_groupParent;
0324:
0325:            /** Map of all parent groups that could not be set immediately, because of the import order. */
0326:            private Map m_groupParents;
0327:
0328:            /** The import helper. */
0329:            private CmsImportHelper m_helper;
0330:
0331:            /** List of ignored properties. */
0332:            private List m_ignoredProperties;
0333:
0334:            /** List of immutable resources. */
0335:            private List m_immutables;
0336:
0337:            /** The flag to import ACEs. */
0338:            private boolean m_importACEs;
0339:
0340:            private Map m_membership;
0341:
0342:            /** The current imported organizational unit. */
0343:            private CmsOrganizationalUnit m_orgUnit;
0344:
0345:            /** The organizational unit description. */
0346:            private String m_orgUnitDescription;
0347:
0348:            /** The organizational unit flags. */
0349:            private int m_orgUnitFlags;
0350:
0351:            /** The organizational unit fqn. */
0352:            private String m_orgUnitName;
0353:
0354:            /** The map of organizational unit resources, this is a global field that will be use at the end of the import. */
0355:            private Map m_orgUnitResources;
0356:
0357:            /** The import parameters to use. */
0358:            private CmsImportParameters m_parameters;
0359:
0360:            /** The list of resource to be parsed, this is a global list, which will be handled at the end of the import. */
0361:            private List m_parseables;
0362:
0363:            /** The project description. */
0364:            private String m_projectDescription;
0365:
0366:            /** The project managers group name. */
0367:            private String m_projectManagers;
0368:
0369:            /** The project fqn. */
0370:            private String m_projectName;
0371:
0372:            /** The current read project resources. */
0373:            private List m_projectResources;
0374:
0375:            /** The project users group name. */
0376:            private String m_projectUsers;
0377:
0378:            /** The map of properties for current imported resource. */
0379:            private Map m_properties;
0380:
0381:            /** The property name value. */
0382:            private String m_propertyName;
0383:
0384:            /** The property value value. */
0385:            private String m_propertyValue;
0386:
0387:            /** The relation id value. */
0388:            private CmsUUID m_relationId;
0389:
0390:            /** The relation path value. */
0391:            private String m_relationPath;
0392:
0393:            /** The map of relations to be created, this is a global map, which will be handled at the end of the import. */
0394:            private Map m_relations;
0395:
0396:            /** The relation type value. */
0397:            private CmsRelationType m_relationType;
0398:
0399:            /** The report. */
0400:            private I_CmsReport m_report;
0401:
0402:            /** The current imported resource. */
0403:            private CmsResource m_resource;
0404:
0405:            /** The resource id value. */
0406:            private CmsUUID m_resourceId;
0407:
0408:            /** The source value. */
0409:            private String m_source;
0410:
0411:            /** The structure id value. */
0412:            private CmsUUID m_structureId;
0413:
0414:            /** Possible exception during xml parsing. */
0415:            private Throwable m_throwable;
0416:
0417:            /** The total number of files to import. */
0418:            private int m_totalFiles;
0419:
0420:            /** The type value. */
0421:            private I_CmsResourceType m_type;
0422:
0423:            /** The current imported user. */
0424:            private CmsUser m_user;
0425:
0426:            /** The user created value. */
0427:            private CmsUUID m_userCreated;
0428:
0429:            /** The current user date created. */
0430:            private long m_userDateCreated;
0431:
0432:            /** The current user email. */
0433:            private String m_userEmail;
0434:
0435:            /** The current user first name. */
0436:            private String m_userFirstname;
0437:
0438:            /** The current user flags. */
0439:            private int m_userFlags;
0440:
0441:            /** The additional information for the current imported user. */
0442:            private Map m_userInfos;
0443:
0444:            /** The user last modified value. */
0445:            private CmsUUID m_userLastModified;
0446:
0447:            /** The current user last name. */
0448:            private String m_userLastname;
0449:
0450:            /** The current user name. */
0451:            private String m_userName;
0452:
0453:            /** The current user password. */
0454:            private String m_userPassword;
0455:
0456:            /** The export version. */
0457:            private int m_version;
0458:
0459:            /**
0460:             * Public constructor.<p> 
0461:             */
0462:            public CmsImportVersion7() {
0463:
0464:                // empty
0465:            }
0466:
0467:            /**
0468:             * Adds an ACE from the current xml data.<p>
0469:             * 
0470:             * @see #addResourceAceRules(Digester, String)
0471:             */
0472:            public void addAccessControlEntry() {
0473:
0474:                try {
0475:                    if ((m_resource == null) || !m_importACEs) {
0476:                        // skip ace import if not intended or the import of the resource failed 
0477:                        return;
0478:                    }
0479:                    if (m_throwable != null) {
0480:                        // user or group of ACE might not exist in target system, ignore ACE
0481:                        if (LOG.isWarnEnabled()) {
0482:                            LOG
0483:                                    .warn(
0484:                                            Messages
0485:                                                    .get()
0486:                                                    .getBundle()
0487:                                                    .key(
0488:                                                            Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1,
0489:                                                            getCms()
0490:                                                                    .getRequestContext()
0491:                                                                    .removeSiteRoot(
0492:                                                                            m_resource
0493:                                                                                    .getRootPath())),
0494:                                            m_throwable);
0495:                        }
0496:                        getReport().println(m_throwable);
0497:                        getReport().addError(m_throwable);
0498:                        m_throwable = null;
0499:                        return;
0500:                    }
0501:                    if (m_aces == null) {
0502:                        // this list will be used and clean up in the importResource and importAccessControlEntries methods
0503:                        m_aces = new ArrayList();
0504:                    }
0505:                    m_aces.add(new CmsAccessControlEntry(m_resource
0506:                            .getResourceId(), m_acePrincipalId,
0507:                            m_acePermissionsAllowed, m_acePermissionsDenied,
0508:                            m_aceFlags));
0509:                } finally {
0510:                    m_acePrincipalId = null;
0511:                    m_acePermissionsAllowed = 0;
0512:                    m_acePermissionsDenied = 0;
0513:                    m_aceFlags = 0;
0514:                }
0515:            }
0516:
0517:            /**
0518:             * Adds a new resource to be associated to the current organizational unit.<p>
0519:             * 
0520:             * @param resourceName the resource name to add
0521:             */
0522:            public void addOrgUnitResource(String resourceName) {
0523:
0524:                if ((m_throwable != null) || (m_orgUnitName == null)) {
0525:                    return;
0526:                }
0527:                if (m_orgUnitResources == null) {
0528:                    m_orgUnitResources = new HashMap();
0529:                }
0530:                List resources = (List) m_orgUnitResources.get(m_orgUnitName);
0531:                if (resources == null) {
0532:                    resources = new ArrayList();
0533:                    m_orgUnitResources.put(m_orgUnitName, resources);
0534:                }
0535:                resources.add(resourceName);
0536:            }
0537:
0538:            /**
0539:             * Adds a new resource to be associated to the current project.<p>
0540:             * 
0541:             * @param resourceName the resource name to add
0542:             */
0543:            public void addProjectResource(String resourceName) {
0544:
0545:                if ((m_throwable != null) || (m_projectName == null)) {
0546:                    return;
0547:                }
0548:                if (m_projectResources == null) {
0549:                    m_projectResources = new ArrayList();
0550:                }
0551:                m_projectResources.add(resourceName);
0552:            }
0553:
0554:            /**
0555:             * Adds a property from the current xml data, in case the type is implicit given.<p>
0556:             * 
0557:             * @see #addResourcePropertyRules(Digester, String)
0558:             */
0559:            public void addProperty() {
0560:
0561:                addProperty("individual");
0562:            }
0563:
0564:            /**
0565:             * Adds a property from the current xml data, in case the type is explicit given.<p>
0566:             * 
0567:             * @param propertyType the type of the property to be added
0568:             * 
0569:             * @see #addResourcePropertyRules(Digester, String)
0570:             */
0571:            public void addProperty(String propertyType) {
0572:
0573:                if (m_properties == null) {
0574:                    // this list will be used and clean up in the importResource method
0575:                    m_properties = new HashMap();
0576:                }
0577:                try {
0578:                    if ((m_propertyName == null)
0579:                            || getIgnoredProperties().contains(m_propertyName)) {
0580:                        // continue if the current property (name) should be ignored or is null
0581:                        return;
0582:                    }
0583:                    CmsProperty property = (CmsProperty) m_properties
0584:                            .get(m_propertyName);
0585:                    if (property == null) {
0586:                        property = new CmsProperty();
0587:                        property.setName(m_propertyName);
0588:                        property.setAutoCreatePropertyDefinition(true);
0589:                        m_properties.put(m_propertyName, property);
0590:                    }
0591:
0592:                    if (m_propertyValue == null) {
0593:                        m_propertyValue = "";
0594:                    }
0595:
0596:                    if ((propertyType != null)
0597:                            && propertyType.equals(PROPERTY_ATTRIB_TYPE_SHARED)) {
0598:                        // it is a shared/resource property value
0599:                        property.setResourceValue(m_propertyValue);
0600:                    } else {
0601:                        // it is an individual/structure value
0602:                        property.setStructureValue(m_propertyValue);
0603:                    }
0604:                } finally {
0605:                    m_propertyName = null;
0606:                    m_propertyValue = null;
0607:                }
0608:            }
0609:
0610:            /**
0611:             * Adds a relation to be imported from the current xml data.<p>
0612:             * 
0613:             * @see #addResourceRelationRules(Digester, String)
0614:             */
0615:            public void addRelation() {
0616:
0617:                if (m_relations == null) {
0618:                    m_relations = new HashMap();
0619:                }
0620:                try {
0621:                    if (m_resource == null) {
0622:                        // skip relation import if the import of the resource failed 
0623:                        return;
0624:                    }
0625:                    if (m_throwable != null) {
0626:                        // relation data is corrupt, ignore relation
0627:                        if (LOG.isWarnEnabled()) {
0628:                            LOG
0629:                                    .warn(
0630:                                            Messages
0631:                                                    .get()
0632:                                                    .getBundle()
0633:                                                    .key(
0634:                                                            Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_RELATION_1,
0635:                                                            getCms()
0636:                                                                    .getRequestContext()
0637:                                                                    .removeSiteRoot(
0638:                                                                            m_resource
0639:                                                                                    .getRootPath())),
0640:                                            m_throwable);
0641:                        }
0642:                        getReport().println(m_throwable);
0643:                        getReport().addError(m_throwable);
0644:                        m_throwable = null;
0645:                        return;
0646:                    }
0647:                    List currentRelations = (List) m_relations.get(m_resource
0648:                            .getRootPath());
0649:                    if (currentRelations == null) {
0650:                        currentRelations = new ArrayList();
0651:                        m_relations.put(m_resource.getRootPath(),
0652:                                currentRelations);
0653:                    }
0654:                    currentRelations.add(new CmsRelation(m_resource
0655:                            .getStructureId(), m_resource.getRootPath(),
0656:                            m_relationId, m_relationPath, m_relationType));
0657:                } finally {
0658:                    m_relationId = null;
0659:                    m_relationPath = null;
0660:                    m_relationType = null;
0661:                }
0662:            }
0663:
0664:            /**
0665:             * Adds the XML digester rules for a single import file.<p>
0666:             * 
0667:             * @param digester the digester to add the rules to
0668:             */
0669:            public void addXmlDigesterRules(Digester digester) {
0670:
0671:                // first accounts
0672:                String xpath = CmsImportExportManager.N_EXPORT + "/"
0673:                        + N_ACCOUNTS + "/" + N_ORGUNITS + "/" + N_ORGUNIT + "/";
0674:                addAccountsOrgunitRules(digester, xpath);
0675:                addAccountsGroupRules(digester, xpath);
0676:                addAccountsUserRules(digester, xpath);
0677:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0678:                        + N_ACCOUNTS + "/" + N_ORGUNITS + "/" + N_ORGUNIT,
0679:                        "setMembership");
0680:
0681:                // then resources
0682:                xpath = CmsImportExportManager.N_EXPORT + "/" + N_FILES + "/"
0683:                        + N_FILE + "/";
0684:                addResourceAttributesRules(digester, xpath);
0685:                addResourcePropertyRules(digester, xpath);
0686:                addResourceRelationRules(digester, xpath);
0687:                addResourceAceRules(digester, xpath);
0688:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0689:                        + N_FILES + "/" + N_FILE, "increaseCounter");
0690:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0691:                        + N_FILES, "importRelations");
0692:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0693:                        + N_FILES, "rewriteParseables");
0694:
0695:                // and now the organizational unit resources
0696:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0697:                        + N_FILES, "associateOrgUnitResources");
0698:
0699:                // then projects
0700:                xpath = CmsImportExportManager.N_EXPORT + "/" + N_PROJECTS
0701:                        + "/" + N_PROJECT + "/";
0702:                addProjectRules(digester, xpath);
0703:            }
0704:
0705:            /**
0706:             * Adds the XML digester rules for pre-processing a single import file.<p>
0707:             * 
0708:             * @param digester the digester to add the rules to
0709:             */
0710:            public void addXmlPreprocessingDigesterRules(Digester digester) {
0711:
0712:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0713:                        + N_FILES + "/" + N_FILE, "increaseTotalFiles");
0714:                digester.addCallMethod(CmsImportExportManager.N_EXPORT + "/"
0715:                        + CmsImportExportManager.N_INFO + "/"
0716:                        + CmsImportExportManager.N_VERSION, "setVersion", 0);
0717:            }
0718:
0719:            /**
0720:             * Associates the stored resources to the created organizational units.<p>
0721:             * 
0722:             * This is a global process that occurs only once at the end of the import, 
0723:             * after all resources have been imported, to make sure that the resources
0724:             * of the organizational units are available.<p>
0725:             * 
0726:             * @see #addAccountsOrgunitRules(Digester, String)
0727:             * @see #addXmlDigesterRules(Digester)
0728:             */
0729:            public void associateOrgUnitResources() {
0730:
0731:                if ((m_orgUnitResources == null)
0732:                        || m_orgUnitResources.isEmpty()) {
0733:                    // no organizational resources to associate
0734:                    return;
0735:                }
0736:
0737:                String site = getCms().getRequestContext().getSiteRoot();
0738:                try {
0739:                    getCms().getRequestContext().setSiteRoot("");
0740:                    List orgUnits = new ArrayList(m_orgUnitResources.keySet());
0741:                    Collections.sort(orgUnits);
0742:                    Iterator it = orgUnits.iterator();
0743:                    while (it.hasNext()) {
0744:                        String orgUnitName = (String) it.next();
0745:                        List resources = (List) m_orgUnitResources
0746:                                .get(orgUnitName);
0747:
0748:                        if (orgUnitName.equals("")) {
0749:                            continue;
0750:                        }
0751:
0752:                        Iterator itResources = resources.iterator();
0753:                        while (itResources.hasNext()) {
0754:                            String resourceName = (String) itResources.next();
0755:                            try {
0756:                                // Add the resource to the organizational unit
0757:                                OpenCms.getOrgUnitManager()
0758:                                        .addResourceToOrgUnit(getCms(),
0759:                                                orgUnitName, resourceName);
0760:                            } catch (CmsException e) {
0761:                                getReport().addWarning(e);
0762:                                if (LOG.isWarnEnabled()) {
0763:                                    LOG.warn(e.getLocalizedMessage());
0764:                                }
0765:                                if (LOG.isDebugEnabled()) {
0766:                                    LOG.debug(e.getLocalizedMessage(), e);
0767:                                }
0768:                            }
0769:                        }
0770:
0771:                        // remove the meanwhile used first resource of the parent organizational unit
0772:                        try {
0773:                            String resName = ((CmsResource) OpenCms
0774:                                    .getOrgUnitManager()
0775:                                    .getResourcesForOrganizationalUnit(
0776:                                            getCms(),
0777:                                            CmsOrganizationalUnit
0778:                                                    .getParentFqn(orgUnitName))
0779:                                    .get(0)).getRootPath();
0780:                            if (!resources.contains(resName)) {
0781:                                OpenCms.getOrgUnitManager()
0782:                                        .removeResourceFromOrgUnit(getCms(),
0783:                                                orgUnitName, resName);
0784:                            }
0785:                        } catch (CmsException e) {
0786:                            getReport().addWarning(e);
0787:                            if (LOG.isWarnEnabled()) {
0788:                                LOG.warn(e.getLocalizedMessage());
0789:                            }
0790:                            if (LOG.isDebugEnabled()) {
0791:                                LOG.debug(e.getLocalizedMessage(), e);
0792:                            }
0793:                        }
0794:
0795:                    }
0796:                } finally {
0797:                    getCms().getRequestContext().setSiteRoot(site);
0798:                }
0799:
0800:                m_orgUnitResources = null;
0801:            }
0802:
0803:            /**
0804:             * Returns the ace Flags.<p>
0805:             *
0806:             * @return the ace Flags
0807:             * 
0808:             * @see #N_FLAGS
0809:             * @see #addResourceAceRules(Digester, String)
0810:             */
0811:            public int getAceFlags() {
0812:
0813:                return m_aceFlags;
0814:            }
0815:
0816:            /**
0817:             * Returns the ace Permissions Allowed.<p>
0818:             *
0819:             * @return the ace Permissions Allowed
0820:             * 
0821:             * @see #N_ACCESSCONTROL_ALLOWEDPERMISSIONS
0822:             * @see #addResourceAceRules(Digester, String)
0823:             */
0824:            public int getAcePermissionsAllowed() {
0825:
0826:                return m_acePermissionsAllowed;
0827:            }
0828:
0829:            /**
0830:             * Returns the acePermissionsDenied.<p>
0831:             *
0832:             * @return the acePermissionsDenied
0833:             * 
0834:             * @see #N_ACCESSCONTROL_DENIEDPERMISSIONS
0835:             * @see #addResourceAceRules(Digester, String)
0836:             */
0837:            public int getAcePermissionsDenied() {
0838:
0839:                return m_acePermissionsDenied;
0840:            }
0841:
0842:            /**
0843:             * Returns the acePrincipalId.<p>
0844:             *
0845:             * @return the acePrincipalId
0846:             * 
0847:             * @see #N_ACCESSCONTROL_PRINCIPAL
0848:             * @see #addResourceAceRules(Digester, String)
0849:             */
0850:            public CmsUUID getAcePrincipalId() {
0851:
0852:                return m_acePrincipalId;
0853:            }
0854:
0855:            /**
0856:             * Returns the cms object.<p>
0857:             *
0858:             * @return the cms object
0859:             */
0860:            public CmsObject getCms() {
0861:
0862:                return m_cms;
0863:            }
0864:
0865:            /**
0866:             * Returns the dateCreated.<p>
0867:             *
0868:             * @return the dateCreated
0869:             * 
0870:             * @see #N_DATECREATED
0871:             * @see #addResourceAttributesRules(Digester, String)
0872:             */
0873:            public long getDateCreated() {
0874:
0875:                return m_dateCreated;
0876:            }
0877:
0878:            /**
0879:             * Returns the dateExpired.<p>
0880:             *
0881:             * @return the dateExpired
0882:             * 
0883:             * @see #N_DATEEXPIRED
0884:             * @see #addResourceAttributesRules(Digester, String)
0885:             */
0886:            public long getDateExpired() {
0887:
0888:                return m_dateExpired;
0889:            }
0890:
0891:            /**
0892:             * Returns the dateLastModified.<p>
0893:             *
0894:             * @return the dateLastModified
0895:             * 
0896:             * @see #N_DATELASTMODIFIED
0897:             * @see #addResourceAttributesRules(Digester, String)
0898:             */
0899:            public long getDateLastModified() {
0900:
0901:                return m_dateLastModified;
0902:            }
0903:
0904:            /**
0905:             * Returns the dateReleased.<p>
0906:             *
0907:             * @return the dateReleased
0908:             * 
0909:             * @see #N_DATERELEASED
0910:             * @see #addResourceAttributesRules(Digester, String)
0911:             */
0912:            public long getDateReleased() {
0913:
0914:                return m_dateReleased;
0915:            }
0916:
0917:            /**
0918:             * Returns the destination.<p>
0919:             *
0920:             * @return the destination
0921:             * 
0922:             * @see #N_DESTINATION
0923:             * @see #addResourceAttributesRules(Digester, String)
0924:             */
0925:            public String getDestination() {
0926:
0927:                return m_destination;
0928:            }
0929:
0930:            /**
0931:             * Returns the flags.<p>
0932:             *
0933:             * @return the flags
0934:             * 
0935:             * @see #N_FLAGS
0936:             * @see #addResourceAttributesRules(Digester, String)
0937:             */
0938:            public int getFlags() {
0939:
0940:                return m_flags;
0941:            }
0942:
0943:            /**
0944:             * Returns the group Description.<p>
0945:             *
0946:             * @return the group Description
0947:             */
0948:            public String getGroupDescription() {
0949:
0950:                return m_groupDescription;
0951:            }
0952:
0953:            /**
0954:             * Returns the group Flags.<p>
0955:             *
0956:             * @return the group Flags
0957:             */
0958:            public int getGroupFlags() {
0959:
0960:                return m_groupFlags;
0961:            }
0962:
0963:            /**
0964:             * Returns the group Name.<p>
0965:             *
0966:             * @return the group Name
0967:             */
0968:            public String getGroupName() {
0969:
0970:                return m_groupName;
0971:            }
0972:
0973:            /**
0974:             * Returns the group Parent.<p>
0975:             *
0976:             * @return the group Parent
0977:             */
0978:            public String getGroupParent() {
0979:
0980:                return m_groupParent;
0981:            }
0982:
0983:            /**
0984:             * Returns the organizational unit description.<p>
0985:             *
0986:             * @return the organizational unit description
0987:             */
0988:            public String getOrgUnitDescription() {
0989:
0990:                return m_orgUnitDescription;
0991:            }
0992:
0993:            /**
0994:             * Returns the organizational unit flags.<p>
0995:             *
0996:             * @return the organizational unit flags
0997:             */
0998:            public int getOrgUnitFlags() {
0999:
1000:                return m_orgUnitFlags;
1001:            }
1002:
1003:            /**
1004:             * Returns the organizational unit name.<p>
1005:             *
1006:             * @return the organizational unit name
1007:             */
1008:            public String getOrgUnitName() {
1009:
1010:                return m_orgUnitName;
1011:            }
1012:
1013:            /**
1014:             * Returns the project Description.<p>
1015:             *
1016:             * @return the project Description
1017:             */
1018:            public String getProjectDescription() {
1019:
1020:                return m_projectDescription;
1021:            }
1022:
1023:            /**
1024:             * Returns the project Managers group name.<p>
1025:             *
1026:             * @return the project Managers group name
1027:             */
1028:            public String getProjectManagers() {
1029:
1030:                return m_projectManagers;
1031:            }
1032:
1033:            /**
1034:             * Returns the project Name.<p>
1035:             *
1036:             * @return the project Name
1037:             */
1038:            public String getProjectName() {
1039:
1040:                return m_projectName;
1041:            }
1042:
1043:            /**
1044:             * Returns the project Users group name.<p>
1045:             *
1046:             * @return the project Users group name
1047:             */
1048:            public String getProjectUsers() {
1049:
1050:                return m_projectUsers;
1051:            }
1052:
1053:            /**
1054:             * Returns the propertyName.<p>
1055:             *
1056:             * @return the propertyName
1057:             * 
1058:             * @see #N_NAME
1059:             * @see #addResourcePropertyRules(Digester, String)
1060:             */
1061:            public String getPropertyName() {
1062:
1063:                return m_propertyName;
1064:            }
1065:
1066:            /**
1067:             * Returns the propertyValue.<p>
1068:             *
1069:             * @return the propertyValue
1070:             * 
1071:             * @see #N_VALUE
1072:             * @see #addResourcePropertyRules(Digester, String)
1073:             */
1074:            public String getPropertyValue() {
1075:
1076:                return m_propertyValue;
1077:            }
1078:
1079:            /**
1080:             * Returns the relationId.<p>
1081:             *
1082:             * @return the relationId
1083:             * 
1084:             * @see #N_ID
1085:             * @see #addResourceRelationRules(Digester, String)
1086:             */
1087:            public CmsUUID getRelationId() {
1088:
1089:                return m_relationId;
1090:            }
1091:
1092:            /**
1093:             * Returns the relationPath.<p>
1094:             *
1095:             * @return the relationPath
1096:             * 
1097:             * @see #N_PATH
1098:             * @see #addResourceRelationRules(Digester, String)
1099:             */
1100:            public String getRelationPath() {
1101:
1102:                return m_relationPath;
1103:            }
1104:
1105:            /**
1106:             * Returns the relationType.<p>
1107:             *
1108:             * @return the relationType
1109:             * 
1110:             * @see #N_TYPE
1111:             * @see #addResourceRelationRules(Digester, String)
1112:             */
1113:            public CmsRelationType getRelationType() {
1114:
1115:                return m_relationType;
1116:            }
1117:
1118:            /**
1119:             * Returns the report.<p>
1120:             *
1121:             * @return the report
1122:             */
1123:            public I_CmsReport getReport() {
1124:
1125:                return m_report;
1126:            }
1127:
1128:            /**
1129:             * Returns the resourceId.<p>
1130:             *
1131:             * @return the resourceId
1132:             * 
1133:             * @see #N_UUIDRESOURCE
1134:             * @see #addResourceAttributesRules(Digester, String)
1135:             */
1136:            public CmsUUID getResourceId() {
1137:
1138:                return m_resourceId;
1139:            }
1140:
1141:            /**
1142:             * Returns the source.<p>
1143:             *
1144:             * @return the source
1145:             * 
1146:             * @see #N_SOURCE
1147:             * @see #addResourceAttributesRules(Digester, String)
1148:             */
1149:            public String getSource() {
1150:
1151:                return m_source;
1152:            }
1153:
1154:            /**
1155:             * Returns the structureId.<p>
1156:             *
1157:             * @return the structureId
1158:             * 
1159:             * @see #N_UUIDSTRUCTURE
1160:             * @see #addResourceAttributesRules(Digester, String)
1161:             */
1162:            public CmsUUID getStructureId() {
1163:
1164:                return m_structureId;
1165:            }
1166:
1167:            /**
1168:             * Returns the throwable.<p>
1169:             *
1170:             * @return the throwable
1171:             */
1172:            public Throwable getThrowable() {
1173:
1174:                return m_throwable;
1175:            }
1176:
1177:            /**
1178:             * Returns the type.<p>
1179:             *
1180:             * @return the type
1181:             * 
1182:             * @see #N_TYPE
1183:             * @see #addResourceAttributesRules(Digester, String)
1184:             */
1185:            public I_CmsResourceType getType() {
1186:
1187:                return m_type;
1188:            }
1189:
1190:            /**
1191:             * Returns the userCreated.<p>
1192:             *
1193:             * @return the userCreated
1194:             * 
1195:             * @see #N_USERCREATED
1196:             * @see #addResourceAttributesRules(Digester, String)
1197:             */
1198:            public CmsUUID getUserCreated() {
1199:
1200:                return m_userCreated;
1201:            }
1202:
1203:            /**
1204:             * Returns the user Date Created.<p>
1205:             *
1206:             * @return the user Date Created
1207:             */
1208:            public long getUserDateCreated() {
1209:
1210:                return m_userDateCreated;
1211:            }
1212:
1213:            /**
1214:             * Returns the user Email address.<p>
1215:             *
1216:             * @return the user Email address
1217:             */
1218:            public String getUserEmail() {
1219:
1220:                return m_userEmail;
1221:            }
1222:
1223:            /**
1224:             * Returns the user First name.<p>
1225:             *
1226:             * @return the user First name
1227:             */
1228:            public String getUserFirstname() {
1229:
1230:                return m_userFirstname;
1231:            }
1232:
1233:            /**
1234:             * Returns the user Flags.<p>
1235:             *
1236:             * @return the user Flags
1237:             */
1238:            public int getUserFlags() {
1239:
1240:                return m_userFlags;
1241:            }
1242:
1243:            /**
1244:             * Returns the userLastModified.<p>
1245:             *
1246:             * @return the userLastModified
1247:             * 
1248:             * @see #N_USERLASTMODIFIED
1249:             * @see #addResourceAttributesRules(Digester, String)
1250:             */
1251:            public CmsUUID getUserLastModified() {
1252:
1253:                return m_userLastModified;
1254:            }
1255:
1256:            /**
1257:             * Returns the user Last name.<p>
1258:             *
1259:             * @return the user Last name
1260:             */
1261:            public String getUserLastname() {
1262:
1263:                return m_userLastname;
1264:            }
1265:
1266:            /**
1267:             * Returns the user Name.<p>
1268:             *
1269:             * @return the user Name
1270:             */
1271:            public String getUserName() {
1272:
1273:                return m_userName;
1274:            }
1275:
1276:            /**
1277:             * Returns the user Password.<p>
1278:             *
1279:             * @return the user Password
1280:             */
1281:            public String getUserPassword() {
1282:
1283:                return m_userPassword;
1284:            }
1285:
1286:            /**
1287:             * @see org.opencms.importexport.I_CmsImport#getVersion()
1288:             */
1289:            public int getVersion() {
1290:
1291:                return IMPORT_VERSION7;
1292:            }
1293:
1294:            /**
1295:             * Imports an ACE from the current xml data.<p>
1296:             * 
1297:             * @see #addResourceAceRules(Digester, String)
1298:             */
1299:            public void importAccessControlEntries() {
1300:
1301:                // only set permissions if the resource did not exists or if the keep permissions flag is not set
1302:                if ((m_resource == null) || !m_importACEs) {
1303:                    return;
1304:                }
1305:                if ((m_aces == null) || (m_aces.size() == 0)) {
1306:                    // no ACE in the list
1307:                    return;
1308:                }
1309:                // if the resource was imported add the access control entries if available
1310:                try {
1311:                    getCms().importAccessControlEntries(m_resource, m_aces);
1312:                } catch (CmsException exc) {
1313:                    getReport().println(
1314:                            Messages.get().container(
1315:                                    Messages.RPT_IMPORT_ACL_DATA_FAILED_0),
1316:                            I_CmsReport.FORMAT_WARNING);
1317:                } finally {
1318:                    m_aces = null;
1319:                }
1320:            }
1321:
1322:            /**
1323:             * @see org.opencms.importexport.I_CmsImport#importData(CmsObject, I_CmsReport, CmsImportParameters)
1324:             */
1325:            public void importData(CmsObject cms, I_CmsReport report,
1326:                    CmsImportParameters parameters) {
1327:
1328:                m_cms = cms;
1329:                m_report = report;
1330:                m_parameters = parameters;
1331:
1332:                // instantiate Digester and enable XML validation
1333:                Digester digester = new Digester();
1334:                digester.setUseContextClassLoader(true);
1335:                digester.setValidating(m_parameters.isXmlValidation());
1336:                digester.setEntityResolver(new CmsXmlEntityResolver(null));
1337:                digester.setRuleNamespaceURI(null);
1338:                digester.setErrorHandler(new CmsXmlErrorHandler(
1339:                        CmsImportExportManager.EXPORT_MANIFEST));
1340:
1341:                // add this object to the Digester
1342:                digester.push(this );
1343:
1344:                addXmlDigesterRules(digester);
1345:
1346:                InputStream stream = null;
1347:                m_helper = new CmsImportHelper(m_parameters);
1348:                try {
1349:                    m_helper.openFile();
1350:                    m_helper.cacheDtdSystemId(DTD_LOCATION, DTD_FILENAME,
1351:                            CmsConfigurationManager.DEFAULT_DTD_PREFIX);
1352:                    // start the parsing process
1353:                    stream = m_helper
1354:                            .getFileStream(CmsImportExportManager.EXPORT_MANIFEST);
1355:                    digester.parse(stream);
1356:                } catch (Exception ioe) {
1357:                    if (LOG.isErrorEnabled()) {
1358:                        LOG.error(Messages.get().getBundle().key(
1359:                                Messages.ERR_IMPORTEXPORT_ERROR_READING_FILE_1,
1360:                                CmsImportExportManager.EXPORT_MANIFEST), ioe);
1361:                    }
1362:                    getReport().println(ioe);
1363:                } finally {
1364:                    try {
1365:                        if (stream != null) {
1366:                            stream.close();
1367:                        }
1368:                    } catch (Exception e) {
1369:                        // noop
1370:                    }
1371:                    m_helper.closeFile();
1372:                }
1373:            }
1374:
1375:            /**
1376:             * Import the current group from xml data.<p>
1377:             */
1378:            public void importGroup() {
1379:
1380:                if (m_orgUnit == null) {
1381:                    return;
1382:                }
1383:                if (m_groupDescription == null) {
1384:                    m_groupDescription = "";
1385:                }
1386:                if (m_groupParents == null) {
1387:                    m_groupParents = new HashMap();
1388:                }
1389:
1390:                String groupName = m_orgUnit.getName() + m_groupName;
1391:                try {
1392:                    if (m_throwable != null) {
1393:                        getReport().println(m_throwable);
1394:
1395:                        CmsMessageContainer message = Messages
1396:                                .get()
1397:                                .container(
1398:                                        Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_GROUP_1,
1399:                                        groupName);
1400:                        if (LOG.isDebugEnabled()) {
1401:                            LOG.debug(message.key(), m_throwable);
1402:                        }
1403:                        m_throwable = null;
1404:                        return;
1405:                    }
1406:
1407:                    getReport().print(
1408:                            Messages.get().container(
1409:                                    Messages.RPT_IMPORT_GROUP_0),
1410:                            I_CmsReport.FORMAT_NOTE);
1411:                    getReport().print(
1412:                            org.opencms.report.Messages.get().container(
1413:                                    org.opencms.report.Messages.RPT_ARGUMENT_1,
1414:                                    groupName));
1415:                    getReport().print(
1416:                            org.opencms.report.Messages.get().container(
1417:                                    org.opencms.report.Messages.RPT_DOTS_0));
1418:
1419:                    try {
1420:                        getCms().readGroup(groupName);
1421:                        // the group already exists and will not be created
1422:                        getReport().println(
1423:                                Messages.get().container(
1424:                                        Messages.RPT_NOT_CREATED_0),
1425:                                I_CmsReport.FORMAT_OK);
1426:                    } catch (CmsDbEntryNotFoundException e) {
1427:                        // ok, let's create it
1428:                        // first check the parent group
1429:                        CmsUUID parentGroupId = null;
1430:                        if (CmsStringUtil.isNotEmpty(m_groupParent)) {
1431:                            try {
1432:                                // parent group exists
1433:                                parentGroupId = getCms().readGroup(
1434:                                        m_groupParent).getId();
1435:                            } catch (CmsDbEntryNotFoundException exc) {
1436:                                // parent group does not exist, remember to set the parent group later
1437:                                List childs = (List) m_groupParents
1438:                                        .get(m_groupParent);
1439:                                if (childs == null) {
1440:                                    childs = new ArrayList();
1441:                                    m_groupParents.put(m_groupParent, childs);
1442:                                }
1443:                                childs.add(groupName);
1444:                            }
1445:                        }
1446:
1447:                        getCms().createGroup(groupName, m_groupDescription,
1448:                                m_groupFlags,
1449:                                parentGroupId == null ? null : m_groupParent);
1450:                        getReport().println(
1451:                                org.opencms.report.Messages.get().container(
1452:                                        org.opencms.report.Messages.RPT_OK_0),
1453:                                I_CmsReport.FORMAT_OK);
1454:
1455:                        // set parents that could not be set before
1456:                        List childs = (List) m_groupParents.remove(groupName);
1457:                        if (childs != null) {
1458:                            Iterator it = childs.iterator();
1459:                            while (it.hasNext()) {
1460:                                String childGroup = (String) it.next();
1461:                                getCms().setParentGroup(childGroup, groupName);
1462:                            }
1463:                        }
1464:                    }
1465:                } catch (Exception e) {
1466:                    getReport().println(e);
1467:
1468:                    CmsMessageContainer message = Messages.get().container(
1469:                            Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_GROUP_1,
1470:                            groupName);
1471:                    if (LOG.isDebugEnabled()) {
1472:                        LOG.debug(message.key(), e);
1473:                    }
1474:                } finally {
1475:                    m_groupDescription = null;
1476:                    m_groupFlags = 0;
1477:                    m_groupName = null;
1478:                    m_groupParent = null;
1479:                    m_throwable = null;
1480:                }
1481:            }
1482:
1483:            /**
1484:             * Imports the current organizational unit.<p>
1485:             */
1486:            public void importOrgUnit() {
1487:
1488:                try {
1489:                    if (m_throwable != null) {
1490:                        getReport().println(m_throwable);
1491:                        getReport().addError(m_throwable);
1492:
1493:                        CmsMessageContainer message = Messages
1494:                                .get()
1495:                                .container(
1496:                                        Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_ORGUNITS_0);
1497:                        if (LOG.isDebugEnabled()) {
1498:                            LOG.debug(message.key(), m_throwable);
1499:                        }
1500:                        m_throwable = null;
1501:                        m_orgUnit = null;
1502:
1503:                        return;
1504:                    }
1505:
1506:                    getReport().print(
1507:                            Messages.get().container(
1508:                                    Messages.RPT_IMPORT_ORGUNIT_0),
1509:                            I_CmsReport.FORMAT_NOTE);
1510:                    getReport().print(
1511:                            org.opencms.report.Messages.get().container(
1512:                                    org.opencms.report.Messages.RPT_ARGUMENT_1,
1513:                                    m_orgUnitName));
1514:                    getReport().print(
1515:                            org.opencms.report.Messages.get().container(
1516:                                    org.opencms.report.Messages.RPT_DOTS_0));
1517:
1518:                    try {
1519:                        m_orgUnit = OpenCms
1520:                                .getOrgUnitManager()
1521:                                .readOrganizationalUnit(getCms(), m_orgUnitName);
1522:                        // the organizational unit already exists and will not be created
1523:                        getReport().println(
1524:                                Messages.get().container(
1525:                                        Messages.RPT_NOT_CREATED_0),
1526:                                I_CmsReport.FORMAT_OK);
1527:                        m_orgUnitResources.remove(m_orgUnitName);
1528:                        return;
1529:                    } catch (CmsDataAccessException e) {
1530:                        // ok, continue creating the ou
1531:                    }
1532:
1533:                    // get the resources that already exist for the organizational unit
1534:                    // if there are resources that does not exist jet, there will be a second try after importing resources       
1535:                    List resources = new ArrayList();
1536:                    String site = getCms().getRequestContext().getSiteRoot();
1537:                    try {
1538:                        getCms().getRequestContext().setSiteRoot("");
1539:
1540:                        boolean remove = true;
1541:                        Iterator itResNames = ((List) m_orgUnitResources
1542:                                .get(m_orgUnitName)).iterator();
1543:                        while (itResNames.hasNext()) {
1544:                            String resName = (String) itResNames.next();
1545:                            try {
1546:                                resources.add(getCms().readResource(resName,
1547:                                        CmsResourceFilter.ALL));
1548:                                itResNames.remove();
1549:                            } catch (CmsVfsResourceNotFoundException e) {
1550:                                // resource does not exist yet, skip it for now
1551:                                remove = false;
1552:                            }
1553:                        }
1554:
1555:                        if (remove) {
1556:                            m_orgUnitResources.remove(m_orgUnitName);
1557:                        }
1558:                    } finally {
1559:                        getCms().getRequestContext().setSiteRoot(site);
1560:                    }
1561:
1562:                    // if no resource available
1563:                    if (resources.isEmpty()) {
1564:                        // meanwhile use the first one of the parent organizational unit
1565:                        resources.add(OpenCms.getOrgUnitManager()
1566:                                .getResourcesForOrganizationalUnit(
1567:                                        getCms(),
1568:                                        CmsOrganizationalUnit
1569:                                                .getParentFqn(m_orgUnitName))
1570:                                .get(0));
1571:                    }
1572:
1573:                    // create the organizational unit with a dummy resource, which will be corrected later
1574:                    m_orgUnit = OpenCms.getOrgUnitManager()
1575:                            .createOrganizationalUnit(
1576:                                    getCms(),
1577:                                    m_orgUnitName,
1578:                                    m_orgUnitDescription,
1579:                                    m_orgUnitFlags,
1580:                                    ((CmsResource) resources.get(0))
1581:                                            .getRootPath());
1582:                    for (int i = 1; i < resources.size(); i++) {
1583:                        OpenCms.getOrgUnitManager().addResourceToOrgUnit(
1584:                                getCms(), m_orgUnitName,
1585:                                ((CmsResource) resources.get(i)).getRootPath());
1586:                    }
1587:
1588:                    getReport().println(
1589:                            org.opencms.report.Messages.get().container(
1590:                                    org.opencms.report.Messages.RPT_OK_0),
1591:                            I_CmsReport.FORMAT_OK);
1592:                } catch (CmsException e) {
1593:                    getReport().println(e);
1594:                    getReport().addError(e);
1595:
1596:                    CmsMessageContainer message = Messages
1597:                            .get()
1598:                            .container(
1599:                                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_ORGUNITS_0);
1600:                    if (LOG.isDebugEnabled()) {
1601:                        LOG.debug(message.key(), e);
1602:                    }
1603:                    m_throwable = null;
1604:                    m_orgUnit = null;
1605:                } finally {
1606:                    m_orgUnitName = null;
1607:                    m_orgUnitDescription = null;
1608:                    m_orgUnitFlags = 0;
1609:                }
1610:
1611:            }
1612:
1613:            /**
1614:             * Imports the current project.<p>
1615:             */
1616:            public void importProject() {
1617:
1618:                try {
1619:                    if (m_throwable != null) {
1620:                        getReport().println(m_throwable);
1621:                        getReport().addError(m_throwable);
1622:
1623:                        CmsMessageContainer message = Messages
1624:                                .get()
1625:                                .container(
1626:                                        Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_PROJECTS_0);
1627:                        if (LOG.isDebugEnabled()) {
1628:                            LOG.debug(message.key(), m_throwable);
1629:                        }
1630:                        m_throwable = null;
1631:
1632:                        return;
1633:                    }
1634:
1635:                    getReport().print(
1636:                            Messages.get().container(
1637:                                    Messages.RPT_IMPORT_PROJECT_0),
1638:                            I_CmsReport.FORMAT_NOTE);
1639:                    getReport().print(
1640:                            org.opencms.report.Messages.get().container(
1641:                                    org.opencms.report.Messages.RPT_ARGUMENT_1,
1642:                                    m_projectName));
1643:                    getReport().print(
1644:                            org.opencms.report.Messages.get().container(
1645:                                    org.opencms.report.Messages.RPT_DOTS_0));
1646:
1647:                    try {
1648:                        getCms().readProject(m_projectName);
1649:                        // the project already exists and will not be created
1650:                        getReport().println(
1651:                                Messages.get().container(
1652:                                        Messages.RPT_NOT_CREATED_0),
1653:                                I_CmsReport.FORMAT_OK);
1654:                        return;
1655:                    } catch (CmsDataAccessException e) {
1656:                        // ok, continue creating the project
1657:                    }
1658:
1659:                    // create the project
1660:                    CmsProject project = getCms().createProject(m_projectName,
1661:                            m_projectDescription, m_projectUsers,
1662:                            m_projectManagers, CmsProject.PROJECT_TYPE_NORMAL);
1663:                    // set the resources
1664:                    if (m_projectResources != null) {
1665:                        String site = getCms().getRequestContext()
1666:                                .getSiteRoot();
1667:                        CmsProject currentProject = getCms()
1668:                                .getRequestContext().currentProject();
1669:                        try {
1670:                            getCms().getRequestContext().setSiteRoot("");
1671:                            getCms().getRequestContext().setCurrentProject(
1672:                                    project);
1673:
1674:                            Iterator itResNames = m_projectResources.iterator();
1675:                            while (itResNames.hasNext()) {
1676:                                String resName = (String) itResNames.next();
1677:                                try {
1678:                                    getCms().copyResourceToProject(resName);
1679:                                } catch (CmsVfsResourceNotFoundException e) {
1680:                                    // resource does not exist, skip
1681:                                }
1682:                            }
1683:                        } finally {
1684:                            getCms().getRequestContext().setSiteRoot(site);
1685:                            getCms().getRequestContext().setCurrentProject(
1686:                                    currentProject);
1687:                        }
1688:                    }
1689:                    getReport().println(
1690:                            org.opencms.report.Messages.get().container(
1691:                                    org.opencms.report.Messages.RPT_OK_0),
1692:                            I_CmsReport.FORMAT_OK);
1693:                } catch (CmsException e) {
1694:                    getReport().println(e);
1695:                    getReport().addError(e);
1696:
1697:                    CmsMessageContainer message = Messages
1698:                            .get()
1699:                            .container(
1700:                                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_PROJECTS_0);
1701:                    if (LOG.isDebugEnabled()) {
1702:                        LOG.debug(message.key(), e);
1703:                    }
1704:                    m_throwable = null;
1705:                } finally {
1706:                    m_projectName = null;
1707:                    m_projectDescription = null;
1708:                    m_projectManagers = null;
1709:                    m_projectUsers = null;
1710:                    m_projectResources = null;
1711:                }
1712:
1713:            }
1714:
1715:            /**
1716:             * Imports all relations from the current xml data.<p>
1717:             * 
1718:             * This is a global process that occurs only once at the end of the import, 
1719:             * after all resources have been imported, to make sure that both resources
1720:             * of the relations are available.<p>
1721:             * 
1722:             * @see #addResourceRelationRules(Digester, String)
1723:             * @see #addXmlDigesterRules(Digester)
1724:             */
1725:            public void importRelations() {
1726:
1727:                if ((m_relations == null) || m_relations.isEmpty()) {
1728:                    // no relations to add
1729:                    return;
1730:                }
1731:
1732:                getReport().println(
1733:                        Messages.get().container(
1734:                                Messages.RPT_START_IMPORT_RELATIONS_0),
1735:                        I_CmsReport.FORMAT_HEADLINE);
1736:
1737:                int i = 0;
1738:                Iterator it = m_relations.entrySet().iterator();
1739:                while (it.hasNext()) {
1740:                    Map.Entry entry = (Entry) it.next();
1741:                    String resourcePath = (String) entry.getKey();
1742:                    List relations = (List) entry.getValue();
1743:
1744:                    if (checkImmutable(resourcePath)) {
1745:                        continue;
1746:                    }
1747:                    getReport()
1748:                            .print(
1749:                                    org.opencms.report.Messages
1750:                                            .get()
1751:                                            .container(
1752:                                                    org.opencms.report.Messages.RPT_SUCCESSION_2,
1753:                                                    String.valueOf(i + 1),
1754:                                                    String.valueOf(m_relations
1755:                                                            .size())),
1756:                                    I_CmsReport.FORMAT_NOTE);
1757:
1758:                    getReport()
1759:                            .print(
1760:                                    Messages
1761:                                            .get()
1762:                                            .container(
1763:                                                    Messages.RPT_IMPORTING_RELATIONS_FOR_2,
1764:                                                    resourcePath,
1765:                                                    new Integer(relations
1766:                                                            .size())),
1767:                                    I_CmsReport.FORMAT_NOTE);
1768:                    getReport().print(
1769:                            org.opencms.report.Messages.get().container(
1770:                                    org.opencms.report.Messages.RPT_DOTS_0));
1771:
1772:                    boolean withErrors = false;
1773:                    Iterator itRelations = relations.iterator();
1774:                    while (itRelations.hasNext()) {
1775:                        CmsRelation relation = (CmsRelation) itRelations.next();
1776:                        try {
1777:                            // Add the relation to the resource
1778:                            getCms().importRelation(
1779:                                    getCms().getSitePath(
1780:                                            relation.getSource(getCms(),
1781:                                                    CmsResourceFilter.ALL)),
1782:                                    getCms().getSitePath(
1783:                                            relation.getTarget(getCms(),
1784:                                                    CmsResourceFilter.ALL)),
1785:                                    relation.getType().getName());
1786:                        } catch (CmsException e) {
1787:                            getReport().addWarning(e);
1788:                            withErrors = true;
1789:                            if (LOG.isWarnEnabled()) {
1790:                                LOG.warn(e.getLocalizedMessage());
1791:                            }
1792:                            if (LOG.isDebugEnabled()) {
1793:                                LOG.debug(e.getLocalizedMessage(), e);
1794:                            }
1795:                        }
1796:                    }
1797:                    if (!withErrors) {
1798:                        getReport().println(
1799:                                org.opencms.report.Messages.get().container(
1800:                                        org.opencms.report.Messages.RPT_OK_0),
1801:                                I_CmsReport.FORMAT_OK);
1802:                    } else {
1803:                        getReport()
1804:                                .println(
1805:                                        org.opencms.report.Messages
1806:                                                .get()
1807:                                                .container(
1808:                                                        org.opencms.report.Messages.RPT_FAILED_0),
1809:                                        I_CmsReport.FORMAT_ERROR);
1810:                    }
1811:                    i++;
1812:                }
1813:
1814:                getReport().println(
1815:                        Messages.get().container(
1816:                                Messages.RPT_END_IMPORT_RELATIONS_0),
1817:                        I_CmsReport.FORMAT_HEADLINE);
1818:
1819:                m_relations = null;
1820:            }
1821:
1822:            /**
1823:             * Imports a resource from the current xml data.<p>
1824:             * 
1825:             * @see #addResourceAttributesRules(Digester, String)
1826:             * @see #addResourcePropertyRules(Digester, String)
1827:             */
1828:            public void importResource() {
1829:
1830:                try {
1831:                    if (m_throwable != null) {
1832:                        getReport().println(m_throwable);
1833:                        getReport().addError(m_throwable);
1834:
1835:                        CmsMessageContainer message = Messages
1836:                                .get()
1837:                                .container(
1838:                                        Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
1839:                        if (LOG.isDebugEnabled()) {
1840:                            LOG.debug(message.key(), m_throwable);
1841:                        }
1842:                        m_throwable = null;
1843:                        m_importACEs = false;
1844:                        m_resource = null;
1845:
1846:                        return;
1847:                    }
1848:
1849:                    // apply name translation and import path   
1850:                    String translatedName = getCms().getRequestContext()
1851:                            .addSiteRoot(
1852:                                    m_parameters.getDestinationPath()
1853:                                            + m_destination);
1854:
1855:                    boolean resourceImmutable = checkImmutable(translatedName);
1856:                    translatedName = getCms().getRequestContext()
1857:                            .removeSiteRoot(translatedName);
1858:                    // if the resource is not immutable and not on the exclude list, import it
1859:                    if (!resourceImmutable) {
1860:                        // print out the information to the report
1861:                        getReport().print(
1862:                                Messages.get().container(
1863:                                        Messages.RPT_IMPORTING_0),
1864:                                I_CmsReport.FORMAT_NOTE);
1865:                        getReport()
1866:                                .print(
1867:                                        org.opencms.report.Messages
1868:                                                .get()
1869:                                                .container(
1870:                                                        org.opencms.report.Messages.RPT_ARGUMENT_1,
1871:                                                        translatedName));
1872:                        getReport()
1873:                                .print(
1874:                                        org.opencms.report.Messages
1875:                                                .get()
1876:                                                .container(
1877:                                                        org.opencms.report.Messages.RPT_DOTS_0));
1878:
1879:                        boolean exists = getCms().existsResource(
1880:                                translatedName, CmsResourceFilter.ALL);
1881:
1882:                        byte[] content = null;
1883:                        // get the file content
1884:                        if (m_source != null) {
1885:                            content = m_helper.getFileBytes(m_source);
1886:                        }
1887:                        int size = 0;
1888:                        if (content != null) {
1889:                            size = content.length;
1890:                        }
1891:
1892:                        // get UUID for the structure
1893:                        if (m_structureId == null) {
1894:                            // if null generate a new structure id
1895:                            m_structureId = new CmsUUID();
1896:                        }
1897:
1898:                        // get UUIDs for the resource
1899:                        if ((m_resourceId == null) || (m_type.isFolder())) {
1900:                            // folders get always a new resource UUID
1901:                            m_resourceId = new CmsUUID();
1902:                        }
1903:
1904:                        // create a new CmsResource                         
1905:                        CmsResource resource = new CmsResource(m_structureId,
1906:                                m_resourceId, translatedName, m_type
1907:                                        .getTypeId(), m_type.isFolder(),
1908:                                m_flags, getCms().getRequestContext()
1909:                                        .currentProject().getUuid(),
1910:                                CmsResource.STATE_NEW, m_dateCreated,
1911:                                m_userCreated, m_dateLastModified,
1912:                                m_userLastModified, m_dateReleased,
1913:                                m_dateExpired, 1, size, System
1914:                                        .currentTimeMillis(), 0);
1915:
1916:                        if (m_properties == null) {
1917:                            m_properties = new HashMap();
1918:                        }
1919:                        // import this resource in the VFS
1920:                        m_resource = getCms().importResource(translatedName,
1921:                                resource, content,
1922:                                new ArrayList(m_properties.values()));
1923:
1924:                        // only set permissions if the resource did not exists or if the keep permissions flag is not set
1925:                        m_importACEs = (m_resource != null)
1926:                                && (!exists || !m_parameters
1927:                                        .isKeepPermissions());
1928:
1929:                        if (m_resource != null) {
1930:                            getReport()
1931:                                    .println(
1932:                                            org.opencms.report.Messages
1933:                                                    .get()
1934:                                                    .container(
1935:                                                            org.opencms.report.Messages.RPT_OK_0),
1936:                                            I_CmsReport.FORMAT_OK);
1937:
1938:                            if (OpenCms.getResourceManager().getResourceType(
1939:                                    m_resource.getTypeId()) instanceof  I_CmsLinkParseable) {
1940:                                // store for later use
1941:                                m_parseables.add(getCms().getSitePath(
1942:                                        m_resource));
1943:                            }
1944:                            if (LOG.isInfoEnabled()) {
1945:                                LOG
1946:                                        .info(Messages
1947:                                                .get()
1948:                                                .getBundle()
1949:                                                .key(
1950:                                                        Messages.LOG_IMPORTING_4,
1951:                                                        new Object[] {
1952:                                                                String
1953:                                                                        .valueOf(m_fileCounter + 1),
1954:                                                                String
1955:                                                                        .valueOf(m_totalFiles),
1956:                                                                translatedName,
1957:                                                                m_destination }));
1958:                            }
1959:                        } else {
1960:                            // resource import failed, since no CmsResource was created
1961:                            getReport().print(
1962:                                    Messages.get().container(
1963:                                            Messages.RPT_SKIPPING_0),
1964:                                    I_CmsReport.FORMAT_NOTE);
1965:                            getReport()
1966:                                    .println(
1967:                                            org.opencms.report.Messages
1968:                                                    .get()
1969:                                                    .container(
1970:                                                            org.opencms.report.Messages.RPT_ARGUMENT_1,
1971:                                                            translatedName));
1972:
1973:                            if (LOG.isInfoEnabled()) {
1974:                                LOG.info(Messages.get().getBundle().key(
1975:                                        Messages.LOG_SKIPPING_3,
1976:                                        String.valueOf(m_fileCounter + 1),
1977:                                        String.valueOf(m_totalFiles),
1978:                                        translatedName));
1979:                            }
1980:                        }
1981:                    } else {
1982:                        m_resource = null;
1983:                        // skip the file import, just print out the information to the report
1984:                        getReport().print(
1985:                                Messages.get().container(
1986:                                        Messages.RPT_SKIPPING_0),
1987:                                I_CmsReport.FORMAT_NOTE);
1988:                        getReport()
1989:                                .println(
1990:                                        org.opencms.report.Messages
1991:                                                .get()
1992:                                                .container(
1993:                                                        org.opencms.report.Messages.RPT_ARGUMENT_1,
1994:                                                        translatedName));
1995:
1996:                        if (LOG.isInfoEnabled()) {
1997:                            LOG.info(Messages.get().getBundle().key(
1998:                                    Messages.LOG_SKIPPING_3,
1999:                                    String.valueOf(m_fileCounter + 1),
2000:                                    String.valueOf(m_totalFiles),
2001:                                    translatedName));
2002:                        }
2003:                        // do not import ACEs
2004:                        m_importACEs = false;
2005:                    }
2006:                } catch (Exception e) {
2007:                    m_resource = null;
2008:                    m_importACEs = false;
2009:
2010:                    getReport().println(e);
2011:                    getReport().addError(e);
2012:
2013:                    CmsMessageContainer message = Messages
2014:                            .get()
2015:                            .container(
2016:                                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
2017:                    if (LOG.isDebugEnabled()) {
2018:                        LOG.debug(message.key(), e);
2019:                    }
2020:
2021:                    return;
2022:                } finally {
2023:                    m_structureId = null;
2024:                    m_resourceId = null;
2025:                    m_destination = null;
2026:                    m_source = null;
2027:                    m_type = null;
2028:                    m_flags = 0;
2029:                    m_dateCreated = 0;
2030:                    m_dateLastModified = 0;
2031:                    m_dateReleased = CmsResource.DATE_RELEASED_DEFAULT;
2032:                    m_dateExpired = CmsResource.DATE_EXPIRED_DEFAULT;
2033:                    m_properties = null;
2034:                    m_throwable = null;
2035:                    m_aces = null;
2036:                    m_properties = null;
2037:                }
2038:            }
2039:
2040:            /**
2041:             * @see org.opencms.importexport.I_CmsImport#importResources(org.opencms.file.CmsObject, java.lang.String, org.opencms.report.I_CmsReport, java.io.File, java.util.zip.ZipFile, org.dom4j.Document)
2042:             * 
2043:             * @deprecated use {@link #importData(CmsObject, I_CmsReport, CmsImportParameters)} instead
2044:             */
2045:            public void importResources(CmsObject cms, String importPath,
2046:                    I_CmsReport report, File importResource, ZipFile importZip,
2047:                    Document docXml) {
2048:
2049:                CmsImportParameters params = new CmsImportParameters(
2050:                        importResource.getAbsolutePath(), importPath, true);
2051:
2052:                importData(cms, report, params);
2053:            }
2054:
2055:            /**
2056:             * Imports a new user from the current xml data.<p>
2057:             */
2058:            public void importUser() {
2059:
2060:                // create a new user id
2061:                String userName = m_orgUnit.getName() + m_userName;
2062:                try {
2063:                    if (m_throwable != null) {
2064:                        m_user = null;
2065:                        getReport().println(m_throwable);
2066:
2067:                        CmsMessageContainer message = Messages
2068:                                .get()
2069:                                .container(
2070:                                        Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_USER_1,
2071:                                        userName);
2072:                        if (LOG.isDebugEnabled()) {
2073:                            LOG.debug(message.key(), m_throwable);
2074:                        }
2075:                        m_throwable = null;
2076:                        return;
2077:                    }
2078:
2079:                    getReport().print(
2080:                            Messages.get()
2081:                                    .container(Messages.RPT_IMPORT_USER_0),
2082:                            I_CmsReport.FORMAT_NOTE);
2083:                    getReport().print(
2084:                            org.opencms.report.Messages.get().container(
2085:                                    org.opencms.report.Messages.RPT_ARGUMENT_1,
2086:                                    userName));
2087:                    getReport().print(
2088:                            org.opencms.report.Messages.get().container(
2089:                                    org.opencms.report.Messages.RPT_DOTS_0));
2090:
2091:                    try {
2092:                        getCms().readUser(userName);
2093:                        // user exists already
2094:                        getReport().println(
2095:                                Messages.get().container(
2096:                                        Messages.RPT_NOT_CREATED_0),
2097:                                I_CmsReport.FORMAT_OK);
2098:                        m_user = null;
2099:                        return;
2100:                    } catch (CmsDbEntryNotFoundException e) {
2101:                        // user does not exist
2102:                    }
2103:
2104:                    Map config = OpenCms.getPasswordHandler()
2105:                            .getConfiguration();
2106:                    if ((config != null)
2107:                            && config
2108:                                    .containsKey(I_CmsPasswordHandler.CONVERT_DIGEST_ENCODING)) {
2109:                        if (Boolean
2110:                                .valueOf(
2111:                                        (String) config
2112:                                                .get(I_CmsPasswordHandler.CONVERT_DIGEST_ENCODING))
2113:                                .booleanValue()) {
2114:                            m_userPassword = convertDigestEncoding(m_userPassword);
2115:                        }
2116:                    }
2117:
2118:                    m_user = getCms().importUser(new CmsUUID().toString(),
2119:                            userName, m_userPassword, m_userFirstname,
2120:                            m_userLastname, m_userEmail, m_userFlags,
2121:                            m_userDateCreated, m_userInfos);
2122:
2123:                    getReport().println(
2124:                            org.opencms.report.Messages.get().container(
2125:                                    org.opencms.report.Messages.RPT_OK_0),
2126:                            I_CmsReport.FORMAT_OK);
2127:                } catch (Throwable e) {
2128:                    m_user = null;
2129:                    getReport().println(e);
2130:
2131:                    CmsMessageContainer message = Messages.get().container(
2132:                            Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_USER_1,
2133:                            userName);
2134:                    if (LOG.isDebugEnabled()) {
2135:                        LOG.debug(message.key(), e);
2136:                    }
2137:                } finally {
2138:                    m_userName = null;
2139:                    m_userPassword = null;
2140:                    m_userFirstname = null;
2141:                    m_userLastname = null;
2142:                    m_userEmail = null;
2143:                    m_userFlags = 0;
2144:                    m_userDateCreated = 0;
2145:                    m_userInfos = null;
2146:                }
2147:            }
2148:
2149:            /**
2150:             * Sets the current user as member of the given group.<p>
2151:             * 
2152:             * It can happen that the organizational unit has not been imported jet,
2153:             * in this case, the data is kept for later.<p>
2154:             * 
2155:             * @param groupName the name of the group to set
2156:             * 
2157:             * @see #setMembership()
2158:             */
2159:            public void importUserGroup(String groupName) {
2160:
2161:                if ((m_throwable != null) || (m_user == null)) {
2162:                    return;
2163:                }
2164:                groupName = OpenCms.getImportExportManager().translateGroup(
2165:                        groupName);
2166:                try {
2167:                    String ouName = CmsOrganizationalUnit
2168:                            .getParentFqn(groupName);
2169:                    try {
2170:                        // check if the organizational unit exists
2171:                        OpenCms.getOrgUnitManager().readOrganizationalUnit(
2172:                                getCms(), ouName);
2173:                        // set the user group
2174:                        getCms().addUserToGroup(m_user.getName(), groupName);
2175:                        return;
2176:                    } catch (CmsDbEntryNotFoundException e) {
2177:                        // organizational unit does not exist
2178:                    }
2179:                    // remember the user and group for later
2180:                    Map membership = (Map) m_membership.get(ouName);
2181:                    if (membership == null) {
2182:                        membership = new HashMap();
2183:                        m_membership.put(ouName, membership);
2184:                    }
2185:                    Map groups = (Map) membership
2186:                            .get(I_CmsPrincipal.PRINCIPAL_GROUP);
2187:                    if (groups == null) {
2188:                        groups = new HashMap();
2189:                        membership.put(I_CmsPrincipal.PRINCIPAL_GROUP, groups);
2190:                    }
2191:                    groups.put(m_user.getName(), groupName);
2192:                } catch (Throwable e) {
2193:                    getReport()
2194:                            .println(
2195:                                    Messages
2196:                                            .get()
2197:                                            .container(
2198:                                                    Messages.RPT_USER_COULDNT_BE_ADDED_TO_GROUP_2,
2199:                                                    m_user.getName(), groupName),
2200:                                    I_CmsReport.FORMAT_WARNING);
2201:                    if (LOG.isDebugEnabled()) {
2202:                        LOG.debug(e.getLocalizedMessage(), e);
2203:                    }
2204:                }
2205:            }
2206:
2207:            /**
2208:             * Creates a new additional information entry for the current user.<p>
2209:             * 
2210:             * @param infoName the name of the additional information entry
2211:             * @param infoType the type of the additional information entry
2212:             * @param infoValue the value of the additional information entry
2213:             */
2214:            public void importUserInfo(String infoName, String infoType,
2215:                    String infoValue) {
2216:
2217:                if (m_userInfos == null) {
2218:                    m_userInfos = new HashMap();
2219:                }
2220:                try {
2221:                    m_userInfos.put(infoName, CmsDataTypeUtil.dataImport(
2222:                            infoValue, infoType));
2223:                } catch (Throwable e) {
2224:                    if (LOG.isErrorEnabled()) {
2225:                        LOG.error(e.getLocalizedMessage(), e);
2226:                    }
2227:                }
2228:            }
2229:
2230:            /**
2231:             * Sets the current user as member of the given role.<p>
2232:             * 
2233:             * It can happen that the organizational unit has not been imported jet,
2234:             * in this case, the data is kept for later.<p>
2235:             * 
2236:             * @param roleName the name of the role to set
2237:             * 
2238:             * @see #setMembership()
2239:             */
2240:            public void importUserRole(String roleName) {
2241:
2242:                if ((m_throwable != null) || (m_user == null)) {
2243:                    return;
2244:                }
2245:                try {
2246:                    CmsRole role = CmsRole.valueOfRoleName(roleName);
2247:                    try {
2248:                        // check if the organizational unit exists
2249:                        OpenCms.getOrgUnitManager().readOrganizationalUnit(
2250:                                getCms(), role.getOuFqn());
2251:                        // set the user role
2252:                        OpenCms.getRoleManager().addUserToRole(getCms(), role,
2253:                                m_user.getName());
2254:                        return;
2255:                    } catch (CmsDbEntryNotFoundException e) {
2256:                        // organizational unit does not exist
2257:                    }
2258:                    // remember the user and role for later
2259:                    Map membership = (Map) m_membership.get(role.getOuFqn());
2260:                    if (membership == null) {
2261:                        membership = new HashMap();
2262:                        m_membership.put(role.getOuFqn(), membership);
2263:                    }
2264:                    Map roles = (Map) membership
2265:                            .get(I_CmsPrincipal.PRINCIPAL_USER);
2266:                    if (roles == null) {
2267:                        roles = new HashMap();
2268:                        membership.put(I_CmsPrincipal.PRINCIPAL_USER, roles);
2269:                    }
2270:                    roles.put(m_user.getName(), role.getFqn());
2271:                } catch (Throwable e) {
2272:                    getReport()
2273:                            .println(
2274:                                    Messages
2275:                                            .get()
2276:                                            .container(
2277:                                                    Messages.RPT_USER_COULDNT_BE_ADDED_TO_ROLE_2,
2278:                                                    m_user.getName(), roleName),
2279:                                    I_CmsReport.FORMAT_WARNING);
2280:                    if (LOG.isDebugEnabled()) {
2281:                        LOG.debug(e.getLocalizedMessage(), e);
2282:                    }
2283:                }
2284:            }
2285:
2286:            /**
2287:             * Increases the file counter.<p>
2288:             */
2289:            public void increaseCounter() {
2290:
2291:                m_fileCounter++;
2292:            }
2293:
2294:            /**
2295:             * Increases the total number of files.<p>
2296:             */
2297:            public void increaseTotalFiles() {
2298:
2299:                m_totalFiles++;
2300:            }
2301:
2302:            /** The location of the OpenCms configuration DTD if the default prefix is the system ID. */
2303:            public static final String DTD_LOCATION = "org/opencms/importexport/";
2304:
2305:            /** The name of the DTD for this import version. */
2306:            public static final String DTD_FILENAME = "opencms-import7.dtd";
2307:
2308:            /**
2309:             * @see org.opencms.importexport.I_CmsImport#matches(org.opencms.importexport.CmsImportParameters)
2310:             */
2311:            public boolean matches(CmsImportParameters parameters)
2312:                    throws CmsImportExportException {
2313:
2314:                m_fileCounter = 1;
2315:                m_totalFiles = 0;
2316:                m_parseables = new ArrayList();
2317:
2318:                m_parameters = parameters;
2319:
2320:                // instantiate Digester and enable XML validation
2321:                Digester digester = new Digester();
2322:                digester.setUseContextClassLoader(true);
2323:                digester.setValidating(m_parameters.isXmlValidation());
2324:                digester.setEntityResolver(new CmsXmlEntityResolver(null));
2325:                digester.setRuleNamespaceURI(null);
2326:                digester.setErrorHandler(new CmsXmlErrorHandler(
2327:                        CmsImportExportManager.EXPORT_MANIFEST));
2328:
2329:                // add this object to the Digester
2330:                digester.push(this );
2331:
2332:                addXmlPreprocessingDigesterRules(digester);
2333:
2334:                InputStream stream = null;
2335:                m_helper = new CmsImportHelper(m_parameters);
2336:                m_helper.cacheDtdSystemId(DTD_LOCATION, DTD_FILENAME,
2337:                        CmsConfigurationManager.DEFAULT_DTD_PREFIX);
2338:                try {
2339:                    m_helper.openFile();
2340:                    // start the parsing process
2341:                    // this will set the version attribute
2342:                    stream = m_helper
2343:                            .getFileStream(CmsImportExportManager.EXPORT_MANIFEST);
2344:                    digester.parse(stream);
2345:                } catch (Exception ioe) {
2346:                    CmsMessageContainer msg = Messages.get().container(
2347:                            Messages.ERR_IMPORTEXPORT_ERROR_READING_FILE_1,
2348:                            CmsImportExportManager.EXPORT_MANIFEST);
2349:                    if (LOG.isErrorEnabled()) {
2350:                        LOG.error(msg.key(), ioe);
2351:                    }
2352:                    throw new CmsImportExportException(msg, ioe);
2353:                } finally {
2354:                    try {
2355:                        if (stream != null) {
2356:                            stream.close();
2357:                        }
2358:                    } catch (Exception e) {
2359:                        // noop
2360:                    }
2361:                    m_helper.closeFile();
2362:                }
2363:                return (m_version == getVersion());
2364:            }
2365:
2366:            /**
2367:             * Rewrites all parseable files, to assure link check.<p>
2368:             * 
2369:             * This is a global process, that is executed only once at the 
2370:             * end of the import to be sure that all link targets are 
2371:             * available.<p>
2372:             * 
2373:             * @see #addXmlDigesterRules(Digester)
2374:             */
2375:            public void rewriteParseables() {
2376:
2377:                if (m_parseables.isEmpty()) {
2378:                    return;
2379:                }
2380:
2381:                getReport().println(
2382:                        Messages.get().container(
2383:                                Messages.RPT_START_PARSE_LINKS_0),
2384:                        I_CmsReport.FORMAT_HEADLINE);
2385:
2386:                int i = 0;
2387:                Iterator it = m_parseables.iterator();
2388:                while (it.hasNext()) {
2389:                    String resName = (String) it.next();
2390:
2391:                    getReport()
2392:                            .print(
2393:                                    org.opencms.report.Messages
2394:                                            .get()
2395:                                            .container(
2396:                                                    org.opencms.report.Messages.RPT_SUCCESSION_2,
2397:                                                    String.valueOf(i + 1),
2398:                                                    String.valueOf(m_parseables
2399:                                                            .size())),
2400:                                    I_CmsReport.FORMAT_NOTE);
2401:
2402:                    getReport().print(
2403:                            Messages.get().container(
2404:                                    Messages.RPT_PARSE_LINKS_FOR_1, resName),
2405:                            I_CmsReport.FORMAT_NOTE);
2406:                    getReport().print(
2407:                            org.opencms.report.Messages.get().container(
2408:                                    org.opencms.report.Messages.RPT_DOTS_0));
2409:
2410:                    try {
2411:                        CmsFile file = getCms().readFile(resName);
2412:                        // make sure the date last modified is kept...
2413:                        file.setDateLastModified(file.getDateLastModified());
2414:                        // make sure the file is locked
2415:                        CmsLock lock = getCms().getLock(file);
2416:                        if (lock.isUnlocked()) {
2417:                            getCms().lockResource(resName);
2418:                        } else if (!lock.isExclusiveOwnedBy(getCms()
2419:                                .getRequestContext().currentUser())) {
2420:                            getCms().changeLock(resName);
2421:                        }
2422:                        // rewrite the file
2423:                        getCms().writeFile(file);
2424:
2425:                        getReport().println(
2426:                                org.opencms.report.Messages.get().container(
2427:                                        org.opencms.report.Messages.RPT_OK_0),
2428:                                I_CmsReport.FORMAT_OK);
2429:                    } catch (Throwable e) {
2430:                        getReport().addWarning(e);
2431:                        getReport()
2432:                                .println(
2433:                                        org.opencms.report.Messages
2434:                                                .get()
2435:                                                .container(
2436:                                                        org.opencms.report.Messages.RPT_FAILED_0),
2437:                                        I_CmsReport.FORMAT_ERROR);
2438:                        if (LOG.isWarnEnabled()) {
2439:                            LOG.warn(Messages.get().getBundle().key(
2440:                                    Messages.LOG_IMPORTEXPORT_REWRITING_1,
2441:                                    resName));
2442:                        }
2443:                        if (LOG.isDebugEnabled()) {
2444:                            LOG.debug(e.getLocalizedMessage(), e);
2445:                        }
2446:                    }
2447:                    i++;
2448:                }
2449:
2450:                getReport().println(
2451:                        Messages.get()
2452:                                .container(Messages.RPT_END_PARSE_LINKS_0),
2453:                        I_CmsReport.FORMAT_HEADLINE);
2454:                m_parseables = null;
2455:            }
2456:
2457:            /**
2458:             * Sets the aceFlags.<p>
2459:             *
2460:             * @param aceFlags the aceFlags to set
2461:             * 
2462:             * @see #N_FLAGS
2463:             * @see #addResourceAceRules(Digester, String)
2464:             */
2465:            public void setAceFlags(String aceFlags) {
2466:
2467:                try {
2468:                    m_aceFlags = Integer.parseInt(aceFlags);
2469:                } catch (Throwable e) {
2470:                    m_throwable = e;
2471:                }
2472:            }
2473:
2474:            /**
2475:             * Sets the acePermissionsAllowed.<p>
2476:             *
2477:             * @param acePermissionsAllowed the acePermissionsAllowed to set
2478:             * 
2479:             * @see #N_ACCESSCONTROL_ALLOWEDPERMISSIONS
2480:             * @see #addResourceAceRules(Digester, String)
2481:             */
2482:            public void setAcePermissionsAllowed(String acePermissionsAllowed) {
2483:
2484:                try {
2485:                    m_acePermissionsAllowed = Integer
2486:                            .parseInt(acePermissionsAllowed);
2487:                } catch (Throwable e) {
2488:                    m_throwable = e;
2489:                }
2490:            }
2491:
2492:            /**
2493:             * Sets the acePermissionsDenied.<p>
2494:             *
2495:             * @param acePermissionsDenied the acePermissionsDenied to set
2496:             * 
2497:             * @see #N_ACCESSCONTROL_DENIEDPERMISSIONS
2498:             * @see #addResourceAceRules(Digester, String)
2499:             */
2500:            public void setAcePermissionsDenied(String acePermissionsDenied) {
2501:
2502:                try {
2503:                    m_acePermissionsDenied = Integer
2504:                            .parseInt(acePermissionsDenied);
2505:                } catch (Throwable e) {
2506:                    m_throwable = e;
2507:                }
2508:            }
2509:
2510:            /**
2511:             * Sets the acePrincipalId.<p>
2512:             *
2513:             * @param acePrincipalId the acePrincipalId to set
2514:             * 
2515:             * @see #N_ACCESSCONTROL_PRINCIPAL
2516:             * @see #addResourceAceRules(Digester, String)
2517:             */
2518:            public void setAcePrincipalId(String acePrincipalId) {
2519:
2520:                try {
2521:                    CmsUUID principalId = null;
2522:                    String principal = acePrincipalId.substring(acePrincipalId
2523:                            .indexOf('.') + 1, acePrincipalId.length());
2524:                    if (acePrincipalId
2525:                            .startsWith(I_CmsPrincipal.PRINCIPAL_GROUP)) {
2526:                        principal = OpenCms.getImportExportManager()
2527:                                .translateGroup(principal);
2528:                        principalId = getCms().readGroup(principal).getId();
2529:                    } else if (acePrincipalId
2530:                            .startsWith(I_CmsPrincipal.PRINCIPAL_USER)) {
2531:                        principal = OpenCms.getImportExportManager()
2532:                                .translateUser(principal);
2533:                        principalId = getCms().readUser(principal).getId();
2534:                    } else if (acePrincipalId
2535:                            .startsWith(CmsRole.PRINCIPAL_ROLE)) {
2536:                        principalId = CmsRole.valueOfRoleName(principal)
2537:                                .getId();
2538:                    } else if (acePrincipalId
2539:                            .equalsIgnoreCase(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME)) {
2540:                        principalId = CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID;
2541:                    } else if (acePrincipalId
2542:                            .equalsIgnoreCase(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME)) {
2543:                        principalId = CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID;
2544:                    } else {
2545:                        if (LOG.isWarnEnabled()) {
2546:                            LOG
2547:                                    .warn(Messages
2548:                                            .get()
2549:                                            .getBundle()
2550:                                            .key(
2551:                                                    Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1,
2552:                                                    acePrincipalId));
2553:                        }
2554:                        throw new CmsIllegalStateException(
2555:                                Messages
2556:                                        .get()
2557:                                        .container(
2558:                                                Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1,
2559:                                                acePrincipalId));
2560:                    }
2561:                    m_acePrincipalId = principalId;
2562:                } catch (Throwable e) {
2563:                    setThrowable(e);
2564:                }
2565:            }
2566:
2567:            /**
2568:             * Sets the dateCreated.<p>
2569:             *
2570:             * @param dateCreated the dateCreated to set
2571:             * 
2572:             * @see #N_DATECREATED
2573:             * @see #addResourceAttributesRules(Digester, String)
2574:             */
2575:            public void setDateCreated(String dateCreated) {
2576:
2577:                try {
2578:                    if (dateCreated != null) {
2579:                        m_dateCreated = convertTimestamp(dateCreated);
2580:                    } else {
2581:                        m_dateCreated = System.currentTimeMillis();
2582:                    }
2583:                } catch (Throwable e) {
2584:                    setThrowable(e);
2585:                }
2586:            }
2587:
2588:            /**
2589:             * Sets the dateExpired.<p>
2590:             *
2591:             * @param dateExpired the dateExpired to set
2592:             * 
2593:             * @see #N_DATEEXPIRED
2594:             * @see #addResourceAttributesRules(Digester, String)
2595:             */
2596:            public void setDateExpired(String dateExpired) {
2597:
2598:                try {
2599:                    if (dateExpired != null) {
2600:                        m_dateExpired = convertTimestamp(dateExpired);
2601:                    } else {
2602:                        m_dateExpired = CmsResource.DATE_EXPIRED_DEFAULT;
2603:                    }
2604:                } catch (Throwable e) {
2605:                    setThrowable(e);
2606:                }
2607:            }
2608:
2609:            /**
2610:             * Sets the dateLastModified.<p>
2611:             *
2612:             * @param dateLastModified the dateLastModified to set
2613:             * 
2614:             * @see #N_DATELASTMODIFIED
2615:             * @see #addResourceAttributesRules(Digester, String)
2616:             */
2617:            public void setDateLastModified(String dateLastModified) {
2618:
2619:                try {
2620:                    if (dateLastModified != null) {
2621:                        m_dateLastModified = convertTimestamp(dateLastModified);
2622:                    } else {
2623:                        m_dateLastModified = System.currentTimeMillis();
2624:                    }
2625:                } catch (Throwable e) {
2626:                    setThrowable(e);
2627:                }
2628:            }
2629:
2630:            /**
2631:             * Sets the dateReleased.<p>
2632:             *
2633:             * @param dateReleased the dateReleased to set
2634:             * 
2635:             * @see #N_DATERELEASED
2636:             * @see #addResourceAttributesRules(Digester, String)
2637:             */
2638:            public void setDateReleased(String dateReleased) {
2639:
2640:                try {
2641:                    if (dateReleased != null) {
2642:                        m_dateReleased = convertTimestamp(dateReleased);
2643:                    } else {
2644:                        m_dateReleased = CmsResource.DATE_RELEASED_DEFAULT;
2645:                    }
2646:                } catch (Throwable e) {
2647:                    setThrowable(e);
2648:                }
2649:            }
2650:
2651:            /**
2652:             * Sets the destination.<p>
2653:             *
2654:             * @param destination the destination to set
2655:             * 
2656:             * @see #N_DESTINATION
2657:             * @see #addResourceAttributesRules(Digester, String)
2658:             */
2659:            public void setDestination(String destination) {
2660:
2661:                m_destination = destination;
2662:            }
2663:
2664:            /**
2665:             * Sets the flags.<p>
2666:             *
2667:             * @param flags the flags to set
2668:             * 
2669:             * @see #N_FLAGS
2670:             * @see #addResourceAttributesRules(Digester, String)
2671:             */
2672:            public void setFlags(String flags) {
2673:
2674:                try {
2675:                    m_flags = Integer.parseInt(flags);
2676:                } catch (Throwable e) {
2677:                    setThrowable(e);
2678:                }
2679:            }
2680:
2681:            /**
2682:             * Sets the group Description.<p>
2683:             *
2684:             * @param groupDescription the description to set
2685:             */
2686:            public void setGroupDescription(String groupDescription) {
2687:
2688:                m_groupDescription = groupDescription;
2689:            }
2690:
2691:            /**
2692:             * Sets the group Flags.<p>
2693:             *
2694:             * @param groupFlags the flags to set
2695:             */
2696:            public void setGroupFlags(String groupFlags) {
2697:
2698:                try {
2699:                    m_groupFlags = Integer.parseInt(groupFlags);
2700:                } catch (Throwable e) {
2701:                    setThrowable(e);
2702:                }
2703:            }
2704:
2705:            /**
2706:             * Sets the group Name.<p>
2707:             *
2708:             * @param groupName the name to set
2709:             */
2710:            public void setGroupName(String groupName) {
2711:
2712:                m_groupName = OpenCms.getImportExportManager().translateGroup(
2713:                        groupName);
2714:            }
2715:
2716:            /**
2717:             * Sets the group Parent.<p>
2718:             *
2719:             * @param groupParent the group Parent to set
2720:             */
2721:            public void setGroupParent(String groupParent) {
2722:
2723:                m_groupParent = OpenCms.getImportExportManager()
2724:                        .translateGroup(groupParent);
2725:            }
2726:
2727:            /**
2728:             * Sets the membership information that could not been set immediately,
2729:             * because of import order issues.<p> 
2730:             */
2731:            public void setMembership() {
2732:
2733:                if ((m_orgUnit == null) || (m_membership == null)) {
2734:                    return;
2735:                }
2736:
2737:                // get the membership data to set
2738:                Map membership = (Map) m_membership.get(m_orgUnit.getName());
2739:                if (membership == null) {
2740:                    return;
2741:                }
2742:
2743:                // set group membership
2744:                Map groups = (Map) membership
2745:                        .get(I_CmsPrincipal.PRINCIPAL_GROUP);
2746:                if (groups != null) {
2747:                    Iterator it = groups.entrySet().iterator();
2748:                    while (it.hasNext()) {
2749:                        Map.Entry entry = (Map.Entry) it.next();
2750:                        String userName = (String) entry.getKey();
2751:                        String groupName = (String) entry.getValue();
2752:
2753:                        // set the users group
2754:                        try {
2755:                            getCms().addUserToGroup(userName, groupName);
2756:                        } catch (Throwable e) {
2757:                            getReport()
2758:                                    .println(
2759:                                            Messages
2760:                                                    .get()
2761:                                                    .container(
2762:                                                            Messages.RPT_USER_COULDNT_BE_ADDED_TO_GROUP_2,
2763:                                                            userName, groupName),
2764:                                            I_CmsReport.FORMAT_WARNING);
2765:                            if (LOG.isDebugEnabled()) {
2766:                                LOG.debug(e.getLocalizedMessage(), e);
2767:                            }
2768:                        }
2769:                    }
2770:                }
2771:
2772:                // set role membership
2773:                Map roles = (Map) membership.get(I_CmsPrincipal.PRINCIPAL_USER);
2774:                if (roles != null) {
2775:                    Iterator it = roles.entrySet().iterator();
2776:                    while (it.hasNext()) {
2777:                        Map.Entry entry = (Map.Entry) it.next();
2778:                        String userName = (String) entry.getKey();
2779:                        String roleName = (String) entry.getValue();
2780:
2781:                        // set the users roles
2782:                        CmsRole role = CmsRole.valueOfRoleName(roleName);
2783:                        try {
2784:                            // set the user role
2785:                            OpenCms.getRoleManager().addUserToRole(getCms(),
2786:                                    role, userName);
2787:                            return;
2788:                        } catch (Throwable e) {
2789:                            getReport()
2790:                                    .println(
2791:                                            Messages
2792:                                                    .get()
2793:                                                    .container(
2794:                                                            Messages.RPT_USER_COULDNT_BE_ADDED_TO_ROLE_2,
2795:                                                            userName, roleName),
2796:                                            I_CmsReport.FORMAT_WARNING);
2797:                            if (LOG.isDebugEnabled()) {
2798:                                LOG.debug(e.getLocalizedMessage(), e);
2799:                            }
2800:                        }
2801:                    }
2802:                }
2803:            }
2804:
2805:            /**
2806:             * Sets the organizational unit description.<p>
2807:             *
2808:             * @param orgUnitDescription the description to set
2809:             */
2810:            public void setOrgUnitDescription(String orgUnitDescription) {
2811:
2812:                m_orgUnitDescription = orgUnitDescription;
2813:            }
2814:
2815:            /**
2816:             * Sets the organizational unit flags.<p>
2817:             *
2818:             * @param orgUnitFlags the flags to set
2819:             */
2820:            public void setOrgUnitFlags(String orgUnitFlags) {
2821:
2822:                try {
2823:                    m_orgUnitFlags = Integer.parseInt(orgUnitFlags);
2824:                } catch (Throwable e) {
2825:                    setThrowable(e);
2826:                }
2827:            }
2828:
2829:            /**
2830:             * Sets the organizational unit name.<p>
2831:             *
2832:             * @param orgUnitName the name to set
2833:             */
2834:            public void setOrgUnitName(String orgUnitName) {
2835:
2836:                m_orgUnitName = orgUnitName;
2837:            }
2838:
2839:            /**
2840:             * Sets the project Description.<p>
2841:             *
2842:             * @param projectDescription the description to set
2843:             */
2844:            public void setProjectDescription(String projectDescription) {
2845:
2846:                m_projectDescription = projectDescription;
2847:            }
2848:
2849:            /**
2850:             * Sets the project Managers group name.<p>
2851:             *
2852:             * @param projectManagers the managers group to set
2853:             */
2854:            public void setProjectManagers(String projectManagers) {
2855:
2856:                m_projectManagers = projectManagers;
2857:            }
2858:
2859:            /**
2860:             * Sets the project Name.<p>
2861:             *
2862:             * @param projectName the name to set
2863:             */
2864:            public void setProjectName(String projectName) {
2865:
2866:                m_projectName = projectName;
2867:            }
2868:
2869:            /**
2870:             * Sets the project Users group name.<p>
2871:             *
2872:             * @param projectUsers the Users group to set
2873:             */
2874:            public void setProjectUsers(String projectUsers) {
2875:
2876:                m_projectUsers = projectUsers;
2877:            }
2878:
2879:            /**
2880:             * Sets the propertyName.<p>
2881:             *
2882:             * @param propertyName the propertyName to set
2883:             * 
2884:             * @see #N_NAME
2885:             * @see #addResourcePropertyRules(Digester, String)
2886:             */
2887:            public void setPropertyName(String propertyName) {
2888:
2889:                m_propertyName = propertyName;
2890:            }
2891:
2892:            /**
2893:             * Sets the propertyValue.<p>
2894:             *
2895:             * @param propertyValue the propertyValue to set
2896:             * 
2897:             * @see #N_VALUE
2898:             * @see #addResourcePropertyRules(Digester, String)
2899:             */
2900:            public void setPropertyValue(String propertyValue) {
2901:
2902:                m_propertyValue = propertyValue;
2903:            }
2904:
2905:            /**
2906:             * Sets the relationId.<p>
2907:             *
2908:             * @param relationId the relationId to set
2909:             * 
2910:             * @see #N_ID
2911:             * @see #addResourceRelationRules(Digester, String)
2912:             */
2913:            public void setRelationId(String relationId) {
2914:
2915:                try {
2916:                    m_relationId = new CmsUUID(relationId);
2917:                } catch (Throwable e) {
2918:                    setThrowable(e);
2919:                }
2920:            }
2921:
2922:            /**
2923:             * Sets the relationPath.<p>
2924:             *
2925:             * @param relationPath the relationPath to set
2926:             * 
2927:             * @see #N_PATH
2928:             * @see #addResourceRelationRules(Digester, String)
2929:             */
2930:            public void setRelationPath(String relationPath) {
2931:
2932:                m_relationPath = relationPath;
2933:            }
2934:
2935:            /**
2936:             * Sets the relationType.<p>
2937:             *
2938:             * @param relationType the relationType to set
2939:             * 
2940:             * @see #N_TYPE
2941:             * @see #addResourceRelationRules(Digester, String)
2942:             */
2943:            public void setRelationType(String relationType) {
2944:
2945:                try {
2946:                    m_relationType = CmsRelationType.valueOf(relationType);
2947:                } catch (Throwable e) {
2948:                    setThrowable(e);
2949:                }
2950:            }
2951:
2952:            /**
2953:             * Sets the resourceId.<p>
2954:             *
2955:             * @param resourceId the resourceId to set
2956:             * 
2957:             * @see #N_UUIDRESOURCE
2958:             * @see #addResourceAttributesRules(Digester, String)
2959:             */
2960:            public void setResourceId(String resourceId) {
2961:
2962:                try {
2963:                    if (!m_type.isFolder()) {
2964:                        m_resourceId = new CmsUUID(resourceId);
2965:                    } else {
2966:                        m_resourceId = new CmsUUID();
2967:                    }
2968:                } catch (Throwable e) {
2969:                    setThrowable(e);
2970:                }
2971:            }
2972:
2973:            /**
2974:             * Sets the source.<p>
2975:             *
2976:             * @param source the source to set
2977:             * 
2978:             * @see #N_SOURCE
2979:             * @see #addResourceAttributesRules(Digester, String)
2980:             */
2981:            public void setSource(String source) {
2982:
2983:                m_source = source;
2984:            }
2985:
2986:            /**
2987:             * Sets the structureId.<p>
2988:             *
2989:             * @param structureId the structureId to set
2990:             * 
2991:             * @see #N_UUIDSTRUCTURE
2992:             * @see #addResourceAttributesRules(Digester, String)
2993:             */
2994:            public void setStructureId(String structureId) {
2995:
2996:                try {
2997:                    m_structureId = new CmsUUID(structureId);
2998:                } catch (Throwable e) {
2999:                    setThrowable(e);
3000:                }
3001:            }
3002:
3003:            /**
3004:             * Sets the throwable.<p>
3005:             *
3006:             * @param throwable the throwable to set
3007:             */
3008:            public void setThrowable(Throwable throwable) {
3009:
3010:                m_throwable = throwable;
3011:            }
3012:
3013:            /**
3014:             * Sets the type.<p>
3015:             *
3016:             * @param typeName the type to set
3017:             * 
3018:             * @see #N_TYPE
3019:             * @see #addResourceAttributesRules(Digester, String)
3020:             */
3021:            public void setType(String typeName) {
3022:
3023:                try {
3024:                    try {
3025:                        m_type = OpenCms.getResourceManager().getResourceType(
3026:                                typeName);
3027:                    } catch (CmsLoaderException e) {
3028:                        // TODO: what happens if the resource type is a specialized folder and is not configured??
3029:                        m_type = OpenCms.getResourceManager().getResourceType(
3030:                                CmsResourceTypePlain.getStaticTypeId());
3031:                    }
3032:                    if (m_type.isFolder()) {
3033:                        // ensure folders end with a "/"
3034:                        if (!CmsResource.isFolder(m_destination)) {
3035:                            m_destination += "/";
3036:                        }
3037:                    }
3038:                } catch (Throwable e) {
3039:                    setThrowable(e);
3040:                }
3041:            }
3042:
3043:            /**
3044:             * Sets the user Created.<p>
3045:             *
3046:             * @param userCreated the user Created to set
3047:             */
3048:            public void setUserCreated(CmsUUID userCreated) {
3049:
3050:                m_userCreated = userCreated;
3051:            }
3052:
3053:            /**
3054:             * Sets the userCreated.<p>
3055:             *
3056:             * @param userCreated the userCreated to set
3057:             * 
3058:             * @see #N_USERCREATED
3059:             * @see #addResourceAttributesRules(Digester, String)
3060:             */
3061:            public void setUserCreated(String userCreated) {
3062:
3063:                try {
3064:                    String userCreatedName = OpenCms.getImportExportManager()
3065:                            .translateUser(userCreated);
3066:                    try {
3067:                        m_userCreated = getCms().readUser(userCreatedName)
3068:                                .getId();
3069:                    } catch (CmsDbEntryNotFoundException e) {
3070:                        m_userCreated = getCms().getRequestContext()
3071:                                .currentUser().getId();
3072:                    }
3073:                } catch (Throwable e) {
3074:                    setThrowable(e);
3075:                }
3076:            }
3077:
3078:            /**
3079:             * Sets the user Date Created.<p>
3080:             *
3081:             * @param userDateCreated the date to set
3082:             */
3083:            public void setUserDateCreated(String userDateCreated) {
3084:
3085:                try {
3086:                    m_userDateCreated = convertTimestamp(userDateCreated);
3087:                } catch (Throwable e) {
3088:                    setThrowable(e);
3089:                }
3090:            }
3091:
3092:            /**
3093:             * Sets the user email address.<p>
3094:             *
3095:             * @param userEmail the email address to set
3096:             */
3097:            public void setUserEmail(String userEmail) {
3098:
3099:                m_userEmail = userEmail;
3100:            }
3101:
3102:            /**
3103:             * Sets the user First name.<p>
3104:             *
3105:             * @param userFirstname the first name to set
3106:             */
3107:            public void setUserFirstname(String userFirstname) {
3108:
3109:                m_userFirstname = userFirstname;
3110:            }
3111:
3112:            /**
3113:             * Sets the user Flags.<p>
3114:             *
3115:             * @param userFlags the flags to set
3116:             */
3117:            public void setUserFlags(String userFlags) {
3118:
3119:                try {
3120:                    m_userFlags = Integer.parseInt(userFlags);
3121:                } catch (Throwable e) {
3122:                    setThrowable(e);
3123:                }
3124:            }
3125:
3126:            /**
3127:             * Sets the user Last Modified.<p>
3128:             *
3129:             * @param userLastModified the user Last Modified to set
3130:             */
3131:            public void setUserLastModified(CmsUUID userLastModified) {
3132:
3133:                m_userLastModified = userLastModified;
3134:            }
3135:
3136:            /**
3137:             * Sets the userLastModified.<p>
3138:             *
3139:             * @param userLastModified the userLastModified to set
3140:             * 
3141:             * @see #N_USERLASTMODIFIED
3142:             * @see #addResourceAttributesRules(Digester, String)
3143:             */
3144:            public void setUserLastModified(String userLastModified) {
3145:
3146:                try {
3147:                    String userLastModifiedName = OpenCms
3148:                            .getImportExportManager().translateUser(
3149:                                    userLastModified);
3150:                    try {
3151:                        m_userLastModified = getCms().readUser(
3152:                                userLastModifiedName).getId();
3153:                    } catch (CmsDbEntryNotFoundException e) {
3154:                        m_userLastModified = getCms().getRequestContext()
3155:                                .currentUser().getId();
3156:                    }
3157:                } catch (Throwable e) {
3158:                    setThrowable(e);
3159:                }
3160:            }
3161:
3162:            /**
3163:             * Sets the user Last name.<p>
3164:             *
3165:             * @param userLastname the last name to set
3166:             */
3167:            public void setUserLastname(String userLastname) {
3168:
3169:                m_userLastname = userLastname;
3170:            }
3171:
3172:            /**
3173:             * Sets the user Name.<p>
3174:             *
3175:             * @param userName the name to set
3176:             */
3177:            public void setUserName(String userName) {
3178:
3179:                m_userName = OpenCms.getImportExportManager().translateUser(
3180:                        userName);
3181:            }
3182:
3183:            /**
3184:             * Sets the user Password.<p>
3185:             *
3186:             * @param userPassword the password to set
3187:             */
3188:            public void setUserPassword(String userPassword) {
3189:
3190:                m_userPassword = new String(Base64.decodeBase64(userPassword
3191:                        .trim().getBytes()));
3192:            }
3193:
3194:            /**
3195:             * Sets the export version from the manifest file.<p>
3196:             * 
3197:             * @param version the export version to set
3198:             */
3199:            public void setVersion(String version) {
3200:
3201:                m_version = Integer.parseInt(version);
3202:            }
3203:
3204:            /**
3205:             * Adds the XML digester rules for groups.<p>
3206:             * 
3207:             * @param digester the digester to add the rules to
3208:             * @param xpath the base xpath for the rules
3209:             */
3210:            protected void addAccountsGroupRules(Digester digester, String xpath) {
3211:
3212:                String xp_group = xpath + N_GROUPS + "/" + N_GROUP;
3213:                digester.addCallMethod(xp_group, "importGroup");
3214:                xp_group += "/";
3215:                digester.addCallMethod(xp_group + N_NAME, "setGroupName", 0);
3216:                digester.addCallMethod(xp_group + N_DESCRIPTION,
3217:                        "setGroupDescription", 0);
3218:                digester.addCallMethod(xp_group + N_FLAGS, "setGroupFlags", 0);
3219:                digester.addCallMethod(xp_group + N_PARENTGROUP,
3220:                        "setGroupParent", 0);
3221:            }
3222:
3223:            /**
3224:             * Adds the XML digester rules for organizational units.<p>
3225:             * 
3226:             * @param digester the digester to add the rules to
3227:             * @param xpath the base xpath for the rules
3228:             */
3229:            protected void addAccountsOrgunitRules(Digester digester,
3230:                    String xpath) {
3231:
3232:                digester.addCallMethod(xpath + N_NAME, "setOrgUnitName", 0);
3233:                digester.addCallMethod(xpath + N_DESCRIPTION,
3234:                        "setOrgUnitDescription", 0);
3235:                digester.addCallMethod(xpath + N_FLAGS, "setOrgUnitFlags", 0);
3236:                digester.addCallMethod(xpath + N_RESOURCES + "/" + N_RESOURCE,
3237:                        "addOrgUnitResource", 0);
3238:                digester.addCallMethod(xpath + N_RESOURCES, "importOrgUnit");
3239:            }
3240:
3241:            /**
3242:             * Adds the XML digester rules for users.<p>
3243:             * 
3244:             * @param digester the digester to add the rules to
3245:             * @param xpath the base xpath for the rules
3246:             */
3247:            protected void addAccountsUserRules(Digester digester, String xpath) {
3248:
3249:                String xp_user = xpath + N_USERS + "/" + N_USER + "/";
3250:                digester.addCallMethod(xp_user + N_NAME, "setUserName", 0);
3251:                digester.addCallMethod(xp_user + N_PASSWORD, "setUserPassword",
3252:                        0);
3253:                digester.addCallMethod(xp_user + N_FIRSTNAME,
3254:                        "setUserFirstname", 0);
3255:                digester.addCallMethod(xp_user + N_LASTNAME, "setUserLastname",
3256:                        0);
3257:                digester.addCallMethod(xp_user + N_EMAIL, "setUserEmail", 0);
3258:                digester.addCallMethod(xp_user + N_FLAGS, "setUserFlags", 0);
3259:                digester.addCallMethod(xp_user + N_DATECREATED,
3260:                        "setUserDateCreated", 0);
3261:                digester.addCallMethod(xp_user + N_USERINFO, "importUser");
3262:
3263:                String xp_info = xp_user + N_USERINFO + "/" + N_USERINFO_ENTRY;
3264:                digester.addCallMethod(xp_info, "importUserInfo", 3);
3265:                digester.addCallParam(xp_info, 0, A_NAME);
3266:                digester.addCallParam(xp_info, 1, A_TYPE);
3267:                digester.addCallParam(xp_info, 2);
3268:
3269:                digester.addCallMethod(
3270:                        xp_user + N_USERROLES + "/" + N_USERROLE,
3271:                        "importUserRole", 0);
3272:                digester.addCallMethod(xp_user + N_USERGROUPS + "/"
3273:                        + N_USERGROUP, "importUserGroup", 0);
3274:            }
3275:
3276:            /**
3277:             * Adds the XML digester rules for projects.<p>
3278:             * 
3279:             * @param digester the digester to add the rules to
3280:             * @param xpath the base xpath for the rules
3281:             */
3282:            protected void addProjectRules(Digester digester, String xpath) {
3283:
3284:                digester.addCallMethod(xpath + N_NAME, "setProjectName", 0);
3285:                digester.addCallMethod(xpath + N_DESCRIPTION,
3286:                        "setProjectDescription", 0);
3287:                digester.addCallMethod(xpath + N_MANAGERSGROUP,
3288:                        "setProjectManagers", 0);
3289:                digester.addCallMethod(xpath + N_USERSGROUP, "setProjectUsers",
3290:                        0);
3291:                digester.addCallMethod(xpath + N_RESOURCES + "/" + N_RESOURCE,
3292:                        "addProjectResource", 0);
3293:                digester.addCallMethod(xpath + N_RESOURCES, "importProject");
3294:            }
3295:
3296:            /**
3297:             * Adds the XML digester rules for resource access control entries.<p>
3298:             * 
3299:             * @param digester the digester to add the rules to
3300:             * @param xpath the base xpath for the rules
3301:             */
3302:            protected void addResourceAceRules(Digester digester, String xpath) {
3303:
3304:                String xp_ace = xpath + N_ACCESSCONTROL_ENTRIES + "/"
3305:                        + N_ACCESSCONTROL_ENTRY;
3306:                digester.addCallMethod(xpath + N_ACCESSCONTROL_ENTRIES,
3307:                        "importAccessControlEntries");
3308:                digester.addCallMethod(xp_ace, "addAccessControlEntry");
3309:                digester.addCallMethod(
3310:                        xp_ace + "/" + N_ACCESSCONTROL_PRINCIPAL,
3311:                        "setAcePrincipalId", 0);
3312:                digester
3313:                        .addCallMethod(xp_ace + "/" + N_FLAGS, "setAceFlags", 0);
3314:                String xp_perms = xp_ace + "/" + N_ACCESSCONTROL_PERMISSIONSET
3315:                        + "/";
3316:                digester.addCallMethod(xp_perms
3317:                        + N_ACCESSCONTROL_ALLOWEDPERMISSIONS,
3318:                        "setAcePermissionsAllowed", 0);
3319:                digester.addCallMethod(xp_perms
3320:                        + N_ACCESSCONTROL_DENIEDPERMISSIONS,
3321:                        "setAcePermissionsDenied", 0);
3322:            }
3323:
3324:            /**
3325:             * Adds the XML digester rules for resource attributes.<p>
3326:             * 
3327:             * @param digester the digester to add the rules to
3328:             * @param xpath the base xpath for the rules
3329:             */
3330:            protected void addResourceAttributesRules(Digester digester,
3331:                    String xpath) {
3332:
3333:                digester.addCallMethod(xpath + N_SOURCE, "setSource", 0);
3334:                digester.addCallMethod(xpath + N_DESTINATION, "setDestination",
3335:                        0);
3336:                digester.addCallMethod(xpath + N_TYPE, "setType", 0);
3337:                digester.addCallMethod(xpath + N_UUIDSTRUCTURE,
3338:                        "setStructureId", 0);
3339:                digester.addCallMethod(xpath + N_UUIDRESOURCE, "setResourceId",
3340:                        0);
3341:                digester.addCallMethod(xpath + N_DATELASTMODIFIED,
3342:                        "setDateLastModified", 0);
3343:                digester.addCallMethod(xpath + N_USERLASTMODIFIED,
3344:                        "setUserLastModified", 0);
3345:                digester.addCallMethod(xpath + N_DATECREATED, "setDateCreated",
3346:                        0);
3347:                digester.addCallMethod(xpath + N_USERCREATED, "setUserCreated",
3348:                        0);
3349:                digester.addCallMethod(xpath + N_DATERELEASED,
3350:                        "setDateReleased", 0);
3351:                digester.addCallMethod(xpath + N_DATEEXPIRED, "setDateExpired",
3352:                        0);
3353:                digester.addCallMethod(xpath + N_FLAGS, "setFlags", 0);
3354:            }
3355:
3356:            /**
3357:             * Adds the XML digester rules for resource properties.<p>
3358:             * 
3359:             * @param digester the digester to add the rules to
3360:             * @param xpath the base xpath for the rules
3361:             */
3362:            protected void addResourcePropertyRules(Digester digester,
3363:                    String xpath) {
3364:
3365:                String xp_props = xpath + N_PROPERTIES + "/" + N_PROPERTY;
3366:                // first rule in case the type is implicit
3367:                digester.addCallMethod(xp_props, "addProperty");
3368:                // second rule in case the type is given
3369:                digester.addCallMethod(xp_props, "addProperty", 1);
3370:                digester.addCallParam(xp_props, 0, A_TYPE);
3371:
3372:                digester.addCallMethod(xp_props + "/" + N_NAME,
3373:                        "setPropertyName", 0);
3374:                digester.addCallMethod(xp_props + "/" + N_VALUE,
3375:                        "setPropertyValue", 0);
3376:                digester.addCallMethod(xpath + N_PROPERTIES, "importResource");
3377:            }
3378:
3379:            /**
3380:             * Adds the XML digester rules for resource relations.<p>
3381:             * 
3382:             * @param digester the digester to add the rules to
3383:             * @param xpath the base xpath for the rules
3384:             */
3385:            protected void addResourceRelationRules(Digester digester,
3386:                    String xpath) {
3387:
3388:                String xp_rels = xpath + N_RELATIONS + "/" + N_RELATION;
3389:                digester.addCallMethod(xp_rels, "addRelation");
3390:                digester
3391:                        .addCallMethod(xp_rels + "/" + N_ID, "setRelationId", 0);
3392:                digester.addCallMethod(xp_rels + "/" + N_PATH,
3393:                        "setRelationPath", 0);
3394:                digester.addCallMethod(xp_rels + "/" + N_TYPE,
3395:                        "setRelationType", 0);
3396:            }
3397:
3398:            /**
3399:             * Checks if the resources is in the list of immutable resources.<p>
3400:             * 
3401:             * @param resourceName the name of the resource
3402:             * 
3403:             * @return <code>true</code> or <code>false</code>
3404:             */
3405:            protected boolean checkImmutable(String resourceName) {
3406:
3407:                boolean resourceImmutable = false;
3408:                if (getImmutableResources().contains(resourceName)) {
3409:                    if (LOG.isDebugEnabled()) {
3410:                        LOG
3411:                                .debug(Messages
3412:                                        .get()
3413:                                        .getBundle()
3414:                                        .key(
3415:                                                Messages.LOG_IMPORTEXPORT_RESOURCENAME_IMMUTABLE_1,
3416:                                                resourceName));
3417:                    }
3418:                    // this resource must not be modified by an import if it already exists
3419:                    String storedSiteRoot = getCms().getRequestContext()
3420:                            .getSiteRoot();
3421:                    try {
3422:                        getCms().getRequestContext().setSiteRoot("/");
3423:                        getCms().readResource(resourceName);
3424:                        resourceImmutable = true;
3425:                        if (LOG.isDebugEnabled()) {
3426:                            LOG
3427:                                    .debug(Messages
3428:                                            .get()
3429:                                            .getBundle()
3430:                                            .key(
3431:                                                    Messages.LOG_IMPORTEXPORT_IMMUTABLE_FLAG_SET_1,
3432:                                                    resourceName));
3433:                        }
3434:                    } catch (CmsException e) {
3435:                        // resourceNotImmutable will be true 
3436:                        if (LOG.isDebugEnabled()) {
3437:                            LOG
3438:                                    .debug(
3439:                                            Messages
3440:                                                    .get()
3441:                                                    .getBundle()
3442:                                                    .key(
3443:                                                            Messages.LOG_IMPORTEXPORT_ERROR_ON_TEST_IMMUTABLE_1,
3444:                                                            resourceName), e);
3445:                        }
3446:                    } finally {
3447:                        getCms().getRequestContext()
3448:                                .setSiteRoot(storedSiteRoot);
3449:                    }
3450:                }
3451:                return resourceImmutable;
3452:            }
3453:
3454:            /**
3455:             * Converts a given digest to base64 encoding.<p>
3456:             * 
3457:             * @param value the digest value in the legacy encoding
3458:             * 
3459:             * @return the digest in the new encoding
3460:             */
3461:            protected String convertDigestEncoding(String value) {
3462:
3463:                byte[] data = new byte[value.length() / 2];
3464:
3465:                for (int i = 0; i < data.length; i++) {
3466:                    data[i] = (byte) (Integer.parseInt(value.substring(i * 2,
3467:                            i * 2 + 2), 16) - 128);
3468:                }
3469:                return new String(Base64.encodeBase64(data));
3470:            }
3471:
3472:            /**
3473:             * Convert a given time stamp from a String format to a long value.<p>
3474:             * 
3475:             * The time stamp is either the string representation of a long value (old export format)
3476:             * or a user-readable string format.<p>
3477:             * 
3478:             * @param timestamp time stamp to convert
3479:             * 
3480:             * @return long value of the time stamp
3481:             */
3482:            protected long convertTimestamp(String timestamp) {
3483:
3484:                long value = 0;
3485:                // try to parse the time stamp string
3486:                // if it successes, its an old style long value
3487:                try {
3488:                    value = Long.parseLong(timestamp);
3489:                } catch (NumberFormatException e) {
3490:                    // the time stamp was in in a user-readable string format, create the long value form it
3491:                    try {
3492:                        value = CmsDateUtil.parseHeaderDate(timestamp);
3493:                    } catch (ParseException pe) {
3494:                        value = System.currentTimeMillis();
3495:                    }
3496:                }
3497:                return value;
3498:            }
3499:
3500:            /**
3501:             * Returns the list of properties to ignore during import.<p>
3502:             * 
3503:             * @return the list of properties to ignore during import
3504:             */
3505:            protected List getIgnoredProperties() {
3506:
3507:                if (m_ignoredProperties == null) {
3508:                    // get list of ignored properties
3509:                    m_ignoredProperties = OpenCms.getImportExportManager()
3510:                            .getIgnoredProperties();
3511:                    if (m_ignoredProperties == null) {
3512:                        m_ignoredProperties = Collections.EMPTY_LIST;
3513:                    }
3514:                }
3515:                return m_ignoredProperties;
3516:            }
3517:
3518:            /**
3519:             * Returns the list of immutable resources.<p>
3520:             * 
3521:             * @return the list of immutable resources
3522:             */
3523:            protected List getImmutableResources() {
3524:
3525:                if (m_immutables == null) {
3526:                    // get list of immutable resources
3527:                    m_immutables = OpenCms.getImportExportManager()
3528:                            .getImmutableResources();
3529:                    if (m_immutables == null) {
3530:                        m_immutables = Collections.EMPTY_LIST;
3531:                    }
3532:                    if (LOG.isDebugEnabled()) {
3533:                        LOG
3534:                                .debug(Messages
3535:                                        .get()
3536:                                        .getBundle()
3537:                                        .key(
3538:                                                Messages.LOG_IMPORTEXPORT_IMMUTABLE_RESOURCES_SIZE_1,
3539:                                                Integer.toString(m_immutables
3540:                                                        .size())));
3541:                    }
3542:                }
3543:                return m_immutables;
3544:            }
3545:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.