Copies the explorer type icons.<p>

@param iconPaths the path to the location where the icons are located

@throws CmsException if something goes wrong
187838
private void cloneExplorerTypeIcons(Map<String, String> iconPaths) throws CmsException {

        for (Map.Entry<String, String> entry : iconPaths.entrySet()) {
            String source = ICON_PATH + entry.getKey();
            String target = ICON_PATH + entry.getValue();
            if (getCms().existsResource(source) && !getCms().existsResource(target)) {
                getCms().copyResource(source, target);
            }
        }
    }
1058128
CmsResourceInfo formatExplorerType(CmsExplorerTypeSettings explorerType) {

        Resource icon = CmsResourceUtil.getBigIconResource(explorerType, null);
        String title = CmsVaadinUtils.getMessageText(explorerType.getKey());
        if (title.startsWith("???")) {
            title = explorerType.getName();
        }
        String subtitle = explorerType.getName();
        if (explorerType.getReference() != null) {
            subtitle += " (" + explorerType.getReference() + ")";
        }
        CmsResourceInfo info = new CmsResourceInfo(title, subtitle, icon);
        return info;
    }
108612
public void moveTo(String cmsNewPath) throws CmsException {

        ensureLock();
        m_cms.moveResource(m_cms.getSitePath(m_resource), cmsNewPath);
        CmsUUID id = m_resource.getStructureId();
        CmsResource updatedRes = m_cms.readResource(id, CmsJlanDiskInterface.STANDARD_FILTER);
        m_resource = updatedRes;
        updateFromResource();
    }
1099497
private String getIconPath(CmsObject cms, CmsUser user, IconSize size) {

        String userIconPath = (String)user.getAdditionalInfo(USER_IMAGE_INFO);
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(userIconPath)) {
            userIconPath += size.equals(IconSize.Big)
            ? ""
            : "?__scale=h:" + size.getSize() + ",w:" + size.getSize() + ",t:2";
            return OpenCms.getLinkManager().substituteLinkForRootPath(cms, userIconPath);
        }

        boolean isAdmin = OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ADMINISTRATOR);
        String name = user.getName() + Boolean.toString(isAdmin);
        String rfsName = toRfsName(name, size);
        String path = toPath(name, size);
        if (!m_cache.hasCacheContent(rfsName)) {

            BufferedImage icon = m_renderer.render(name, isAdmin, size.getSize());
            try {
                m_cache.saveCacheFile(rfsName, getImageBytes(icon));
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return path;
    }
169830
public static Resource getSmallIconResource(CmsExplorerTypeSettings explorerType, String resourceName) {

        if (explorerType == null) {
            explorerType = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                (resourceName == null) && !CmsResource.isFolder(resourceName)
                ? CmsResourceTypeUnknownFile.RESOURCE_TYPE_NAME
                : "unknown_folder");
        }

        if (!explorerType.getIconRules().isEmpty() && (resourceName != null)) {
            String extension = CmsResource.getExtension(resourceName);
            if (extension != null) {
                CmsIconRule rule = explorerType.getIconRules().get(extension);
                if ((rule != null) && (rule.getSmallIconStyle() != null)) {
                    return new CmsCssIcon(rule.getSmallIconStyle());
                }
            }
        }
        if (explorerType.getSmallIconStyle() != null) {
            return new CmsCssIcon(explorerType.getSmallIconStyle());
        } else {
            return new ExternalResource(
                CmsWorkplace.getResourceUri(CmsWorkplace.RES_PATH_FILETYPES + explorerType.getOriginalIcon()));
        }
    }
