Stores the import resource in an Object member variable.<p>
@throws CmsVfsException if the file to import is no valid zipfile
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);
            }
        }
    }
1338235
protected void initMembers() {

        synchronized (LOCK) {
            m_resourceInitHandlers = new ArrayList<I_CmsResourceInit>();
            m_requestHandlers = new HashMap<String, I_CmsRequestHandler>();
            m_systemInfo = new CmsSystemInfo();
            m_exportPoints = Collections.emptySet();
            m_defaultUsers = new CmsDefaultUsers();
            m_localeManager = new CmsLocaleManager(Locale.ENGLISH);
            m_sessionManager = new CmsSessionManager();
            m_runtimeProperties = new Hashtable<Object, Object>();
            // the default event manager must be available because the configuration already registers events
            m_eventManager = new CmsEventManager();
            // default link manager is required for test cases
            m_linkManager = new CmsLinkManager(new CmsDefaultLinkSubstitutionHandler());
        }
    }
227020
protected void processImportResource(CmsObject cms, CmsResourceImportData resData, int index) {

        boolean changed = false;
        m_report.print(
            org.opencms.report.Messages.get().container(
                org.opencms.report.Messages.RPT_ARGUMENT_1,
                "( " + index + " / " + m_moduleData.getResourceData().size() + " ) "),
            I_CmsReport.FORMAT_NOTE);
        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, resData.getPath()));
        m_report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
        try {
            CmsResource oldRes = null;
            try {
                if (resData.hasStructureId()) {
                    oldRes = cms.readResource(
                        resData.getResource().getStructureId(),
                        CmsResourceFilter.IGNORE_EXPIRATION);
                } else {
                    oldRes = cms.readResource(resData.getPath(), CmsResourceFilter.IGNORE_EXPIRATION);
                }
            } catch (CmsVfsResourceNotFoundException e) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
            CmsResource currentRes = oldRes;
            if (oldRes != null) {
                String oldPath = cms.getSitePath(oldRes);
                String newPath = resData.getPath();
                if (!CmsStringUtil.comparePaths(oldPath, resData.getPath())) {
                    cms.moveResource(oldPath, newPath);
                    changed = true;
                    currentRes = cms.readResource(oldRes.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
                }
            }
            boolean needsImport = true;
            boolean reducedExport = !resData.hasDateLastModified();
            byte[] content = resData.getContent();
            if (oldRes != null) {
                if (!resData.hasStructureId()) {
                    needsImport = false;
                } else if (oldRes.getState().isUnchanged()
                    && !needToUpdateResourceFields(oldRes, resData.getResource(), reducedExport)) {

                    // if resource is changed or new, we don't want to go into this code block
                    // because even if the content / metaadata are the same, we still want the file to be published at the end,
                    // so we import it to add it to the current working project

                    if (oldRes.isFile() && (content != null)) {
                        CmsFile file = cms.readFile(oldRes);
                        if (Arrays.equals(file.getContents(), content)) {
                            needsImport = false;
                        } else {
                            LOG.debug("Content mismatch for " + file.getRootPath());
                        }
                    } else {
                        needsImport = false;
                    }
                }
            }
            if (needsImport || (oldRes == null)) { // oldRes null check is redundant, we just do it to remove the warning in Eclipse
                currentRes = cms.importResource(
                    resData.getPath(),
                    resData.getResource(),
                    content,
                    new ArrayList<CmsProperty>());
                changed = true;
                m_importIds.add(currentRes.getStructureId());
            } else {
                currentRes = cms.readResource(oldRes.getStructureId(), CmsResourceFilter.ALL);
                CmsLock lock = cms.getLock(currentRes);
                if (lock.isUnlocked()) {
                    lock(cms, currentRes);
                }
            }
            resData.setImportResource(currentRes);
            List<CmsProperty> propsToWrite = compareProperties(cms, resData, currentRes);
            if (!propsToWrite.isEmpty()) {
                cms.writePropertyObjects(currentRes, propsToWrite);
                changed = true;
            }
            changed |= updateAcls(cms, resData, currentRes);
            if (changed) {
                m_report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                    I_CmsReport.FORMAT_OK);
            } else {
                m_report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_SKIPPED_0),
                    I_CmsReport.FORMAT_NOTE);
            }

        } catch (Exception e) {
            m_report.println(e);
            LOG.error(e.getLocalizedMessage(), e);

        }
    }
