summaryrefslogtreecommitdiff
path: root/source/de/anomic/crawler/IndexingStack.java
blob: 7d872ff0b5db656971efdbe5c48caf3b3aadd1d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
// IndexingStack.java
// (C) 2005 by Michael Peter Christen; mc@yacy.net
// first published on http://yacy.net
// Frankfurt, Germany, 2005
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// LICENSE
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


package de.anomic.crawler;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;

import de.anomic.http.httpHeader;
import de.anomic.http.httpResponseHeader;
import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.table.Stack;
import de.anomic.kelondro.text.MetadataRepository;
import de.anomic.kelondro.text.metadataPrototype.URLMetadataRow;
import de.anomic.kelondro.util.DateFormatter;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
import de.anomic.yacy.logging.Log;

public class IndexingStack {

    private final Stack sbQueueStack;
    private final CrawlProfile profiles;
    private final yacySeedDB peers;
    private final ConcurrentHashMap<String, QueueEntry> queueInProcess;
    
    public IndexingStack(
            final yacySeedDB peers,
            final File sbQueueStackPath,
            final CrawlProfile profiles) {
        this.profiles = profiles;
        this.peers = peers;
        this.queueInProcess = new ConcurrentHashMap<String, QueueEntry>();
        this.sbQueueStack = Stack.open(sbQueueStackPath, rowdef);
    }
    
    public static final Row rowdef = new Row(
            "String url-256, " +                                       // the url
            "String refhash-" + yacySeedDB.commonHashLength + ", " +   // the url's referrer hash
            "Cardinal modifiedsince-11 {b64e}, " +                     // from ifModifiedSince
            "byte[] flags-1, " +                                       // flags
            "String initiator-" + yacySeedDB.commonHashLength + ", " + // the crawling initiator
            "Cardinal depth-2 {b64e}, " +                              // the prefetch depth so far, starts at 0
            "String profile-" + yacySeedDB.commonHashLength + ", " +   // the name of the prefetch profile handle
            "String urldescr-80",
            NaturalOrder.naturalOrder
    );

    public synchronized int size() {
        return (sbQueueStack == null) ? 0 : sbQueueStack.size();
    }

    public String file() {
    	return this.sbQueueStack.filename;
    }
    
    public synchronized void push(final QueueEntry entry) throws IOException {
        if (entry == null) return;
        if (sbQueueStack == null) return; // may occur during shutdown
        sbQueueStack.push(sbQueueStack.row().newEntry(new byte[][]{
            entry.url.toString().getBytes(),
            (entry.referrerHash == null) ? "".getBytes() : entry.referrerHash.getBytes(),
            Base64Order.enhancedCoder.encodeLong((entry.ifModifiedSince == null) ? 0 : entry.ifModifiedSince.getTime(), 11).getBytes(),
            new byte[]{entry.flags},
            (entry.initiator == null) ? "".getBytes() : entry.initiator.getBytes(),
            Base64Order.enhancedCoder.encodeLong(entry.depth, rowdef.width(5)).getBytes(),
            (entry.profileHandle == null) ? "".getBytes() : entry.profileHandle.getBytes(),
            (entry.anchorName == null) ? "-".getBytes("UTF-8") : entry.anchorName.getBytes("UTF-8")
        }));
    }

    public synchronized QueueEntry pop() throws IOException {
    	if (sbQueueStack == null) return null;
    	// this shall not return null because it may cause a emergency reset!
		int sizeBefore;
    	while ((sizeBefore = sbQueueStack.size()) > 0) {
	        Row.Entry b = sbQueueStack.pot();
	        if (b == null) {
	        	Log.logInfo("IndexingStack", "sbQueueStack.pot() == null, file = " + sbQueueStack.filename);
	        	if (sbQueueStack.size() < sizeBefore) continue;
	        	Log.logSevere("IndexingStack", "sbQueueStack " + sbQueueStack.filename + " does not shrink after pot() == null; trying pop()");
	        }
	        if (sbQueueStack.size() < sizeBefore) {
	        	return new QueueEntry(b);
	        }
	        Log.logSevere("IndexingStack", "sbQueueStack " + sbQueueStack.filename + " does not shrink after pot() != null; trying pop()");
	        
	        sizeBefore = sbQueueStack.size();
	        b = sbQueueStack.pop();
	        if (b == null) {
	        	Log.logInfo("IndexingStack", "sbQueueStack.pop() == null, file = " + sbQueueStack.filename);
	        	if (sbQueueStack.size() < sizeBefore) continue;
	        	Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pop() == null; failed; file = " + sbQueueStack.filename);
	        	return null;
	        }
	        return new QueueEntry(b);
    	}
    	Log.logInfo("IndexingStack", "sbQueueStack.size() == 0");
        return null;
    }