1352372
public void openPath(String path) {

        if (!CmsStringUtil.isPrefixPath(m_root.getRootPath(), path)) {
            CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(path);
            if (site != null) {
                // the given path is a root path switch to the determined site
                getSiteSelector().setValue(site.getSiteRoot());
                path = m_currentCms.getRequestContext().removeSiteRoot(path);
            } else if (OpenCms.getSiteManager().startsWithShared(path)) {
                getSiteSelector().setValue(OpenCms.getSiteManager().getSharedFolder());
            } else if (path.startsWith(CmsWorkplace.VFS_PATH_SYSTEM)) {
                Container container = getSiteSelector().getContainerDataSource();
                String newSiteRoot = null;
                for (String possibleSiteRoot : Arrays.asList("", "/", "/system", "/system/")) {
                    if (container.containsId(possibleSiteRoot)) {
                        newSiteRoot = possibleSiteRoot;
                        break;
                    }
                }
                if (newSiteRoot == null) {
                    LOG.warn(
                        "Couldn't open path in site selector because neither root site nor system folder are in the site selector. path="
                            + path);
                    return;
                }
                getSiteSelector().setValue(newSiteRoot);
            }
        }
        if (!"/".equals(path)) {
            List<CmsUUID> idsToOpen = Lists.newArrayList();
            try {
                CmsResource currentFolder = m_currentCms.readResource(CmsResource.getParentFolder(path));
                if (!m_root.getStructureId().equals(currentFolder.getStructureId())) {
                    idsToOpen.add(currentFolder.getStructureId());
                    CmsResource parentFolder = null;

                    do {
                        try {
                            parentFolder = m_currentCms.readParentFolder(currentFolder.getStructureId());
                            idsToOpen.add(parentFolder.getStructureId());
                            currentFolder = parentFolder;
                        } catch (CmsException | NullPointerException e) {
                            LOG.info(e.getLocalizedMessage(), e);
                            break;
                        }
                    } while (!parentFolder.getStructureId().equals(m_root.getStructureId()));
                    // we need to iterate from "top" to "bottom", so we reverse the list of folders
                    Collections.reverse(idsToOpen);

                    for (CmsUUID id : idsToOpen) {
                        m_fileTree.expandItem(id);
                    }
                }
            } catch (CmsException e) {
                LOG.debug("Can not read parent folder of current path.", e);
            }
        }
    }
1280129
public static Resource getSitemapResourceIcon(CmsObject cms, CmsResource resource, IconMode iconMode) {

        CmsResource defaultFile = null;
        List<CmsResource> resourcesForType = Lists.newArrayList();
        resourcesForType.add(resource);
        boolean skipDefaultFile = (iconMode == IconMode.sitemapSelect)
            && OpenCms.getResourceManager().matchResourceType(
                CmsResourceTypeFolderSubSitemap.TYPE_SUBSITEMAP,
                resource.getTypeId());
        if (resource.isFolder() && !skipDefaultFile) {

            try {
                defaultFile = cms.readDefaultFile(resource, CmsResourceFilter.IGNORE_EXPIRATION);
                if (defaultFile != null) {
                    resourcesForType.add(0, defaultFile);
                }
            } catch (Exception e) {
                // Shouldn't normally happen - readDefaultFile returns null instead of throwing an exception when it doesn't find a default file
            }
        }
        if (CmsJspNavBuilder.isNavLevelFolder(cms, resource)) {
            return new CmsCssIcon(CmsExplorerTypeSettings.ICON_STYLE_NAV_LEVEL_BIG);
        }
        CmsResource maybePage = resourcesForType.get(0);
        if (CmsResourceTypeXmlContainerPage.isContainerPage(maybePage)) {
            CmsADEConfigData config = OpenCms.getADEManager().lookupConfiguration(cms, maybePage.getRootPath());
            for (CmsDetailPageInfo realInfo : config.getAllDetailPages(true)) {
                if (realInfo.getUri().equals(maybePage.getRootPath())
                    || realInfo.getUri().equals(CmsResource.getParentFolder(maybePage.getRootPath()))) {
                    CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                        realInfo.getIconType());
                    if (settings != null) {
                        return CmsResourceUtil.getBigIconResource(settings, resource.getName());
                    }
                }
            }
        }

        Resource result = null;
        for (CmsResource res : resourcesForType) {
            I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(res);
            CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(type.getTypeName());
            if (settings != null) {
                result = CmsResourceUtil.getBigIconResource(settings, res.getName());
                break;
            }
        }
        return result;
    }
997801
protected void updateBasePath(String basePath) {

        if (m_folderOrName != null) {
            if (m_folderOrName.isName()) {
                m_folderOrName = new CmsContentFolderDescriptor(basePath, m_folderOrName.getFolderName());
            }
        } else {
            m_folderOrName = new CmsContentFolderDescriptor(basePath, m_typeName);
        }
    }
