001: // /xml/blacklists_p.java
002: // -------------------------------
003: // (C) 2006 Alexander Schier
004: // part of YaCy
005: //
006: // This program is free software; you can redistribute it and/or modify
007: // it under the terms of the GNU General Public License as published by
008: // the Free Software Foundation; either version 2 of the License, or
009: // (at your option) any later version.
010: //
011: // This program is distributed in the hope that it will be useful,
012: // but WITHOUT ANY WARRANTY; without even the implied warranty of
013: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: // GNU General Public License for more details.
015: //
016: // You should have received a copy of the GNU General Public License
017: // along with this program; if not, write to the Free Software
018: // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
019:
020: package xml;
021:
022: import java.io.File;
023: import java.util.ArrayList;
024:
025: import de.anomic.data.listManager;
026: import de.anomic.http.httpHeader;
027: import de.anomic.plasma.urlPattern.abstractURLPattern;
028: import de.anomic.server.serverObjects;
029: import de.anomic.server.serverSwitch;
030:
031: public class blacklists_p {
032:
033: public static serverObjects respond(httpHeader header,
034: serverObjects post, serverSwitch env) {
035: serverObjects prop = new serverObjects();
036:
037: listManager.listsPath = new File(listManager.switchboard
038: .getRootPath(), listManager.switchboard.getConfig(
039: "listManager.listsPath", "DATA/LISTS"));
040: String[] dirlist = listManager
041: .getDirListing(listManager.listsPath);
042: int blacklistCount = 0;
043:
044: ArrayList<String> list;
045: int count;
046: if (dirlist != null) {
047: for (int i = 0; i <= dirlist.length - 1; i++) {
048: prop.putHTML("lists_" + blacklistCount + "_name",
049: dirlist[i]);
050:
051: if (listManager.listSetContains("BlackLists.Shared",
052: dirlist[i])) {
053: prop
054: .put("lists_" + blacklistCount + "_shared",
055: "1");
056: } else {
057: prop
058: .put("lists_" + blacklistCount + "_shared",
059: "0");
060: }
061:
062: String[] types = abstractURLPattern.BLACKLIST_TYPES_STRING
063: .split(",");
064: for (int j = 0; j < types.length; j++) {
065: prop.put("lists_" + blacklistCount + "_types_" + j
066: + "_name", types[j]);
067: prop.put("lists_" + blacklistCount + "_types_" + j
068: + "_value", listManager.listSetContains(
069: types[j] + ".Blacklist", dirlist[i]) ? 1
070: : 0);
071: }
072: prop.put("lists_" + blacklistCount + "_types",
073: types.length);
074:
075: list = listManager.getListArray(new File(
076: listManager.listsPath, dirlist[i]));
077:
078: count = 0;
079: for (int j = 0; j < list.size(); ++j) {
080: String nextEntry = (String) list.get(j);
081:
082: if (nextEntry.length() == 0)
083: continue;
084: if (nextEntry.startsWith("#"))
085: continue;
086:
087: prop.putHTML("lists_" + blacklistCount + "_items_"
088: + count + "_item", nextEntry);
089: count++;
090: }
091: prop.put("lists_" + blacklistCount + "_items", count);
092: blacklistCount++;
093: }
094: }
095: prop.put("lists", blacklistCount);
096:
097: // return rewrite properties
098: return prop;
099: }
100:
101: }
|