weaver 2004/08/25 12:28:57
Modified: components/file-cache/src/java/org/apache/jetspeed/cache/file
FileCache.java
Log:
The key passed into FileCache may not resolve to an actual file unless we provide
the correct root directory.
Revision Changes Path
1.3 +29 -6
jakarta-jetspeed-2/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
Index: FileCache.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileCache.java 19 May 2004 20:19:49 -0000 1.2
+++ FileCache.java 25 Aug 2004 19:28:57 -0000 1.3
@@ -24,6 +24,7 @@
import java.util.LinkedList;
import java.util.Iterator;
import java.io.File;
+import java.io.FileNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -174,6 +175,10 @@
public void put(File file, Object document)
throws java.io.IOException
{
+ if(!file.exists())
+ {
+ throw new FileNotFoundException("File to cache:
"+file.getAbsolutePath()+" does not exist.");
+ }
FileCacheEntry entry = new FileCacheEntryImpl(file, document);
cache.put(file.getCanonicalPath(), entry);
}
@@ -184,12 +189,16 @@
* @param path the full path name of the file
* @param document the cached document
*/
- public void put(String key, Object document)
+ public void put(String key, Object document, File rootFile)
throws java.io.IOException
{
- File file = new File(key);
+ File file = new File(rootFile, key);
+ if(!file.exists())
+ {
+ throw new FileNotFoundException("File to cache:
"+file.getAbsolutePath()+" does not exist.");
+ }
FileCacheEntry entry = new FileCacheEntryImpl(file, document);
- cache.put(file.getCanonicalPath(), entry);
+ cache.put(key, entry);
}
/**
@@ -281,7 +290,14 @@
{
FileCacheEventListener listener =
(FileCacheEventListener) lit.next();
- listener.evict(entry);
+ try
+ {
+ listener.evict(entry);
+ }
+ catch (Exception e1)
+ {
+ log.warn("Unable to evict cache entry. "+e1.toString(),
e1);
+ }
}
cache.remove(key);
@@ -348,7 +364,14 @@
{
FileCacheEventListener listener =
(FileCacheEventListener) lit.next();
- listener.refresh(entry);
+ try
+ {
+ listener.refresh(entry);
+ }
+ catch (Exception e1)
+ {
+ log.warn("Unable to refresh cached
document: "+e1.toString(), e1);
+ }
entry.setLastModified(modified);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]