899828
protected List<CmsResource> getTopFolders(List<CmsResource> folders) {

        List<String> folderPaths = new ArrayList<String>();
        List<CmsResource> topFolders = new ArrayList<CmsResource>();
        Map<String, CmsResource> foldersByPath = new HashMap<String, CmsResource>();
        for (CmsResource folder : folders) {
            folderPaths.add(folder.getRootPath());
            foldersByPath.put(folder.getRootPath(), folder);
        }
        Collections.sort(folderPaths);
        Set<String> topFolderPaths = new HashSet<String>(folderPaths);
        for (int i = 0; i < folderPaths.size(); i++) {
            for (int j = i + 1; j < folderPaths.size(); j++) {
                if (folderPaths.get(j).startsWith((folderPaths.get(i)))) {
                    topFolderPaths.remove(folderPaths.get(j));
                } else {
                    break;
                }
            }
        }
        for (String path : topFolderPaths) {
            topFolders.add(foldersByPath.get(path));
        }
        return topFolders;
    }
566955
private function preventDirectoryTraversal(string $themePath, string $filePath)
    {
        $themePath = realpath($themePath);
        $filePath  = realpath($filePath);

        if ($filePath === false || strpos($filePath, $themePath) !== 0) {
            throw new DirectoryTraversalException('Trying to load a file outside of the theme directory.');
        }
    }
534107
public String getTinyIconPath(CmsObject cms, CmsUser user) {

        return getIconPath(cms, user, IconSize.Tiny);
    }
347910
public void setFilePaths(String... filePaths) {
		Path[] paths = new Path[filePaths.length];
		for (int i = 0; i < paths.length; i++) {
			paths[i] = new Path(filePaths[i]);
		}
		setFilePaths(paths);
	}
1146996
public BufferedImage buildBufferedImageOfIconInOS(Path path) {
		path = JMOptional
				.getNullableAndFilteredOptional(path, JMPath.NotExistFilter)
				.flatMap(JMPathOperation::createTempFilePathAsOpt).orElse(path);
		Icon iconInOS = os.getIcon(path.toFile());
		BufferedImage bufferedImage = new BufferedImage(iconInOS.getIconWidth(),
				iconInOS.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
		iconInOS.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
		return bufferedImage;
	}
394257
public void setFilePath(String filePath)
    {
        //create a new file
        File fileInstance=null;
        if(filePath!=null)
        {
            fileInstance=new File(filePath);
        }
        
        //set file
        this.setFile(fileInstance);
    }
767214
public static void createFolder(CmsObject cms, String rootPath) throws CmsException {

        CmsObject rootCms = OpenCms.initCmsObject(cms);
        rootCms.getRequestContext().setSiteRoot("");
        List<String> parents = new ArrayList<String>();
        String currentPath = rootPath;
        while (currentPath != null) {
            if (rootCms.existsResource(currentPath)) {
                break;
            }
            parents.add(currentPath);
            currentPath = CmsResource.getParentFolder(currentPath);
        }
        parents = Lists.reverse(parents);
        for (String parent : parents) {
            try {
                rootCms.createResource(
                    parent,
                    OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName()));
                try {
                    rootCms.unlockResource(parent);
                } catch (CmsException e) {
                    // may happen if parent folder is locked also
                    if (LOG.isInfoEnabled()) {
                        LOG.info(e);
                    }
                }
            } catch (CmsVfsResourceAlreadyExistsException e) {
                // nop
            }
        }
    }
512595
public void setFilePaths(Path... filePaths) {
		if (!supportsMultiPaths() && filePaths.length > 1) {
			throw new UnsupportedOperationException(
				"Multiple paths are not supported by this FileInputFormat.");
		}
		if (filePaths.length < 1) {
			throw new IllegalArgumentException("At least one file path must be specified.");
		}
		if (filePaths.length == 1) {
			// set for backwards compatibility
			this.filePath = filePaths[0];
		} else {
			// clear file path in case it had been set before
			this.filePath = null;
		}

		this.filePaths = filePaths;
	}
1113595
public static CmsFlexBucketConfiguration loadFromVfsFile(CmsObject cms, String path) throws CmsException {

        if (!cms.existsResource(path)) {
            return null;
        }
        CmsResource configRes = cms.readResource(path);
        if (configRes.isFolder()) {
            return null;
        }
        CmsFile configFile = cms.readFile(configRes);
        String encoding = CmsFileUtil.getEncoding(cms, configRes);
        Properties props = new Properties();
        try {
            props.load(new InputStreamReader(new ByteArrayInputStream(configFile.getContents()), encoding));
            return loadFromProperties(props);
        } catch (IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return null;
    }