"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java" between
apache-openmeetings-6.1.0-src.tar.gz and apache-openmeetings-6.2.0-src.tar.gz

About: OpenMeetings is a browser-based software that allows you to set up instantly a conference in the Web. You can use your microphone or webcam, share documents on a white board, share your screen or record meetings. Source code.

BackupImport.java  (apache-openmeetings-6.1.0-src):BackupImport.java  (apache-openmeetings-6.2.0-src)
skipping to change at line 154 skipping to change at line 154
import static org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultTimez one; import static org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultTimez one;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getMinLoginLeng th; import static org.apache.openmeetings.util.OpenmeetingsVariables.getMinLoginLeng th;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
skipping to change at line 233 skipping to change at line 232
import org.apache.openmeetings.db.entity.server.LdapConfig; import org.apache.openmeetings.db.entity.server.LdapConfig;
import org.apache.openmeetings.db.entity.server.OAuthServer; import org.apache.openmeetings.db.entity.server.OAuthServer;
import org.apache.openmeetings.db.entity.user.Group; import org.apache.openmeetings.db.entity.user.Group;
import org.apache.openmeetings.db.entity.user.GroupUser; import org.apache.openmeetings.db.entity.user.GroupUser;
import org.apache.openmeetings.db.entity.user.PrivateMessage; import org.apache.openmeetings.db.entity.user.PrivateMessage;
import org.apache.openmeetings.db.entity.user.PrivateMessageFolder; import org.apache.openmeetings.db.entity.user.PrivateMessageFolder;
import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.entity.user.UserContact; import org.apache.openmeetings.db.entity.user.UserContact;
import org.apache.openmeetings.db.util.AuthLevelUtil; import org.apache.openmeetings.db.util.AuthLevelUtil;
import org.apache.openmeetings.db.util.XmlHelper; import org.apache.openmeetings.db.util.XmlHelper;
import org.apache.openmeetings.util.CalendarPatterns;
import org.apache.openmeetings.util.OmFileHelper; import org.apache.openmeetings.util.OmFileHelper;
import org.apache.openmeetings.util.StoredFile; import org.apache.openmeetings.util.StoredFile;
import org.apache.openmeetings.util.crypt.SCryptImplementation; import org.apache.openmeetings.util.crypt.SCryptImplementation;
import org.apache.wicket.util.string.Strings; import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
skipping to change at line 385 skipping to change at line 383
final String canonicalPath = fentry.getCanonicalPath(); final String canonicalPath = fentry.getCanonicalPath();
if (canonicalPath.startsWith(intendedPath)) { if (canonicalPath.startsWith(intendedPath)) {
return fentry; return fentry;
} else { } else {
throw new IllegalStateException("File is outside extracti on target directory."); throw new IllegalStateException("File is outside extracti on target directory.");
} }
} }
private static File unzip(InputStream is) throws IOException { private static File unzip(InputStream is) throws IOException {
File f = OmFileHelper.getNewDir(OmFileHelper.getUploadImportDir() , "import_" + CalendarPatterns.getTimeForStreamId(new Date())); File f = OmFileHelper.getNewDir(OmFileHelper.getUploadImportDir() , randomUUID().toString());
log.debug("##### EXTRACTING BACKUP TO: {}", f); log.debug("##### EXTRACTING BACKUP TO: {}", f);
try (ZipInputStream zis = new ZipInputStream(is)) { try (ZipInputStream zis = new ZipInputStream(is)) {
ZipEntry zipentry = null; ZipEntry zipentry = null;
while ((zipentry = zis.getNextEntry()) != null) { while ((zipentry = zis.getNextEntry()) != null) {
// for each entry to be extracted // for each entry to be extracted
File fentry = validate(zipentry.getName(), f); File fentry = validate(zipentry.getName(), f);
File dir = zipentry.isDirectory() ? fentry : fent ry.getParentFile(); File dir = zipentry.isDirectory() ? fentry : fent ry.getParentFile();
if (!dir.exists() && !dir.mkdirs()) { if (!dir.exists() && !dir.mkdirs()) {
log.warn("Failed to create folders: {}", dir); log.warn("Failed to create folders: {}", dir);
skipping to change at line 409 skipping to change at line 407
IOUtils.copy(zis, fos); IOUtils.copy(zis, fos);
} }
zis.closeEntry(); zis.closeEntry();
} }
} }
} }
return f; return f;
} }
public void performImport(InputStream is, ProgressHolder progressHolder) throws Exception { public void performImport(InputStream is, ProgressHolder progressHolder) throws Exception {
progressHolder.setProgress(0); File f = null;
cleanup(); boolean success = false;
messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID); try {
messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID); progressHolder.setProgress(0);
messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID); cleanup();
messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
File f = unzip(is); messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
BackupVersion ver = getVersion(f);
progressHolder.setProgress(2); f = unzip(is);
importConfigs(f);
progressHolder.setProgress(7); BackupVersion ver = getVersion(f);
importGroups(f); progressHolder.setProgress(2);
progressHolder.setProgress(12); importConfigs(f);
importLdap(f); progressHolder.setProgress(7);
progressHolder.setProgress(17); importGroups(f);
importOauth(f); progressHolder.setProgress(12);
progressHolder.setProgress(22); importLdap(f);
importUsers(f); progressHolder.setProgress(17);
progressHolder.setProgress(27); importOauth(f);
importRooms(f); progressHolder.setProgress(22);
progressHolder.setProgress(32); importUsers(f);
importRoomGroups(f); progressHolder.setProgress(27);
progressHolder.setProgress(37); importRooms(f);
importChat(f); progressHolder.setProgress(32);
progressHolder.setProgress(42); importRoomGroups(f);
importCalendars(f); progressHolder.setProgress(37);
progressHolder.setProgress(47); importChat(f);
importAppointments(f); progressHolder.setProgress(42);
progressHolder.setProgress(52); importCalendars(f);
importMeetingMembers(f); progressHolder.setProgress(47);
progressHolder.setProgress(57); importAppointments(f);
importRecordings(f); progressHolder.setProgress(52);
progressHolder.setProgress(62); importMeetingMembers(f);
importPrivateMsgFolders(f); progressHolder.setProgress(57);
progressHolder.setProgress(67); importRecordings(f);
importContacts(f); progressHolder.setProgress(62);
progressHolder.setProgress(72); importPrivateMsgFolders(f);
importPrivateMsgs(f); progressHolder.setProgress(67);
progressHolder.setProgress(77); importContacts(f);
List<FileItem> files = importFiles(f); progressHolder.setProgress(72);
progressHolder.setProgress(82); importPrivateMsgs(f);
importPolls(f); progressHolder.setProgress(77);
progressHolder.setProgress(87); List<FileItem> files = importFiles(f);
importRoomFiles(f); progressHolder.setProgress(82);
progressHolder.setProgress(92); importPolls(f);
importExtraMenus(f); progressHolder.setProgress(87);
progressHolder.setProgress(95); importRoomFiles(f);
progressHolder.setProgress(92);
log.info("Extra menus import complete, starting copy of files and importExtraMenus(f);
folders"); progressHolder.setProgress(95);
/*
* ##################### Import real files and folders log.info("Extra menus import complete, starting copy of f
*/ iles and folders");
importFolders(f); /*
progressHolder.setProgress(97); * ##################### Import real files and folders
*/
if (ver.compareTo(BackupVersion.get("4.0.0")) < 0) { importFolders(f);
for (FileItem bfi : files) { progressHolder.setProgress(97);
if (bfi.isDeleted()) {
continue; if (ver.compareTo(BackupVersion.get("4.0.0")) < 0) {
} for (FileItem bfi : files) {
if (BaseFileItem.Type.PRESENTATION == bfi.getType if (bfi.isDeleted()) {
()) { continue;
convertOldPresentation(bfi); }
fileItemDao.updateBase(bfi); if (BaseFileItem.Type.PRESENTATION == bfi
} .getType()) {
if (BaseFileItem.Type.WML_FILE == bfi.getType()) convertOldPresentation(bfi);
{ fileItemDao.updateBase(bfi);
try { }
Whiteboard wb = WbConverter.conve if (BaseFileItem.Type.WML_FILE == bfi.get
rt(bfi); Type()) {
wb.save(bfi.getFile().toPath()); try {
} catch (Exception e) { Whiteboard wb = WbConvert
log.error("Unexpected error while er.convert(bfi);
converting WB", e); wb.save(bfi.getFile().toP
ath());
} catch (Exception e) {
log.error("Unexpected err
or while converting WB", e);
}
} }
} }
} }
log.info("File explorer item import complete");
success = true;
} catch (Exception e) {
throw e;
} finally {
if (f != null) {
log.info("Clearing temp files ...");
FileUtils.deleteDirectory(f);
}
cleanup();
if (success) {
progressHolder.setProgress(100);
}
} }
log.info("File explorer item import complete, clearing temp files
");
FileUtils.deleteDirectory(f);
cleanup();
progressHolder.setProgress(100);
} }
void cleanup() { void cleanup() {
ldapMap.clear(); ldapMap.clear();
oauthMap.clear(); oauthMap.clear();
userMap.clear(); userMap.clear();
groupMap.clear(); groupMap.clear();
calendarMap.clear(); calendarMap.clear();
appointmentMap.clear(); appointmentMap.clear();
roomMap.clear(); roomMap.clear();
 End of changes. 6 change blocks. 
85 lines changed or deleted 95 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)