2006-10-08 00:25:05 +02:00
|
|
|
|
2006-10-08 00:16:09 +02:00
|
|
|
|
2007-05-06 14:36:49 +02:00
|
|
|
import java.text.ParseException;
|
2006-10-08 00:16:09 +02:00
|
|
|
import java.util.Date;
|
2010-11-21 04:39:53 +01:00
|
|
|
import java.util.List;
|
2006-10-08 00:16:09 +02:00
|
|
|
|
2011-01-03 21:52:54 +01:00
|
|
|
import net.yacy.cora.date.ISO8601Formatter;
|
2010-08-23 14:32:02 +02:00
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
2012-09-21 15:48:16 +02:00
|
|
|
import net.yacy.data.BookmarksDB;
|
2009-10-10 01:22:22 +02:00
|
|
|
import net.yacy.kelondro.order.Digest;
|
2011-09-25 18:59:06 +02:00
|
|
|
import net.yacy.search.Switchboard;
|
2012-09-21 15:48:16 +02:00
|
|
|
import net.yacy.server.serverObjects;
|
|
|
|
import net.yacy.server.serverSwitch;
|
2006-10-08 00:16:09 +02:00
|
|
|
|
|
|
|
public class get {
|
2009-07-19 22:37:44 +02:00
|
|
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2006-10-08 00:16:09 +02:00
|
|
|
// return variable that accumulates replacements
|
2009-07-19 22:37:44 +02:00
|
|
|
final Switchboard switchboard = (Switchboard) env;
|
2011-11-25 15:09:25 +01:00
|
|
|
final boolean isAdmin=switchboard.verifyAuthentication(header);
|
2008-08-02 14:12:04 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2010-11-21 04:39:53 +01:00
|
|
|
String tag = null;
|
|
|
|
final String date;
|
2006-10-08 00:16:09 +02:00
|
|
|
//String url=""; //urlfilter not yet implemented
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2010-11-21 04:39:53 +01:00
|
|
|
if (post != null && post.containsKey("tag")) {
|
2011-01-03 21:52:54 +01:00
|
|
|
tag = post.get("tag");
|
2006-10-08 00:16:09 +02:00
|
|
|
}
|
2010-11-21 04:39:53 +01:00
|
|
|
if (post != null && post.containsKey("date")) {
|
2011-01-03 21:52:54 +01:00
|
|
|
date = post.get("date");
|
2010-11-21 04:39:53 +01:00
|
|
|
} else {
|
2011-02-25 22:11:53 +01:00
|
|
|
date = ISO8601Formatter.FORMATTER.format();
|
2006-10-08 00:16:09 +02:00
|
|
|
}
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2007-05-31 16:54:56 +02:00
|
|
|
// if an extended xml should be used
|
2008-08-02 14:12:04 +02:00
|
|
|
final boolean extendedXML = (post != null && post.containsKey("extendedXML"));
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2006-10-08 00:16:09 +02:00
|
|
|
int count=0;
|
2011-11-25 15:09:25 +01:00
|
|
|
|
|
|
|
Date parsedDate = null;
|
2007-05-06 14:36:49 +02:00
|
|
|
try {
|
2011-01-03 21:52:54 +01:00
|
|
|
parsedDate = ISO8601Formatter.FORMATTER.parse(date);
|
2010-11-21 04:39:53 +01:00
|
|
|
} catch (final ParseException e) {
|
|
|
|
parsedDate = new Date();
|
|
|
|
}
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2010-11-21 04:39:53 +01:00
|
|
|
final List<String> bookmark_hashes = switchboard.bookmarksDB.getDate(Long.toString(parsedDate.getTime())).getBookmarkList();
|
|
|
|
BookmarksDB.Bookmark bookmark = null;
|
|
|
|
for (final String bookmark_hash : bookmark_hashes){
|
|
|
|
bookmark=switchboard.bookmarksDB.getBookmark(bookmark_hash);
|
2011-01-03 21:52:54 +01:00
|
|
|
if (ISO8601Formatter.FORMATTER.format(new Date(bookmark.getTimeStamp())).equals(date) &&
|
2006-10-08 00:16:09 +02:00
|
|
|
tag==null || bookmark.getTags().contains(tag) &&
|
|
|
|
isAdmin || bookmark.getPublic()){
|
2008-09-20 09:55:30 +02:00
|
|
|
prop.putHTML("posts_"+count+"_url", bookmark.getUrl());
|
|
|
|
prop.putHTML("posts_"+count+"_title", bookmark.getTitle());
|
|
|
|
prop.putHTML("posts_"+count+"_description", bookmark.getDescription());
|
2009-01-30 16:33:00 +01:00
|
|
|
prop.put("posts_"+count+"_md5", Digest.encodeMD5Hex(bookmark.getUrl()));
|
2007-07-23 02:50:57 +02:00
|
|
|
prop.put("posts_"+count+"_time", date);
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.putHTML("posts_"+count+"_tags", bookmark.getTagsString().replaceAll(","," "));
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2007-05-31 16:54:56 +02:00
|
|
|
// additional XML tags
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("posts_"+count+"_isExtended",extendedXML ? "1" : "0");
|
2007-05-31 16:54:56 +02:00
|
|
|
if (extendedXML) {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("posts_"+count+"_isExtended_private", Boolean.toString(!bookmark.getPublic()));
|
2007-05-31 16:54:56 +02:00
|
|
|
}
|
2006-10-08 00:16:09 +02:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prop.put("posts", count);
|
|
|
|
|
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
2011-11-25 15:09:25 +01:00
|
|
|
|
2006-10-08 00:25:05 +02:00
|
|
|
}
|