Imports the OpenCms groups.<p>

@throws CmsImportExportException if something goes wrong
540928
protected void importGroups() throws CmsImportExportException {

        List<Node> groupNodes;
        Element currentElement;
        String name, description, flags, parentgroup;
        try {
            // getAll group nodes
            groupNodes = m_docXml.selectNodes("//" + A_CmsImport.N_GROUPDATA);
            // walk through all groups in manifest
            for (int i = 0; i < groupNodes.size(); i++) {
                currentElement = (Element)groupNodes.get(i);
                name = getChildElementTextValue(currentElement, A_CmsImport.N_NAME);
                name = OpenCms.getImportExportManager().translateGroup(name);
                description = getChildElementTextValue(currentElement, A_CmsImport.N_DESCRIPTION);
                flags = getChildElementTextValue(currentElement, A_CmsImport.N_FLAGS);
                parentgroup = getChildElementTextValue(currentElement, A_CmsImport.N_PARENTGROUP);
                if ((parentgroup != null) && (parentgroup.length() > 0)) {
                    parentgroup = OpenCms.getImportExportManager().translateGroup(parentgroup);
                }
                // import this group

                importGroup(name, description, flags, parentgroup);
            }

            // now try to import the groups in the stack
            while (!m_groupsToCreate.empty()) {
                Stack<Map<String, String>> tempStack = m_groupsToCreate;
                m_groupsToCreate = new Stack<Map<String, String>>();
                while (tempStack.size() > 0) {
                    Map<String, String> groupdata = tempStack.pop();
                    name = groupdata.get(A_CmsImport.N_NAME);
                    description = groupdata.get(A_CmsImport.N_DESCRIPTION);
                    flags = groupdata.get(A_CmsImport.N_FLAGS);
                    parentgroup = groupdata.get(A_CmsImport.N_PARENTGROUP);
                    // try to import the group
                    importGroup(name, description, flags, parentgroup);
                }
            }
        } catch (CmsImportExportException e) {

            throw e;
        } catch (Exception e) {

            m_report.println(e);

            CmsMessageContainer message = Messages.get().container(Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_GROUPS_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }

            throw new CmsImportExportException(message, e);
        }
    }
283137
public static Map<CmsUUID, CmsUser> addExportAllUsers(CmsObject cms, String ou, Map<CmsUUID, CmsUser> exportUsers)
    throws CmsException {

        List<CmsUser> users = OpenCms.getOrgUnitManager().getUsers(cms, ou, false);
        if ((users != null) && (users.size() > 0)) {
            Iterator<CmsUser> itUsers = users.iterator();
            while (itUsers.hasNext()) {
                CmsUser user = itUsers.next();
                if (!exportUsers.containsKey(user.getId())) {
                    exportUsers.put(user.getId(), user);
                }
            }
        }
        return exportUsers;
    }
142972
private synchronized void initModuleExportPoints() {

        Set<CmsExportPoint> exportPoints = new HashSet<CmsExportPoint>();
        Iterator<CmsModule> i = m_modules.values().iterator();
        while (i.hasNext()) {
            CmsModule module = i.next();
            List<CmsExportPoint> moduleExportPoints = module.getExportPoints();
            for (int j = 0; j < moduleExportPoints.size(); j++) {
                CmsExportPoint point = moduleExportPoints.get(j);
                if (exportPoints.contains(point)) {
                    if (LOG.isWarnEnabled()) {
                        LOG.warn(
                            Messages.get().getBundle().key(
                                Messages.LOG_DUPLICATE_EXPORT_POINT_2,
                                point,
                                module.getName()));
                    }
                } else {
                    exportPoints.add(point);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(
                            Messages.get().getBundle().key(Messages.LOG_ADD_EXPORT_POINT_2, point, module.getName()));
                    }
                }
            }
        }
        m_moduleExportPoints = Collections.unmodifiableSet(exportPoints);
    }