601394
private void init(CmsResource resource, CmsObject cms) {

        List<CmsProperty> properties;

        try {
            properties = cms.readPropertyObjects(resource, false);
        } catch (CmsException e) {
            m_priority = 0;
            m_title = "";
            return;
        }

        try {
            m_priority = Integer.parseInt(
                CmsProperty.get(CmsPriorityResourceCollector.PROPERTY_PRIORITY, properties).getValue());
        } catch (NumberFormatException e) {
            m_priority = CmsPriorityResourceCollector.PRIORITY_STANDARD;
        }

        m_title = CmsProperty.get(CmsPropertyDefinition.PROPERTY_TITLE, properties).getValue();
        if (CmsStringUtil.isEmpty(m_title)) {
            m_title = "";
        }
    }
1008583
private void init() throws CmsException {

        // first get all installed plugins
        // plugins are subfolders of the "/plugin/" folder with a template
        // property holdding the name of the plugin class
        List resources = m_cms.readResourcesWithProperty(VFS_PATH_PLUGIN_FOLDER, CmsToolManager.HANDLERCLASS_PROPERTY);
        Iterator i = resources.iterator();
        while (i.hasNext()) {
            CmsResource res = (CmsResource)i.next();
            // ony check folders
            if (res.isFolder()) {
                String classname = m_cms.readPropertyObject(
                    res.getRootPath(),
                    CmsToolManager.HANDLERCLASS_PROPERTY,
                    false).getValue();
                try {
                    Object objectInstance = Class.forName(classname).newInstance();
                    if (objectInstance instanceof I_CmsContentCheck) {
                        I_CmsContentCheck plugin = (I_CmsContentCheck)objectInstance;
                        plugin.init(m_cms);
                        // store the plugin instance
                        m_plugins.add(plugin);
                        LOG.info(Messages.get().getBundle().key(Messages.LOG_CREATE_PLUGIN_1, classname));
                    } else {
                        LOG.warn(Messages.get().getBundle().key(Messages.LOG_CANNOT_CREATE_PLUGIN_1, classname));
                    }
                } catch (Throwable t) {
                    LOG.error(Messages.get().getBundle().key(Messages.LOG_CANNOT_CREATE_PLUGIN_2, classname, t));
                }
            }
        }
    }
590283
protected void init() throws CmsException {

        m_cms = OpenCms.initCmsObject(m_cms);
        // we want to use autocorrection when writing XML contents back
        //m_cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
        m_cms.getRequestContext().setSiteRoot("");
        List<CmsPair<CmsResource, CmsResource>> allMatchingResources = Lists.newArrayList();
        for (CmsPair<String, String> pair : m_sourceTargetPairs) {
            List<CmsPair<CmsResource, CmsResource>> matchingResources = getMatchingResources(
                pair.getFirst(),
                pair.getSecond());
            allMatchingResources.addAll(matchingResources);
        }
        for (CmsPair<CmsResource, CmsResource> resPair : allMatchingResources) {
            CmsResource source = resPair.getFirst();
            CmsResource target = resPair.getSecond();
            m_translationsById.put(source.getStructureId(), target);
            m_translationsByPath.put(source.getRootPath(), target);
        }
    }
705087
protected void initSettingsObject() {

        Object o;
        if (CmsStringUtil.isEmpty(getParamAction())) {
            o = new CmsXmlContentRepairSettings(getCms());
        } else {
            // this is not the initial call, get the settings object from session
            o = getDialogObject();
        }

        if (o == null) {
            // create a new settings object
            m_settings = new CmsXmlContentRepairSettings(getCms());
        } else {
            // reuse settings object stored in session
            m_settings = (CmsXmlContentRepairSettings)o;
        }

    }
