001: // httpdRobotsTxtConfig.java
002: // ---------
003: // part of YaCy
004: // (C) by Michael Peter Christen; mc@anomic.de
005: // first published on http://www.anomic.de
006: // Frankfurt, Germany, 2007
007: // Created 22.02.2007
008: //
009: // This file is contributed by Franz Brausze
010: //
011: // $LastChangedDate: $
012: // $LastChangedRevision: $
013: // $LastChangedBy: $
014: //
015: // This program is free software; you can redistribute it and/or modify
016: // it under the terms of the GNU General Public License as published by
017: // the Free Software Foundation; either version 2 of the License, or
018: // (at your option) any later version.
019: //
020: // This program is distributed in the hope that it will be useful,
021: // but WITHOUT ANY WARRANTY; without even the implied warranty of
022: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: // GNU General Public License for more details.
024: //
025: // You should have received a copy of the GNU General Public License
026: // along with this program; if not, write to the Free Software
027: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
028: //
029: // Using this software in any meaning (reading, learning, copying, compiling,
030: // running) means that you agree that the Author(s) is (are) not responsible
031: // for cost, loss of data or any harm that may be caused directly or indirectly
032: // by usage of this softare or this documentation. The usage of this software
033: // is on your own risk. The installation and usage (starting/running) of this
034: // software may allow other people or application to access your computer and
035: // any attached devices and is highly dependent on the configuration of the
036: // software which must be done by the user of the software; the author(s) is
037: // (are) also not responsible for proper configuration and usage of the
038: // software, even if provoked by documentation provided together with
039: // the software.
040: //
041: // Any changes to this file according to the GPL as documented in the file
042: // gpl.txt aside this file in the shipment you received can be done to the
043: // lines that follows this copyright notice here, but changes must not be
044: // done inside the copyright notive above. A re-distribution must contain
045: // the intact and unchanged copyright notice.
046: // Contributions and changes to the program code must be marked as such.
047:
048: package de.anomic.http;
049:
050: import de.anomic.plasma.plasmaSwitchboard;
051: import de.anomic.server.serverSwitch;
052:
053: public final class httpdRobotsTxtConfig {
054:
055: public static final String WIKI = "wiki";
056: public static final String BLOG = "blog";
057: public static final String BOOKMARKS = "bookmarks";
058: public static final String HOMEPAGE = "homepage";
059: public static final String FILESHARE = "fileshare";
060: public static final String SURFTIPS = "surftips";
061: public static final String NEWS = "news";
062: public static final String STATUS = "status";
063: public static final String LOCKED = "locked";
064: public static final String DIRS = "dirs";
065: public static final String NETWORK = "network";
066: public static final String PROFILE = "profile";
067: public static final String ALL = "all";
068:
069: private boolean allDisallowed = false;
070: private boolean lockedDisallowed = true;
071: private boolean dirsDisallowed = true;
072: private boolean wikiDisallowed = false;
073: private boolean blogDisallowed = false;
074: private boolean fileshareDisallowed = false;
075: private boolean homepageDisallowed = false;
076: private boolean newsDisallowed = false;
077: private boolean statusDisallowed = false;
078: private boolean networkDisallowed = false;
079: private boolean surftipsDisallowed = false;
080: private boolean bookmarksDisallowed = false;
081: private boolean profileDisallowed = true;
082:
083: public httpdRobotsTxtConfig() {
084: }
085:
086: public httpdRobotsTxtConfig(String[] active) {
087: if (active == null)
088: return;
089: for (int i = 0; i < active.length; i++) {
090: if (active[i] == null)
091: continue;
092: if (active[i].equals(BLOG)) {
093: this .blogDisallowed = true;
094: continue;
095: }
096: if (active[i].equals(WIKI)) {
097: this .wikiDisallowed = true;
098: continue;
099: }
100: if (active[i].equals(BOOKMARKS)) {
101: this .bookmarksDisallowed = true;
102: continue;
103: }
104: if (active[i].equals(HOMEPAGE)) {
105: this .homepageDisallowed = true;
106: continue;
107: }
108: if (active[i].equals(FILESHARE)) {
109: this .fileshareDisallowed = true;
110: continue;
111: }
112: if (active[i].equals(SURFTIPS)) {
113: this .surftipsDisallowed = true;
114: continue;
115: }
116: if (active[i].equals(NEWS)) {
117: this .newsDisallowed = true;
118: continue;
119: }
120: if (active[i].equals(STATUS)) {
121: this .statusDisallowed = true;
122: continue;
123: }
124: if (active[i].equals(NETWORK)) {
125: this .networkDisallowed = true;
126: continue;
127: }
128: if (active[i].equals(LOCKED)) {
129: this .lockedDisallowed = true;
130: continue;
131: }
132: if (active[i].equals(DIRS)) {
133: this .dirsDisallowed = true;
134: continue;
135: }
136: if (active[i].equals(PROFILE)) {
137: this .profileDisallowed = true;
138: continue;
139: }
140: if (active[i].equals(ALL)) {
141: this .allDisallowed = true;
142: continue;
143: }
144: }
145: }
146:
147: public static httpdRobotsTxtConfig init(serverSwitch env) {
148: String cfg = env.getConfig(plasmaSwitchboard.ROBOTS_TXT,
149: plasmaSwitchboard.ROBOTS_TXT_DEFAULT);
150: if (cfg == null)
151: return new httpdRobotsTxtConfig();
152: return new httpdRobotsTxtConfig(cfg.split(","));
153: }
154:
155: public String toString() {
156: if (this .allDisallowed)
157: return ALL;
158: StringBuffer sb = new StringBuffer();
159: if (this .blogDisallowed)
160: sb.append(BLOG).append(",");
161: if (this .bookmarksDisallowed)
162: sb.append(BOOKMARKS).append(",");
163: if (this .dirsDisallowed)
164: sb.append(DIRS).append(",");
165: if (this .fileshareDisallowed)
166: sb.append(FILESHARE).append(",");
167: if (this .homepageDisallowed)
168: sb.append(HOMEPAGE).append(",");
169: if (this .lockedDisallowed)
170: sb.append(LOCKED).append(",");
171: if (this .networkDisallowed)
172: sb.append(NETWORK).append(",");
173: if (this .newsDisallowed)
174: sb.append(NEWS).append(",");
175: if (this .statusDisallowed)
176: sb.append(STATUS).append(",");
177: if (this .surftipsDisallowed)
178: sb.append(SURFTIPS).append(",");
179: if (this .wikiDisallowed)
180: sb.append(WIKI).append(",");
181: if (this .profileDisallowed)
182: sb.append(PROFILE).append(",");
183: return sb.toString();
184: }
185:
186: public boolean isAllDisallowed() {
187: return allDisallowed;
188: }
189:
190: public void setAllDisallowed(boolean allDisallowed) {
191: this .allDisallowed = allDisallowed;
192: }
193:
194: public boolean isLockedDisallowed() {
195: return lockedDisallowed || this .allDisallowed;
196: }
197:
198: public void setLockedDisallowed(boolean lockedDisallowed) {
199: this .lockedDisallowed = lockedDisallowed;
200: }
201:
202: public boolean isDirsDisallowed() {
203: return dirsDisallowed || this .allDisallowed;
204: }
205:
206: public void setDirsDisallowed(boolean dirsDisallowed) {
207: this .dirsDisallowed = dirsDisallowed;
208: }
209:
210: public boolean isBlogDisallowed() {
211: return blogDisallowed || this .allDisallowed;
212: }
213:
214: public void setBlogDisallowed(boolean blogDisallowed) {
215: this .blogDisallowed = blogDisallowed;
216: }
217:
218: public boolean isBookmarksDisallowed() {
219: return bookmarksDisallowed || this .allDisallowed;
220: }
221:
222: public void setBookmarksDisallowed(boolean bookmarksDisallowed) {
223: this .bookmarksDisallowed = bookmarksDisallowed;
224: }
225:
226: public boolean isFileshareDisallowed() {
227: return fileshareDisallowed || this .allDisallowed;
228: }
229:
230: public void setFileshareDisallowed(boolean fileshareDisallowed) {
231: this .fileshareDisallowed = fileshareDisallowed;
232: }
233:
234: public boolean isHomepageDisallowed() {
235: return homepageDisallowed || this .allDisallowed;
236: }
237:
238: public void setHomepageDisallowed(boolean homepageDisallowed) {
239: this .homepageDisallowed = homepageDisallowed;
240: }
241:
242: public boolean isNetworkDisallowed() {
243: return networkDisallowed || this .allDisallowed;
244: }
245:
246: public void setNetworkDisallowed(boolean networkDisallowed) {
247: this .networkDisallowed = networkDisallowed;
248: }
249:
250: public boolean isNewsDisallowed() {
251: return newsDisallowed || this .allDisallowed;
252: }
253:
254: public void setNewsDisallowed(boolean newsDisallowed) {
255: this .newsDisallowed = newsDisallowed;
256: }
257:
258: public boolean isStatusDisallowed() {
259: return statusDisallowed || this .allDisallowed;
260: }
261:
262: public void setStatusDisallowed(boolean statusDisallowed) {
263: this .statusDisallowed = statusDisallowed;
264: }
265:
266: public boolean isSurftipsDisallowed() {
267: return surftipsDisallowed || this .allDisallowed;
268: }
269:
270: public void setSurftipsDisallowed(boolean surftipsDisallowed) {
271: this .surftipsDisallowed = surftipsDisallowed;
272: }
273:
274: public boolean isWikiDisallowed() {
275: return wikiDisallowed || this .allDisallowed;
276: }
277:
278: public void setWikiDisallowed(boolean wikiDisallowed) {
279: this .wikiDisallowed = wikiDisallowed;
280: }
281:
282: public boolean isProfileDisallowed() {
283: return profileDisallowed || this .allDisallowed;
284: }
285:
286: public void setProfileDisallowed(boolean profileDisallowed) {
287: this.profileDisallowed = profileDisallowed;
288: }
289: }
|