001: // /xml/bookmarks/posts/all.java
002: // -------------------------------
003: // part of the AnomicHTTPD caching proxy
004: // (C) by Michael Peter Christen; mc@anomic.de
005: // first published on http://www.anomic.de
006: // Frankfurt, Germany, 2004, 2005
007: //
008: // last major change: 27.12.2005
009: // this file is contributed by Alexander Schier
010: //
011: // This program is free software; you can redistribute it and/or modify
012: // it under the terms of the GNU General Public License as published by
013: // the Free Software Foundation; either version 2 of the License, or
014: // (at your option) any later version.
015: //
016: // This program is distributed in the hope that it will be useful,
017: // but WITHOUT ANY WARRANTY; without even the implied warranty of
018: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
019: // GNU General Public License for more details.
020: //
021: // You should have received a copy of the GNU General Public License
022: // along with this program; if not, write to the Free Software
023: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: //
025: // Using this software in any meaning (reading, learning, copying, compiling,
026: // running) means that you agree that the Author(s) is (are) not responsible
027: // for cost, loss of data or any harm that may be caused directly or indirectly
028: // by usage of this softare or this documentation. The usage of this software
029: // is on your own risk. The installation and usage (starting/running) of this
030: // software may allow other people or application to access your computer and
031: // any attached devices and is highly dependent on the configuration of the
032: // software which must be done by the user of the software; the author(s) is
033: // (are) also not responsible for proper configuration and usage of the
034: // software, even if provoked by documentation provided together with
035: // the software.
036: //
037: // Any changes to this file according to the GPL as documented in the file
038: // gpl.txt aside this file in the shipment you received can be done to the
039: // lines that follows this copyright notice here, but changes must not be
040: // done inside the copyright notive above. A re-distribution must contain
041: // the intact and unchanged copyright notice.
042: // Contributions and changes to the program code must be marked as such.
043:
044: // You must compile this file with
045: // javac -classpath .:../classes IndexCreate_p.java
046: // if the shell's current path is HTROOT
047: package xml.bookmarks.posts;
048:
049: import java.util.Date;
050: import java.util.Iterator;
051:
052: import de.anomic.data.bookmarksDB;
053: import de.anomic.http.httpHeader;
054: import de.anomic.plasma.plasmaSwitchboard;
055: import de.anomic.server.serverCodings;
056: import de.anomic.server.serverDate;
057: import de.anomic.server.serverObjects;
058: import de.anomic.server.serverSwitch;
059:
060: public class all {
061: public static serverObjects respond(httpHeader header,
062: serverObjects post, serverSwitch env) {
063: // return variable that accumulates replacements
064: plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
065: boolean isAdmin = switchboard
066: .verifyAuthentication(header, true);
067: serverObjects prop = new serverObjects();
068:
069: Iterator<String> it;
070: if (post != null && post.containsKey("tag")) {
071: it = switchboard.bookmarksDB.getBookmarksIterator(
072: (String) post.get("tag"), isAdmin);
073: } else {
074: it = switchboard.bookmarksDB.getBookmarksIterator(isAdmin);
075: }
076:
077: // if an extended xml should be used
078: boolean extendedXML = (post != null && post
079: .containsKey("extendedXML"));
080:
081: int count = 0;
082: bookmarksDB.Bookmark bookmark;
083: Date date;
084: while (it.hasNext()) {
085: bookmark = switchboard.bookmarksDB.getBookmark((String) it
086: .next());
087: prop.put("posts_" + count + "_url", bookmark.getUrl());
088: prop.put("posts_" + count + "_title", bookmark.getTitle());
089: prop.put("posts_" + count + "_description", bookmark
090: .getDescription());
091: prop.put("posts_" + count + "_md5", serverCodings
092: .encodeMD5Hex(bookmark.getUrl()));
093: date = new Date(bookmark.getTimeStamp());
094: prop.put("posts_" + count + "_time", serverDate
095: .formatISO8601(date));
096: prop.put("posts_" + count + "_tags", bookmark
097: .getTagsString().replaceAll(",", " "));
098:
099: // additional XML tags
100: prop.put("posts_" + count + "_isExtended",
101: extendedXML ? "1" : "0");
102: if (extendedXML) {
103: prop.put("posts_" + count + "_isExtended_private",
104: Boolean.toString(!bookmark.getPublic()));
105: }
106: count++;
107: }
108: prop.put("posts", count);
109:
110: // return rewrite properties
111: return prop;
112: }
113:
114: }
|