    public synchronized QueueEntry remove(final String urlHash) {
        final Iterator<Row.Entry> i = sbQueueStack.stackIterator(true);
        Row.Entry rowentry;
        QueueEntry entry;
        while (i.hasNext()) {
            rowentry = i.next();
            entry = new QueueEntry(rowentry);
            if (entry.url().hash().equals(urlHash)) {
                i.remove();
                return entry;
            }
        }
        return null;
    }

    public void clear() {
        sbQueueStack.clear();
    }

    public void close() {
        if (sbQueueStack != null) {
            sbQueueStack.close();
        }
    }

    protected void finalize() throws Throwable {
        try {
        close();
        } catch (final Exception e) {
            throw new IOException("plasmaSwitchboardQueue.finalize()" + e.getMessage());
    }
        super.finalize();
    }

    public Iterator<QueueEntry> entryIterator(final boolean up) {
        // iterates the elements in an ordered way.
        // returns plasmaSwitchboardQueue.Entry - type Objects
        return new entryIterator(up);
    }

    public class entryIterator implements Iterator<QueueEntry> {

        Iterator<Row.Entry> rows;
        
        public entryIterator(final boolean up) {
            rows = sbQueueStack.stackIterator(up);
        }

        public boolean hasNext() {
            return rows.hasNext();
        }

        public QueueEntry next() {
            return new QueueEntry(rows.next());
        }

        public void remove() {
            rows.remove();
        }
    }
    
    public QueueEntry newEntry(final yacyURL url, final String referrer, final Date ifModifiedSince, final boolean requestWithCookie,
                     final String initiator, final int depth, final String profilehandle, final String anchorName) {
        return new QueueEntry(url, referrer, ifModifiedSince, requestWithCookie, initiator, depth, profilehandle, anchorName);
    }
    
    public void enQueueToActive(final QueueEntry entry) {
        queueInProcess.put(entry.url().hash(), entry);
    }
    
    public QueueEntry getActiveEntry(final String urlhash) {
        // show one entry from the queue
        return this.queueInProcess.get(urlhash);
    }
    
    public int getActiveQueueSize() {
        return this.queueInProcess.size();
    }
   
    public Collection<QueueEntry> getActiveQueueEntries() {
        // todo: check dead entries?
        return this.queueInProcess.values();
    }
    
    public static final int QUEUE_STATE_FRESH             = 0;
    public static final int QUEUE_STATE_PARSING           = 1;
    public static final int QUEUE_STATE_CONDENSING        = 2;
    public static final int QUEUE_STATE_STRUCTUREANALYSIS = 3;
    public static final int QUEUE_STATE_INDEXSTORAGE      = 4;
    public static final int QUEUE_STATE_FINISHED          = 5;
    
    public class QueueEntry {
        yacyURL url;          // plasmaURL.urlStringLength
        String referrerHash;  // plasmaURL.urlHashLength
        Date ifModifiedSince; // 6
        byte flags;           // 1
        String initiator;     // yacySeedDB.commonHashLength
        int depth;            // plasmaURL.urlCrawlDepthLength
        String profileHandle; // plasmaURL.urlCrawlProfileHandleLength
        String anchorName;    // plasmaURL.urlDescrLength
        int status;
        
        // computed values
        private CrawlProfile.entry profileEntry;
        private httpResponseHeader responseHeader;
        private yacyURL referrerURL;

        public QueueEntry(final yacyURL url, final String referrer, final Date ifModifiedSince, final boolean requestWithCookie,
                     final String initiator, final int depth, final String profileHandle, final String anchorName) {
            this.url = url;
            this.referrerHash = referrer;
            this.ifModifiedSince = ifModifiedSince;
            this.flags = (requestWithCookie) ? (byte) 1 : (byte) 0;
            this.initiator = initiator;
            this.depth = depth;
            this.profileHandle = profileHandle;
            this.anchorName = (anchorName==null)?"":anchorName.trim();
            
            this.profileEntry = null;
            this.responseHeader = null;
            this.referrerURL = null;
            this.status = QUEUE_STATE_FRESH;
        }

