1   /* PersistLoadProcessor.java
2    * 
3    * Created on Feb 13, 2005
4    *
5    * Copyright (C) 2007 Internet Archive.
6    * 
7    * This file is part of the Heritrix web crawler (crawler.archive.org).
8    * 
9    * Heritrix is free software; you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser Public License as published by
11   * the Free Software Foundation; either version 2.1 of the License, or
12   * any later version.
13   * 
14   * Heritrix is distributed in the hope that it will be useful, 
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU Lesser Public License for more details.
18   * 
19   * You should have received a copy of the GNU Lesser Public License
20   * along with Heritrix; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22   */
23  package org.archive.crawler.processor.recrawl;
24  
25  
26  import java.util.Iterator;
27  
28  import org.archive.crawler.datamodel.CrawlURI;
29  
30  import st.ata.util.AList;
31  
32  /***
33   * Store CrawlURI attributes from latest fetch to persistent storage for
34   * consultation by a later recrawl. 
35   * 
36   * @author gojomo
37   * @version $Date: 2006-09-25 20:19:54 +0000 (Mon, 25 Sep 2006) $, $Revision: 4654 $
38   */
39  public class PersistLoadProcessor extends PersistOnlineProcessor {
40      private static final long serialVersionUID = -1917169316015093131L;
41  
42      /***
43       * Usual constructor
44       * 
45       * @param name
46       */
47      public PersistLoadProcessor(String name) {
48          super(name, "PersistLoadProcessor. Loads CrawlURI attributes " +
49                  "from a previous crawl for current consultation.");
50      }
51  
52      @Override
53      protected void innerProcess(CrawlURI curi) throws InterruptedException {
54          if(shouldLoad(curi)) {
55              AList prior = (AList) store.get(persistKeyFor(curi));
56              if(prior!=null) {
57                  // merge in keys
58                  Iterator iter = prior.getKeys();
59                  curi.getAList().copyKeysFrom(iter,prior);
60              }
61          }
62      }
63  }