/** * Deletes the given file from the RFS if it exists, * also deletes all parameter variations of the file.<p> * * @param rfsFilePath the path of the RFS file to delete * @param vfsName the VFS name of the file to delete (required for logging) */ protected void purgeFile(String rfsFilePath, String vfsName) { File rfsFile = new File(rfsFilePath); // first delete the base file deleteFile(rfsFile, vfsName); // now delete the file parameter variations // get the parent folder File parent = rfsFile.getParentFile(); if (parent != null) { // list all files in the parent folder that are variations of the base file File[] paramVariants = parent.listFiles(new PrefixFileFilter(rfsFile)); if (paramVariants != null) { for (int v = 0; v < paramVariants.length; v++) { deleteFile(paramVariants[v], vfsName); } } } }
/** * Deletes the given file from the RFS, with error handling and logging.<p> * * @param file the file to delete * @param vfsName the VFS name of the file (required for logging) */ private void deleteFile(File file, String vfsName) { try { if (file.exists() && file.canWrite()) { file.delete(); // write log message if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); } } } catch (Throwable t) { // ignore, nothing to do about this if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key(Messages.LOG_FILE_DELETION_FAILED_1, getRfsName(file, vfsName)), t); } } }
/** * Purges a list of files from the rfs.<p> * * @param files the list of files to purge * @param vfsName the vfs name of the originally file to purge * @param scrubbedFiles the list which stores all the scrubbed files */ private void purgeFiles(List<File> files, String vfsName, Set<String> scrubbedFiles) { for (File file : files) { purgeFile(file.getAbsolutePath(), vfsName); String rfsName = CmsFileUtil.normalizePath( OpenCms.getStaticExportManager().getRfsPrefix(vfsName) + "/" + file.getAbsolutePath().substring( OpenCms.getStaticExportManager().getExportPath(vfsName).length())); rfsName = CmsStringUtil.substitute(rfsName, new String(new char[] {File.separatorChar}), "/"); scrubbedFiles.add(rfsName); } } }
List<String> siblings = getSiblingsList(cms, resPath); OpenCms.getStaticExportManager().getRfsPrefix(vfsName).length())); purgeFile(rfsExportFileName, vfsName); List<File> relFilesToPurge = getRelatedFilesToPurge(rfsExportFileName, vfsName); purgeFiles(relFilesToPurge, vfsName, scrubbedFiles); List<File> detailPageFiles = getDetailPageFiles(cms, res, vfsName); purgeFiles(detailPageFiles, vfsName, scrubbedFiles); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_PURGED_DETAILPAGES_0)); List<File> referencingContainerPages = getContainerPagesToPurge(cms, res.getStructureId()); purgeFiles(referencingContainerPages, vfsName, scrubbedFiles); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_PURGED_CONTAINERPAGES_0)); purgeFile(rfsExportFileName, vfsName); scrubbedFiles.add(rfsName);
List siblings = getSiblingsList(cms, resPath); + rfsName.substring(OpenCms.getStaticExportManager().getRfsPrefix(vfsName).length())); purgeFile(rfsExportFileName, vfsName); scrubbedFiles.add(rfsName); List fileList = getRelatedFilesToPurge(rfsExportFileName, vfsName); Iterator iter = fileList.iterator(); while (iter.hasNext()) { File file = (File)iter.next(); purgeFile(file.getAbsolutePath(), vfsName); rfsName = CmsFileUtil.normalizePath(OpenCms.getStaticExportManager().getRfsPrefix(vfsName) + "/"
publishedResources = addMovedLinkSources(cms, publishedResources); scrubResource(cms, res, scrubbedFolders, scrubbedFiles);
purgePages.addAll(getContainerPagesToPurge(cms, source.getStructureId()));
publishedResources = addMovedLinkSources(cms, publishedResources); scrubResource(cms, res, scrubbedFolders, scrubbedFiles);
/** * Deletes the given file from the RFS if it exists, * also deletes all parameter variations of the file.<p> * * @param rfsFilePath the path of the RFS file to delete * @param vfsName the VFS name of the file to delete (required for logging) */ protected void purgeFile(String rfsFilePath, String vfsName) { File rfsFile = new File(rfsFilePath); // first delete the base file deleteFile(rfsFile, vfsName); // now delete the file parameter variations // get the parent folder File parent = rfsFile.getParentFile(); if (parent != null) { // list all files in the parent folder that are variations of the base file File[] paramVariants = parent.listFiles(new PrefixFileFilter(rfsFile)); if (paramVariants != null) { for (int v = 0; v < paramVariants.length; v++) { deleteFile(paramVariants[v], vfsName); } } } }
LOG.info(Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); if (LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); Messages.get().getBundle().key(Messages.LOG_FILE_DELETION_FAILED_1, getRfsName(file, vfsName)), t);