Author: solomax
Date: Fri Apr  6 04:21:51 2012
New Revision: 1310162

URL: http://svn.apache.org/viewvc?rev=1310162&view=rev
Log:
OPENMEETINGS-111 both command line and GUI backup/restore are fixed

Modified:
    incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.bat
    incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh
    
incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/hibernate/hibRtmpConnection.lzx
    incubator/openmeetings/trunk/singlewebapp/build.properties
    incubator/openmeetings/trunk/singlewebapp/build.xml
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupImportController.java

Modified: incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.bat
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.bat?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.bat 
(original)
+++ incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.bat Fri Apr 
 6 04:21:51 2012
@@ -1,6 +1,6 @@
-set RED5DIR=%~dp0
+set RED5_HOME=%~dp0
 
-set 
CLASSPATH=%RED5DIR%\*;%RED5DIR%\conf;%RED5DIR%\lib\*;%RED5DIR%\webapps\openmeetings\WEB-INF\lib\*;%RED5DIR%\webapps\openmeetings\WEB-INF;%RED5DIR%\webapps\openmeetings\WEB-INF\classes
+set 
CLASSPATH=%RED5_HOME%\*;%RED5_HOME%\conf;%RED5_HOME%\lib\*;%RED5_HOME%\webapps\openmeetings\WEB-INF\lib\*;%RED5_HOME%\webapps\openmeetings\WEB-INF;%RED5_HOME%\webapps\openmeetings\WEB-INF\classes
 
-java -cp "%CLASSPATH%" -Dred5.home=%RED5DIR% org.openmeetings.app.Admin %*
+java -cp "%CLASSPATH%" org.openmeetings.app.Admin %*
 

Modified: incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh 
(original)
+++ incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh Fri Apr  
6 04:21:51 2012
@@ -1,7 +1,7 @@
 #!/bin/bash
-export RED5DIR=$(cd $(dirname "$0"); pwd) 
+export RED5_HOME=$(cd $(dirname "$0"); pwd) 
 
