You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.0 KiB
77 lines
3.0 KiB
18 years ago
|
|
||
18 years ago
|
|
||
18 years ago
|
import java.text.ParseException;
|
||
18 years ago
|
import java.util.ArrayList;
|
||
|
import java.util.Date;
|
||
|
import java.util.Iterator;
|
||
|
|
||
|
import de.anomic.data.bookmarksDB;
|
||
16 years ago
|
import de.anomic.http.httpRequestHeader;
|
||
16 years ago
|
import de.anomic.kelondro.kelondroDigest;
|
||
18 years ago
|
import de.anomic.plasma.plasmaSwitchboard;
|
||
18 years ago
|
import de.anomic.server.serverDate;
|
||
18 years ago
|
import de.anomic.server.serverObjects;
|
||
|
import de.anomic.server.serverSwitch;
|
||
|
|
||
|
public class get {
|
||
16 years ago
|
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
|
||
18 years ago
|
// return variable that accumulates replacements
|
||
17 years ago
|
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
|
||
|
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
|
||
|
final serverObjects prop = new serverObjects();
|
||
18 years ago
|
String tag=null;
|
||
|
String date;
|
||
|
//String url=""; //urlfilter not yet implemented
|
||
|
|
||
|
if(post != null && post.containsKey("tag")){
|
||
17 years ago
|
tag=post.get("tag");
|
||
18 years ago
|
}
|
||
|
if(post != null && post.containsKey("date")){
|
||
17 years ago
|
date=post.get("date");
|
||
18 years ago
|
}else{
|
||
17 years ago
|
date=serverDate.formatISO8601(new Date(System.currentTimeMillis()));
|
||
18 years ago
|
}
|
||
18 years ago
|
|
||
|
// if an extended xml should be used
|
||
17 years ago
|
final boolean extendedXML = (post != null && post.containsKey("extendedXML"));
|
||
18 years ago
|
|
||
18 years ago
|
int count=0;
|
||
18 years ago
|
|
||
|
Date parsedDate = null;
|
||
|
try {
|
||
17 years ago
|
parsedDate = serverDate.parseISO8601(date);
|
||
17 years ago
|
} catch (final ParseException e) {
|
||
18 years ago
|
parsedDate = new Date();
|
||
|
}
|
||
|
|
||
17 years ago
|
final ArrayList<String> bookmark_hashes=switchboard.bookmarksDB.getDate(Long.toString(parsedDate.getTime())).getBookmarkList();
|
||
|
final Iterator<String> it=bookmark_hashes.iterator();
|
||
18 years ago
|
bookmarksDB.Bookmark bookmark=null;
|
||
|
while(it.hasNext()){
|
||
17 years ago
|
bookmark=switchboard.bookmarksDB.getBookmark(it.next());
|
||
17 years ago
|
if(serverDate.formatISO8601(new Date(bookmark.getTimeStamp())).equals(date) &&
|
||
18 years ago
|
tag==null || bookmark.getTags().contains(tag) &&
|
||
|
isAdmin || bookmark.getPublic()){
|
||
16 years ago
|
prop.putHTML("posts_"+count+"_url", bookmark.getUrl());
|
||
|
prop.putHTML("posts_"+count+"_title", bookmark.getTitle());
|
||
|
prop.putHTML("posts_"+count+"_description", bookmark.getDescription());
|
||
16 years ago
|
prop.put("posts_"+count+"_md5", kelondroDigest.encodeMD5Hex(bookmark.getUrl()));
|
||
18 years ago
|
prop.put("posts_"+count+"_time", date);
|
||
17 years ago
|
prop.putHTML("posts_"+count+"_tags", bookmark.getTagsString().replaceAll(","," "));
|
||
18 years ago
|
|
||
|
// additional XML tags
|
||
17 years ago
|
prop.put("posts_"+count+"_isExtended",extendedXML ? "1" : "0");
|
||
18 years ago
|
if (extendedXML) {
|
||
17 years ago
|
prop.put("posts_"+count+"_isExtended_private", Boolean.toString(!bookmark.getPublic()));
|
||
18 years ago
|
}
|
||
18 years ago
|
count++;
|
||
|
}
|
||
|
}
|
||
|
prop.put("posts", count);
|
||
|
|
||
|
// return rewrite properties
|
||
|
return prop;
|
||
|
}
|
||
|
|
||
18 years ago
|
}
|