Bugfix for last commit.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1964 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 219d847aaa
commit 918445a2f4

@ -49,6 +49,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import de.anomic.data.bookmarksDB; import de.anomic.data.bookmarksDB;
@ -103,7 +104,7 @@ public class Bookmarks {
if(tagsString.equals("")){ if(tagsString.equals("")){
tagsString="unsorted"; //defaulttag tagsString="unsorted"; //defaulttag
} }
ArrayList tags=listManager.string2arraylist(tagsString); HashSet tags=listManager.string2hashset(tagsString);
bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url); bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url);
if(bookmark != null){ if(bookmark != null){

@ -219,13 +219,13 @@ public class bookmarksDB {
*/ */
public void storeBookmark(Bookmark bookmark){ public void storeBookmark(Bookmark bookmark){
try { try {
bookmarksDB.this.bookmarksTable.set(bookmark.getUrlHash(), bookmark.mem); bookmarksDB.this.bookmarksTable.set(bookmark.getUrlHash(), bookmark.getMap());
} catch (IOException e) {} } catch (IOException e) {}
} }
public void flushBookmarkCache(){ public void flushBookmarkCache(){
Iterator it=bookmarkCache.keySet().iterator(); Iterator it=bookmarkCache.keySet().iterator();
while(it.hasNext()){ while(it.hasNext()){
storeBookmark((Bookmark) it.next()); storeBookmark((Bookmark) bookmarkCache.get(it.next()));
} }
bookmarkCache=new HashMap(); bookmarkCache=new HashMap();
} }
@ -347,10 +347,10 @@ public class bookmarksDB {
saveTag(tag); saveTag(tag);
Iterator it = urlHashes.iterator(); Iterator it = urlHashes.iterator();
Bookmark bookmark; Bookmark bookmark;
ArrayList tags; HashSet tags;
while (it.hasNext()) { while (it.hasNext()) {
bookmark = getBookmark((String) it.next()); bookmark = getBookmark((String) it.next());
tags = listManager.string2arraylist(bookmark.getTags()); tags = listManager.string2hashset(bookmark.getTags());
tags.remove(oldName); //this will fail, if upper/lowercase is not matching tags.remove(oldName); //this will fail, if upper/lowercase is not matching
tags.add(newName); tags.add(newName);
bookmark.setTags(tags, true); bookmark.setTags(tags, true);
@ -478,7 +478,7 @@ public class bookmarksDB {
Iterator it; Iterator it;
String url,title; String url,title;
Bookmark bm; Bookmark bm;
ArrayList tags=listManager.string2arraylist(tag); //this allow multiple default tags HashSet tags=listManager.string2hashset(tag); //this allow multiple default tags
try { try {
//load the links //load the links
htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL); htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL);
@ -542,13 +542,13 @@ public class bookmarksDB {
if(attributes.getNamedItem("time")!=null){ if(attributes.getNamedItem("time")!=null){
time=attributes.getNamedItem("time").getNodeValue(); time=attributes.getNamedItem("time").getNodeValue();
} }
ArrayList tags=new ArrayList(); HashSet tags=new HashSet();
if(title != null){ if(title != null){
bm.setProperty(Bookmark.BOOKMARK_TITLE, title); bm.setProperty(Bookmark.BOOKMARK_TITLE, title);
} }
if(tagsString!=null){ if(tagsString!=null){
tags = listManager.string2arraylist(tagsString.replace(' ', ',')); tags = listManager.string2hashset(tagsString.replace(' ', ','));
} }
bm.setTags(tags, true); bm.setTags(tags, true);
if(time != null){ if(time != null){
@ -760,6 +760,9 @@ public class bookmarksDB {
mem=new HashMap(); mem=new HashMap();
mem.put(BOOKMARK_URL, url); mem.put(BOOKMARK_URL, url);
} }
public Map getMap(){
return mem;
}
public String getUrlHash(){ public String getUrlHash(){
return urlHash; return urlHash;
} }
@ -806,11 +809,11 @@ public class bookmarksDB {
//setBookmarksTable(); //setBookmarksTable();
} }
public void addTag(String tag){ public void addTag(String tag){
ArrayList tags; HashSet tags;
if(!mem.containsKey(BOOKMARK_TAGS)){ if(!mem.containsKey(BOOKMARK_TAGS)){
tags=new ArrayList(); tags=new HashSet();
}else{ }else{
tags=listManager.string2arraylist((String) mem.get(BOOKMARK_TAGS)); tags=listManager.string2hashset((String) mem.get(BOOKMARK_TAGS));
} }
tags.add(tag); tags.add(tag);
this.setTags(tags, true); this.setTags(tags, true);
@ -819,7 +822,7 @@ public class bookmarksDB {
* set the Tags of the bookmark, and write them into the tags table. * set the Tags of the bookmark, and write them into the tags table.
* @param tags a ArrayList with the tags * @param tags a ArrayList with the tags
*/ */
public void setTags(ArrayList tags){ public void setTags(HashSet tags){
setTags(tags, true); setTags(tags, true);
} }
/** /**
@ -827,8 +830,8 @@ public class bookmarksDB {
* @param tags ArrayList with the tagnames * @param tags ArrayList with the tagnames
* @param local sets, whether the updated tags should be stored to tagsDB * @param local sets, whether the updated tags should be stored to tagsDB
*/ */
public void setTags(ArrayList tags, boolean local){ public void setTags(HashSet tags, boolean local){
mem.put(BOOKMARK_TAGS, listManager.arraylist2string(tags)); mem.put(BOOKMARK_TAGS, listManager.hashset2string(tags));
Iterator it=tags.iterator(); Iterator it=tags.iterator();
while(it.hasNext()){ while(it.hasNext()){
String tagName=(String) it.next(); String tagName=(String) it.next();

Loading…
Cancel
Save