/** * 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(); } } } }
/** * 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(); } }
/** * 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(); } } } }
/** * 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(); } }
if ((i + 1) > exportBackups) { CmsFileUtil.purgeDirectory(staticExportBackupOld); } else { CmsFileUtil.purgeDirectory(staticExport);
if ((i + 1) > exportBackups) { CmsFileUtil.purgeDirectory(staticExportBackupOld); } else { CmsFileUtil.purgeDirectory(staticExport);
/** * Removes the given backup folder of this index.<p> * * @param path the backup folder to remove * * @see #isBackupReindexing() */ protected void removeIndexBackup(String path) { if (!isBackupReindexing()) { // if no backup is generated we don't need to do anything return; } // check if the target directory already exists File file = new File(path); if (!file.exists()) { // index does not exist yet return; } try { FSDirectory dir = FSDirectory.getDirectory(file); dir.close(); CmsFileUtil.purgeDirectory(file); } catch (Exception e) { // TODO: logging etc. } } }
/** * Purges the JSP repository.<p< * * @param afterPurgeAction the action to execute after purging */ protected void doPurge(Runnable afterPurgeAction) { if (LOG.isInfoEnabled()) { LOG.info( org.opencms.flex.Messages.get().getBundle().key( org.opencms.flex.Messages.LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0)); } File d; d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_ONLINE + File.separator); CmsFileUtil.purgeDirectory(d); d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_OFFLINE + File.separator); CmsFileUtil.purgeDirectory(d); if (afterPurgeAction != null) { afterPurgeAction.run(); } if (LOG.isInfoEnabled()) { LOG.info( org.opencms.flex.Messages.get().getBundle().key( org.opencms.flex.Messages.LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0)); } }
/** * Removes the given backup folder of this index.<p> * * @param path the backup folder to remove */ protected void removeIndexBackup(String path) { if (!isBackupReindexing()) { // if no backup is generated we don't need to do anything return; } // check if the target directory already exists File file = new File(path); if (!file.exists()) { // index does not exist yet return; } try { FSDirectory dir = FSDirectory.open(file.toPath()); dir.close(); CmsFileUtil.purgeDirectory(file); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_IO_INDEX_BACKUP_REMOVE_2, getName(), path), e); } }
/** * This method purges the JSP repository dirs, * i.e. it deletes all JSP files that OpenCms has written to the * real FS.<p> * * Obviously this method must be used with caution. * Purpose of this method is to allow * a complete purge of all JSP pages on a machine after * a major update of JSP templates was made.<p> */ private synchronized void purgeJspRepository() { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0)); } File d; d = new File(org.opencms.loader.CmsJspLoader.getJspRepository() + REPOSITORY_ONLINE + File.separator); CmsFileUtil.purgeDirectory(d); d = new File(org.opencms.loader.CmsJspLoader.getJspRepository() + REPOSITORY_OFFLINE + File.separator); CmsFileUtil.purgeDirectory(d); clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0)); } }
CmsFileUtil.purgeDirectory(exportFolder); CmsFileUtil.purgeDirectory(exportFolder);
CmsFileUtil.purgeDirectory(exportFolder); CmsFileUtil.purgeDirectory(exportFolder);
CmsFileUtil.purgeDirectory(exportFolder);
m_report.println(Messages.get().container(Messages.RPT_HTML_DELETE_0), I_CmsReport.FORMAT_NOTE); CmsFileUtil.purgeDirectory(streamFolder);
CmsFileUtil.purgeDirectory(exportFolder);