811440
public void actionCopy() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        CmsResource resource = null;
        try {
            boolean isFolder = false;
            String source = getResourceList().get(0);
            String target = CmsLinkManager.getAbsoluteUri(getParamTarget(), CmsResource.getParentFolder(source));
            if (!isMultiOperation()) {
                resource = getCms().readResource(source, CmsResourceFilter.ALL);
                isFolder = resource.isFolder();
            } else {
                String siteRootFolder = null;
                try {
                    // check if a site root was added to the target name
                    if (OpenCms.getSiteManager().getSiteRoot(target) != null) {
                        siteRootFolder = getCms().getRequestContext().getSiteRoot();
                        if (siteRootFolder.endsWith("/")) {
                            siteRootFolder = siteRootFolder.substring(0, siteRootFolder.length() - 1);
                        }
                        getCms().getRequestContext().setSiteRoot("/");
                    }
                    resource = getCms().readResource(target, CmsResourceFilter.ALL);
                } finally {
                    if (siteRootFolder != null) {
                        getCms().getRequestContext().setSiteRoot(siteRootFolder);
                    }
                }
                if (!resource.isFolder()) {
                    // no folder selected for multi operation, throw exception
                    throw new CmsVfsException(
                        Messages.get().container(Messages.ERR_COPY_MULTI_TARGET_NOFOLDER_1, target));
                }
            }
            if (performDialogOperation()) {
                // if no exception is caused and "true" is returned copy operation was successful
                if (isMultiOperation() || isFolder) {
                    // set request attribute to reload the explorer tree view
                    List<String> folderList = new ArrayList<String>(1);
                    String targetParent = CmsResource.getParentFolder(target);
                    folderList.add(targetParent);
                    getJsp().getRequest().setAttribute(REQUEST_ATTRIBUTE_RELOADTREE, folderList);
                }
                actionCloseDialog();
            } else {
                // "false" returned, display "please wait" screen
                getJsp().include(FILE_DIALOG_SCREEN_WAIT);
            }
        } catch (Throwable e) {
            // check if this exception requires a confirmation or error screen for single resource operations
            if (!isMultiOperation()
                && ((e instanceof CmsVfsResourceAlreadyExistsException) || (e instanceof CmsLockException))
                && (resource != null)
                && !(resource.isFolder())) {
                // file copy but file already exists, now check target file type
                int targetType = -1;
                String storedSiteRoot = null;
                try {
                    if (OpenCms.getSiteManager().getSiteRoot(getParamTarget()) != null) {
                        storedSiteRoot = getCms().getRequestContext().getSiteRoot();
                        getCms().getRequestContext().setSiteRoot("/");
                    }
                    CmsResource targetRes = getCms().readResource(getParamTarget());
                    targetType = targetRes.getTypeId();
                } catch (CmsException e2) {
                    // can usually be ignored
                    if (LOG.isInfoEnabled()) {
                        LOG.info(e2.getLocalizedMessage());
                    }
                } finally {
                    if (storedSiteRoot != null) {
                        getCms().getRequestContext().setSiteRoot(storedSiteRoot);
                    }
                }
                if (resource.getTypeId() == targetType) {
                    // file type of target is the same as source, show confirmation dialog
                    setParamMessage(
                        CmsStringUtil.escapeHtml(key(
                            Messages.GUI_COPY_CONFIRM_OVERWRITE_2,
                            new Object[] {getParamResource(), getParamTarget()})));
                    getJsp().include(FILE_DIALOG_SCREEN_CONFIRM);
                } else {
                    // file type is different, create error message
                    includeErrorpage(this, e);
                }
            } else {
                // error during copy, show error dialog
                includeErrorpage(this, e);
            }
        }
    }
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);

    }
393993
protected void initSessionObject() {

        try {
            if (!CmsStringUtil.isEmpty(getParamAction()) && !CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
                m_resources = (List)getDialogObject();
                // test
                m_resources.size();
            }
        } catch (Exception e) {
            // ignore
        }
        if (m_resources == null) {
            // create a new project object
            m_resources = new ArrayList();
            try {
                Iterator it = OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit(
                    getCms(),
                    getCms().getRequestContext().getOuFqn()).iterator();
                while (it.hasNext()) {
                    CmsResource res = (CmsResource)it.next();
                    m_resources.add(getCms().getSitePath(res));
                }
            } catch (CmsException e1) {
                // should never happen
            }
        }
    }
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();
    }
