|
|
|
@ -27,6 +27,7 @@ import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import net.yacy.cora.services.federated.yacy.CacheStrategy;
|
|
|
|
|
import net.yacy.kelondro.data.meta.DigestURI;
|
|
|
|
|
import net.yacy.kelondro.logging.Log;
|
|
|
|
|
import net.yacy.kelondro.util.FileUtils;
|
|
|
|
|
import net.yacy.repository.LoaderDispatcher;
|
|
|
|
|
import de.anomic.crawler.retrieval.Response;
|
|
|
|
@ -47,7 +48,20 @@ public class OAIPMHLoader {
|
|
|
|
|
this.source = source;
|
|
|
|
|
|
|
|
|
|
// load the file from the net
|
|
|
|
|
final Response response = loader.load(loader.request(source, false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, true);
|
|
|
|
|
Response response = null;
|
|
|
|
|
IOException ee = null;
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
// make some retries if first attempt fails
|
|
|
|
|
try {
|
|
|
|
|
response = loader.load(loader.request(source, false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, true);
|
|
|
|
|
break;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
Log.logWarning("OAIPMHLoader", "loading failed at attempt " + (i + 1) + ": " + source.toNormalform(true, false));
|
|
|
|
|
ee = e;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (response == null) throw ee;
|
|
|
|
|
final byte[] b = response.getContent();
|
|
|
|
|
this.resumptionToken = new ResumptionToken(source, b);
|
|
|
|
|
//System.out.println("*** ResumptionToken = " + this.resumptionToken.toString());
|
|
|
|
@ -57,19 +71,6 @@ public class OAIPMHLoader {
|
|
|
|
|
// transaction-safe writing
|
|
|
|
|
FileUtils.copy(b, f0);
|
|
|
|
|
f0.renameTo(f1);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SurrogateReader sr = new SurrogateReader(new ByteArrayInputStream(b), 100);
|
|
|
|
|
Thread srt = new Thread(sr);
|
|
|
|
|
srt.start();
|
|
|
|
|
DCEntry dce;
|
|
|
|
|
while ((dce = sr.take()) != DCEntry.poison) {
|
|
|
|
|
System.out.println(dce.toString());
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
srt.join();
|
|
|
|
|
} catch (InterruptedException e) {}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResumptionToken getResumptionToken() {
|
|
|
|
|