001: // ResourceInfo.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, 2006
007: //
008: // This file ist contributed by Martin Thelian
009: //
010: // $LastChangedDate: 2006-02-20 23:57:42 +0100 (Mo, 20 Feb 2006) $
011: // $LastChangedRevision: 1715 $
012: // $LastChangedBy: theli $
013: //
014: // This program is free software; you can redistribute it and/or modify
015: // it under the terms of the GNU General Public License as published by
016: // the Free Software Foundation; either version 2 of the License, or
017: // (at your option) any later version.
018: //
019: // This program is distributed in the hope that it will be useful,
020: // but WITHOUT ANY WARRANTY; without even the implied warranty of
021: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022: // GNU General Public License for more details.
023: //
024: // You should have received a copy of the GNU General Public License
025: // along with this program; if not, write to the Free Software
026: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
027: //
028: // Using this software in any meaning (reading, learning, copying, compiling,
029: // running) means that you agree that the Author(s) is (are) not responsible
030: // for cost, loss of data or any harm that may be caused directly or indirectly
031: // by usage of this softare or this documentation. The usage of this software
032: // is on your own risk. The installation and usage (starting/running) of this
033: // software may allow other people or application to access your computer and
034: // any attached devices and is highly dependent on the configuration of the
035: // software which must be done by the user of the software; the author(s) is
036: // (are) also not responsible for proper configuration and usage of the
037: // software, even if provoked by documentation provided together with
038: // the software.
039: //
040: // Any changes to this file according to the GPL as documented in the file
041: // gpl.txt aside this file in the shipment you received can be done to the
042: // lines that follows this copyright notice here, but changes must not be
043: // done inside the copyright notive above. A re-distribution must contain
044: // the intact and unchanged copyright notice.
045: // Contributions and changes to the program code must be marked as such.
046:
047: package de.anomic.plasma.cache.ftp;
048:
049: import java.util.Date;
050: import java.util.Map;
051: import java.util.TreeMap;
052:
053: import de.anomic.plasma.cache.IResourceInfo;
054: import de.anomic.plasma.cache.ResourceInfoFactory;
055: import de.anomic.yacy.yacyURL;
056:
057: public class ResourceInfo implements IResourceInfo {
058:
059: public static final String MIMETYPE = "mimetype";
060: public static final String MODIFICATION_DATE = "modificationDate";
061:
062: private yacyURL objectURL, refererURL;
063: private TreeMap<String, String> propertyMap;
064:
065: /**
066: * Constructor used by the {@link ResourceInfoFactory}
067: * @param objectURL
068: * @param objectInfo
069: */
070: public ResourceInfo(yacyURL objectURL,
071: Map<String, String> objectInfo) {
072: if (objectURL == null)
073: throw new NullPointerException();
074: if (objectInfo == null)
075: throw new NullPointerException();
076:
077: // generating the url hash
078: this .objectURL = objectURL;
079: this .refererURL = null;
080:
081: // create the http header object
082: this .propertyMap = new TreeMap<String, String>(objectInfo);
083: }
084:
085: public ResourceInfo(yacyURL objectURL, yacyURL refererUrl,
086: String mimeType, Date fileDate) {
087: if (objectURL == null)
088: throw new NullPointerException();
089:
090: // generating the url hash
091: this .objectURL = objectURL;
092:
093: // create the http header object
094: this .propertyMap = new TreeMap<String, String>();
095: if (refererUrl != null)
096: this .refererURL = refererUrl;
097: if (mimeType != null)
098: this .propertyMap.put(MIMETYPE, mimeType);
099: if (fileDate != null)
100: this .propertyMap.put(MODIFICATION_DATE, Long
101: .toString(fileDate.getTime()));
102: }
103:
104: public TreeMap<String, String> getMap() {
105: return this .propertyMap;
106: }
107:
108: public String getMimeType() {
109: return (String) ((this .propertyMap == null) ? null
110: : this .propertyMap.get(MIMETYPE));
111: }
112:
113: public Date getModificationDate() {
114: if (this .propertyMap == null
115: || !this .propertyMap.containsKey(MODIFICATION_DATE))
116: return new Date();
117: return new Date(Long.valueOf(
118: (String) this .propertyMap.get(MODIFICATION_DATE))
119: .longValue());
120: }
121:
122: public yacyURL getRefererUrl() {
123: return this .refererURL;
124: }
125:
126: public yacyURL getUrl() {
127: return this .objectURL;
128: }
129:
130: public Date ifModifiedSince() {
131: return null;
132: }
133:
134: public boolean requestProhibitsIndexing() {
135: return false;
136: }
137:
138: public boolean requestWithCookie() {
139: return false;
140: }
141:
142: public String shallIndexCacheForCrawler() {
143: return null;
144: }
145:
146: public String shallIndexCacheForProxy() {
147: return null;
148: }
149:
150: public String shallStoreCacheForProxy() {
151: return null;
152: }
153:
154: public boolean shallUseCacheForProxy() {
155: return false;
156: }
157:
158: public boolean validResponseStatus(String responseStatus) {
159: return responseStatus != null
160: && responseStatus.equalsIgnoreCase("OK");
161: }
162:
163: public String getCharacterEncoding() {
164: return null;
165: }
166:
167: }
|