Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
XML import works. Please backup your bookmarks.db before trying it, i had many kelondro errors while importing del.icio.us xml-Files
allofb5c38736816
diff --git a/htroot/Bookmarks_p.html b/htroot/Bookmarks_p.htmlindex 941aa3852..be0561c6b 100644--- a/htroot/Bookmarks_p.html+++ b/htroot/Bookmarks_p.html@@ -44,7 +44,7 @@<option value="private" #(public)#selected::#(/public)#>no</option></select></td>- </tr>+ </tr><tr><td colspan="2" colspan="2" valign="top" class="TableHeader" width="100%">#(edit)#@@ -66,6 +66,14 @@<td valign="top" class="TableCellDark">File:</td><td valign="top" class="TableCellLight" width="100%"><input type="file" name="xmlfile"></td></tr>+ <tr>+ <td valign="top" class="TableCellDark">import as Public:</td>+ <td valign="top" class="TableCellLight"><select name="public">+ <option value="public">yes</option>+ <option value="private">no</option>+ </select>+ </td>+ </tr><tr><td colspan="2" colspan="2" valign="top" class="TableHeader" width="100%"><input type="submit" name="importxml" value="import">@@ -82,7 +90,7 @@<td><h3>Tags</h3></td></tr><tr>- <td width="100%">+ <td width="100%" valign="top">#{bookmarks}#<p style="border-bottom:1px #000 dashed; padding-bottom: 1em;">#(public)#<img class="bookmarkIcon" src="env/grafics/bookmarkpriv.gif" alt="private">::<img class="bookmarkIcon" src="env/grafics/bookmarkpub.gif" alt="public">#(/public)#diff --git a/htroot/Bookmarks_p.java b/htroot/Bookmarks_p.javaindex d3525d2f1..685315f1b 100644--- a/htroot/Bookmarks_p.java+++ b/htroot/Bookmarks_p.java@@ -100,7 +100,11 @@ public class Bookmarks_p {if(bookmark != null){bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);- bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_PUBLIC, (String) post.get("public"));+ if(((String) post.get("public")).equals("public")){+ bookmark.setPublic(true);+ }else{+ bookmark.setPublic(false);+ }bookmark.setTags(tags);bookmark.setBookmarksTable();}else{@@ -145,9 +149,12 @@ public class Bookmarks_p {}}}- }- if(post.containsKey("xmlfile")){- switchboard.bookmarksDB.importFromXML(new String((byte[])post.get("xmlfile$file")));+ }else if(post.containsKey("xmlfile")){+ boolean isPublic=false;+ if(((String) post.get("public")).equals("public")){+ isPublic=true;+ }+ switchboard.bookmarksDB.importFromXML(new String((byte[])post.get("xmlfile$file")), isPublic);}if(post.containsKey("delete")){diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex 30f140e1b..3b485e864 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -388,13 +388,13 @@ public class bookmarksDB {}- public void importFromXML(String input){+ public void importFromXML(String input, boolean isPublic){SAXParser parser;try {ByteArrayInputStream is=new ByteArrayInputStream(input.getBytes());parser = SAXParserFactory.newInstance().newSAXParser();- xmlImportHandler handler=new xmlImportHandler();+ xmlImportHandler handler=new xmlImportHandler(isPublic);parser.parse(is, handler);} catch (ParserConfigurationException e) {// TODO Auto-generated catch block@@ -411,17 +411,38 @@ public class bookmarksDB {}}public class xmlImportHandler extends DefaultHandler{+ boolean importPublic;+ public xmlImportHandler(boolean isPublic){+ importPublic=isPublic;+ }public void startElement(String uri, String localName, String qName, Attributes attributes) {- System.out.println(qName);if (qName.equals("post")) {- Bookmark bm = new Bookmark(attributes.getValue("href"));- Vector tags = listManager.string2vector(attributes.getValue("tag").replace(' ', ','));+ String url=attributes.getValue("href");+ if(url.equals("")){+ return;+ }+ Bookmark bm = new Bookmark(url);+ String tagsString=attributes.getValue("tag").replace(' ', ',');+ String title=attributes.getValue("description");+ String description=attributes.getValue("extended");+ String time=attributes.getValue("time");+ Vector tags=new Vector();++ if(title != null){+ bm.setProperty(Bookmark.BOOKMARK_TITLE, title);+ }+ if(tagsString!=null){+ tags = listManager.string2vector(tagsString);+ }bm.setTags(tags);- bm.setTimeStamp(iso8601ToDate(attributes.getValue("time")).getTime());- bm.setProperty(Bookmark.BOOKMARK_TITLE, attributes.getValue("description"));- bm.setProperty(Bookmark.BOOKMARK_DESCRIPTION, attributes.getValue("extended"));+ if(time != null){+ bm.setTimeStamp(iso8601ToDate(time).getTime());+ }+ if(description!=null){+ bm.setProperty(Bookmark.BOOKMARK_DESCRIPTION, description);+ }+ bm.setPublic(importPublic);bm.setBookmarksTable();- System.out.println(bm.getUrl());}}}@@ -663,6 +684,13 @@ public class bookmarksDB {return false;}}+ public void setPublic(boolean isPublic){+ if(isPublic){+ this.mem.put(BOOKMARK_PUBLIC, "public");+ }else{+ this.mem.put(BOOKMARK_PUBLIC, "private");+ }+ }public void setProperty(String name, String value){mem.put(name, value);//setBookmarksTable();@@ -692,7 +720,7 @@ public class bookmarksDB {}public void setBookmarksTable(){try {- bookmarksDB.this.bookmarksTable.set(getUrlHash(), mem);+ bookmarksDB.this.bookmarksTable.set(urlHash, mem);} catch (IOException e) {}}public long getTimeStamp(){