Fills the unset fields for an imported resource with default values.<p>

@throws CmsImportExportException if something goes wrong
966883
protected void setDefaultsForEmptyResourceFields() throws CmsImportExportException {

        // get UUID for the structure
        if (m_resourceBuilder.getStructureId() == null) {
            // if null generate a new structure id
            m_resourceBuilder.setStructureId(new CmsUUID());
        }

        // get UUIDs for the resource
        if ((m_resourceBuilder.getResourceId() == null) || (m_resourceBuilder.getType().isFolder())) {
            // folders get always a new resource UUID
            m_resourceBuilder.setResourceId(new CmsUUID());
            m_resourceIdWasNull = true;
        }

        // read date last modified from the resource, default to currentTime for folders
        if (m_resourceBuilder.getDateLastModified() == DATE_LAST_MODIFICATION_FILETIME) {
            if (null != m_source) {
                m_resourceBuilder.setDateLastModified(m_helper.getFileModification(m_source));
            } else {
                m_resourceBuilder.setDateLastModified(System.currentTimeMillis());
            }
        }

        if (m_resourceBuilder.getDateLastModified() == DATE_LAST_MODIFICATION_UNSPECIFIED) {
            m_resourceBuilder.setDateLastModified(System.currentTimeMillis());
        }

        if (null == m_resourceBuilder.getUserLastModified()) {
            m_resourceBuilder.setUserLastModified(m_cms.getRequestContext().getCurrentUser().getId());
        }

        if (m_resourceBuilder.getDateCreated() == DATE_CREATED_UNSPECIFIED) {
            m_resourceBuilder.setDateCreated(System.currentTimeMillis());
        }

        if (m_resourceBuilder.getUserCreated().isNullUUID()) {
            m_resourceBuilder.setUserCreated(getRequestContext().getCurrentUser().getId());
        }

        if (m_properties == null) {
            m_properties = new HashMap<String, CmsProperty>();
        }
    }
892881
public void importResource() {

        boolean resourceIdWasNull = false;

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

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

                return;
            }

            // apply name translation and import path
            String translatedName = getCms().getRequestContext().addSiteRoot(
                m_parameters.getDestinationPath() + m_destination);

            boolean resourceImmutable = checkImmutable(translatedName);
            translatedName = getCms().getRequestContext().removeSiteRoot(translatedName);
            // if the resource is not immutable and not on the exclude list, import it
            if (!resourceImmutable) {
                // print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
                getReport().print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                        translatedName));
                getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

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

                byte[] content = null;
                // get the file content
                if (m_source != null) {
                    content = m_helper.getFileBytes(m_source);
                }
                int size = 0;
                if (content != null) {
                    size = content.length;
                }

                // get UUID for the structure
                if (m_structureId == null) {
                    // if null generate a new structure id
                    m_structureId = new CmsUUID();
                }

                // get UUIDs for the resource
                if ((m_resourceId == null) || (m_type.isFolder())) {
                    // folders get always a new resource UUID
                    m_resourceId = new CmsUUID();
                    resourceIdWasNull = true;
                }

                // create a new CmsResource
                CmsResource resource = new CmsResource(
                    m_structureId,
                    m_resourceId,
                    translatedName,
                    m_type.getTypeId(),
                    m_type.isFolder(),
                    m_flags,
                    getCms().getRequestContext().getCurrentProject().getUuid(),
                    CmsResource.STATE_NEW,
                    m_dateCreated,
                    m_userCreated,
                    m_dateLastModified,
                    m_userLastModified,
                    m_dateReleased,
                    m_dateExpired,
                    1,
                    size,
                    System.currentTimeMillis(),
                    0);

                if (m_properties == null) {
                    m_properties = new HashMap<String, CmsProperty>();
                }

                if (m_type.isFolder() || resourceIdWasNull || hasContentInVfsOrImport(resource)) {
                    // import this resource in the VFS
                    m_resource = getCms().importResource(
                        translatedName,
                        resource,
                        content,
                        new ArrayList<CmsProperty>(m_properties.values()));
                }

                // only set permissions if the resource did not exists or if the keep permissions flag is not set
                m_importACEs = (m_resource != null) && (!exists || !m_parameters.isKeepPermissions());

                if (m_resource != null) {
                    getReport().println(
                        org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                        I_CmsReport.FORMAT_OK);

                    if (OpenCms.getResourceManager().getResourceType(
                        m_resource.getTypeId()) instanceof I_CmsLinkParseable) {
                        // store for later use
                        m_parseables.add(m_resource);
                    }
                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_IMPORTING_4,
                                new Object[] {
                                    String.valueOf(m_fileCounter),
                                    String.valueOf(m_totalFiles),
                                    translatedName,
                                    m_destination}));
                    }
                } else {
                    // resource import failed, since no CmsResource was created
                    getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                    getReport().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(m_fileCounter),
                                String.valueOf(m_totalFiles),
                                translatedName));
                    }
                }
            } else {
                m_resource = null;
                // skip the file import, just print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                getReport().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(m_fileCounter),
                            String.valueOf(m_totalFiles),
                            translatedName));
                }
                // do not import ACEs
                m_importACEs = false;
            }
        } catch (Exception e) {
            m_resource = null;
            m_importACEs = false;

            getReport().println(e);
            getReport().addError(e);

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

            return;
        } finally {
            m_structureId = null;
            m_resourceId = null;
            m_destination = null;
            m_source = null;
            m_type = null;
            m_flags = 0;
            m_dateCreated = 0;
            m_dateLastModified = 0;
            m_dateReleased = CmsResource.DATE_RELEASED_DEFAULT;
            m_dateExpired = CmsResource.DATE_EXPIRED_DEFAULT;
            m_properties = null;
            m_throwable = null;
            m_aces = null;
            m_properties = null;
        }
    }
