weaver      2004/05/27 12:51:11

  Modified:    portal/src/java/org/apache/jetspeed/page/impl
                        CastorXmlPageManager.java
  Log:
  added file existence checking
  
  Revision  Changes    Path
  1.4       +19 -5     
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java
  
  Index: CastorXmlPageManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CastorXmlPageManager.java 8 Mar 2004 00:29:27 -0000       1.3
  +++ CastorXmlPageManager.java 27 May 2004 19:51:11 -0000      1.4
  @@ -18,6 +18,7 @@
   
   //standard java stuff
   import java.io.File;
  +import java.io.FileNotFoundException;
   import java.io.FileReader;
   import java.io.FileWriter;
   import java.io.FilenameFilter;
  @@ -89,17 +90,19 @@
       /** the Castor mapping file name */
       protected Mapping mapping = null;
   
  -    public CastorXmlPageManager(IdGenerator generator, FileCache fileCache, String 
root)
  +    public CastorXmlPageManager(IdGenerator generator, FileCache fileCache, String 
root) throws FileNotFoundException
       {    
           super(generator);
           this.rootDir = new File(root);
  +        verifyPath(rootDir);
           this.pages = fileCache;        
       }
       
  -    public CastorXmlPageManager(IdGenerator generator, FileCache fileCache, String 
root, List modelClasses)
  +    public CastorXmlPageManager(IdGenerator generator, FileCache fileCache, String 
root, List modelClasses) throws FileNotFoundException
       {
           super(generator, modelClasses);
           this.rootDir = new File(root);
  +        verifyPath(rootDir);
           this.pages = fileCache;        
       }
   
  @@ -107,7 +110,7 @@
                                   FileCache fileCache, 
                                   String root,                                        
                                   List modelClasses,
  -                                String extension) 
  +                                String extension) throws FileNotFoundException 
                                          
       {
           this(generator, fileCache, root, modelClasses);
  @@ -122,7 +125,10 @@
           
   
           //If the rootDir does not exist, treat it as context relative
  -        if (!rootDir.exists())
  +        // NO NO NO!  If a value gets passed in, it should be expected to exist
  +        // only default to context relative if rootDir == null 
  +        //if (!rootDir.exists())
  +        if(rootDir == null)
           {
               try
               {
  @@ -438,5 +444,13 @@
       public void evict(FileCacheEntry entry)
       {
           log.debug("Entry is evicting: " + entry.getFile().getName());
  +    }
  +    
  +    protected void verifyPath(File path) throws FileNotFoundException
  +    {
  +        if(!path.exists())
  +        {
  +            throw new FileNotFoundException("Could not locate root pages path 
"+path.getAbsolutePath());
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to