Roller roller = RollerFactory.getRoller();
Date now = new Date();
long startTime = System.currentTimeMillis();
PlanetConfigData config = getConfiguration();
// can't continue without cache dir
if (config == null || config.getCacheDir() == null) {
log.warn("Planet cache directory not set, aborting refresh");
return;
}
// allow ${user.home} in cache dir property
String cacheDirName = config.getCacheDir().replaceFirst(
"\\$\\{user.home}",System.getProperty("user.home"));
// allow ${catalina.home} in cache dir property
if (System.getProperty("catalina.home") != null) {
cacheDirName = cacheDirName.replaceFirst(
"\\$\\{catalina.home}",System.getProperty("catalina.home"));
}
// create cache dir if it does not exist
File cacheDir = null;
try {
cacheDir = new File(cacheDirName);
if (!cacheDir.exists()) cacheDir.mkdirs();
} catch (Exception e) {
log.error("Unable to create planet cache directory");
return;
}
// abort if cache dir is not writable
if (!cacheDir.canWrite()) {
log.error("Planet cache directory is not writable");
return;
}
FeedFetcherCache feedInfoCache =
new DiskFeedInfoCache(cacheDirName);
if (config.getProxyHost()!=null && config.getProxyPort() > 0) {
System.setProperty("proxySet", "true");
System.setProperty("http.proxyHost", config.getProxyHost());
System.setProperty("http.proxyPort",
Integer.toString(config.getProxyPort()));
}
/** a hack to set 15 sec timeouts for java.net.HttpURLConnection */
System.setProperty("sun.net.client.defaultConnectTimeout", "15000");
System.setProperty("sun.net.client.defaultReadTimeout", "15000");