/** * Sets the resources of this project.<p> * * @param value the project resources to set */ public void setResources(List value) { if (value == null) { m_resources = new ArrayList(); return; } m_resources = CmsFileUtil.removeRedundancies(value); }
/** * Reads all bytes from the given input stream, closes it * and returns the result in an array.<p> * * @param in the input stream to read the bytes from * @return the byte content of the input stream * * @throws IOException in case of errors in the underlying java.io methods used */ public static byte[] readFully(InputStream in) throws IOException { return readFully(in, true); }
/** * Gets the cache key for a given base path.<p> * * @param basePath the base path * * @return the cache key for the base path */ protected String getCacheKey(String basePath) { assert !basePath.endsWith(INHERITANCE_CONFIG_FILE_NAME); return CmsFileUtil.addTrailingSeparator(basePath); }
/** * Returns the RFS name to use for caching the given VFS resource with parameters in the disk cache.<p> * * @param online if true, the online disk cache is used, the offline disk cache otherwise * @param rootPath the VFS resource root path to get the RFS cache name for * @param parameters the parameters of the request to the VFS resource * * @return the RFS name to use for caching the given VFS resource with parameters */ public String getCacheName(boolean online, String rootPath, String parameters) { String rfsName = CmsFileUtil.getRepositoryName(m_rfsRepository, rootPath, online); if (CmsStringUtil.isNotEmpty(parameters)) { String extension = CmsFileUtil.getExtension(rfsName); // build the RFS name for the VFS name with parameters rfsName = CmsFileUtil.getRfsPath(rfsName, extension, parameters); } return rfsName; }
Integer size = new Integer(m_rfsRules.size() + 1); String exportFolderName = CmsFileUtil.normalizePath(m_staticExportPath + '/'); try { File exportFolder = new File(exportFolderName); CmsFileUtil.purgeDirectory(exportFolder); while (it.hasNext()) { CmsStaticExportRfsRule rule = (CmsStaticExportRfsRule)it.next(); exportFolderName = CmsFileUtil.normalizePath(rule.getExportPath() + '/'); try { File exportFolder = new File(exportFolderName); CmsFileUtil.purgeDirectory(exportFolder);
/** * Creates a new instance of PrefixFileFilter.<p> * * @param baseFile the base file to compare with. */ public PrefixFileFilter(File baseFile) { String fileName = baseFile.getName(); m_baseExtension = CmsFileUtil.getExtension(fileName); m_baseName = fileName + "_"; }
/** * Removes the old export output, which may be an existing file or directory.<p> * * @param exportPath the export output path */ protected void removeOldExport(String exportPath) { File output = new File(exportPath); if (output.exists()) { // the output already exists if (output.isDirectory()) { // purge the complete directory CmsFileUtil.purgeDirectory(output); } else { // remove the existing file if (m_isExportAsFiles) { // in case we write to a file we can just overwrite, // but for a folder we must remove an existing file output.delete(); } } } }
String extension = CmsFileUtil.getExtension(rfsName); File rfsFile = new File(CmsFileUtil.normalizePath(OpenCms.getStaticExportManager().getExportPath( vfsName) + rfsName)); rfsName = CmsFileUtil.getRfsPath(rfsName, extension, parameters);
while (i.hasNext()) { CmsSite site = m_siteMatcherSites.get(i.next()); String folder = CmsFileUtil.addTrailingSeparator(site.getSiteRoot()); if (!siteroots.contains(folder)) { siteroots.add(folder); String folder = CmsFileUtil.addTrailingSeparator(m_defaultSite.getSiteRoot()); if (!siteroots.contains(folder)) { siteroots.add(folder); if (!siteroots.contains(CmsFileUtil.addTrailingSeparator(storedSiteRoot))) { siteroots.add(CmsFileUtil.addTrailingSeparator(storedSiteRoot)); CmsSite configuredSite = m_siteRootSites.get(CmsFileUtil.removeTrailingSeparator(folder));
String extension = CmsFileUtil.getExtension(rfsName); CmsFileUtil.normalizePath( getExportPath(cms.getRequestContext().addSiteRoot(vfsName)) + rfsName)); File parent = rfsFile.getParentFile();
/** * Copies a given file.<p> * * @param source the source file * @param target the destination file */ public void copyFile(String source, String target) { try { CmsFileUtil.copy(m_configRfsPath + source, m_configRfsPath + target); } catch (IOException e) { m_errors.add("Could not copy " + source + " to " + target + " \n"); m_errors.add(e.toString() + "\n"); } }
dbc.report(null, Messages.get().container( Messages.ERR_GET_RELATED_RESOURCES_PUBLISH_DIRECT_1, CmsFileUtil.formatResourceNames(context, publishList.getDirectPublishResources())), e); } finally { dbc.clear();
/** * Checks if all resources of the module are present.<p> * * @param cms an initialized OpenCms user context which must have read access to all module resources * * @throws CmsIllegalArgumentException in case not all module resources exist or can be read with the given OpenCms user context */ public void checkResources(CmsObject cms) throws CmsIllegalArgumentException { CmsFileUtil.checkResources(cms, getResources()); }
Integer size = new Integer(m_rfsRules.size() + 1); String exportFolderName = CmsFileUtil.normalizePath(m_staticExportPath + '/'); try { File exportFolder = new File(exportFolderName); CmsFileUtil.purgeDirectory(exportFolder); while (it.hasNext()) { CmsStaticExportRfsRule rule = it.next(); exportFolderName = CmsFileUtil.normalizePath(rule.getExportPath() + '/'); try { File exportFolder = new File(exportFolderName); CmsFileUtil.purgeDirectory(exportFolder);
/** * Creates a new instance of PrefixFileFilter.<p> * * @param baseFile the base file to compare with. */ public PrefixFileFilter(File baseFile) { String fileName = baseFile.getName(); m_baseExtension = CmsFileUtil.getExtension(fileName); m_baseName = fileName + "_"; }
/** * Deletes a directory in the file system and all subfolders of that directory.<p> * * @param directory the directory to delete */ public static void purgeDirectory(File directory) { if (directory.canRead() && directory.isDirectory()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isDirectory()) { purgeDirectory(f); } if (f.canWrite()) { f.delete(); } } directory.delete(); } }
/** * Returns the RFS name to use for caching the given VFS resource with parameters in the disk cache.<p> * * @param online if true, the online disk cache is used, the offline disk cache otherwise * @param rootPath the VFS resource root path to get the RFS cache name for * @param parameters the parameters of the request to the VFS resource * * @return the RFS name to use for caching the given VFS resource with parameters */ public String getCacheName(boolean online, String rootPath, String parameters) { String rfsName = CmsFileUtil.getRepositoryName(m_rfsRepository, rootPath, online); if (CmsStringUtil.isNotEmpty(parameters)) { String extension = CmsFileUtil.getExtension(rfsName); // build the RFS name for the VFS name with parameters rfsName = CmsFileUtil.getRfsPath(rfsName, extension, parameters); } return rfsName; }
/** * Creates a backup of the given XML configurations input file.<p> * * @param configuration the configuration for which the input file should be backed up */ private void backupXmlConfiguration(I_CmsXmlConfiguration configuration) { String fromName = m_baseFolder.getAbsolutePath() + File.separatorChar + configuration.getXmlFileName(); String toDatePrefix = BACKUP_DATE_FORMAT.format(new Date()); String toName = m_backupFolder.getAbsolutePath() + File.separatorChar + toDatePrefix + configuration.getXmlFileName(); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_CREATE_CONFIG_BKP_2, fromName, toName)); } try { CmsFileUtil.copy(fromName, toName); } catch (IOException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_CREATE_CONFIG_BKP_FAILURE_1, toName), e); } }