2006-02-05 15:54:07 +01:00
|
|
|
|
2007-09-05 11:01:35 +02:00
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
2011-05-27 10:24:54 +02:00
|
|
|
import net.yacy.cora.document.ASCII;
|
2010-08-23 14:32:02 +02:00
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
2009-10-11 02:12:19 +02:00
|
|
|
import net.yacy.kelondro.data.meta.DigestURI;
|
|
|
|
|
2009-07-19 22:37:44 +02:00
|
|
|
import de.anomic.search.Switchboard;
|
2006-02-05 15:54:07 +01:00
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
|
|
|
|
public class delete_p {
|
2009-07-19 22:37:44 +02:00
|
|
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2006-02-05 15:54:07 +01:00
|
|
|
// return variable that accumulates replacements
|
2009-07-19 22:37:44 +02:00
|
|
|
final Switchboard switchboard = (Switchboard) env;
|
2008-08-02 14:12:04 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2008-09-16 23:38:13 +02:00
|
|
|
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
|
2006-02-05 15:54:07 +01:00
|
|
|
if(post!= null){
|
2008-09-16 23:38:13 +02:00
|
|
|
if(!isAdmin){
|
|
|
|
// force authentication if desired
|
|
|
|
if(post.containsKey("login")){
|
|
|
|
prop.put("AUTHENTICATE","admin log-in");
|
|
|
|
}
|
|
|
|
return prop;
|
|
|
|
}
|
2007-09-05 11:01:35 +02:00
|
|
|
try {
|
2011-05-27 10:24:54 +02:00
|
|
|
if (post.containsKey("url") && switchboard.bookmarksDB.removeBookmark(ASCII.String((new DigestURI(post.get("url", "nourl"))).hash()))) {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("result", "1");
|
2010-04-08 02:11:32 +02:00
|
|
|
} else if (post.containsKey("urlhash") && switchboard.bookmarksDB.removeBookmark(post.get("urlhash", "nohash"))) {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("result", "1");
|
2010-04-08 02:11:32 +02:00
|
|
|
} else {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("result", "0");
|
2007-09-05 11:01:35 +02:00
|
|
|
}
|
2008-08-02 14:12:04 +02:00
|
|
|
} catch (final MalformedURLException e) {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("result", "0");
|
2007-09-05 11:01:35 +02:00
|
|
|
}
|
2006-02-05 15:54:07 +01:00
|
|
|
}else{
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("result", "0");
|
2008-09-16 23:38:13 +02:00
|
|
|
}
|
2006-02-05 15:54:07 +01:00
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
2008-09-16 23:38:13 +02:00
|
|
|
}
|
2006-02-05 15:54:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|