        public QueueEntry(final Row.Entry row) {
            final long ims = row.getColLong(2);
            final byte flags = row.getColByte(3);
            try {
                this.url = new yacyURL(row.getColString(0, "UTF-8"), null);
            } catch (final MalformedURLException e) {
                this.url = null;
            }
            this.referrerHash = row.getColString(1, "UTF-8");
            this.ifModifiedSince = (ims == 0) ? null : new Date(ims);
            this.flags = ((flags & 1) == 1) ? (byte) 1 : (byte) 0;
            this.initiator = row.getColString(4, "UTF-8");
            this.depth = (int) row.getColLong(5);
            this.profileHandle = row.getColString(6, "UTF-8");
            this.anchorName = row.getColString(7, "UTF-8");

            this.profileEntry = null;
            this.responseHeader = null;
            this.referrerURL = null;
            this.status = QUEUE_STATE_FRESH;
        }

        public QueueEntry(final byte[][] row) throws IOException {
            final long ims = (row[2] == null) ? 0 : Base64Order.enhancedCoder.decodeLong(new String(row[2], "UTF-8"));
            final byte flags = (row[3] == null) ? 0 : row[3][0];
            try {
                this.url = new yacyURL(new String(row[0], "UTF-8"), null);
            } catch (final MalformedURLException e) {
                this.url = null;
            }
            this.referrerHash = (row[1] == null) ? null : new String(row[1], "UTF-8");
            this.ifModifiedSince = (ims == 0) ? null : new Date(ims);
            this.flags = ((flags & 1) == 1) ? (byte) 1 : (byte) 0;
            this.initiator = (row[4] == null) ? null : new String(row[4], "UTF-8");
            this.depth = (int) Base64Order.enhancedCoder.decodeLong(new String(row[5], "UTF-8"));
            this.profileHandle = new String(row[6], "UTF-8");
            this.anchorName = (row[7] == null) ? null : (new String(row[7], "UTF-8")).trim();

            this.profileEntry = null;
            this.responseHeader = null;
            this.referrerURL = null;
            this.status = QUEUE_STATE_FRESH;
        }
        
        public void updateStatus(final int newStatus) {
            this.status = newStatus;
        }
        
        public void close() {
            queueInProcess.remove(this.url.hash());
        }
        
        protected void finalize() {
            this.close();
        }
        
        public yacyURL url() {
            return url;
        }

        public boolean requestedWithCookie() {
            return (flags & 1) == 1;
        }

        public boolean proxy() {
            // FIXME the equals seems to be incorrect: String.equals(boolean)
            return (initiator == null) || (initiator.equals(initiator.length() == 0));
        }

        public String initiator() {
            return (initiator == null) ? "------------" : initiator; // TODO: this may cause problems for methods that check if the initiator is the proxy
        }
        
        public yacySeed initiatorPeer() {
            if ((initiator == null) || (initiator.length() == 0)) return null;
            if (initiator.equals(peers.mySeed().hash)) {
                // normal crawling
                return null;
            }
            // this was done for remote peer (a global crawl)
            return peers.getConnected(initiator);
        }

        public int depth() {
            return depth;
        }

        public long size() {
            return plasmaHTCache.getResourceContentLength(this.url);
        }

        public CrawlProfile.entry profile() {
            if (profileEntry == null) profileEntry = profiles.getEntry(profileHandle);
            return profileEntry;
        }

        private void getResponseHeader() {
            if (this.responseHeader == null) try {
                this.responseHeader = plasmaHTCache.loadResponseHeader(this.url);
            } catch (final Exception e) {
                Log.logSevere("PLASMA", "responseHeader: failed to get header", e);
            }
        }

        public String getMimeType() {
            this.getResponseHeader();
            return (responseHeader == null) ? null : responseHeader.mime();
        }
        
        public String getCharacterEncoding() {
            getResponseHeader();
            return (responseHeader == null) ? null : responseHeader.getCharacterEncoding();
        }
        
        public Date getModificationDate() {
            getResponseHeader();
            return (responseHeader == null) ? new Date() : responseHeader.lastModified();            
        }
        
        public yacyURL referrerURL(MetadataRepository repository) {
            if (referrerURL == null) {
                // FIXME the equals seems to be incorrect: String.equals(boolean)
                if ((referrerHash == null) || ((initiator != null) && (referrerHash.equals(initiator.length() == 0)))) return null;
                final URLMetadataRow entry = repository.load(referrerHash, null, 0);
                if (entry == null) referrerURL = null; else referrerURL = entry.metadata().url();
            }
            return referrerURL;
        }
        
        public String referrerHash() {
            return (referrerHash == null) ? "" : referrerHash;
        }