-export 
CLASSPATH=$RED5DIR/*:$RED5DIR/conf:$RED5DIR/lib/*:$RED5DIR/webapps/openmeetings/WEB-INF/lib/*:$RED5DIR/webapps/openmeetings/WEB-INF:$RED5DIR/webapps/openmeetings/WEB-INF/classes
+export 
CLASSPATH=$RED5_HOME/*:$RED5_HOME/conf:$RED5_HOME/lib/*:$RED5_HOME/webapps/openmeetings/WEB-INF/lib/*:$RED5_HOME/webapps/openmeetings/WEB-INF:$RED5_HOME/webapps/openmeetings/WEB-INF/classes
 
-java -cp "$CLASSPATH" "-Dred5.home=$RED5DIR" org.openmeetings.app.Admin $*
+java -cp "$CLASSPATH" org.openmeetings.app.Admin $*
 

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/hibernate/hibRtmpConnection.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/hibernate/hibRtmpConnection.lzx?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/hibernate/hibRtmpConnection.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/hibernate/hibRtmpConnection.lzx
 Fri Apr  6 04:21:51 2012
@@ -1696,8 +1696,8 @@
                     } else if (value.message=='library'){
                         
                         if (value.action == 'import') {
-                            
canvas.currentUploadWindow.myFileUpload.onComplete("byRemote");
-                            return
+                            
canvas.currentUploadWindow.myFileUpload.onCompleteByRemote(value);
+                            return;
                         }
                         
                         var error = false;

Modified: incubator/openmeetings/trunk/singlewebapp/build.properties
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/build.properties?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/build.properties (original)
+++ incubator/openmeetings/trunk/singlewebapp/build.properties Fri Apr  6 
04:21:51 2012
@@ -1,4 +1,6 @@
 project.version=2.0.0
 project.status=SNAPSHOT
 red5.revision=4315
+laszlo.debug=false
+laszlo.proxied=solo
 db=derby

Modified: incubator/openmeetings/trunk/singlewebapp/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/build.xml?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/build.xml (original)
+++ incubator/openmeetings/trunk/singlewebapp/build.xml Fri Apr  6 04:21:51 2012
@@ -59,8 +59,6 @@
        <property name="webcontent.src.dir" value="${basedir}/WebContent" />
        <property name="laszlo.as3.src.dir" value="${webcontent.src.dir}/swf10" 
/>
        <property name="laszlo.src.dir" value="${webcontent.src.dir}/src" />
-       <property name="laszlo.debug" value="false" />
-       <property name="laszlo.proxied" value="solo" />
 
        <property name="keystore.file" 
value="${build.base.dir}/filetest.keystore" />
        

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java 
(original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java 
Fri Apr  6 04:21:51 2012
@@ -2,7 +2,6 @@ package org.openmeetings.app;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import org.apache.commons.cli.CommandLine;
@@ -15,13 +14,13 @@ import org.apache.commons.cli.Parser;
 import org.apache.commons.cli.PosixParser;
 import org.openmeetings.servlet.outputhandler.BackupExport;
 import org.openmeetings.servlet.outputhandler.BackupImportController;
+import org.openmeetings.utils.math.CalendarPatterns;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class Admin {
        private static final Logger log = 
Red5LoggerFactory.getLogger(Admin.class);
-       private SimpleDateFormat sdf = new 
SimpleDateFormat("yyyy-MM-dd_hhmmss");
        private boolean verbose = false;
        private Options opts = buildOptions();
 
@@ -64,7 +63,7 @@ public class Admin {
                if (verbose) {
                        log.error(msg, e);
                } else {
-                       log.error(msg + e.getMessage());
+                       log.error(msg + " " + e.getMessage());
                }
                System.exit(1);
        }
@@ -80,7 +79,7 @@ public class Admin {
        }
        
        private void process(String[] args) {
-               File omHome = new File(System.getProperty("red5.home"), 
"webapps/openmeetings");
+               File omHome = new File(System.getenv("RED5_HOME"), 
"webapps/openmeetings");
                
                Parser parser = new PosixParser();
                CommandLine cmdl = null;
@@ -118,14 +117,14 @@ public class Admin {
                        case backup:
                                try {
                                        if (!cmdl.hasOption('f')) {
-                                               file = "backup_" + 
sdf.format(new Date()) + ".zip";
+                                               file = "backup_" + 
CalendarPatterns.getTimeForStreamId(new Date()) + ".zip";
                                                System.out.println("File name 
was not specified, '" + file + "' will be used");
                                        }
                                        boolean includeFiles = 
Boolean.getBoolean(cmdl.getOptionValue("exclude-files", "true"));
                                        BackupExport export = 
applicationContext.getBean(BackupExport.class);
                                        File backup_dir = new File(omHome, 
"uploadtemp/" + System.currentTimeMillis());
                                        backup_dir.mkdirs();
-                                       export.performExport(file, 
backup_dir.getAbsolutePath(), includeFiles, omHome.getAbsolutePath());
+                                       export.performExport(file, backup_dir, 
includeFiles, omHome.getAbsolutePath());
                                        export.deleteDirectory(backup_dir);
                                        backup_dir.delete();
                                } catch (Exception e) {
@@ -141,7 +140,7 @@ public class Admin {
                                                System.exit(1);
                                        }
                                        BackupImportController importCtrl = 
applicationContext.getBean(BackupImportController.class);
-                                       importCtrl.performImport(new 
FileInputStream(backup), omHome.getAbsolutePath(), backup.getAbsolutePath());
+                                       importCtrl.performImport(new 
FileInputStream(backup), omHome.getAbsolutePath());
                                } catch (Exception e) {
                                        handleError("Restore failed", e);
                                }

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
 Fri Apr  6 04:21:51 2012
@@ -128,8 +128,13 @@ public class BackupExport {
        @Autowired
        private PollManagement pollManagement;
 
-       public void performExport(String filePath, String backup_dir,
+       public void performExport(String filePath, File backup_dir,
                        boolean includeFiles, String omFilesDir) throws 
Exception {
+
+               if (!backup_dir.exists()) {
+                       backup_dir.mkdirs();
+               }
+               
                /*
                 * ##################### Backup Organizations
                 */
@@ -387,18 +392,13 @@ public class BackupExport {
 
                        copyDirectory(sourceDirRec, targetDirRec);
                }
-               File backup_dirFile = new File(backup_dir);
-
-               if (!backup_dirFile.exists()) {
-                       backup_dirFile.mkdir();
-               }
 
                List<File> fileList = new ArrayList<File>();
                log.debug("---Getting references to all files in: "
-                               + backup_dirFile.getCanonicalPath());
-               getAllFiles(backup_dirFile, fileList);
+                               + backup_dir.getCanonicalPath());
+               getAllFiles(backup_dir, fileList);
                log.debug("---Creating zip file");
-               writeZipFile(backup_dirFile, fileList, new 
FileOutputStream(filePath));
+               writeZipFile(backup_dir, fileList, new 
FileOutputStream(filePath));
                log.debug("---Done");
        }
        
