@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { super.formInnerEvent(ureq, source, event); if (source == cancelButton) { fireEvent(ureq, Event.CANCELLED_EVENT); } else if (source == importFile) { if (importFile.isUploadSuccess()) { File tmpJar = importFile.getUploadFile(); Set<String> importLangKeys = I18nManager.getInstance().sarchForAvailableLanguagesInJarFile(tmpJar, true); if (importLangKeys.size() == 0) { showError("configuration.management.package.import.failure.empty"); return; } // // enable language key selection String[] langKeys = ArrayHelper.toArray(importLangKeys); importKeys.setKeysAndValues(langKeys, langKeys); importKeys.selectAll(); importKeys.setVisible(true); // In language adaption mode the import is done as a package - can't deselect anything importKeys.setEnabled(false); } } }
private void uploadFiles(FileElement attachmentFileElement) { VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile()); ProjectBrokerManagerFactory.getProjectBrokerManager() .saveAttachedFile( project, attachmentFileElement.getUploadFileName(), uploadedItem, courseEnv, courseNode); }
@Override protected void formOK(UserRequest ureq) { if (importKeys.isVisible() && importKeys.getSelectedKeys().size() > 0) { Collection<String> importLangKeys = importKeys.getSelectedKeys(); Set<String> alreadyInstalledLangs = new HashSet<String>(); for (String langKey : importLangKeys) { if (I18nModule.getAvailableLanguageKeys().contains(langKey)) { alreadyInstalledLangs.add(langKey); } } if (I18nModule.isTransToolEnabled()) { // In translation mode importing will copy the language package // over an existing language or create a new language File tmpJar = importFile.getUploadFile(); I18nManager.getInstance().copyLanguagesFromJar(tmpJar, importLangKeys); logAudit("Uploaded languages from jar::" + importFile.getUploadFileName(), null); showInfo("configuration.management.package.import.success", importLangKeys.toString()); } else { // In language adaption mode: import is copied to user managed i18n package space in // olatdata if (alreadyInstalledLangs.size() == importLangKeys.size()) { showError("configuration.management.package.import.failure.installed"); return; } // Ok, contains at least one language, copy to lang pack dir importFile.moveUploadFileTo(I18nModule.LANG_PACKS_DIRECTORY); logAudit("Uploaded language pack::" + importFile.getUploadFileName(), null); if (alreadyInstalledLangs.size() > 0) { getWindowControl() .setWarning( getTranslator() .translate( "configuration.management.package.import.success.with.existing", new String[] { importLangKeys.toString(), alreadyInstalledLangs.toString() })); } else { showInfo("configuration.management.package.import.success", importLangKeys.toString()); } } // Reset i18n system I18nModule.reInitializeAndFlushCache(); fireEvent(ureq, Event.DONE_EVENT); } }