1079127
private void importAllResources() throws CmsImportExportException {

        String source, destination, type, uuidresource, userlastmodified, usercreated, flags, timestamp;
        long datelastmodified, datecreated;

        List<Node> fileNodes;
        List<Node> acentryNodes;
        Element currentElement, currentEntry;
        List<CmsProperty> properties = null;

        // get list of unwanted properties
        List<String> deleteProperties = OpenCms.getImportExportManager().getIgnoredProperties();
        if (deleteProperties == null) {
            deleteProperties = new ArrayList<String>();
        }
        // get list of immutable resources
        List<String> immutableResources = OpenCms.getImportExportManager().getImmutableResources();
        if (immutableResources == null) {
            immutableResources = Collections.EMPTY_LIST;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(
                Messages.get().getBundle().key(
                    Messages.LOG_IMPORTEXPORT_IMMUTABLE_RESOURCES_SIZE_1,
                    Integer.toString(immutableResources.size())));
        }
        // get the wanted page type for imported pages
        m_convertToXmlPage = OpenCms.getImportExportManager().convertToXmlPage();

        try {
            // get all file-nodes
            fileNodes = m_docXml.selectNodes("//" + A_CmsImport.N_FILE);

            int importSize = fileNodes.size();
            // walk through all files in manifest
            for (int i = 0; i < fileNodes.size(); i++) {
                m_report.print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_SUCCESSION_2,
                        String.valueOf(i + 1),
                        String.valueOf(importSize)));
                currentElement = (Element)fileNodes.get(i);
                // get all information for a file-import
                // <source>
                source = getChildElementTextValue(currentElement, A_CmsImport.N_SOURCE);
                // <destintion>
                destination = getChildElementTextValue(currentElement, A_CmsImport.N_DESTINATION);
                // <type>
                type = getChildElementTextValue(currentElement, A_CmsImport.N_TYPE);
                // <uuidstructure>
                //uuidstructure = CmsImport.getChildElementTextValue(
                //    currentElement,
                //    CmsImportExportManager.N_UUIDSTRUCTURE);
                // <uuidresource>
                uuidresource = getChildElementTextValue(currentElement, A_CmsImport.N_UUIDRESOURCE);
                // <datelastmodified>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATELASTMODIFIED);
                if (timestamp != null) {
                    datelastmodified = Long.parseLong(timestamp);
                } else {
                    datelastmodified = System.currentTimeMillis();
                }
                // <userlastmodified>
                userlastmodified = getChildElementTextValue(currentElement, A_CmsImport.N_USERLASTMODIFIED);
                // <datecreated>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATECREATED);
                if (timestamp != null) {
                    datecreated = Long.parseLong(timestamp);
                } else {
                    datecreated = System.currentTimeMillis();
                }
                // <usercreated>
                usercreated = getChildElementTextValue(currentElement, A_CmsImport.N_USERCREATED);
                // <flags>
                flags = getChildElementTextValue(currentElement, A_CmsImport.N_FLAGS);

                String translatedName = m_cms.getRequestContext().addSiteRoot(m_importPath + destination);
                if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type)) {
                    translatedName += "/";
                }
                // translate the name during import
                translatedName = m_cms.getRequestContext().getDirectoryTranslator().translateResource(translatedName);
                // check if this resource is immutable
                boolean resourceNotImmutable = checkImmutable(translatedName, immutableResources);
                translatedName = m_cms.getRequestContext().removeSiteRoot(translatedName);
                // if the resource is not immutable and not on the exclude list, import it
                if (resourceNotImmutable) {
                    // print out the information to the report
                    m_report.print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
                    m_report.print(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));
                    //m_report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0));
                    // get all properties
                    properties = readPropertiesFromManifest(currentElement, deleteProperties);

                    // import the resource
                    CmsResource res = importResource(
                        source,
                        destination,
                        type,
                        uuidresource,
                        datelastmodified,
                        userlastmodified,
                        datecreated,
                        usercreated,
                        flags,
                        properties);

                    List<CmsAccessControlEntry> aceList = new ArrayList<CmsAccessControlEntry>();
                    if (res != null) {
                        // write all imported access control entries for this file
                        acentryNodes = currentElement.selectNodes("*/" + A_CmsImport.N_ACCESSCONTROL_ENTRY);
                        // collect all access control entries
                        for (int j = 0; j < acentryNodes.size(); j++) {
                            currentEntry = (Element)acentryNodes.get(j);
                            // get the data of the access control entry
                            String id = getChildElementTextValue(currentEntry, A_CmsImport.N_ACCESSCONTROL_PRINCIPAL);
                            String acflags = getChildElementTextValue(currentEntry, A_CmsImport.N_FLAGS);
                            String allowed = getChildElementTextValue(
                                currentEntry,
                                A_CmsImport.N_ACCESSCONTROL_PERMISSIONSET
                                    + "/"
                                    + A_CmsImport.N_ACCESSCONTROL_ALLOWEDPERMISSIONS);
                            String denied = getChildElementTextValue(
                                currentEntry,
                                A_CmsImport.N_ACCESSCONTROL_PERMISSIONSET
                                    + "/"
                                    + A_CmsImport.N_ACCESSCONTROL_DENIEDPERMISSIONS);

                            // get the correct principal
                            try {
                                String principalId = new CmsUUID().toString();
                                String principal = id.substring(id.indexOf('.') + 1, id.length());

                                if (id.startsWith(I_CmsPrincipal.PRINCIPAL_GROUP)) {
                                    principal = OpenCms.getImportExportManager().translateGroup(principal);
                                    principalId = m_cms.readGroup(principal).getId().toString();
                                } else {
                                    principal = OpenCms.getImportExportManager().translateUser(principal);
                                    principalId = m_cms.readUser(principal).getId().toString();
                                }

                                // add the entry to the list
                                aceList.add(getImportAccessControlEntry(res, principalId, allowed, denied, acflags));
                            } catch (CmsDataAccessException e) {
                                // user or group not found, so do not import the ace
                            }
                        }
                        importAccessControlEntries(res, aceList);

                    } else {
                        // resource import failed, since no CmsResource was created
                        m_report.print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                        m_report.println(
                            org.opencms.report.Messages.get().container(
                                org.opencms.report.Messages.RPT_ARGUMENT_1,
                                translatedName));
                    }
                } else {
                    // skip the file import, just print out the information to the report
                    m_report.print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                    m_report.println(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));
                }
            }

        } catch (Exception e) {
            m_report.println(e);
            m_report.addError(e);

            CmsMessageContainer message = Messages.get().container(
                Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }
            throw new CmsImportExportException(message, e);
        }

    }
