Author: toad
Date: 2007-11-21 00:14:43 +0000 (Wed, 21 Nov 2007)
New Revision: 15894

Modified:
   trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
   trunk/freenet/src/freenet/config/StringArrOption.java
Log:
Fix bookmark import

Modified: trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java        
2007-11-20 23:56:34 UTC (rev 15893)
+++ trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java        
2007-11-21 00:14:43 UTC (rev 15894)
@@ -9,12 +9,16 @@
 import java.util.regex.Pattern;

 import freenet.client.async.USKCallback;
+import freenet.config.StringArrOption;
 import freenet.keys.FreenetURI;
 import freenet.keys.USK;
 import freenet.l10n.L10n;
 import freenet.node.NodeClientCore;
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
+import freenet.support.StringArray;
+import freenet.support.URLEncodedFormatException;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -68,7 +72,13 @@
                     "Frost", true, node.alerts));

             //TODO: remove
-            String[] oldBookmarks = oldConfig.getAll("bookmarks");
+            String[] oldBookmarks;
+                       try {
+                               oldBookmarks = 
StringArrOption.stringToArray(oldConfig.get("fproxy.bookmarks"));
+                       } catch (URLEncodedFormatException e) {
+                               Logger.error(this, "Not possible to migrate: 
caught "+e, e);
+                               oldBookmarks = null;
+                       }
             if (oldBookmarks != null) {
                 migrateOldBookmarks(oldBookmarks);
             }
@@ -86,6 +96,8 @@
     }

     private void migrateOldBookmarks(String[] newVals) {
+       if(Logger.shouldLog(Logger.MINOR, this))
+               Logger.minor(this, "Migrating bookmarks: 
"+StringArray.toString(newVals));
         //FIXME: for some reason that doesn't work... if someone wants to fix 
it ;)
         Pattern pattern = Pattern.compile("/(.*/)([^/]*)=([A-Z]{3}@.*).*");
         FreenetURI key;
@@ -171,6 +183,8 @@
     }

     public void addBookmark(String parentPath, Bookmark bookmark) {
+       if(Logger.shouldLog(Logger.MINOR, this))
+               Logger.minor(this, "Adding bookmark "+bookmark+" to 
"+parentPath);
         BookmarkCategory parent = getCategoryByPath(parentPath);
         parent.addBookmark(bookmark);
         putPaths(parentPath + bookmark.getName() + ((bookmark instanceof 
BookmarkCategory) ? "/" : ""),

Modified: trunk/freenet/src/freenet/config/StringArrOption.java
===================================================================
--- trunk/freenet/src/freenet/config/StringArrOption.java       2007-11-20 
23:56:34 UTC (rev 15893)
+++ trunk/freenet/src/freenet/config/StringArrOption.java       2007-11-21 
00:14:43 UTC (rev 15894)
@@ -46,7 +46,7 @@
                }
        }

-       private String[] stringToArray(String val) throws 
URLEncodedFormatException {
+       public static String[] stringToArray(String val) throws 
URLEncodedFormatException {
                if(val.length() == 0) return new String[0];
                String[] out = val.split(delimiter);
                for(int i=0;i<out.length;i++) {


Reply via email to