Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

some more bookmark changes towards multiuser bookmarks

allo14f2068dafdd
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index f5debe7de..5e24b6aeb 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -74,6 +74,15 @@ public class Bookmarks {
int start=0;
userDB.Entry user=switchboard.userDB.getUser(header);
boolean isAdmin=(switchboard.verifyAuthentication(header, true) || user!= null && user.hasBookmarkRight());
+ String username="";
+ if(user != null)
+ username=user.getUserName();
+ else if(isAdmin)
+ username="admin";
+
+ //redirect to userpage
+ if(username!="" &&(post == null || !post.containsKey("user")))
+ prop.put("LOCATION", "/Bookmarks.html?user="+username);
//defaultvalues
prop.put("mode", 0);
@@ -111,7 +120,7 @@ public class Bookmarks {
}
HashSet tags=listManager.string2hashset(tagsString);
- bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url);
+ bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url, username);
if(bookmark != null){
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index 455114ca7..50c794ae5 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -91,6 +91,9 @@ public class bookmarksDB {
public static String tagHash(String tagName){
return plasmaCondenser.word2hash(tagName.toLowerCase());
}
+ public static String tagHash(String tagName, String user){
+ return plasmaCondenser.word2hash(user+":"+tagName.toLowerCase());
+ }
public static String dateToiso8601(Date date){
return new SimpleDateFormat("yyyy-MM-dd").format(date)+"T"+(new SimpleDateFormat("HH:mm:ss")).format(date)+"Z";
}
@@ -407,6 +410,9 @@ public class bookmarksDB {
saveTag(tag);
}
}
+ return removeFromBookmarkCache(urlHash);
+ }
+ private boolean removeFromBookmarkCache(String urlHash) {
try {
if(bookmarkCache.containsKey(urlHash))
bookmarkCache.remove(urlHash);
@@ -416,9 +422,10 @@ public class bookmarksDB {
return false;
}
}
- public Bookmark createBookmark(String url){
+ public Bookmark createBookmark(String url, String user){
if (url == null || url.length() == 0) return null;
Bookmark bk = new Bookmark(url);
+ bk.setOwner(user);
return (bk.getUrlHash() == null || bk.getMap() == null) ? null : bk;
}
public Iterator tagIterator(boolean up){
diff --git a/source/de/anomic/soap/services/BookmarkService.java b/source/de/anomic/soap/services/BookmarkService.java
index 6927b476a..cb0aa4f85 100644
--- a/source/de/anomic/soap/services/BookmarkService.java
+++ b/source/de/anomic/soap/services/BookmarkService.java
@@ -244,7 +244,7 @@ public class BookmarkService extends AbstractService {
if (url == null || url.length()==0) throw new IllegalArgumentException("The url must not be null or empty");
// create new bookmark object
- bookmarksDB.Bookmark bookmark = getBookmarkDB().createBookmark(url);
+ bookmarksDB.Bookmark bookmark = getBookmarkDB().createBookmark(url, "admin"); //FIXME: "admin" can be user.getUserName() for users with bookmarkrights
// set bookmark properties
if(bookmark != null){