1034079
private void init() {
		Collection<String> paths = StringSupport.split(classpath, ";:", false);

		for (String location : paths) {

			location = FileSupport.convertToUnixStylePath(location);
			if (location.endsWith(".zip") || location.endsWith(".jar")) {
				mapFilesInZip(location);
			} else {
				File dir = new File(location);
				if (dir.isDirectory()) {
					if (!location.endsWith("/")) {
						location += '/';
					}
					Collection<File> classFiles = FileSupport.getFilesInDirectoryTree(dir);
					for (File file : classFiles) {
						String fileName = file.getPath();
						if ((fileName.endsWith(".jar") || fileName.endsWith(".zip")) && !file.isHidden()) {
							mapFilesInZip(fileName);
						} else { // .class .properties etc.
							mapClassResourceEntry(file.getPath().substring(location.length()), file);
							fileCreationTimes.put(file, new Long(file.lastModified()));
						}
					}
				} else {
					//path can not be mapped
				}
			}
		}
	}
121638
protected void initCacheObject() {

        CmsFlexController controller = (CmsFlexController)getJsp().getRequest().getAttribute(
            CmsFlexController.ATTRIBUTE_NAME);
        CmsFlexCache cache = controller.getCmsCache();

        setVariations("" + cache.size());
        setKeys("" + cache.keySize());
        CmsLruCache entryLruCache = cache.getEntryLruCache();

        if (entryLruCache != null) {
            Locale locale = getLocale();
            setMaxSize(CmsFileUtil.formatFilesize(entryLruCache.getMaxCacheCosts(), locale));
            setAvgSize(CmsFileUtil.formatFilesize(entryLruCache.getAvgCacheCosts(), locale));
            setCurSize(CmsFileUtil.formatFilesize(entryLruCache.getObjectCosts(), locale));
        }
    }
133618
public void initialize(CmsObject cms) throws CmsRoleViolationException {

        OpenCms.getRoleManager().checkRole(cms, CmsRole.WORKPLACE_MANAGER);
        try {
            // store the Admin cms to index Cms resources
            m_adminCms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            // this should never happen
            LOG.error(e.getLocalizedMessage(), e);
        }
        // make sure the site root is the root site
        m_adminCms.getRequestContext().setSiteRoot("/");

        // create the extraction result cache
        m_extractionResultCache = new CmsExtractionResultCache(
            OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(getDirectory()),
            "/extractCache");
        initializeFieldConfigurations();
        initializeIndexes();
        initOfflineIndexes();

        // register this object as event listener
        OpenCms.addCmsEventListener(
            this,
            new int[] {
                I_CmsEventListener.EVENT_CLEAR_CACHES,
                I_CmsEventListener.EVENT_PUBLISH_PROJECT,
                I_CmsEventListener.EVENT_REBUILD_SEARCHINDEXES});
    }
710813
private void initializeFileData(String baseSitePath) throws CmsException {

        m_resultMap.clear();
        m_siteRootLink = OpenCms.getLinkManager().getOnlineLink(m_siteGuestCms, "/");
        m_siteRootLink = CmsFileUtil.removeTrailingSeparator(m_siteRootLink);
        m_detailPageInfos = OpenCms.getADEManager().getAllDetailPages(m_guestCms);
        for (CmsDetailPageInfo detailPageInfo : m_detailPageInfos) {
            String type = detailPageInfo.getType();
            String path = detailPageInfo.getUri();
            path = CmsFileUtil.removeTrailingSeparator(path);
            m_detailTypesByPage.put(path, type);
        }
        List<CmsAlias> siteAliases = OpenCms.getAliasManager().getAliasesForSite(
            m_siteGuestCms,
            m_siteGuestCms.getRequestContext().getSiteRoot());
        for (CmsAlias alias : siteAliases) {
            if (isAliasBelowBaseFolder(alias) && (alias.getMode() == CmsAliasMode.page)) {
                CmsUUID aliasId = alias.getStructureId();
                m_pageAliasesBelowBaseFolderByStructureId.put(aliasId, alias);
            }
        }

    }
899414
private void writeZipFile() {

        try {
            FileOutputStream fos = new FileOutputStream(ZIP_PATH);
            ZipGenerator zipGen = new ZipGenerator(fos);
            for (File file : CmsLogFileOptionProvider.getLogFiles()) {
                if (!file.isDirectory() & !ZIP_PATH.equals(file.getAbsolutePath())) {
                    zipGen.addToZip(new File(CmsLogFileApp.LOG_FOLDER), file);
                }
            }
            zipGen.close();
            fos.close();

        } catch (IOException e) {
            LOG.error("unable to build zip file", e);
        }
    }
