diff --git a/htroot/xml/bookmarks/posts/get.java b/htroot/xml/bookmarks/posts/get.java new file mode 100644 index 000000000..f15872162 --- /dev/null +++ b/htroot/xml/bookmarks/posts/get.java @@ -0,0 +1,70 @@ +// /xml/bookmarks/posts/all.java +// ------------------------------- +// (C) 2006 Alexander Schier +// part of yacy +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +package xml.bookmarks.posts; + +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; + +import de.anomic.data.bookmarksDB; +import de.anomic.http.httpHeader; +import de.anomic.plasma.plasmaSwitchboard; +import de.anomic.server.serverCodings; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; + +public class get { + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { + // return variable that accumulates replacements + plasmaSwitchboard switchboard = (plasmaSwitchboard) env; + boolean isAdmin=switchboard.verifyAuthentication(header, true); + serverObjects prop = new serverObjects(); + String tag=null; + String date; + //String url=""; //urlfilter not yet implemented + + if(post != null && post.containsKey("tag")){ + tag=(String) post.get("tag"); + } + if(post != null && post.containsKey("date")){ + date=(String)post.get("date"); + }else{ + date=bookmarksDB.dateToiso8601(new Date(System.currentTimeMillis())); + } + int count=0; + ArrayList bookmark_hashes=switchboard.bookmarksDB.getDate(Long.toString(bookmarksDB.iso8601ToDate(date).getTime())).getBookmarkList(); + Iterator it=bookmark_hashes.iterator(); + bookmarksDB.Bookmark bookmark=null; + while(it.hasNext()){ + bookmark=switchboard.bookmarksDB.getBookmark((String) it.next()); + if(bookmarksDB.dateToiso8601(new Date(bookmark.getTimeStamp())) == date && + tag==null || bookmark.getTags().contains(tag) && + isAdmin || bookmark.getPublic()){ + prop.putNoHTML("posts_"+count+"_url", bookmark.getUrl()); + prop.putNoHTML("posts_"+count+"_title", bookmark.getTitle()); + prop.putNoHTML("posts_"+count+"_description", bookmark.getDescription()); + prop.putNoHTML("posts_"+count+"_md5", serverCodings.encodeMD5Hex(bookmark.getUrl())); + prop.putNoHTML("posts_"+count+"_time", date); + prop.putNoHTML("posts_"+count+"_tags", bookmark.getTagsString().replaceAll(","," ")); + count++; + } + } + prop.put("posts", count); + + // return rewrite properties + return prop; + } + +} \ No newline at end of file diff --git a/htroot/xml/bookmarks/posts/get.xml b/htroot/xml/bookmarks/posts/get.xml new file mode 100644 index 000000000..35c36b32a --- /dev/null +++ b/htroot/xml/bookmarks/posts/get.xml @@ -0,0 +1,5 @@ + + +#{posts}# +#{/posts}# + \ No newline at end of file diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java index a657371d2..f89dfd917 100644 --- a/source/de/anomic/data/bookmarksDB.java +++ b/source/de/anomic/data/bookmarksDB.java @@ -618,17 +618,22 @@ public class bookmarksDB { public static final String URL_HASHES="urlHashes"; private Map mem; String date; + public bookmarksDate(String mydate){ - date=mydate; + //round to seconds, but store as milliseconds (java timestamp) + date=String.valueOf((Long.parseLong(mydate)/1000)*1000); mem=new HashMap(); mem.put(URL_HASHES, ""); } + public bookmarksDate(String mydate, Map map){ - date=mydate; + //round to seconds, but store as milliseconds (java timestamp) + date=String.valueOf((Long.parseLong(mydate)/1000)*1000); mem=map; } public bookmarksDate(String mydate, ArrayList entries){ - date=mydate; + //round to seconds, but store as milliseconds (java timestamp) + date=String.valueOf((Long.parseLong(mydate)/1000)*1000); mem=new HashMap(); mem.put(URL_HASHES, listManager.arraylist2string(entries)); } @@ -671,6 +676,9 @@ public class bookmarksDB { public String getDateString(){ return date; } + public ArrayList getBookmarkList(){ + return listManager.string2arraylist((String)this.mem.get(URL_HASHES)); + } public int size(){ return listManager.string2arraylist(((String)this.mem.get(URL_HASHES))).size(); }