@@ -447,25 +447,20 @@ public class BackupExport {
                                         */
 
                                        String current_dir = 
servletCtx.getRealPath("/");
-                                       String working_dir = current_dir + 
"upload"
-                                                       + File.separatorChar + 
"backup"
-                                                       + File.separatorChar;
-                                       File working_dirFile = new 
File(working_dir);
+                                       File working_dir = new 
File(current_dir, "upload"
+                                                       + File.separatorChar + 
"backup");
 
-                                       if (!working_dirFile.exists()) {
-                                               working_dirFile.mkdir();
+                                       if (!working_dir.exists()) {
+                                               working_dir.mkdir();
                                        }
 
                                        String dateString = "backup_"
                                                        + 
CalendarPatterns.getTimeForStreamId(new Date());
 
-                                       String backup_file = working_dir + 
File.separatorChar
-                                                       + dateString;
-
-                                       String backup_dir = backup_file + 
File.separatorChar;
-
-                                       String full_path = backup_file + ".zip";
+                                       File backup_dir = new File(working_dir, 
dateString);
+                                       File backupFile = new File(backup_dir, 
dateString + ".zip");
 
+                                       String full_path = 
backupFile.getAbsolutePath();
                                        performExport(full_path, backup_dir, 
includeFiles, current_dir);
                                        
                                        RandomAccessFile rf = new 
RandomAccessFile(full_path, "r");
@@ -495,14 +490,12 @@ public class BackupExport {
                                        out.flush();
                                        out.close();
 
-                                       File backupFile = new File(full_path);
-
                                        if (backupFile.exists()) {
                                                // log.debug("DELETE :1: 
"+backupFile.getAbsolutePath());
                                                backupFile.delete();
                                        }
 
-                                       deleteDirectory(new File(backup_dir));
+                                       deleteDirectory(backup_dir);
 
                                }
                        } else {

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupImportController.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupImportController.java?rev=1310162&r1=1310161&r2=1310162&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupImportController.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupImportController.java
 Fri Apr  6 04:21:51 2012
@@ -39,7 +39,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
@@ -85,7 +84,6 @@ import org.openmeetings.app.persistence.
 import org.openmeetings.app.persistence.beans.user.Users;
 import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
 import org.openmeetings.utils.math.CalendarPatterns;
-import org.openmeetings.utils.stringhandlers.StringComparer;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -151,7 +149,25 @@ public class BackupImportController exte
                USERS, ORGANISATIONS, APPOINTMENTS, ROOMS, MESSAGEFOLDERS, 
USERCONTACTS, FILEEXPLORERITEMS
        };
 
-       public void performImport(InputStream is, String current_dir, String 
completeName) throws Exception {
+       public void performImport(InputStream is, String current_dir) throws 
Exception {
+               File working_dir = new File(current_dir, "upload"
+                               + File.separatorChar + "import");
+               if (!working_dir.exists()) {
+                       working_dir.mkdir();
+               }
+
+               File f = new File(working_dir, "import_" + 
CalendarPatterns.getTimeForStreamId(new Date()));
+
+               int recursiveNumber = 0;
+               do {
+                       if (f.exists()) {
+                               f = new File(f.getAbsolutePath() + 
(recursiveNumber++));
+                       }
+               } while (f.exists());
+               f.mkdir();
+
+               log.debug("##### WRITE FILE TO: " + f);
+               
                ZipInputStream zipinputstream = new ZipInputStream(is);
                byte[] buf = new byte[1024];
 
@@ -159,29 +175,18 @@ public class BackupImportController exte
 
                while (zipentry != null) {
                        // for each entry to be extracted
-                       String entryName = completeName + File.separatorChar
-                                       + zipentry.getName();
-                       entryName = entryName.replace('/', File.separatorChar);
-                       entryName = entryName.replace('\\', File.separatorChar);
-
-                       // log.debug("entryname " + entryName);
-
-                       // zipentry.get
-
                        int n;
                        FileOutputStream fileoutputstream;
-                       File newFile = new File(entryName);
+                       File fentryName = new File(f, zipentry.getName());
 
                        if (zipentry.isDirectory()) {
-                               if (!newFile.mkdir()) {
+                               if (!fentryName.mkdir()) {
                                        break;
                                }
                                zipentry = zipinputstream.getNextEntry();
                                continue;
                        }
 
-                       File fentryName = new File(entryName);
-
                        File fparent = new File(fentryName.getParent());
 
                        if (!fparent.exists()) {
@@ -214,7 +219,7 @@ public class BackupImportController exte
 
                        }
 
-                       fileoutputstream = new FileOutputStream(entryName);
+                       fileoutputstream = new FileOutputStream(fentryName);
 
                        while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
                                fileoutputstream.write(buf, 0, n);
@@ -231,9 +236,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Organizations
                 */
-               String orgListXML = completeName + File.separatorChar
-                               + "organizations.xml";
-               File orgFile = new File(orgListXML);
+               File orgFile = new File(f, "organizations.xml");
                if (!orgFile.exists()) {
                        throw new Exception("organizations.xml missing");
                }
@@ -244,9 +247,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Users
                 */
-               String userListXML = completeName + File.separatorChar
-                               + "users.xml";
-               File userFile = new File(userListXML);
+               File userFile = new File(f, "users.xml");
                if (!userFile.exists()) {
                        throw new Exception("users.xml missing");
                }
@@ -257,9 +258,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Rooms
                 */
-               String roomListXML = completeName + File.separatorChar
-                               + "rooms.xml";
-               File roomFile = new File(roomListXML);
+               File roomFile = new File(f, "rooms.xml");
                if (!roomFile.exists()) {
                        throw new Exception("rooms.xml missing");
                }
@@ -270,9 +269,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Room Organisations
                 */
-               String orgRoomListXML = completeName + File.separatorChar
-                               + "rooms_organisation.xml";
-               File orgRoomListFile = new File(orgRoomListXML);
+               File orgRoomListFile = new File(f, "rooms_organisation.xml");
                if (!orgRoomListFile.exists()) {
                        throw new Exception("rooms_organisation.xml missing");
                }
@@ -283,9 +280,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Appointements
                 */
-               String appointementListXML = completeName
-                               + File.separatorChar + "appointements.xml";
-               File appointementListFile = new File(appointementListXML);
+               File appointementListFile = new File(f, "appointements.xml");
                if (!appointementListFile.exists()) {
                        throw new Exception("appointements.xml missing");
                }
@@ -298,10 +293,7 @@ public class BackupImportController exte
                 * 
                 * Reminder Invitations will be NOT send!
                 */
-               String meetingmembersListXML = completeName
-                               + File.separatorChar + "meetingmembers.xml";
-               File meetingmembersListFile = new File(
-                               meetingmembersListXML);
+               File meetingmembersListFile = new File(f, "meetingmembers.xml");
                if (!meetingmembersListFile.exists()) {
                        throw new Exception("meetingmembersListFile missing");
                }
@@ -312,9 +304,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import LDAP Configs
                 */
-               String ldapConfigListXML = completeName
-                               + File.separatorChar + "ldapconfigs.xml";
-               File ldapConfigListFile = new File(ldapConfigListXML);
+               File ldapConfigListFile = new File(f, "ldapconfigs.xml");
                if (!ldapConfigListFile.exists()) {
                        log.debug("meetingmembersListFile missing");
                        // throw new Exception
@@ -328,9 +318,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Recordings
                 */
-               String flvRecordingsListXML = completeName
-                               + File.separatorChar + "flvRecordings.xml";
-               File flvRecordingsListFile = new File(flvRecordingsListXML);
+               File flvRecordingsListFile = new File(f, "flvRecordings.xml");
                if (!flvRecordingsListFile.exists()) {
                        log.debug("flvRecordingsListFile missing");
                        // throw new Exception
@@ -344,10 +332,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Private Message Folders
                 */
-               String privateMessageFoldersXML = completeName
-                               + File.separatorChar + 
"privateMessageFolder.xml";
-               File privateMessageFoldersFile = new File(
-                               privateMessageFoldersXML);
+               File privateMessageFoldersFile = new File(f, 
"privateMessageFolder.xml");
                if (!privateMessageFoldersFile.exists()) {
                        log.debug("privateMessageFoldersFile missing");
                        // throw new Exception
@@ -361,9 +346,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import Private Messages
                 */
-               String privateMessagesXML = completeName
-                               + File.separatorChar + "privateMessages.xml";
-               File privateMessagesFile = new File(privateMessagesXML);
+               File privateMessagesFile = new File(f, "privateMessages.xml");
                if (!privateMessagesFile.exists()) {
                        log.debug("privateMessagesFile missing");
                        // throw new Exception
@@ -377,9 +360,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import User Contacts
                 */
-               String userContactsXML = completeName + File.separatorChar
-                               + "userContacts.xml";
-               File userContactsFile = new File(userContactsXML);
+               File userContactsFile = new File(f, "userContacts.xml");
                if (!userContactsFile.exists()) {
                        log.debug("userContactsFile missing");
                        // throw new Exception
@@ -393,9 +374,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import File-Explorer Items
                 */
-               String fileExplorerListXML = completeName
-                               + File.separatorChar + "fileExplorerItems.xml";
-               File fileExplorerListFile = new File(fileExplorerListXML);
+               File fileExplorerListFile = new File(f, 
"fileExplorerItems.xml");
                if (!fileExplorerListFile.exists()) {
                        log.debug("fileExplorerListFile missing");
                        // throw new Exception
@@ -409,9 +388,7 @@ public class BackupImportController exte
                /*
                 * ##################### Import File-Explorer Items
                 */
-               String roomPollListXML = completeName + File.separatorChar
-                               + "roompolls.xml";
-               File roomPollListFile = new File(roomPollListXML);
+               File roomPollListFile = new File(f, "roompolls.xml");
                if (!roomPollListFile.exists()) {
                        log.debug("roomPollListFile missing");
                } else {
@@ -423,9 +400,11 @@ public class BackupImportController exte
                /*
                 * ##################### Import real files and folders
                 */
-               importFolders(current_dir, completeName);
+               importFolders(current_dir, f);
 
                log.info("File explorer item import complete, clearing temp 
files");
+               
+               deleteDirectory(f);
        }
        
     @RequestMapping(value = "/backup.upload", method = RequestMethod.POST)
@@ -436,53 +415,16 @@ public class BackupImportController exte
        UploadInfo info = validate(request, true);
        try {
                        String current_dir = context.getRealPath("/");
-                       String working_dir = current_dir + "upload"
-                                       + File.separatorChar + "import"
-                                       + File.separatorChar;
-                       File working_dirFile = new File(working_dir);
-                       if (!working_dirFile.exists()) {
-                               working_dirFile.mkdir();
-                       }
-
                        MultipartFile multipartFile = info.file;
                        InputStream is = multipartFile.getInputStream();
-                       String fileSystemName = 
multipartFile.getOriginalFilename();
-
-                       StringUtils.deleteWhitespace(fileSystemName);
-
-                       int dotidx = fileSystemName.lastIndexOf('.');
-                       String newFileSystemName = StringComparer.getInstance()
-                                       .compareForRealPaths(
-                                                       
fileSystemName.substring(0, dotidx));
-
-                       String completeName = working_dir + newFileSystemName;
-
-                       File f = new File(completeName + File.separatorChar);
-
-                       if (f.exists()) {
-                               int recursiveNumber = 0;
-                               String tempd = completeName + "_" + 
recursiveNumber;
-                               while (f.exists()) {
-                                       recursiveNumber++;
-                                       tempd = completeName + "_" + 
recursiveNumber;
-                                       f = new File(tempd + 
File.separatorChar);
-
-                               }
-                               completeName = tempd;
-                       }
-
-                       f.mkdir();
-
-                       log.debug("##### WRITE FILE TO: " + completeName);
-                       performImport(is, current_dir, completeName);
-                       deleteDirectory(f);
+                       performImport(is, current_dir);
 
                        LinkedHashMap<String, Object> hs = new 
LinkedHashMap<String, Object>();
                        hs.put("user", usersDao.getUser(info.userId));
                        hs.put("message", "library");
                        hs.put("action", "import");
                        hs.put("error", "");
-                       hs.put("fileName", completeName);
+                       hs.put("fileName", multipartFile.getOriginalFilename());
 
                        
scopeApplicationAdapter.sendMessageWithClientByPublicSID(
                                        hs, info.publicSID);
@@ -2195,12 +2137,11 @@ public class BackupImportController exte
                return null;
        }
 
-       private void importFolders(String current_dir, String completeName)
+       private void importFolders(String current_dir, File importBaseDir)
                        throws IOException {
 
                // Now check the room files and import them
-               File roomFilesFolder = new File(completeName + 
File.separatorChar
-                               + "roomFiles");
+               File roomFilesFolder = new File(importBaseDir, "roomFiles");
 
                String library_dir = current_dir + "upload" + 
File.separatorChar;
 
@@ -2319,8 +2260,7 @@ public class BackupImportController exte
 
                // Now check the recordings and import them
 
-               File sourceDirRec = new File(completeName + File.separatorChar
-                               + "recordingFiles");
+               File sourceDirRec = new File(importBaseDir, "recordingFiles");
 
                log.debug("sourceDirRec PATH " + 
sourceDirRec.getAbsolutePath());
 


Reply via email to