1132999
private void copyOtherFiles(String startfolder) {

        try {
            File folder = new File(startfolder);
            // get all subresources
            File[] subresources = folder.listFiles();
            int plainId = OpenCms.getResourceManager().getResourceType(
                CmsResourceTypePlain.getStaticTypeName()).getTypeId();
            // now loop through all subresources
            for (int i = 0; i < subresources.length; i++) {
                // if the subresource is a folder, get all subresources of it as well
                if (subresources[i].isDirectory()) {
                    copyOtherFiles(subresources[i].getAbsolutePath());
                } else {
                    // do not import the "meta.properties" file
                    if (!subresources[i].getName().equals(META_PROPERTIES)) {
                        // create a new file in the VFS
                        String vfsFileName = (String)m_fileIndex.get(
                            subresources[i].getAbsolutePath().replace('\\', '/'));
                        // get the file type of the FS file
                        int type = getFileType(vfsFileName);
                        if (plainId != type) {
                            if (isExternal(vfsFileName)) {
                                m_report.print(
                                    Messages.get().container(Messages.RPT_SKIP_EXTERNAL_0),
                                    I_CmsReport.FORMAT_NOTE);
                                m_report.print(
                                    org.opencms.report.Messages.get().container(
                                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                                        subresources[i]));
                                m_report.print(
                                    org.opencms.report.Messages.get().container(
                                        org.opencms.report.Messages.RPT_DOTS_0));
                                m_report.print(
                                    Messages.get().container(Messages.RPT_ARROW_RIGHT_0),
                                    I_CmsReport.FORMAT_NOTE);
                                m_report.println(
                                    org.opencms.report.Messages.get().container(
                                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                                        vfsFileName));
                            } else {

                                m_report.print(
                                    Messages.get().container(Messages.RPT_IMPORT_0),
                                    I_CmsReport.FORMAT_NOTE);
                                m_report.print(
                                    org.opencms.report.Messages.get().container(
                                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                                        vfsFileName));
                                m_report.print(
                                    org.opencms.report.Messages.get().container(
                                        org.opencms.report.Messages.RPT_DOTS_0));

                                // get the content of the FS file
                                byte[] content = getFileBytes(subresources[i]);
                                // get the filename from the fileIndex list

                                // check if there are some image info's stored for this resource
                                List properties = new ArrayList();
                                String altText = (String)m_imageInfo.get(
                                    subresources[i].getAbsolutePath().replace('\\', '/'));
                                CmsProperty property1 = new CmsProperty(
                                    CmsPropertyDefinition.PROPERTY_DESCRIPTION,
                                    altText,
                                    altText);
                                CmsProperty property2 = new CmsProperty(
                                    CmsPropertyDefinition.PROPERTY_TITLE,
                                    altText,
                                    altText);
                                // add them to the title and description property
                                if (altText != null) {
                                    properties.add(property1);
                                    properties.add(property2);
                                }
                                // create the file
                                if (!m_overwrite) {
                                    m_cmsObject.createResource(vfsFileName, type, content, properties);
                                } else {
                                    try {
                                        CmsLock lock = m_cmsObject.getLock(vfsFileName);
                                        if (lock.getType() != CmsLockType.EXCLUSIVE) {
                                            m_cmsObject.lockResource(vfsFileName);
                                        }
                                        m_cmsObject.deleteResource(vfsFileName, CmsResource.DELETE_PRESERVE_SIBLINGS);
                                    } catch (CmsException e) {
                                        // the file did not exist, so create it
                                    } finally {
                                        m_cmsObject.createResource(vfsFileName, type, content, properties);
                                    }

                                    m_report.print(
                                        Messages.get().container(Messages.RPT_OVERWRITE_0),
                                        I_CmsReport.FORMAT_NOTE);
                                    m_report.print(
                                        org.opencms.report.Messages.get().container(
                                            org.opencms.report.Messages.RPT_DOTS_0));
                                }
                                m_report.println(
                                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                                    I_CmsReport.FORMAT_OK);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_report.println(e);
        }
    }