482978
public void addImportVersionClass(I_CmsImport importVersionClass) {

        if (LOG.isDebugEnabled()) {
            LOG.debug(
                Messages.get().getBundle().key(Messages.LOG_IMPORTEXPORT_ADDED_IMPORT_VERSION_1, importVersionClass));
        }
        m_importVersionClasses.add(importVersionClass);
    }
198018
private void getImportResource() throws CmsVfsException {

        // get the import resource
        m_importResource = new File(m_importFolderName);
        // check if this is a folder or a ZIP file
        if (m_importResource.isFile()) {
            try {
                m_zipStreamIn = new ZipInputStream(new FileInputStream(m_importResource));
            } catch (IOException e) {
                // if file but no ZIP file throw an exception
                throw new CmsVfsException(
                    Messages.get().container(Messages.ERR_NO_ZIPFILE_1, m_importResource.getName()),
                    e);
            }
        }
    }
1348348
public CmsGroup readGroupOfProject(CmsUUID project) throws Exception {

        return m_cms.readGroup(m_cms.readProject(project));
    }
704027
public void importProject() {

        try {
            if (m_throwable != null) {
                getReport().println(m_throwable);
                getReport().addError(m_throwable);

                CmsMessageContainer message = Messages.get().container(
                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_PROJECTS_0);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(message.key(), m_throwable);
                }
                m_throwable = null;

                return;
            }

            getReport().print(Messages.get().container(Messages.RPT_IMPORT_PROJECT_0), I_CmsReport.FORMAT_NOTE);
            getReport().print(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_ARGUMENT_1, m_projectName));
            getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

            try {
                getCms().readProject(m_projectName);
                // the project already exists and will not be created
                getReport().println(Messages.get().container(Messages.RPT_NOT_CREATED_0), I_CmsReport.FORMAT_OK);
                return;
            } catch (CmsDataAccessException e) {
                // ok, continue creating the project
            }

            // create the project
            CmsProject project = getCms().createProject(
                m_projectName,
                m_projectDescription,
                m_projectUsers,
                m_projectManagers,
                CmsProject.PROJECT_TYPE_NORMAL);
            // set the resources
            if (m_projectResources != null) {
                String site = getCms().getRequestContext().getSiteRoot();
                CmsProject currentProject = getCms().getRequestContext().getCurrentProject();
                try {
                    getCms().getRequestContext().setSiteRoot("");
                    getCms().getRequestContext().setCurrentProject(project);

                    Iterator<String> itResNames = m_projectResources.iterator();
                    while (itResNames.hasNext()) {
                        String resName = itResNames.next();
                        try {
                            getCms().copyResourceToProject(resName);
                        } catch (CmsVfsResourceNotFoundException e) {
                            // resource does not exist, skip
                        }
                    }
                } finally {
                    getCms().getRequestContext().setSiteRoot(site);
                    getCms().getRequestContext().setCurrentProject(currentProject);
                }
            }
            getReport().println(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                I_CmsReport.FORMAT_OK);
        } catch (CmsException e) {
            getReport().println(e);
            getReport().addError(e);

            CmsMessageContainer message = Messages.get().container(
                Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_PROJECTS_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }
            m_throwable = null;
        } finally {
            m_projectName = null;
            m_projectDescription = null;
            m_projectManagers = null;
            m_projectUsers = null;
            m_projectResources = null;
        }

    }
