mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-15 10:20:47 +00:00
Merge branch 'master' into speculative-links
This commit is contained in:
commit
31df3a8f03
26 files changed
+843
-470
No files matched your search
@@ -125,6 +125,9 @@ public class Checkpoint implements InitializingBean {
|
||||
public void saveJson(String beanName, JSONObject json) {
|
||||
try {
|
||||
File targetFile = new File(getCheckpointDir().getFile(),beanName);
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("saving json to " + targetFile);
|
||||
}
|
||||
FileUtils.writeStringToFile(
|
||||
targetFile,
|
||||
json.toString());
|
||||
@@ -137,6 +140,9 @@ public class Checkpoint implements InitializingBean {
|
||||
public JSONObject loadJson(String beanName) {
|
||||
File sourceFile = new File(getCheckpointDir().getFile(),beanName);
|
||||
try {
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("reading json from " + sourceFile);
|
||||
}
|
||||
return new JSONObject(FileUtils.readFileToString(sourceFile));
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -148,6 +154,9 @@ public class Checkpoint implements InitializingBean {
|
||||
public BufferedWriter saveWriter(String beanName, String extraName) throws IOException {
|
||||
try {
|
||||
File targetFile = new File(getCheckpointDir().getFile(),beanName+"-"+extraName);
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("opening for writing: " + targetFile);
|
||||
}
|
||||
return new BufferedWriter(new FileWriter(targetFile));
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(Level.SEVERE,"unable to save checkpoint writer state "+extraName+" of "+beanName,e);
|
||||
|
||||
@@ -21,8 +21,11 @@ package org.archive.spring;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -132,12 +135,16 @@ public class PathSharingContext extends FileSystemXmlApplicationContext {
|
||||
|
||||
protected File getConfigurationFile() {
|
||||
String primaryConfigurationPath = getPrimaryConfigurationPath();
|
||||
if(primaryConfigurationPath.startsWith("file:")) {
|
||||
if (primaryConfigurationPath.startsWith("file:")) {
|
||||
// strip URI-scheme if present (as is usual)
|
||||
primaryConfigurationPath = primaryConfigurationPath.substring(5);
|
||||
try {
|
||||
return new File(new URI(primaryConfigurationPath));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return new File(primaryConfigurationPath);
|
||||
}
|
||||
File configFile = new File(primaryConfigurationPath);
|
||||
return configFile;
|
||||
}
|
||||
|
||||
protected void initLaunchDir() {
|
||||
@@ -178,4 +185,18 @@ public class PathSharingContext extends FileSystemXmlApplicationContext {
|
||||
}
|
||||
super.initLifecycleProcessor();
|
||||
}
|
||||
|
||||
protected ConcurrentHashMap<Object, Object> data;
|
||||
|
||||
/**
|
||||
* @return a shared map for arbitrary use during a crawl; for example, could
|
||||
* be used for state persisting for the duration of the crawl,
|
||||
* shared among ScriptedProcessor, scripting console, etc scripts
|
||||
*/
|
||||
public ConcurrentHashMap<Object, Object> getData() {
|
||||
if (data == null) {
|
||||
data = new ConcurrentHashMap<Object, Object>();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -557,6 +557,11 @@ public class ArchiveUtils {
|
||||
}
|
||||
|
||||
private static String doubleToString(double val, int maxFractionDigits, int minFractionDigits) {
|
||||
// NumberFormat returns U+FFFD REPLACEMENT CHARACTER for NaN which looks
|
||||
// like a bug in the UI
|
||||
if (Double.isNaN(val)) {
|
||||
return "NaN";
|
||||
}
|
||||
NumberFormat f = NumberFormat.getNumberInstance(Locale.US);
|
||||
f.setMaximumFractionDigits(maxFractionDigits);
|
||||
f.setMinimumFractionDigits(minFractionDigits);
|
||||
|
||||
Reference in new issue
Block a user