Revision: 4008
Author: solomax666
Date: Wed Jul 27 05:56:23 2011
Log: - import is improved (user mapping for existent user is added)
- correct mapping is used for the folders
http://code.google.com/p/openmeetings/source/detail?r=4008
Modified:
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/GenerateImage.java
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/BackupImport.java
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/DownloadHandler.java
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/UploadHandler.java
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/GenerateImage.java
Sat Jul 23 04:28:08 2011
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/GenerateImage.java
Wed Jul 27 05:56:23 2011
@@ -90,10 +90,10 @@
HashMap<String, HashMap<String, Object>> returnMap = new HashMap<String,
HashMap<String, Object>>();
String working_imgdir = current_dir + "upload" +
File.separatorChar
- + "profiles" + File.separatorChar + "profile_"
+ users_id
+ + "profiles" + File.separatorChar +
ScopeApplicationAdapter.profilesPrefix + users_id
+ File.separatorChar;
String working_pptdir = current_dir + "uploadtemp" +
File.separatorChar
- + "profiles" + File.separatorChar + "profile_"
+ users_id
+ + "profiles" + File.separatorChar +
ScopeApplicationAdapter.profilesPrefix + users_id
+ File.separatorChar;
String fileFullPath = working_pptdir + fileName + fileExt;
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
Sat Jul 23 04:28:08 2011
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
Wed Jul 27 05:56:23 2011
@@ -77,6 +77,7 @@
public static String webAppPath = "";
public static final String webAppRootKey = "openmeetings";//FIXME
public static String configDirName = "conf";
+ public static String profilesPrefix = "profile_";
public static String configKeyCryptClassName = null;
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/BackupImport.java
Tue Jul 26 10:30:16 2011
+++
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/BackupImport.java
Wed Jul 27 05:56:23 2011
@@ -15,7 +15,6 @@
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -26,7 +25,6 @@
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
-import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.openmeetings.app.data.basic.AuthLevelmanagement;
@@ -50,9 +48,6 @@
import org.openmeetings.app.data.user.dao.PrivateMessagesDaoImpl;
import org.openmeetings.app.data.user.dao.UserContactsDaoImpl;
import org.openmeetings.app.data.user.dao.UsersDaoImpl;
-import org.openmeetings.app.documents.GenerateImage;
-import org.openmeetings.app.documents.GeneratePDF;
-import org.openmeetings.app.documents.GenerateThumbs;
import org.openmeetings.app.persistence.beans.adresses.Adresses;
import org.openmeetings.app.persistence.beans.adresses.States;
import org.openmeetings.app.persistence.beans.basic.Configuration;
@@ -244,114 +239,6 @@
zipinputstream.close();
- //Now check the room files and import them
-
- File roomFilesFolder = new File(completeName +
File.separatorChar + "roomFiles");
-
-
- String library_dir = current_dir + "upload"
-
+ File.separatorChar;
-
- log.debug("roomFilesFolder PATH " +
roomFilesFolder.getAbsolutePath());
-
- if (roomFilesFolder.exists()) {
-
- File[] files = roomFilesFolder.listFiles();
- for (File file : files) {
- if (file.isDirectory()) {
-
- String
parentFolderName = file.getName();
-
- //Is a room folder or the
profiles folder
- String parentPath = library_dir + parentFolderName +
File.separatorChar;
-
- File parentPathFile = new
File(parentPath);
-
- if (!parentPathFile.exists()) {
- parentPathFile.mkdir();
- }
-
- File[] roomOrProfileFiles =
file.listFiles();
- for (File roomOrProfileFileOrFolder : roomOrProfileFiles)
{
-
-
- if
(roomOrProfileFileOrFolder.isDirectory()) {
-
- String roomDocumentFolderName = parentPath +
roomOrProfileFileOrFolder.getName() + File.separatorChar;
-
- File roomDocumentFolder = new
File(roomDocumentFolderName);
-
- if
(!roomDocumentFolder.exists()) {
-
roomDocumentFolder.mkdir();
-
- File[] roomDocumentFiles =
roomOrProfileFileOrFolder.listFiles();
-
- for (File
roomDocumentFile : roomDocumentFiles) {
-
- if
(roomDocumentFile.isDirectory()) {
- log.error("Folder detected in Documents space!
Folder "+roomDocumentFolderName);
- } else {
-
- String roomDocumentFileName =
roomDocumentFolderName + roomDocumentFile.getName();
-
- this.copyFile(roomDocumentFile, new
File(roomDocumentFileName));
-
- }
-
- }
-
- } else {
-
- log.debug("Document already
exists :: ",roomDocumentFolderName);
-
- }
-
-
-
- } else {
-
- String roomFileOrProfileName = parentPath +
roomOrProfileFileOrFolder.getName();
-
- File roomFileOrProfileFile = new
File(roomFileOrProfileName);
-
- if
(!roomFileOrProfileFile.exists()) {
-
- this.copyFile(roomOrProfileFileOrFolder,
roomFileOrProfileFile);
-
- } else {
-
- log.debug("File does already
exist :: ",roomFileOrProfileName);
-
- }
-
-
- }
-
-
-
- }
-
- }
- }
-
- }
-
-
- //Now check the recordings and import them
-
- File sourceDirRec = new File(completeName +
File.separatorChar + "recordingFiles");
-
-
- log.debug("sourceDirRec PATH " +
sourceDirRec.getAbsolutePath());
-
- if (sourceDirRec.exists()) {
-
- File targetDirRec = new File(current_dir + "streams" +
File.separatorChar
-
+ "hibernate" + File.separatorChar);
-
- copyDirectory(sourceDirRec,targetDirRec);
-
- }
/* #####################
* Import Organizations
@@ -493,6 +380,8 @@
} else {
this.importFileExplorerItems(fileExplorerListFile);
}
+
+ importFolders(current_dir,
completeName);
this.deleteDirectory(f);
@@ -781,23 +670,29 @@
//check if login does already exists
Users storedUser =
Usermanagement.getInstance().getUserByLoginOrEmail(us.getLogin());
- if (storedUser != null) {
- log.info("A user with the given login does already
exist "+us.getLogin());
- return;
- }
-
- storedUser =
Usermanagement.getInstance().getUserByLoginOrEmail(email);
-
- if (storedUser != null) {
- log.info("A user with the given email as login does already
exist "+email);
- return;
- }
-
- log.debug("Import User ID
"+us.getUser_id());
+ Long userId = us.getUser_id();
+ if (us.getExternalUserId() == null || us.getExternalUserId()
== 0){
+ if (storedUser != null) {
+ log.info("A user with the given login does already
exist "+us.getLogin());
+ } else {
+
+ storedUser =
Usermanagement.getInstance().getUserByLoginOrEmail(email);
+
+ if (storedUser != null)
{
+ log.info("A user with the given email as login does already
exist "+email);
+ }
+ }
+ if (storedUser != null) {
+ usersMap.put(userId,
storedUser.getUser_id());
+ continue;
+ }
+ }
+
+ log.debug("Import User ID "+userId);
us.setUser_id(null);
us.setStarttime(new Date());
Long actualNewUserId =
Usermanagement.getInstance().addUserBackup(us);
- usersMap.put(us.getUser_id(),
actualNewUserId);
+ usersMap.put(userId, actualNewUserId);
for (Iterator<Organisation_Users> orgUserIterator =
orgUsers.iterator();orgUserIterator.hasNext();) {
@@ -1774,6 +1669,129 @@
}
return null;
}
+
+ private void importFolders(String current_dir, String completeName)
throws IOException {
+
+ //Now check the room files and import them
+ File roomFilesFolder = new File(completeName + File.separatorChar
+ "roomFiles");
+
+
+ String library_dir = current_dir + "upload"
+ +
File.separatorChar;
+
+ log.debug("roomFilesFolder PATH " +
roomFilesFolder.getAbsolutePath());
+
+ if (roomFilesFolder.exists()) {
+
+ File[] files = roomFilesFolder.listFiles();
+ for (File file : files) {
+ if (file.isDirectory()) {
+
+ String parentFolderName =
file.getName();
+
+ //Is a room folder or the profiles folder
+ String parentPath = library_dir + parentFolderName +
File.separatorChar;
+
+ File parentPathFile = new File(parentPath);
+
+ if (!parentPathFile.exists()) {
+ parentPathFile.mkdir();
+ }
+
+ File[] roomOrProfileFiles = file.listFiles();
+ for (File roomOrProfileFileOrFolder :
roomOrProfileFiles) {
+
+
+ if
(roomOrProfileFileOrFolder.isDirectory()) {
+
+ String fileOrFolderName =
roomOrProfileFileOrFolder.getName();
+ int beginIndex =
fileOrFolderName.indexOf(ScopeApplicationAdapter.profilesPrefix);
+ // Profile folder should be renamed if new user id is differ
from current id.
+ if (beginIndex > -1 ){
+ beginIndex = beginIndex +
ScopeApplicationAdapter.profilesPrefix.length();
+ Long profileId =
importLongType(fileOrFolderName.substring(beginIndex));
+ Long newProfileID =
getNewId(profileId, Maps.USERS);
+ if (profileId !=
newProfileID){
+ fileOrFolderName =
fileOrFolderName.replaceFirst(ScopeApplicationAdapter.profilesPrefix +
profileId, ScopeApplicationAdapter.profilesPrefix + newProfileID);
+ }
+ }
+ String roomDocumentFolderName = parentPath + fileOrFolderName +
File.separatorChar;
+
+ File roomDocumentFolder = new
File(roomDocumentFolderName);
+
+ if (!roomDocumentFolder.exists()) {
+ roomDocumentFolder.mkdir();
+
+ File[] roomDocumentFiles =
roomOrProfileFileOrFolder.listFiles();
+
+ for (File roomDocumentFile :
roomDocumentFiles) {
+
+ if
(roomDocumentFile.isDirectory()) {
+ log.error("Folder detected in Documents space!
Folder "+roomDocumentFolderName);
+ } else {
+
+ String roomDocumentFileName = roomDocumentFolderName +
roomDocumentFile.getName();
+
+ this.copyFile(roomDocumentFile, new
File(roomDocumentFileName));
+
+ }
+
+ }
+
+ } else {
+
+ log.debug("Document already
exists :: ",roomDocumentFolderName);
+
+ }
+
+
+
+ } else {
+
+ String roomFileOrProfileName = parentPath +
roomOrProfileFileOrFolder.getName();
+
+ File roomFileOrProfileFile =
new File(roomFileOrProfileName);
+
+ if
(!roomFileOrProfileFile.exists()) {
+
+
this.copyFile(roomOrProfileFileOrFolder, roomFileOrProfileFile);
+
+ } else {
+
+ log.debug("File does already
exist :: ",roomFileOrProfileName);
+
+ }
+
+
+ }
+
+
+
+ }
+
+ }
+ }
+
+ }
+
+
+ //Now check the recordings and import them
+
+ File sourceDirRec = new File(completeName + File.separatorChar
+ "recordingFiles");
+
+
+ log.debug("sourceDirRec PATH " + sourceDirRec.getAbsolutePath());
+
+ if (sourceDirRec.exists()) {
+
+ File targetDirRec = new File(current_dir + "streams" +
File.separatorChar
+ +
"hibernate" + File.separatorChar);
+
+ copyDirectory(sourceDirRec,targetDirRec);
+
+ }
+
+ }
private Integer importIntegerType(String value) {
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/DownloadHandler.java
Wed Nov 10 23:23:56 2010
+++
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/DownloadHandler.java
Wed Jul 27 05:56:23 2011
@@ -20,6 +20,7 @@
import org.red5.logging.Red5LoggerFactory;
import org.openmeetings.app.data.basic.Sessionmanagement;
import org.openmeetings.app.data.user.Usermanagement;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
public class DownloadHandler extends HttpServlet {
@@ -142,7 +143,7 @@
}
}
- working_dir += "profile_"+users_id +
File.separatorChar;
+ working_dir += ScopeApplicationAdapter.profilesPrefix+users_id +
File.separatorChar;
File f2 = new File(working_dir);
if (!f2.exists()) {
boolean c = f2.mkdir();
@@ -165,7 +166,7 @@
remoteUser_id = "0";
}
- working_dir += "profile_"+remoteUser_id
+ File.separatorChar;
+ working_dir += ScopeApplicationAdapter.profilesPrefix+remoteUser_id +
File.separatorChar;
File f2 = new File(working_dir);
if (!f2.exists()) {
boolean c = f2.mkdir();
@@ -191,7 +192,7 @@
remoteUser_id = "0";
}
- working_dir += "profile_"+remoteUser_id
+ File.separatorChar;
+ working_dir += ScopeApplicationAdapter.profilesPrefix+remoteUser_id +
File.separatorChar;
File f2 = new File(working_dir);
if (!f2.exists()) {
boolean c = f2.mkdir();
@@ -218,7 +219,7 @@
remoteUser_id = "0";
}
- working_dir += "profile_"+remoteUser_id
+ File.separatorChar;
+ working_dir += ScopeApplicationAdapter.profilesPrefix+remoteUser_id +
File.separatorChar;
File f2 = new File(working_dir);
if (!f2.exists()) {
boolean c = f2.mkdir();
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/UploadHandler.java
Sat Jul 23 04:28:08 2011
+++
/trunk/singlewebapp/src/app/org/openmeetings/servlet/outputhandler/UploadHandler.java
Wed Jul 27 05:56:23 2011
@@ -178,7 +178,7 @@
// System.out.println("cannot write to
directory");
}
}
- completeName += "profile_" + userId +
File.separatorChar;
+ completeName += ScopeApplicationAdapter.profilesPrefix + userId +
File.separatorChar;
File f2 = new File(completeName);
if (!f2.exists()) {
boolean c = f2.mkdir();
@@ -204,7 +204,7 @@
+ "uploadtemp"
+ File.separatorChar
+ ((userProfile) ? "profiles" +
File.separatorChar
- + "profile_" + userId :
roomName)
+ +
ScopeApplicationAdapter.profilesPrefix + userId : roomName)
+ File.separatorChar;
localFolder = new File(workingDirPpt);
if (!localFolder.exists()) {
@@ -365,7 +365,7 @@
Long users_id) throws Exception {
String working_imgdir = current_dir + "upload" +
File.separatorChar
- + "profiles" + File.separatorChar + "profile_"
+ users_id
+ + "profiles" + File.separatorChar +
ScopeApplicationAdapter.profilesPrefix + users_id
+ File.separatorChar;
File f = new File(working_imgdir);
if (f.exists() && f.isDirectory()) {
@@ -377,7 +377,7 @@
throws Exception {
String working_imgdir = current_dir + "upload" +
File.separatorChar
- + "profiles" + File.separatorChar + "profile_"
+ users_id
+ + "profiles" + File.separatorChar +
ScopeApplicationAdapter.profilesPrefix + users_id
+ File.separatorChar;
for (int i = 0; i < this.filesString.length; i++) {
--
You received this message because you are subscribed to the Google Groups
"OpenMeetings developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/openmeetings-dev?hl=en.