430467
private CmsModule createModuleFolders(CmsObject cms, CmsModule module) throws CmsException {

        String modulePath = CmsWorkplace.VFS_PATH_MODULES + module.getName() + "/";
        List<CmsExportPoint> exportPoints = module.getExportPoints();
        List<String> resources = module.getResources();

        // set the createModuleFolder flag if any other flag is set
        if (module.isCreateClassesFolder()
            || module.isCreateElementsFolder()
            || module.isCreateI18NFolder()
            || module.isCreateLibFolder()
            || module.isCreateResourcesFolder()
            || module.isCreateSchemasFolder()
            || module.isCreateTemplateFolder()
            || module.isCreateFormattersFolder()) {
            module.setCreateModuleFolder(true);
        }

        Set<String> exportPointPaths = new HashSet<String>();
        for (CmsExportPoint exportPoint : exportPoints) {
            exportPointPaths.add(exportPoint.getUri());
        }

        // check if we have to create the module folder

        I_CmsResourceType folderType = OpenCms.getResourceManager().getResourceType(
            CmsResourceTypeFolder.getStaticTypeName());
        I_CmsResourceType configType = OpenCms.getResourceManager().getResourceType(CmsADEManager.MODULE_CONFIG_TYPE);

        if (module.isCreateModuleFolder()) {
            CmsResource resource = cms.createResource(modulePath, folderType);
            CmsResource configResource = cms.createResource(modulePath + CONFIG_FILE, configType);
            try {
                cms.unlockResource(resource);
                cms.unlockResource(configResource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
            // add the module folder to the resource list
            resources.add(modulePath);
            module.setResources(resources);
        }

        // check if we have to create the template folder
        if (module.isCreateTemplateFolder()) {
            String path = modulePath + PATH_TEMPLATES;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        if (module.isCreateI18NFolder()) {
            String path = modulePath + PATH_i18n;
            CmsResource resource = cms.createResource(path, folderType);
            CmsResource bundleResource = cms.createResource(
                path + module.getName() + SUFFIX_BUNDLE_FILE + "_" + CmsLocaleManager.getDefaultLocale(),
                OpenCms.getResourceManager().getResourceType(CmsVfsBundleManager.TYPE_PROPERTIES_BUNDLE),
                null,
                null);
            cms.writeResource(bundleResource);
            try {
                cms.unlockResource(resource);
                cms.unlockResource(bundleResource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        // check if we have to create the elements folder
        if (module.isCreateElementsFolder()) {
            String path = modulePath + PATH_ELEMENTS;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        if (module.isCreateFormattersFolder()) {
            String path = modulePath + PATH_FORMATTERS;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        // check if we have to create the schemas folder
        if (module.isCreateSchemasFolder()) {
            String path = modulePath + PATH_SCHEMAS;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        // check if we have to create the resources folder
        if (module.isCreateResourcesFolder()) {
            String path = modulePath + PATH_RESOURCES;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
        }

        // check if we have to create the lib folder
        if (module.isCreateLibFolder()) {
            String path = modulePath + PATH_LIB;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
            if (!exportPointPaths.contains(path)) {
                CmsExportPoint exp = new CmsExportPoint(path, "WEB-INF/lib/");
                exportPoints.add(exp);
            }
            module.setExportPoints(exportPoints);
        }

        // check if we have to create the classes folder
        if (module.isCreateClassesFolder()) {
            String path = modulePath + PATH_CLASSES;
            CmsResource resource = cms.createResource(path, folderType);
            try {
                cms.unlockResource(resource);
            } catch (CmsLockException locke) {
                LOG.warn("Unbale to unlock resource", locke);
            }
            if (!exportPointPaths.contains(path)) {
                CmsExportPoint exp = new CmsExportPoint(path, "WEB-INF/classes/");
                exportPoints.add(exp);
                module.setExportPoints(exportPoints);
            }

            // now create all subfolders for the package structure
            StringTokenizer tok = new StringTokenizer(m_module.getName(), ".");
            while (tok.hasMoreTokens()) {
                String folder = tok.nextToken();
                path += folder + "/";
                CmsResource resource2 = cms.createResource(path, folderType);
                try {
                    cms.unlockResource(resource2);
                } catch (CmsLockException locke) {
                    LOG.warn("Unbale to unlock resource", locke);
                }
            }
        }
        return module;
    }
562041
private void attachLocaleGroups(CmsResource copiedPage) throws CmsException {

        CmsLocaleGroupService localeGroupService = getRootCms().getLocaleGroupService();
        if (Status.linkable == localeGroupService.checkLinkable(m_originalPage, copiedPage)) {
            try {
                localeGroupService.attachLocaleGroupIndirect(m_originalPage, copiedPage);
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
    }
1187673
protected void initialize(CmsObject cms) throws CmsRoleViolationException {

        checkFrozen();
        // check if the user has the required permissions
        OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER);

        m_frozen = true;
        m_resources = Collections.unmodifiableList(m_resources);
        m_excluderesources = Collections.unmodifiableList(m_excluderesources);
    }
152130
public List<CmsModelPageEntry> getModelGroups() {

        List<CmsModelPageEntry> result = new ArrayList<CmsModelPageEntry>();
        CmsResourceTypeConfig config = m_adeConfig.getResourceType(
            CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME);
        if ((config != null) && !config.isDisabled()) {
            String modelGroupFolderPath = config.getFolderPath(m_cms, m_adeConfig.getBasePath());
            if (m_cms.existsResource(modelGroupFolderPath)) {
                try {
                    Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms);
                    List<CmsResource> modelResources = m_cms.readResources(
                        modelGroupFolderPath,
                        CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(
                            OpenCms.getResourceManager().getResourceType(
                                CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME)),
                        false);
                    for (CmsResource model : modelResources) {
                        CmsModelPageEntry entry = createModelPageEntry(model, false, false, wpLocale);
                        if (entry != null) {
                            result.add(entry);
                        }
                    }
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
        }
        return result;
    }
991695
@SuppressWarnings("unchecked")
    protected void readResourcesFromManifest() throws CmsImportExportException {

        String source = null, destination = null, uuidstructure = null, uuidresource = null, userlastmodified = null,
        usercreated = null, flags = null, timestamp = null;
        long datelastmodified = 0, datecreated = 0, datereleased = 0, dateexpired = 0;

        List<Node> fileNodes = null, acentryNodes = null;
        Element currentElement = null, currentEntry = null;
        List<CmsProperty> properties = null;

        // get list of immutable resources
        List<String> immutableResources = OpenCms.getImportExportManager().getImmutableResources();
        if (immutableResources == null) {
            immutableResources = Collections.emptyList();
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(
                Messages.get().getBundle().key(
                    Messages.LOG_IMPORTEXPORT_IMMUTABLE_RESOURCES_SIZE_1,
                    Integer.toString(immutableResources.size())));
        }
        // get list of ignored properties
        List<String> ignoredProperties = OpenCms.getImportExportManager().getIgnoredProperties();
        if (ignoredProperties == null) {
            ignoredProperties = Collections.emptyList();
        }

        // get the desired page type for imported pages
        m_convertToXmlPage = OpenCms.getImportExportManager().convertToXmlPage();

        try {
            // get all file-nodes
            fileNodes = m_docXml.selectNodes("//" + A_CmsImport.N_FILE);
            int importSize = fileNodes.size();

            // walk through all files in manifest
            for (int i = 0; i < fileNodes.size(); i++) {
                m_report.print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_SUCCESSION_2,
                        String.valueOf(i + 1),
                        String.valueOf(importSize)),
                    I_CmsReport.FORMAT_NOTE);
                currentElement = (Element)fileNodes.get(i);

                // <source>
                source = getChildElementTextValue(currentElement, A_CmsImport.N_SOURCE);
                // <destination>
                destination = getChildElementTextValue(currentElement, A_CmsImport.N_DESTINATION);

                // <type>
                String typeName = getChildElementTextValue(currentElement, A_CmsImport.N_TYPE);
                I_CmsResourceType type;
                try {
                    type = OpenCms.getResourceManager().getResourceType(typeName);
                } catch (CmsLoaderException e) {
                    int plainId;
                    try {
                        plainId = OpenCms.getResourceManager().getResourceType(
                            CmsResourceTypePlain.getStaticTypeName()).getTypeId();
                    } catch (CmsLoaderException e1) {
                        // this should really never happen
                        plainId = CmsResourceTypePlain.getStaticTypeId();
                    }
                    type = OpenCms.getResourceManager().getResourceType(plainId);
                }

                // <uuidstructure>
                uuidstructure = getChildElementTextValue(currentElement, A_CmsImport.N_UUIDSTRUCTURE);

                // <uuidresource>
                if (!type.isFolder()) {
                    uuidresource = getChildElementTextValue(currentElement, A_CmsImport.N_UUIDRESOURCE);
                } else {
                    uuidresource = null;
                }

                // <datelastmodified>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATELASTMODIFIED);
                if (timestamp != null) {
                    datelastmodified = convertTimestamp(timestamp);
                } else {
                    datelastmodified = System.currentTimeMillis();
                }

                // <userlastmodified>
                userlastmodified = getChildElementTextValue(currentElement, A_CmsImport.N_USERLASTMODIFIED);
                userlastmodified = OpenCms.getImportExportManager().translateUser(userlastmodified);

                // <datecreated>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATECREATED);
                if (timestamp != null) {
                    datecreated = convertTimestamp(timestamp);
                } else {
                    datecreated = System.currentTimeMillis();
                }

                // <usercreated>
                usercreated = getChildElementTextValue(currentElement, A_CmsImport.N_USERCREATED);
                usercreated = OpenCms.getImportExportManager().translateUser(usercreated);

                // <datereleased>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATERELEASED);
                if (timestamp != null) {
                    datereleased = convertTimestamp(timestamp);
                } else {
                    datereleased = CmsResource.DATE_RELEASED_DEFAULT;
                }

                // <dateexpired>
                timestamp = getChildElementTextValue(currentElement, A_CmsImport.N_DATEEXPIRED);
                if (timestamp != null) {
                    dateexpired = convertTimestamp(timestamp);
                } else {
                    dateexpired = CmsResource.DATE_EXPIRED_DEFAULT;
                }

                // <flags>
                flags = getChildElementTextValue(currentElement, A_CmsImport.N_FLAGS);

                // apply name translation and import path
                String translatedName = m_cms.getRequestContext().addSiteRoot(m_importPath + destination);
                if (type.isFolder()) {
                    // ensure folders end with a "/"
                    if (!CmsResource.isFolder(translatedName)) {
                        translatedName += "/";
                    }
                }

                // check if this resource is immutable
                boolean resourceNotImmutable = checkImmutable(translatedName, immutableResources);
                translatedName = m_cms.getRequestContext().removeSiteRoot(translatedName);
                // if the resource is not immutable and not on the exclude list, import it
                if (resourceNotImmutable) {
                    // print out the information to the report
                    m_report.print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
                    m_report.print(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));
                    m_report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
                    // get all properties
                    properties = readPropertiesFromManifest(currentElement, ignoredProperties);

                    boolean exists = m_cms.existsResource(translatedName, CmsResourceFilter.ALL);

                    // import the resource
                    CmsResource res = importResource(
                        source,
                        translatedName,
                        type,
                        uuidstructure,
                        uuidresource,
                        datelastmodified,
                        userlastmodified,
                        datecreated,
                        usercreated,
                        datereleased,
                        dateexpired,
                        flags,
                        properties);

                    if (res != null) {
                        // only set permissions if the resource did not exists or if the keep permissions flag is not set
                        if (!exists || !m_keepPermissions) {
                            // if the resource was imported add the access control entries if available
                            List<CmsAccessControlEntry> aceList = new ArrayList<CmsAccessControlEntry>();

                            // write all imported access control entries for this file
                            acentryNodes = currentElement.selectNodes("*/" + A_CmsImport.N_ACCESSCONTROL_ENTRY);

                            // collect all access control entries
                            for (int j = 0; j < acentryNodes.size(); j++) {
                                currentEntry = (Element)acentryNodes.get(j);

                                // get the data of the access control entry
                                String id = getChildElementTextValue(
                                    currentEntry,
                                    A_CmsImport.N_ACCESSCONTROL_PRINCIPAL);
                                String principalId = new CmsUUID().toString();
                                String principal = id.substring(id.indexOf('.') + 1, id.length());

                                try {
                                    if (id.startsWith(I_CmsPrincipal.PRINCIPAL_GROUP)) {
                                        principal = OpenCms.getImportExportManager().translateGroup(principal);
                                        principalId = m_cms.readGroup(principal).getId().toString();
                                    } else if (id.startsWith(I_CmsPrincipal.PRINCIPAL_USER)) {
                                        principal = OpenCms.getImportExportManager().translateUser(principal);
                                        principalId = m_cms.readUser(principal).getId().toString();
                                    } else if (id.startsWith(CmsRole.PRINCIPAL_ROLE)) {
                                        principalId = CmsRole.valueOfRoleName(principal).getId().toString();
                                    } else if (id.equalsIgnoreCase(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME)) {
                                        principalId = CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.toString();
                                    } else if (id.equalsIgnoreCase(
                                        CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME)) {
                                        principalId = CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.toString();
                                    } else {
                                        if (LOG.isWarnEnabled()) {
                                            LOG.warn(
                                                Messages.get().getBundle().key(
                                                    Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1,
                                                    id));
                                        }
                                    }

                                    String acflags = getChildElementTextValue(currentEntry, A_CmsImport.N_FLAGS);

                                    String allowed = ((Element)currentEntry.selectNodes("./"
                                        + A_CmsImport.N_ACCESSCONTROL_PERMISSIONSET
                                        + "/"
                                        + A_CmsImport.N_ACCESSCONTROL_ALLOWEDPERMISSIONS).get(0)).getTextTrim();

                                    String denied = ((Element)currentEntry.selectNodes("./"
                                        + A_CmsImport.N_ACCESSCONTROL_PERMISSIONSET
                                        + "/"
                                        + A_CmsImport.N_ACCESSCONTROL_DENIEDPERMISSIONS).get(0)).getTextTrim();

                                    // add the entry to the list
                                    aceList.add(
                                        getImportAccessControlEntry(res, principalId, allowed, denied, acflags));
                                } catch (CmsException e) {
                                    // user or group of ACE might not exist in target system, ignore ACE
                                    if (LOG.isWarnEnabled()) {
                                        LOG.warn(
                                            Messages.get().getBundle().key(
                                                Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1,
                                                translatedName),
                                            e);
                                    }
                                    m_report.println(e);
                                    m_report.addError(e);
                                }
                            }
                            importAccessControlEntries(res, aceList);
                        }

                        // Add the relations for the resource
                        importRelations(res, currentElement);

                        if (OpenCms.getResourceManager().getResourceType(
                            res.getTypeId()) instanceof I_CmsLinkParseable) {
                            // store for later use
                            m_parseables.add(res);
                        }

                        if (LOG.isInfoEnabled()) {
                            LOG.info(
                                Messages.get().getBundle().key(
                                    Messages.LOG_IMPORTING_4,
                                    new Object[] {
                                        String.valueOf(i + 1),
                                        String.valueOf(importSize),
                                        translatedName,
                                        destination}));
                        }
                    } else {
                        // resource import failed, since no CmsResource was created
                        m_report.print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                        m_report.println(
                            org.opencms.report.Messages.get().container(
                                org.opencms.report.Messages.RPT_ARGUMENT_1,
                                translatedName));

                        if (LOG.isInfoEnabled()) {
                            LOG.info(
                                Messages.get().getBundle().key(
                                    Messages.LOG_SKIPPING_3,
                                    String.valueOf(i + 1),
                                    String.valueOf(importSize),
                                    translatedName));
                        }
                    }

                } else {
                    // skip the file import, just print out the information to the report

                    m_report.print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                    m_report.println(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));

                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_SKIPPING_3,
                                String.valueOf(i + 1),
                                String.valueOf(importSize),
                                translatedName));
                    }
                }
            }
        } catch (Exception e) {
            m_report.println(e);
            m_report.addError(e);

            CmsMessageContainer message = Messages.get().container(
                Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }

            throw new CmsImportExportException(message, e);
        }
    }
71600
public void updateCmsObject(CmsObject cms) {

        try {
            m_cms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_cms = cms;
        }
    }
387223
protected void initHtmlImportObject() {

        Object o;
        String uri = getJsp().getRequestContext().getUri();
        if ((uri == null) || uri.endsWith(IMPORT_STANDARD_PATH)) {
            m_dialogMode = MODE_STANDARD;
        } else if (uri.endsWith(IMPORT_DEFAULT_PATH)) {
            m_dialogMode = MODE_DEFAULT;
        } else {
            m_dialogMode = MODE_ADVANCED;
        }
        if (CmsStringUtil.isEmpty(getParamAction())) {
            o = new CmsHtmlImport(getJsp().getCmsObject());
        } else {
            // this is not the initial call, get the job object from session
            o = getDialogObject();
        }

        if (!(o instanceof CmsHtmlImport)) {
            // create a new HTML import handler object
            m_htmlimport = new CmsHtmlImport(getJsp().getCmsObject());
        } else {
            // reuse HTML import handler object stored in session
            m_htmlimport = (CmsHtmlImport)o;
            // this is needed, because the user can switch between the sites, now get the current
            m_htmlimport.setCmsObject(getJsp().getCmsObject());
        }

        // gets the data from the configuration file
        fillHtmlImport();
    }
1337510
private CmsObject initCms(CmsObject cms) {

        try {
            cms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            LOG.error("Unable to init CmsObject");
        }
        cms.getRequestContext().setSiteRoot("");
        return cms;
    }
433153
public synchronized String addImportResult(List<CmsAliasImportResult> importResults) {

        String key = (new CmsUUID()).toString();
        m_entries.put(key, importResults);
        return key;
    }