roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r377865 - /incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java
Date Tue, 14 Feb 2006 22:34:10 GMT
Author: snoopdave
Date: Tue Feb 14 14:34:09 2006
New Revision: 377865

URL: http://svn.apache.org/viewcvs?rev=377865&view=rev
Log:
Fix for ROL-1046, easier to set planet cache dir

Modified:
    incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java

Modified: incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java?rev=377865&r1=377864&r2=377865&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java Tue Feb 14 14:34:09
2006
@@ -26,6 +26,7 @@
 import com.sun.syndication.fetcher.impl.FeedFetcherCache;
 import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
 import com.sun.syndication.fetcher.impl.SyndFeedInfo;
+import java.io.File;
 
 /**
  * Base class for PlanetManager implementations.
@@ -52,12 +53,39 @@
         Date now = new Date();
         long startTime = System.currentTimeMillis();
         PlanetConfigData config = getConfiguration();
+        
+        // can't continue without cache dir
         if (config == null || config.getCacheDir() == null) {
             logger.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
+        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) {
+            logger.error("Unable to create planet cache directory");
+            return;
+        }
+        
+        // abort if cache dir is not writable
+        if (!cacheDir.canWrite()) {
+            logger.error("Planet cache directory is not writable");
+            return;        
         }
+        
         FeedFetcherCache feedInfoCache =
-                new DiskFeedInfoCache(config.getCacheDir());
+                new DiskFeedInfoCache(cacheDirName);
         
         if (config.getProxyHost()!=null && config.getProxyPort() > 0) {
             System.setProperty("proxySet", "true");



Mime
View raw message