        public String anchorName() {
            return anchorName;
        }

        public int processCase() {
            // we must distinguish the following cases: resource-load was initiated by
            // 1) global crawling: the index is extern, not here (not possible here)
            // 2) result of search queries, some indexes are here (not possible here)
            // 3) result of index transfer, some of them are here (not possible here)
            // 4) proxy-load (initiator is "------------")
            // 5) local prefetch/crawling (initiator is own seedHash)
            // 6) local fetching for global crawling (other known or unknwon initiator)
            int processCase = plasmaSwitchboardConstants.PROCESSCASE_0_UNKNOWN;
            // FIXME the equals seems to be incorrect: String.equals(boolean)
            if ((initiator == null) || initiator.length() == 0 || initiator.equals("------------")) {
                // proxy-load
                processCase = plasmaSwitchboardConstants.PROCESSCASE_4_PROXY_LOAD;
            } else if (initiator.equals(peers.mySeed().hash)) {
                // normal crawling
                processCase = plasmaSwitchboardConstants.PROCESSCASE_5_LOCAL_CRAWLING;
            } else {
                // this was done for remote peer (a global crawl)
                processCase = plasmaSwitchboardConstants.PROCESSCASE_6_GLOBAL_CRAWLING;
            }
            return processCase;
        }
        
        /**
         * decide upon header information if a specific file should be indexed
         * this method returns null if the answer is 'YES'!
         * if the answer is 'NO' (do not index), it returns a string with the reason
         * to reject the crawling demand in clear text
         * 
         * This function is used by plasmaSwitchboard#processResourceStack
         */
        public final String shallIndexCacheForProxy() {
            if (profile() == null) {
                return "shallIndexCacheForProxy: profile() is null !";
            }

            // check profile
            if (!profile().indexText() && !profile().indexMedia()) {
                return "Indexing_Not_Allowed";
            }

            // -CGI access in request
            // CGI access makes the page very individual, and therefore not usable in caches
            if (!profile().crawlingQ()) {
                if (url.isPOST()) {
                    return "Dynamic_(POST)";
                }
                if (url.isCGI()) {
                    return "Dynamic_(CGI)";
                }
            }

            // -authorization cases in request
            // we checked that in shallStoreCache

            // -ranges in request
            // we checked that in shallStoreCache

            // a picture cannot be indexed
            if (plasmaHTCache.noIndexingURL(url)) {
                return "Media_Content_(forbidden)";
            }

            // -cookies in request
            // unfortunately, we cannot index pages which have been requested with a cookie
            // because the returned content may be special for the client
            if (requestedWithCookie()) {
//              System.out.println("***not indexed because cookie");
                return "Dynamic_(Requested_With_Cookie)";
            }

            getResponseHeader();
            if (responseHeader != null) {
                // -set-cookie in response
                // the set-cookie from the server does not indicate that the content is special
                // thus we do not care about it here for indexing                
                
                // a picture cannot be indexed
                final String mimeType = responseHeader.mime();
                if (plasmaHTCache.isPicture(mimeType)) {
                    return "Media_Content_(Picture)";
                }
                if (!plasmaHTCache.isText(mimeType)) {
                    return "Media_Content_(not_text)";
                }
    
                // -if-modified-since in request
                // if the page is fresh at the very moment we can index it
                final Date ifModifiedSince = getModificationDate();
                if ((ifModifiedSince != null) && (responseHeader.containsKey(httpHeader.LAST_MODIFIED))) {
                    // parse date
                    Date d = responseHeader.lastModified();
                    if (d == null) {
                        d = new Date(DateFormatter.correctedUTCTime());
                    }
                    // finally, we shall treat the cache as stale if the modification time is after the if-.. time
                    if (d.after(ifModifiedSince)) {
                        //System.out.println("***not indexed because if-modified-since");
                        return "Stale_(Last-Modified>Modified-Since)";
                    }
                }
    
                // -pragma in cached response
                if (responseHeader.containsKey(httpHeader.PRAGMA) &&
                    (responseHeader.get(httpHeader.PRAGMA)).toUpperCase().equals("NO-CACHE")) {
                    return "Denied_(pragma_no_cache)";
                }
    
                // see for documentation also:
                // http://www.web-caching.com/cacheability.html
    
                // look for freshnes information
    
                // -expires in cached response
                // the expires value gives us a very easy hint when the cache is stale
                // sometimes, the expires date is set to the past to prevent that a page is cached
                // we use that information to see if we should index it
                final Date expires = responseHeader.expires();
                if (expires != null && expires.before(new Date(DateFormatter.correctedUTCTime()))) {
                    return "Stale_(Expired)";
                }
    
                // -lastModified in cached response
                // this information is too weak to use it to prevent indexing
                // even if we can apply a TTL heuristic for cache usage
    
                // -cache-control in cached response
                // the cache-control has many value options.
                String cacheControl = responseHeader.get(httpHeader.CACHE_CONTROL);
                if (cacheControl != null) {
                    cacheControl = cacheControl.trim().toUpperCase();
                    /* we have the following cases for cache-control:
                       "public" -- can be indexed
                       "private", "no-cache", "no-store" -- cannot be indexed
                       "max-age=<delta-seconds>" -- stale/fresh dependent on date
                     */
                    if (cacheControl.startsWith("PRIVATE") ||
                        cacheControl.startsWith("NO-CACHE") ||
                        cacheControl.startsWith("NO-STORE")) {
                        // easy case
                        return "Stale_(denied_by_cache-control=" + cacheControl + ")";
    //              } else if (cacheControl.startsWith("PUBLIC")) {
    //                  // ok, do nothing
                    } else if (cacheControl.startsWith("MAX-AGE=")) {
                        // we need also the load date
                        final Date date = responseHeader.date();
                        if (date == null) {
                            return "Stale_(no_date_given_in_response)";
                        }
                        try {
                            final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
                            if (DateFormatter.correctedUTCTime() - date.getTime() > ttl) {
                                //System.out.println("***not indexed because cache-control");
                                return "Stale_(expired_by_cache-control)";
                            }
                        } catch (final Exception e) {
                            return "Error_(" + e.getMessage() + ")";
                        }
                    }
                }
            }
            return null;
        }