212851
protected void importUserFromFile() {

        CmsImportUserThread thread = new CmsImportUserThread(
            m_cms,
            m_ou,
            m_userImportList,
            getGroupsList(m_importGroups, true),
            getRolesList(m_importRoles, true),
            m_sendMail.getValue().booleanValue());
        thread.start();
        CmsShowReportDialog dialog = new CmsShowReportDialog(thread, new Runnable() {

            public void run() {

                m_window.close();
            }
        });
        m_window.setContent(dialog);

    }
799117
public void clear() {
        this.variables.clear();
        this.methods.clear();
        this.importedClasses.clear();
        this.importedPackages.clear();
        this.importedCommands.clear();
        this.importedObjects.clear();
        if (this.parent == null)
            this.loadDefaultImports();
        this.classCache.clear();
        this.names.clear();
    }
1254368
public void updateExportPoints(CmsDbContext dbc) {

        try {
            // read the export points and return immediately if there are no export points at all
            Set<CmsExportPoint> exportPoints = new HashSet<CmsExportPoint>();
            exportPoints.addAll(OpenCms.getExportPoints());
            exportPoints.addAll(OpenCms.getModuleManager().getExportPoints());
            if (exportPoints.size() == 0) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_EXPORT_POINTS_CONFIGURED_0));
                }
                return;
            }

            // create the driver to write the export points
            I_CmsExportPointDriver exportPointDriver = OpenCms.getImportExportManager().createExportPointDriver(
                exportPoints);

            // the export point hash table contains RFS export paths keyed by their internal VFS paths
            Iterator<String> i = exportPointDriver.getExportPointPaths().iterator();
            I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
            while (i.hasNext()) {
                String currentExportPoint = i.next();

                // print some report messages
                if (LOG.isInfoEnabled()) {
                    LOG.info(Messages.get().getBundle().key(Messages.LOG_WRITE_EXPORT_POINT_1, currentExportPoint));
                }

                try {
                    CmsResourceFilter filter = CmsResourceFilter.DEFAULT;
                    List<CmsResource> resources = vfsDriver.readResourceTree(
                        dbc,
                        CmsProject.ONLINE_PROJECT_ID,
                        currentExportPoint,
                        filter.getType(),
                        filter.getState(),
                        filter.getModifiedAfter(),
                        filter.getModifiedBefore(),
                        filter.getReleaseAfter(),
                        filter.getReleaseBefore(),
                        filter.getExpireAfter(),
                        filter.getExpireBefore(),
                        CmsDriverManager.READMODE_INCLUDE_TREE
                            | (filter.excludeType() ? CmsDriverManager.READMODE_EXCLUDE_TYPE : 0)
                            | (filter.excludeState() ? CmsDriverManager.READMODE_EXCLUDE_STATE : 0));

                    Iterator<CmsResource> j = resources.iterator();
                    while (j.hasNext()) {
                        CmsResource currentResource = j.next();

                        if (currentResource.isFolder()) {
                            // export the folder
                            exportPointDriver.createFolder(currentResource.getRootPath(), currentExportPoint);
                        } else {
                            // try to create the exportpoint folder
                            exportPointDriver.createFolder(currentExportPoint, currentExportPoint);
                            byte[] onlineContent = vfsDriver.readContent(
                                dbc,
                                CmsProject.ONLINE_PROJECT_ID,
                                currentResource.getResourceId());
                            // export the file content online
                            exportPointDriver.writeFile(
                                currentResource.getRootPath(),
                                currentExportPoint,
                                onlineContent);
                        }
                    }
                } catch (CmsException e) {
                    // there might exist export points without corresponding resources in the VFS
                    // -> ignore exceptions which are not "resource not found" exception quiet here
                    if (e instanceof CmsVfsResourceNotFoundException) {
                        if (LOG.isErrorEnabled()) {
                            LOG.error(Messages.get().getBundle().key(Messages.LOG_UPDATE_EXORT_POINTS_ERROR_0), e);
                        }
                    }
                }
            }
        } catch (Exception e) {
            if (LOG.isErrorEnabled()) {
                LOG.error(Messages.get().getBundle().key(Messages.LOG_UPDATE_EXORT_POINTS_ERROR_0), e);
            }
        }
    }
