01: // /xml/bookmarks/posts/delete_p.java
02: // -------------------------------
03: // part of the AnomicHTTPD caching proxy
04: // (C) by Michael Peter Christen; mc@anomic.de
05: // first published on http://www.anomic.de
06: // Frankfurt, Germany, 2004, 2005
07: //
08: // last major change: 05.02.2006
09: // this file is contributed by Alexander Schier
10: //
11: // This program is free software; you can redistribute it and/or modify
12: // it under the terms of the GNU General Public License as published by
13: // the Free Software Foundation; either version 2 of the License, or
14: // (at your option) any later version.
15: //
16: // This program is distributed in the hope that it will be useful,
17: // but WITHOUT ANY WARRANTY; without even the implied warranty of
18: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: // GNU General Public License for more details.
20: //
21: // You should have received a copy of the GNU General Public License
22: // along with this program; if not, write to the Free Software
23: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: //
25: // Using this software in any meaning (reading, learning, copying, compiling,
26: // running) means that you agree that the Author(s) is (are) not responsible
27: // for cost, loss of data or any harm that may be caused directly or indirectly
28: // by usage of this softare or this documentation. The usage of this software
29: // is on your own risk. The installation and usage (starting/running) of this
30: // software may allow other people or application to access your computer and
31: // any attached devices and is highly dependent on the configuration of the
32: // software which must be done by the user of the software; the author(s) is
33: // (are) also not responsible for proper configuration and usage of the
34: // software, even if provoked by documentation provided together with
35: // the software.
36: //
37: // Any changes to this file according to the GPL as documented in the file
38: // gpl.txt aside this file in the shipment you received can be done to the
39: // lines that follows this copyright notice here, but changes must not be
40: // done inside the copyright notive above. A re-distribution must contain
41: // the intact and unchanged copyright notice.
42: // Contributions and changes to the program code must be marked as such.
43:
44: package xml.bookmarks.posts;
45:
46: import java.net.MalformedURLException;
47:
48: import de.anomic.http.httpHeader;
49: import de.anomic.plasma.plasmaSwitchboard;
50: import de.anomic.server.serverObjects;
51: import de.anomic.server.serverSwitch;
52: import de.anomic.yacy.yacyURL;
53:
54: public class delete_p {
55: public static serverObjects respond(httpHeader header,
56: serverObjects post, serverSwitch env) {
57: // return variable that accumulates replacements
58: plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
59: serverObjects prop = new serverObjects();
60: if (post != null) {
61: try {
62: if (post.containsKey("url")
63: && switchboard.bookmarksDB
64: .removeBookmark((new yacyURL(post.get(
65: "url", "nourl"), null)).hash())) {
66: prop.put("result", "1");
67: } else if (post.containsKey("urlhash")
68: && switchboard.bookmarksDB.removeBookmark(post
69: .get("urlhash", "nohash"))) {
70: prop.put("result", "1");
71: } else {
72: prop.put("result", "0");
73: }
74: } catch (MalformedURLException e) {
75: prop.put("result", "0");
76: }
77: } else {
78: prop.put("result", "0");
79: }
80: // return rewrite properties
81: return prop;
82: }
83:
84: }
|