        /**
         * decide upon header information if a specific file should be indexed
         * this method returns null if the answer is 'YES'!
         * if the answer is 'NO' (do not index), it returns a string with the reason
         * to reject the crawling demand in clear text
         *
         * This function is used by plasmaSwitchboard#processResourceStack
         */
        public final String shallIndexCacheForCrawler() {
            if (profile() == null) {
                return "shallIndexCacheForCrawler: profile() is null !";
            }

            // check profile
            if (!profile().indexText() && !profile().indexMedia()) {
                return "Indexing_Not_Allowed";
            }

            // -CGI access in request
            // CGI access makes the page very individual, and therefore not usable in caches
            if (!profile().crawlingQ()) {
                if (url().isPOST()) { return "Dynamic_(POST)"; }
                if (url().isCGI()) { return "Dynamic_(CGI)"; }
            }

            // -authorization cases in request
            // we checked that in shallStoreCache

            // -ranges in request
            // we checked that in shallStoreCache

            // a picture cannot be indexed
            getResponseHeader();
            if (responseHeader != null) {
                final String mimeType = responseHeader.mime();
                if (plasmaHTCache.isPicture(mimeType)) { return "Media_Content_(Picture)"; }
                if (!plasmaHTCache.isText(mimeType)) { return "Media_Content_(not_text)"; }
            }
            if (plasmaHTCache.noIndexingURL(url())) { return "Media_Content_(forbidden)"; }

            // -if-modified-since in request
            // if the page is fresh at the very moment we can index it
            // -> this does not apply for the crawler

            // -cookies in request
            // unfortunately, we cannot index pages which have been requested with a cookie
            // because the returned content may be special for the client
            // -> this does not apply for a crawler

            // -set-cookie in response
            // the set-cookie from the server does not indicate that the content is special
            // thus we do not care about it here for indexing
            // -> this does not apply for a crawler

            // -pragma in cached response
            // -> in the crawler we ignore this

            // look for freshnes information

            // -expires in cached response
            // the expires value gives us a very easy hint when the cache is stale
            // sometimes, the expires date is set to the past to prevent that a page is cached
            // we use that information to see if we should index it
            // -> this does not apply for a crawler

            // -lastModified in cached response
            // this information is too weak to use it to prevent indexing
            // even if we can apply a TTL heuristic for cache usage

            // -cache-control in cached response
            // the cache-control has many value options.
            // -> in the crawler we ignore this

            return null;
        }
        
        /*
         * (non-Javadoc)
         * 
         * @see java.lang.Object#toString()
         */
        public String toString() {
            return "QueueEntry of "+ url.toString() + ", ref="+referrerHash +", initiator="+initiator +", flags="+ flags +", anchor="+ anchorName;
        }
    } // class Entry
}