847161
protected void initUserObject() {

        if (m_fieldconfiguration == null) {
            try {
                m_fieldconfiguration = m_searchManager.getFieldConfiguration(getParamFieldconfiguration());
                if (m_fieldconfiguration == null) {
                    m_fieldconfiguration = new CmsLuceneFieldConfiguration();
                }
            } catch (Exception e) {
                m_fieldconfiguration = new CmsLuceneFieldConfiguration();
            }
        }

        if (m_field == null) {
            try {
                Iterator<CmsSearchField> itFields = m_fieldconfiguration.getFields().iterator();
                while (itFields.hasNext()) {
                    CmsSearchField curField = itFields.next();
                    if (curField.getName().equals(getParamField())) {
                        m_field = curField;
                        break;
                    }
                }
                if (m_field == null) {
                    m_field = new CmsLuceneField();
                }
            } catch (Exception e) {
                m_field = new CmsLuceneField();
            }
        }
        if (m_mapping == null) {
            try {
                Iterator<I_CmsSearchFieldMapping> itMappings = m_field.getMappings().iterator();
                while (itMappings.hasNext()) {
                    I_CmsSearchFieldMapping curMapping = itMappings.next();
                    if (curMapping.getType().toString().equals(getParamType())
                        && (((curMapping.getParam() == null) && getParamParam().equals("-"))
                            || (curMapping.getParam().equals(getParamParam())))) {
                        m_mapping = curMapping;
                        break;
                    }
                }
                if (m_mapping == null) {
                    m_mapping = new CmsSearchFieldMapping(true);
                }
            } catch (Exception e) {
                m_mapping = new CmsSearchFieldMapping(true);
            }
        }
    }
1259076
void resetFields() {

        if (m_bundleComponentKeyMap != null) {
            Set<TextField> setBundles = m_bundleComponentKeyMap.keySet();

            for (TextField field : setBundles) {
                m_bundleValues.removeComponent(field);
            }
            m_bundleComponentKeyMap.clear();
        }
        m_fieldKeepTemplate.setVisible(!CmsStringUtil.isEmptyOrWhitespaceOnly(m_fieldLoadSiteTemplate.getValue()));
        m_fieldKeepTemplate.setValue(
            Boolean.valueOf(!CmsStringUtil.isEmptyOrWhitespaceOnly(m_fieldLoadSiteTemplate.getValue())));
    }
1340723
public void fillTable(CmsObject cms, List<CmsResource> resources, boolean clearFilter, boolean sort) {

        Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
        m_container.removeAllItems();
        if (clearFilter) {
            m_container.removeAllContainerFilters();
        }
        for (CmsResource resource : resources) {
            fillItem(cms, resource, wpLocale);
        }
        if (sort) {
            m_fileTable.sort();
        }
        clearSelection();
    }
943445
public function reset()
    {
        $this->layout = null;
        $this->namedCompilers = [];
        $this->importPaths = [];
        $this->importNodeYielded = false;
        $this->importNode = null;
        $this->parentCompiler = null;
    }
1291356
public void initConfiguration() throws CmsConfigurationException {

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LOADER_CONFIG_FINISHED_0));
        }

        m_resourceTypesFromXml = Collections.unmodifiableList(m_resourceTypesFromXml);
        m_loaderList = Collections.unmodifiableList(m_loaderList);
        Collections.sort(m_configuredMimeTypes);
        m_configuredMimeTypes = Collections.unmodifiableList(m_configuredMimeTypes);
        m_configuredRelationTypes = Collections.unmodifiableList(m_configuredRelationTypes);

        // initialize the HTML converters
        initHtmlConverters();
        m_configuredHtmlConverters = Collections.unmodifiableList(m_configuredHtmlConverters);

        // initialize the resource types
        initResourceTypes();
        // initialize the MIME types
        initMimeTypes();
    }
