public void deleteCollaborationToolsFolder(final String folderPath) { final File fFolderRoot = getFolder(folderPath); if (fFolderRoot.exists()) { FileUtils.deleteDirsAndFiles(fFolderRoot, true, true); } }
protected void removeDevToolTests() { Locale testLocale = i18nMgr.getLocaleOrDefault("de"); // cleanup devtools source/target files // 1) source files File baseDir = I18nModule.getPropertyFilesBaseDir(testLocale, testSourceBundle); File testSFile = i18nMgr.getPropertiesFile(testLocale, testSourceBundle, baseDir); File sourcePath = testSFile.getParentFile().getParentFile(); FileUtils.deleteDirsAndFiles(sourcePath, true, true); // 2) target files baseDir = I18nModule.getPropertyFilesBaseDir(testLocale, testTargetBundle); File testTFile = i18nMgr.getPropertiesFile(testLocale, testTargetBundle, baseDir); File targetPath = testTFile.getParentFile().getParentFile(); FileUtils.deleteDirsAndFiles(targetPath, true, true); // 3) move target files baseDir = I18nModule.getPropertyFilesBaseDir(testLocale, testMoveTargetBundle); File testMFile = i18nMgr.getPropertiesFile(testLocale, testMoveTargetBundle, baseDir); File movePath = testMFile.getParentFile().getParentFile().getParentFile(); FileUtils.deleteDirsAndFiles(movePath, true, true); }
@After public void tearDown() throws Exception { Locale testLocale = i18nMgr.getLocaleOrDefault("de"); File baseDir = I18nModule.getPropertyFilesBaseDir(testLocale, testNewBundle); // only delete files when basedir available if (baseDir == null) return; File testFile = i18nMgr.getPropertiesFile(testLocale, testNewBundle, baseDir); // delete not only new/_i18n/LocalStrings_de.properties, delete also _i18n and new itself if (testFile.getParentFile().getParentFile().exists()) { FileUtils.deleteDirsAndFiles(testFile.getParentFile().getParentFile(), true, true); } // don't do inline translation markup i18nMgr.setMarkLocalizedStringsEnabled(null, false); // cleanup dev tools test case files removeDevToolTests(); }
public void archiveWiki(final OLATResourceable ores, final String archivFilePath) { final VFSContainer wikiContainer = WikiManager.getInstance().getWikiRootContainer(ores); final VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(wikiContainer); final String exportFileName = "del_wiki_" + ores.getResourceableId() + ".zip"; final File archiveDir = new File(archivFilePath); if (!archiveDir.exists()) { archiveDir.mkdir(); } final String fullFilePath = archivFilePath + File.separator + exportFileName; try { FileUtils.bcopy(wikiZip.getInputStream(), new File(fullFilePath), "archive wiki"); } catch (final FileNotFoundException e) { log.warn("Can not archive wiki repoEntry=" + ores.getResourceableId()); } catch (final IOException ioe) { log.warn("Can not archive wiki repoEntry=" + ores.getResourceableId()); } }
/** @param reallyRemoveIt true: really remove it; false: dry run, only produce logging */ public void removeReferenceLanguageCopiesTask(boolean reallyRemoveIt) { List<String> allBundles = I18nModule.getBundleNamesContainingI18nFiles(); // don't remove EN and DE here, this is a shared Map!! int counter = 0; int aliasCounter = 0; // prepare exclusion list String exKeys = FileUtils.load( new File( I18nModule.getTransToolApplicationLanguagesSrcDir() + "/org/olat/lms/commons/i18n/devtools/exclusionKeys.txt"), "UTF-8"); String[] exArray = exKeys.split("\n"); List<String> exList = new ArrayList<String>(Arrays.asList(exArray)); Set<String> allLangs = getAllLanguages(); for (String langKey : allLangs) { Locale locale = i18nMgr.getLocaleOrNull(langKey); if (locale.toString().equals("de") || locale.toString().equals("en")) { // don't compare with DE and EN itself continue; } for (String bundleName : allBundles) { Properties properties = i18nMgr.getPropertiesWithoutResolvingRecursively(locale, bundleName); Properties refPropDe = i18nMgr.getPropertiesWithoutResolvingRecursively(new Locale("de"), bundleName); Properties refPropEn = i18nMgr.getPropertiesWithoutResolvingRecursively(new Locale("en"), bundleName); Set<Object> keys = properties.keySet(); for (Object keyObj : keys) { String key = (String) keyObj; // dont handle if in exclusion list if (!exList.contains(key)) { String value = properties.getProperty(key); // get ref-lang. value and compare: boolean foundInReferenceDe = false; boolean foundInReferenceEn = false; if (value.equals(refPropDe.getProperty(key))) { log.info( "Value of Key found in reference Language DE. lang::" + locale.getLanguage() + " bundle::" + bundleName + " key::" + key + " value::" + value); foundInReferenceDe = true; } if (value.equals(refPropEn.getProperty(key))) { log.info( "Value of Key found in reference Language EN. lang::" + locale.getLanguage() + " bundle::" + bundleName + " key::" + key + " value::" + value); foundInReferenceEn = true; } // probably an alias if found in both ref. lang. boolean readyToDelete = (foundInReferenceDe || foundInReferenceEn); if (foundInReferenceDe && foundInReferenceEn) { log.info( "Matching value in both reference languages. lang::" + locale.getLanguage() + " bundle::" + bundleName + " key::" + key + " value::" + value); readyToDelete = false; aliasCounter++; } if (readyToDelete && reallyRemoveIt) { deleteKey(locale, bundleName, key); } if (readyToDelete) { counter++; logText.append( i18nMgr.getPropertiesFile( locale, bundleName, I18nModule.getPropertyFilesBaseDir(locale, bundleName)) + " value of key found in reference -> remove lang::" + locale.getLanguage() + " bundle::" + bundleName + " key::" + key + " value::" + value + "\n"); } } } } } log.info(counter + " Keys found/deleted with values copied from only one reference languages!"); log.info(aliasCounter + " Keys which seems to be alias found and NOT deleted!"); }
public void moveLanguageTask( Locale sourceLocale, String sourceDir, String targetDir, boolean doMoveNoCopy) { MoveLanguagesVisitor srcVisitor = new MoveLanguagesVisitor(sourceDir, targetDir, sourceLocale, doMoveNoCopy); FileUtils.visitRecursively(new File(sourceDir), srcVisitor); }