directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r546304 - /directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java
Date Mon, 11 Jun 2007 22:16:05 GMT
Author: seelmann
Date: Mon Jun 11 15:16:03 2007
New Revision: 546304

URL: http://svn.apache.org/viewvc?view=rev&rev=546304
Log:
Added code to convert connections.xml from old ldapstudio plugin or .ldapstudio workspace

Modified:
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java?view=diff&rev=546304&r1=546303&r2=546304
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ConnectionManager.java
Mon Jun 11 15:16:03 2007
@@ -132,22 +132,32 @@
         File file = new File( filename );
         if ( !file.exists() )
         {
-            // try to convert old connections.xml
-            String oldFilename = filename.replaceAll( "org.apache.directory.studio.ldapbrowser.core",
+            // try to convert old connections.xml:
+            // 1st search it in current workspace with the old ldapstudio plugin ID
+            // 2nd search it in old .ldapstudio workspace with the old ldapstudio plugin
ID
+            String[] oldFilenames = new String[2];
+            oldFilenames[0] = filename.replace( "org.apache.directory.studio.ldapbrowser.core",
                 "org.apache.directory.ldapstudio.browser.core" );
-            File oldFile = new File( oldFilename );
-            if ( oldFile.exists() )
+            oldFilenames[1] = oldFilenames[0].replace( ".ApacheDirectoryStudio",
+                ".ldapstudio" );
+            for ( int i = 0; i < oldFilenames.length; i++ )
             {
-                try
+                File oldFile = new File( oldFilenames[i] );
+                System.out.println("Trying oldFile " + oldFile);
+                if ( oldFile.exists() )
                 {
-                    String oldContent = FileUtils.readFileToString( oldFile, "UTF-8" );
-                    String newContent = oldContent.replaceAll( "org.apache.directory.ldapstudio.browser.core",
-                        "org.apache.directory.studio.ldapbrowser.core" );
-                    FileUtils.writeStringToFile( file, newContent, "UTF-8" );
-                }
-                catch ( IOException e )
-                {
-                    e.printStackTrace();
+                    try
+                    {
+                        String oldContent = FileUtils.readFileToString( oldFile, "UTF-8"
);
+                        String newContent = oldContent.replace( "org.apache.directory.ldapstudio.browser.core",
+                            "org.apache.directory.studio.ldapbrowser.core" );
+                        FileUtils.writeStringToFile( file, newContent, "UTF-8" );
+                        break;
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();
+                    }
                 }
             }
         }



Mime
View raw message