446379
protected void initializeMissingFieldsFromVfs(CmsObject cms, CmsUUID structureId) {

        if (structureId == null) {
            return;
        }
        if ((m_title != null) && (m_description != null)) {
            return;
        }

        try {
            CmsResource res = cms.readResource(structureId);
            if (m_description == null) {
                CmsProperty descProp = cms.readPropertyObject(
                    res,
                    CmsPropertyDefinition.PROPERTY_DESCRIPTION,
                    CmsResourceTypeXmlContainerPage.isContainerPage(res));
                m_description = descProp.getValue();
            }

            if (m_title == null) {
                CmsProperty titleProp = cms.readPropertyObject(
                    res,
                    CmsPropertyDefinition.PROPERTY_TITLE,
                    CmsResourceTypeXmlContainerPage.isContainerPage(res));
                m_title = titleProp.getValue();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_title)) {
                    m_title = res.getName();
                }
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return;
        }
    }
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;
        }

    }
455473
protected void initUserObject() {

        if (m_fieldconfiguration == null) {
            try {
                m_fieldconfiguration = m_searchManager.getFieldConfiguration(getParamFieldconfiguration());
                if (m_fieldconfiguration == null) {
                    m_fieldconfiguration = new CmsLuceneFieldConfiguration();
                }
            } catch (Exception e) {
                m_fieldconfiguration = new CmsLuceneFieldConfiguration();
            }
        }
    }
154800
private void createResources(CmsUploadListener listener) throws CmsException, UnsupportedEncodingException {

        CmsObject cms = getCmsObject();
        String[] isRootPathVals = m_parameterMap.get(I_CmsUploadConstants.UPLOAD_IS_ROOT_PATH_FIELD_NAME);
        if ((isRootPathVals != null) && (isRootPathVals.length > 0) && Boolean.parseBoolean(isRootPathVals[0])) {
            cms = m_rootCms;
        }
        // get the target folder
        String targetFolder = getTargetFolder(cms);
        m_uploadHook = OpenCms.getWorkplaceManager().getUploadHook(cms, targetFolder);

        List<String> filesToUnzip = getFilesToUnzip();

        // iterate over the list of files to upload and create each single resource
        for (FileItem fileItem : m_multiPartFileItems) {
            if ((fileItem != null) && (!fileItem.isFormField())) {
                // read the content of the file
                byte[] content = fileItem.get();
                fileItem.delete();

                // determine the new resource name
                String fileName = m_parameterMap.get(
                    fileItem.getFieldName() + I_CmsUploadConstants.UPLOAD_FILENAME_ENCODED_SUFFIX)[0];
                fileName = URLDecoder.decode(fileName, "UTF-8");

                if (filesToUnzip.contains(CmsResource.getName(fileName.replace('\\', '/')))) {
                    // import the zip
                    CmsImportFolder importZip = new CmsImportFolder();
                    try {
                        importZip.importZip(content, targetFolder, cms, false);
                    } finally {
                        // get the created resource names
                        for (CmsResource importedResource : importZip.getImportedResources()) {
                            m_resourcesCreated.put(
                                importedResource.getStructureId().toString(),
                                importedResource.getName());
                        }
                    }
                } else {
                    // create the resource
                    CmsResource importedResource = createSingleResource(cms, fileName, targetFolder, content);
                    // add the name of the created resource to the list of successful created resources
                    m_resourcesCreated.put(importedResource.getStructureId().toString(), importedResource.getName());
                }

                if (listener.isCanceled()) {
                    throw listener.getException();
                }
            }
        }
    }
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);
        }

    }
1331585
protected void removeEmptyResourceFields() {

        Set<Component> componentsToRemove = new HashSet<Component>();
        int count = 0;
        Component lastElement = null;

        for (Component c : m_resources) {
            if (c instanceof CmsRemovableFormRow<?>) {
                count++;
                AbstractField<?> field = (AbstractField<?>)((CmsRemovableFormRow)c).getInput();
                String value = (String)(field.getValue());
                if (value.isEmpty()) {
                    componentsToRemove.add(c);
                    lastElement = c;
                }
            }
        }

        //if all fields are empty -> keep one of them to attach validator to
        if (componentsToRemove.size() == count) {
            componentsToRemove.remove(lastElement);
        }

        if (count == 0) {
            addResource("");
        }

        for (Component c : componentsToRemove) {
            m_resources.removeComponent(c);
            m_componentsToValidate.remove(c);
        }
    }
893216
public void initialize(CmsObject cms) {

        if (!m_availableLocales.contains(Locale.ENGLISH)) {
            throw new RuntimeException("The locale 'en' must be configured in opencms-system.xml.");
        }
        // init the locale handler
        m_localeHandler.initHandler(cms);
        // set default locale
        m_defaultLocale = m_defaultLocales.get(0);
        initLanguageDetection();
        // set initialized status
        m_initialized = true;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_CONFIG_VFSACCESS_0));
        }
    }