You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/10/05 22:19:29 UTC

svn commit: r453354 - in /incubator/roller/trunk: src/org/apache/roller/business/ src/org/apache/roller/model/ src/org/apache/roller/pojos/ src/org/apache/roller/ui/authoring/struts/actions/ src/org/apache/roller/ui/authoring/struts/formbeans/ src/org/...

Author: agilliland
Date: Thu Oct  5 13:19:28 2006
New Revision: 453354

URL: http://svn.apache.org/viewvc?view=rev&rev=453354
Log:
Thirs commit for Roller 3.1 Theme Encapsulation work ...

http://rollerweblogger.org/wiki/Wiki.jsp?page=Proposal_ThemeEncapsulation

1. Added new WeblogResource interface to represent uploaded weblog resources.

2. More modifications to FileManager.

  * FileManager now takes a true WebsiteData object as a parameter to its methods rather than just a weblog handle.
  * FileManager now returns a WeblogResource for calls to getFile() and getFiles().
  * Updated FileManager unit tests to match.
  * Modified all callers of FileManager methods with new method signatures.

3. Updated file uploads form to handle subdirectories.

  * Updated UploadFile.jsp to display both files and directories in the listing as well as to pass around a "path" parameter in the form fields.
  * Updated UploadFileFormAction and its PageModel to account for changes needed to handle subdirectories.

NOTE: at this point this work mostly implements the functionality of the proposal, however there are some additional items to complete before being totally finished.  Primarily, this commit breaks part of the theme preview functionality.


Added:
    incubator/roller/trunk/src/org/apache/roller/pojos/WeblogResource.java
Modified:
    incubator/roller/trunk/src/org/apache/roller/business/FileManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/model/FileManager.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/ImportEntriesAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/UploadFileFormAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/formbeans/UploadFileForm.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/URLModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/ResourceServlet.java
    incubator/roller/trunk/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java
    incubator/roller/trunk/tests/org/apache/roller/business/FileManagerTest.java
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/UploadFile.jsp

Modified: incubator/roller/trunk/src/org/apache/roller/business/FileManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/FileManagerImpl.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/FileManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/FileManagerImpl.java Thu Oct  5 13:19:28 2006
@@ -19,6 +19,7 @@
 package org.apache.roller.business;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -33,11 +34,14 @@
 import org.apache.roller.model.FilePathException;
 import org.apache.roller.model.FileManager;
 import org.apache.roller.model.FileNotFoundException;
+import org.apache.roller.pojos.WeblogResource;
+import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.URLUtilities;
 
 
 /**
- * Manages files uploaded to Roller.  
+ * Manages files uploaded to Roller weblogs.  
  * 
  * This base implementation writes resources to a filesystem.
  */
@@ -69,11 +73,11 @@
     /**
      * @see org.apache.roller.model.FileManager#getFile(java.lang.String, java.lang.String)
      */
-    public File getFile(String weblogHandle, String path) 
+    public WeblogResource getFile(WebsiteData weblog, String path) 
             throws FileNotFoundException, FilePathException {
         
         // get a reference to the file, checks that file exists & is readable
-        File resourceFile = this.getRealFile(weblogHandle, path);
+        File resourceFile = this.getRealFile(weblog, path);
         
         // make sure file is not a directory
         if(resourceFile.isDirectory()) {
@@ -81,19 +85,19 @@
                     "path is a directory.");
         }
         
-        // everything looks good, return file
-        return resourceFile;
+        // everything looks good, return resource
+        return new WeblogResourceFile(weblog, path, resourceFile);
     }
     
     
     /**
      * @see org.apache.roller.model.FileManager#getFiles(java.lang.String, java.lang.String)
      */
-    public File[] getFiles(String weblogHandle, String path) 
+    public WeblogResource[] getFiles(WebsiteData weblog, String path) 
             throws FileNotFoundException, FilePathException {
         
         // get a reference to the dir, checks that dir exists & is readable
-        File dirFile = this.getRealFile(weblogHandle, path);
+        File dirFile = this.getRealFile(weblog, path);
         
         // make sure path is a directory
         if(!dirFile.isDirectory()) {
@@ -102,14 +106,16 @@
         }
         
         // everything looks good, list contents
-        return dirFile.listFiles();
+        WeblogResource dir = new WeblogResourceFile(weblog, path, dirFile);
+        
+        return dir.getChildren();
     }
     
     
     /**
      * @see org.apache.roller.model.FileManager#saveFile(java.lang.String, java.lang.String, java.lang.String, long, java.io.InputStream)
      */
-    public void saveFile(String weblogHandle, 
+    public void saveFile(WebsiteData weblog, 
                          String path, 
                          String contentType, 
                          long size, 
@@ -118,12 +124,12 @@
         
         // make sure we are allowed to save this file
         RollerMessages msgs = new RollerMessages();
-        if (!canSave(weblogHandle, path, contentType, size, msgs)) {
+        if (!canSave(weblog, path, contentType, size, msgs)) {
             throw new FileIOException(msgs.toString());
         }
         
         // make sure uploads area exists for this weblog
-        File dirPath = this.getRealFile(weblogHandle, null);
+        File dirPath = this.getRealFile(weblog, null);
         File saveFile = new File(dirPath.getAbsolutePath() + File.separator + path);
         
         byte[] buffer = new byte[8192];
@@ -152,11 +158,11 @@
     /**
      * @see org.apache.roller.model.FileManager#createDirectory(java.lang.String, java.lang.String)
      */
-    public void createDirectory(String weblogHandle, String path)
+    public void createDirectory(WebsiteData weblog, String path)
             throws FileNotFoundException, FilePathException, FileIOException {
         
         // get path to weblog's uploads area
-        File uploadDir = this.getRealFile(weblogHandle, null);
+        File uploadDir = this.getRealFile(weblog, null);
         
         // now construct path to new directory
         File dir = new File(uploadDir.getAbsolutePath() + File.separator + path);
@@ -179,11 +185,11 @@
     /**
      * @see org.apache.roller.model.FileManager#deleteFile(java.lang.String, java.lang.String)
      */
-    public void deleteFile(String weblogHandle, String path) 
+    public void deleteFile(WebsiteData weblog, String path) 
             throws FileNotFoundException, FilePathException, FileIOException {
         
         // get path to delete file, checks that path exists and is readable
-        File delFile = this.getRealFile(weblogHandle, path);
+        File delFile = this.getRealFile(weblog, path);
         
         if(!delFile.delete()) {
             throw new FileIOException("Delete failed for ["+path+"], "+
@@ -195,7 +201,7 @@
     /**
      * @see org.apache.roller.model.FileManager#overQuota(java.lang.String)
      */
-    public boolean overQuota(String weblogHandle) {
+    public boolean overQuota(WebsiteData weblog) {
         
         String maxDir = RollerRuntimeConfig.getProperty("uploads.dir.maxsize");
         String maxFile = RollerRuntimeConfig.getProperty("uploads.file.maxsize");
@@ -205,7 +211,7 @@
         long maxDirBytes = (long)(1024000 * maxDirSize.doubleValue());
         
         try {
-            File uploadsDir = this.getRealFile(weblogHandle, null);
+            File uploadsDir = this.getRealFile(weblog, null);
             long weblogDirSize = this.getDirSize(uploadsDir, true);
             
             return weblogDirSize > maxDirBytes;
@@ -224,7 +230,7 @@
     /**
      * Determine if file can be saved given current RollerConfig settings.
      */
-    private boolean canSave(String weblogHandle, 
+    private boolean canSave(WebsiteData weblog, 
                            String path, 
                            String contentType,
                            long size, 
@@ -252,7 +258,7 @@
                 RollerRuntimeConfig.getProperty("uploads.dir.maxsize"));
         long maxDirBytes = (long)(1024000 * maxDirMB.doubleValue());
         try {
-            File uploadsDir = this.getRealFile(weblogHandle, null);
+            File uploadsDir = this.getRealFile(weblog, null);
             long userDirSize = getDirSize(uploadsDir, true);
             if (userDirSize + size > maxDirBytes) {
                 messages.addError("error.upload.dirmax", maxDirMB.toString());
@@ -280,7 +286,7 @@
             String dirPath = path.substring(0, path.lastIndexOf("/"));
             
             try {
-                File parent = this.getRealFile(weblogHandle, dirPath);
+                File parent = this.getRealFile(weblog, dirPath);
                 if(parent == null || !parent.exists()) {
                     messages.addError("error.upload.badPath");
                 }
@@ -427,11 +433,11 @@
     /**
      * Construct the full real path to a resource in a weblog's uploads area.
      */
-    private File getRealFile(String weblogHandle, String path) 
+    private File getRealFile(WebsiteData weblog, String path) 
             throws FileNotFoundException, FilePathException {
         
         // make sure uploads area exists for this weblog
-        File weblogDir = new File(this.upload_dir + weblogHandle);
+        File weblogDir = new File(this.upload_dir + weblog.getHandle());
         if(!weblogDir.exists()) {
             weblogDir.mkdirs();
         }
@@ -476,6 +482,97 @@
         }
         
         return file;
+    }
+    
+    
+    /**
+     * A FileManagerImpl specific implementation of a WeblogResource.
+     *
+     * WeblogResources from the FileManagerImpl are backed by a java.io.File
+     * object which represents the resource on a filesystem.
+     *
+     * This class is internal to the FileManagerImpl class because there should 
+     * not be any external classes which need to construct their own instances
+     * of this class.
+     */
+    class WeblogResourceFile implements WeblogResource {
+        
+        // the physical java.io.File backing this resource
+        private File resourceFile = null;
+        
+        // the relative path of the resource within the weblog's uploads area
+        private String relativePath = null;
+        
+        // the weblog the resource is attached to
+        private WebsiteData weblog = null;
+        
+        
+        public WeblogResourceFile(WebsiteData weblog, String path, File file) {
+            this.weblog = weblog;
+            relativePath = path;
+            resourceFile = file;
+        }
+        
+        public WebsiteData getWeblog() {
+            return weblog;
+        }
+        
+        public String getURL(boolean absolute) {
+            return URLUtilities.getWeblogResourceURL(weblog, relativePath, absolute);
+        }
+        
+        public WeblogResource[] getChildren() {
+            
+            if(!resourceFile.isDirectory()) {
+                return null;
+            }
+            
+            File[] dirFiles = resourceFile.listFiles();
+            WeblogResource[] resources = new WeblogResource[dirFiles.length];
+            for(int i=0; i < dirFiles.length; i++) {
+                String filePath = dirFiles[i].getName();
+                if(relativePath != null && !relativePath.trim().equals("")) {
+                    filePath = relativePath + "/" + filePath;
+                }
+                
+                resources[i] = new WeblogResourceFile(weblog, filePath, dirFiles[i]);
+            }
+            
+            return resources;
+        }
+        
+        public String getName() {
+            return resourceFile.getName();
+        }
+        
+        public String getPath() {
+            return relativePath;
+        }
+        
+        public long getLastModified() {
+            return resourceFile.lastModified();
+        }
+        
+        public long getLength() {
+            return resourceFile.length();
+        }
+        
+        public boolean isDirectory() {
+            return resourceFile.isDirectory();
+        }
+        
+        public boolean isFile() {
+            return resourceFile.isFile();
+        }
+        
+        public InputStream getInputStream() {
+            try {
+                return new FileInputStream(resourceFile);
+            } catch (java.io.FileNotFoundException ex) {
+                // should never happen, rethrow as runtime exception
+                throw new RuntimeException("Error constructing input stream", ex);
+            }
+        }
     }
     
 }

Modified: incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java Thu Oct  5 13:19:28 2006
@@ -241,9 +241,9 @@
                 
                 try {
                     if(resourceFile.isDirectory()) {
-                        fileMgr.createDirectory(website.getHandle(), path);
+                        fileMgr.createDirectory(website, path);
                     } else {
-                        fileMgr.saveFile(website.getHandle(), path, "text/plain", 
+                        fileMgr.saveFile(website, path, "text/plain", 
                                 resourceFile.length(), new FileInputStream(resourceFile));
                     }
                 } catch (Exception ex) {

Modified: incubator/roller/trunk/src/org/apache/roller/model/FileManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/model/FileManager.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/model/FileManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/model/FileManager.java Thu Oct  5 13:19:28 2006
@@ -18,9 +18,9 @@
 
 package org.apache.roller.model;
 
-import java.io.File;
 import java.io.InputStream;
-import org.apache.roller.RollerException;
+import org.apache.roller.pojos.WeblogResource;
+import org.apache.roller.pojos.WebsiteData;
 
 
 /**
@@ -34,16 +34,16 @@
      * This method always returns a valid file or will throw an exception
      * if the specificed path doesn't exist, is a directory, or can't be read.
      * 
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      * @param path The relative path to the desired resource within 
      * the weblog's uploads area.
      *
      * @throws FileNotFoundException If path does not exist.
      * @throws FilePathException If path is invalid, is a directory, or can't be read.
      *
-     * @return File representing the real file resource.
+     * @return WeblogResource representing the real file resource.
      */
-    public File getFile(String weblogHandle, String path) 
+    public WeblogResource getFile(WebsiteData weblog, String path) 
         throws FileNotFoundException, FilePathException;
     
     
@@ -57,23 +57,23 @@
      * This method should return the files at the root of the weblog's uploads
      * area given a path value of null, "" (empty string), or "/"
      * 
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      * @param path The relative path to the desired resource within 
      * the weblog's uploads area.
      * 
      * @throws FileNotFoundException If path does not exist.
      * @throws FilePathException If path is invalid, is not a directory, or can't be read.
      *
-     * @return File[] of files in website's uploads area at given path.
+     * @return WeblogResource[] of files in website's uploads area at given path.
      */
-    public File[] getFiles(String weblogHandle, String path) 
+    public WeblogResource[] getFiles(WebsiteData weblog, String path) 
         throws FileNotFoundException, FilePathException;
     
     
     /**
      * Save a file to weblog's uploads area.
      * 
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      * @param path The relative path to the desired location within 
      * the weblog's uploads area where the file should be saved.
      * @param contentType Content type of the file.
@@ -84,7 +84,7 @@
      * @throws FilePathException If path is invalid, is not a directory, or can't be read.
      * @throws FileIOException If there is an unexpected error during the save.
      */
-    public void saveFile(String weblogHandle, 
+    public void saveFile(WebsiteData weblog, 
                          String path, 
                          String contentType, 
                          long size,
@@ -95,7 +95,7 @@
     /**
      * Create an empty subdirectory in the weblog's uploads area.
      *
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      * @param path The relative path to the desired location within 
      * the weblog's uploads area where the directory should be created.
      *
@@ -103,14 +103,14 @@
      * @throws FilePathException If path is invalid, is not a directory, or can't be read.
      * @throws FileIOException If there is an unexpected error during the create.
      */
-    public void createDirectory(String weblogHandle, String path) 
+    public void createDirectory(WebsiteData weblog, String path) 
         throws FileNotFoundException, FilePathException, FileIOException;
     
     
     /**
      * Delete file or directory from weblog's uploads area.
      * 
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      * @param path The relative path to the file within the weblog's uploads 
      * area that should be deleted.
      *
@@ -118,18 +118,18 @@
      * @throws FilePathException If path is invalid, or can't be read.
      * @throws FileIOException If there is an unexpected error during the delete.
      */
-    public void deleteFile(String weblogHandle, String path) 
+    public void deleteFile(WebsiteData weblog, String path) 
         throws FileNotFoundException, FilePathException, FileIOException;
     
     
     /** 
      * Is the given weblog over the file-upload quota limit?
      *
-     * @param weblogHandle The handle of the weblog.
+     * @param weblog The weblog we are working on.
      *
      * @return True if weblog is over set quota, False otherwise.
      */
-    public boolean overQuota(String weblogHandle);
+    public boolean overQuota(WebsiteData weblog);
     
     
     /**

Added: incubator/roller/trunk/src/org/apache/roller/pojos/WeblogResource.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WeblogResource.java?view=auto&rev=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WeblogResource.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WeblogResource.java Thu Oct  5 13:19:28 2006
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.pojos;
+
+import java.io.InputStream;
+
+
+/**
+ * Represents a static resource file uploaded to a weblog.
+ *
+ * The main reason for having this interface is so that we can provide a layer 
+ * of abstraction between how Roller uses uploaded resource files and how those
+ * files are physically being managed by the underlying code.
+ */
+public interface WeblogResource {
+    
+    /**
+     * The weblog this resource is attached to.
+     *
+     * @returns The weblog object owning this resource.
+     */
+    public WebsiteData getWeblog();
+    
+    
+    /**
+     * The name of this resource.
+     * i.e. "some.jpg"
+     *
+     * @returns The short name for the resource.
+     */
+    public String getName();
+    
+    
+    /**
+     * The path to this resource, relative to the weblog's uploads area.
+     * i.e. "images/some.jpg"
+     *
+     * @returns The path to the resource, relative to the weblog's uploads area.
+     */
+    public String getPath();
+    
+    
+    /**
+     * The last-modified time for this resource.
+     *
+     * @returns The last time the resource changed, as a long value.
+     */
+    public long getLastModified();
+    
+    
+    /**
+     * The length of this resource, in bytes.
+     *
+     * @returns The length of the resource in bytes.
+     */
+    public long getLength();
+    
+    
+    /**
+     * Does this resource represent a directory?  True if yes, False otherwise.
+     *
+     * @returns True if the resource is a directory, False otherwise.
+     */
+    public boolean isDirectory();
+    
+    
+    /**
+     * Does this resource represent a file?  True if yes, False otherwise.
+     *
+     * @returns True if the resource is a file, False otherwise.
+     */
+    public boolean isFile();
+    
+    
+    /**
+     * List child resources if this resource represents a directory.
+     *
+     * @returns null if resource is not a directory, otherwise a WeblogResource[].
+     */
+    public WeblogResource[] getChildren();
+    
+    
+    /**
+     * The web url where the resource can be accessed, optionally absolute.
+     *
+     * @param absolute should the url be absolute or not?
+     *
+     * @returns a String representing the web url to this resource.
+     */
+    public String getURL(boolean absolute);
+    
+    
+    /**
+     * An InputStream that the resource can be read from.
+     *
+     * @returns an InputStream for the resource.
+     */
+    public InputStream getInputStream();
+    
+}

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/ImportEntriesAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/ImportEntriesAction.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/ImportEntriesAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/ImportEntriesAction.java Thu Oct  5 13:19:28 2006
@@ -35,7 +35,6 @@
 import org.apache.struts.action.ActionMessage;
 import org.apache.struts.action.ActionMessages;
 import org.apache.struts.actions.DispatchAction;
-import org.apache.roller.RollerException;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.core.RollerRequest;
@@ -44,6 +43,7 @@
 import org.apache.roller.ui.authoring.struts.formbeans.ImportEntriesForm;
 import org.apache.commons.lang.StringUtils;
 import org.apache.roller.model.FileManager;
+import org.apache.roller.pojos.WeblogResource;
 
 /**
  * TODO: revisit this class once Atom 1.0 support comes to Rome
@@ -84,7 +84,7 @@
 
                     // load selected file
                     FileManager fMgr = RollerFactory.getRoller().getFileManager();
-                    File f = fMgr.getFile(website.getHandle(), form.getImportFileName());
+                    WeblogResource f = fMgr.getFile(website, form.getImportFileName());
 
                     //ArchiveParser archiveParser =
                         //new ArchiveParser(RollerFactory.getRoller(), rreq.getWebsite(), f);

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/UploadFileFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/UploadFileFormAction.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/UploadFileFormAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/UploadFileFormAction.java Thu Oct  5 13:19:28 2006
@@ -18,10 +18,9 @@
 
 package org.apache.roller.ui.authoring.struts.actions;
 
-import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
@@ -43,9 +42,9 @@
 import org.apache.roller.RollerException;
 import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.model.FileManager;
-import org.apache.roller.model.PropertiesManager;
 import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
+import org.apache.roller.pojos.WeblogResource;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.core.BasePageModel;
 import org.apache.roller.ui.core.RollerContext;
@@ -82,12 +81,17 @@
         WebsiteData website = getWebsite(request);
         
         if (rses.isUserAuthorizedToAuthor(website)) {
+            // this is the path in the uploads area that is being used
+            UploadFileForm uploadForm = (UploadFileForm) actionForm;
+            String path = uploadForm.getPath();
+            
             UploadFilePageModel pageModel = new UploadFilePageModel(
-                    request, response, mapping, website);
+                    request, response, mapping, website, path);
             pageModel.setWebsite(website);
             request.setAttribute("model", pageModel);
             fwd = mapping.findForward("uploadFiles.page");
         }
+        
         return fwd;
     }
     
@@ -115,6 +119,7 @@
             ActionMessages messages = new ActionMessages();
             ActionErrors errors = new ActionErrors();
             UploadFileForm theForm = (UploadFileForm)actionForm;
+            String path = theForm.getPath();
             if (theForm.getUploadedFiles().length > 0) {
                 ServletContext app = servlet.getServletConfig().getServletContext();
                 
@@ -149,11 +154,14 @@
                             // disallow sneaky null terminated strings
                             fileName = fileName.substring(0, terminated).trim();
                         }
+                        if(path != null) {
+                            fileName = path + "/" + fileName;
+                        }
                         
                         fileSize = files[i].getFileSize();
                         
                         InputStream stream = files[i].getInputStream();
-                        fmgr.saveFile(website.getHandle(), fileName,
+                        fmgr.saveFile(website, fileName,
                                 files[i].getContentType(), fileSize, stream);
                         lastUploads.add(fileName);
 
@@ -168,12 +176,10 @@
             }
             
             UploadFilePageModel pageModel = new UploadFilePageModel(
-                    request, response, mapping, website, lastUploads);
+                    request, response, mapping, website, path, lastUploads);
             request.setAttribute("model", pageModel);
             pageModel.setWebsite(website);
             
-            RollerContext rctx = RollerContext.getRollerContext();
-            String resourcesBaseURL = URLUtilities.getWeblogResourceURL(website, "", true);
             Iterator uploads = lastUploads.iterator();
             if (uploads.hasNext()) {
                 messages.add(ActionMessages.GLOBAL_MESSAGE,
@@ -228,7 +234,7 @@
                     || deleteFiles[i].indexOf("..") != -1) {
                         // ignore absolute paths, or paths that contiain '..'
                     } else {
-                        fmgr.deleteFile(website.getHandle(), deleteFiles[i]);
+                        fmgr.deleteFile(website, deleteFiles[i]);
                         count++;
                     }
                 }
@@ -242,8 +248,9 @@
                     new ActionMessage("uploadFiles.deletedFiles", new Integer(count)));
             saveMessages(request, messages);
             
+            String path = theForm.getPath();
             UploadFilePageModel pageModel = new UploadFilePageModel(
-                    request, response, mapping, website);
+                    request, response, mapping, website, path);
             pageModel.setWebsite(website);
             request.setAttribute("model", pageModel);
         }
@@ -256,7 +263,7 @@
      * request params don't come accross in a file-upload post so we have to
      * stash the website handle in the session.
      */
-    public static WebsiteData getWebsite(HttpServletRequest request) throws RollerException {
+    private WebsiteData getWebsite(HttpServletRequest request) throws RollerException {
         RollerRequest rreq = RollerRequest.getRollerRequest(request);
         WebsiteData website = rreq.getWebsite();
         if (website != null) {
@@ -275,6 +282,9 @@
         private String resourcesBaseURL = null;
         private boolean uploadEnabled = true;
         private boolean overQuota = false;
+        private boolean showingRoot = true;
+        private String path = null;
+        private String parentPath = null;
         private String maxDirMB = null; // in megabytes
         private String maxFileMB = null; // in megabytes
         private List files = null;
@@ -285,8 +295,9 @@
                 HttpServletRequest req,
                 HttpServletResponse res,
                 ActionMapping mapping,
-                WebsiteData weblog) throws RollerException {
-            this(req, res, mapping, weblog, null);
+                WebsiteData weblog,
+                String uploadsPath) throws RollerException {
+            this(req, res, mapping, weblog, uploadsPath, null);
         }
         
         public UploadFilePageModel(
@@ -294,31 +305,39 @@
                 HttpServletResponse res,
                 ActionMapping mapping,
                 WebsiteData weblog,
+                String uploadsPath,
                 List lastUploads) throws RollerException {
             
             super("uploadFiles.title", req, res, mapping);
             
-            Roller roller = RollerFactory.getRoller();
-            PropertiesManager pmgr = roller.getPropertiesManager();
-            FileManager fmgr = roller.getFileManager();
+            FileManager fmgr = RollerFactory.getRoller().getFileManager();
+            
+            path = uploadsPath;
+            
+            // are we showing the root of the weblog's upload area?
+            // are we in a subdirectory which has a parent path?
+            if(uploadsPath != null && !uploadsPath.trim().equals("")) {
+                showingRoot = false;
+                if(uploadsPath.indexOf("/") != -1) {
+                    parentPath = uploadsPath.substring(0, uploadsPath.lastIndexOf("/"));
+                }
+            }
             
             resourcesBaseURL = URLUtilities.getWeblogResourceURL(weblog, "", false);
             
-            RollerRequest rreq = RollerRequest.getRollerRequest(req);
-            WebsiteData website = UploadFileFormAction.getWebsite(req);
             maxDirMB = RollerRuntimeConfig.getProperty("uploads.dir.maxsize");
             maxFileMB = RollerRuntimeConfig.getProperty("uploads.file.maxsize");
             
-            overQuota = fmgr.overQuota(weblog.getHandle());
+            overQuota = fmgr.overQuota(weblog);
             uploadEnabled = RollerRuntimeConfig.getBooleanProperty("uploads.enabled");
             
-            files = new ArrayList();
-            File[] rawFiles = fmgr.getFiles(weblog.getHandle(), null);
-            for (int i=0; i<rawFiles.length; i++) {
-                files.add(new FileBean(rawFiles[i]));
-                totalSize += rawFiles[i].length();
+            WeblogResource[] resources = fmgr.getFiles(weblog, uploadsPath);
+            for (int i=0; i<resources.length; i++) {
+                totalSize += resources[i].getLength();
             }
-            Collections.sort(files, new FileBeanNameComparator());
+            
+            files = Arrays.asList(resources);
+            Collections.sort(files, new WeblogResourceComparator());
         }
         
         public boolean isUploadEnabled() {
@@ -345,33 +364,51 @@
         public List getLastUploads() {
             return lastUploads;
         }
-    }
-    
-    
-    /**
-     * If java.io.File followed bean conventions we wouldn't need this. (perhaps
-     * we shouldn't be using files directly here in the presentation layer)
-     */
-    public class FileBean {
-        private File file;
-        public FileBean(File file) {
-            this.file = file;
+        public String getParentPath() {
+            return parentPath;
+        }
+        public boolean isShowingRoot() {
+            return showingRoot;
+        }
+
+        public String getPath() {
+            return path;
         }
-        public String getName() { return file.getName(); }
-        public long getLength() { return file.length(); }
     }
     
     
-    public class FileBeanNameComparator implements Comparator {
+    public class WeblogResourceComparator implements Comparator {
         public int compare(Object o1, Object o2) {
-            FileBean fb1 = (FileBean)o1;
-            FileBean fb2 = (FileBean)o2;
-            return fb1.getName().compareTo(fb2.getName());
+            WeblogResource r1 = (WeblogResource)o1;
+            WeblogResource r2 = (WeblogResource)o2;
+            
+            // consider directories so they go to the top of the list
+            if(r1.isDirectory() && r2.isDirectory()) {
+                // if we have 2 directories then just go by name
+                return r1.getPath().compareTo(r2.getPath());
+            } else if(r1.isDirectory()) {
+                // directories go before files
+                return -1;
+            } else if(r2.isDirectory()) {
+                // directories go before files
+                return 1;
+            } else {
+                // if we have 2 files then just go by name
+                return r1.getPath().compareTo(r2.getPath());
+            }
         }
         public boolean equals(Object o1, Object o2) {
-            FileBean fb1 = (FileBean)o1;
-            FileBean fb2 = (FileBean)o2;
-            return fb1.getName().equals(fb2.getName());
+            WeblogResource r1 = (WeblogResource)o1;
+            WeblogResource r2 = (WeblogResource)o2;
+            
+            // need to be same type to be equals, i.e both files or directories
+            if((r1.isDirectory() && !r2.isDirectory()) ||
+                    (r1.isFile() && !r2.isFile())) {
+                return false;
+            }
+            
+            // after that it's just a matter of comparing paths
+            return r1.getPath().equals(r2.getPath());
         }
     }
     

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/formbeans/UploadFileForm.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/formbeans/UploadFileForm.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/formbeans/UploadFileForm.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/formbeans/UploadFileForm.java Thu Oct  5 13:19:28 2006
@@ -44,6 +44,9 @@
     
     protected String[] deleted;
     
+    protected String path = null;
+    
+    
     public UploadFileForm() {
         super();
     }
@@ -100,5 +103,13 @@
     }
     
     public String[] getDeleteFiles() { return deleted; }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
 }
 

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/URLModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/URLModel.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/URLModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/URLModel.java Thu Oct  5 13:19:28 2006
@@ -125,14 +125,13 @@
     
     
     public String themeResource(String theme, String filePath) {
-        return getSite()+RollerRuntimeConfig.getProperty("users.themes.path")+"/"+theme+"/"+filePath;
+        // starting in Roller 3.1 even theme resources go through ResourceServlet
+        return resource(filePath);
     }
         
     public String themeResource(String theme, String filePath, boolean absolute) {
-        if (absolute) {
-            return getAbsoluteSite()+RollerRuntimeConfig.getProperty("users.themes.path")+"/"+theme+"/"+filePath;
-        }
-        return themeResource(theme, filePath);
+        // starting in Roller 3.1 even theme resources go through ResourceServlet
+        return resource(filePath);
     }
         
     public String getHome() {

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/ResourceServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/ResourceServlet.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/ResourceServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/ResourceServlet.java Thu Oct  5 13:19:28 2006
@@ -20,7 +20,6 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -33,11 +32,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
-import org.apache.roller.ThemeNotFoundException;
 import org.apache.roller.model.FileManager;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.ThemeManager;
 import org.apache.roller.pojos.Theme;
+import org.apache.roller.pojos.WeblogResource;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.rendering.util.ModDateHeaderUtil;
 import org.apache.roller.ui.rendering.util.WeblogResourceRequest;
@@ -101,14 +100,17 @@
         
         log.debug("Resource requested ["+resourceRequest.getResourcePath()+"]");
         
-        File resource = null;
+        long resourceLastMod = 0;
+        InputStream resourceStream = null;
         
         // first see if resource comes from weblog's shared theme
         if(!Theme.CUSTOM.equals(weblog.getEditorTheme())) {
             try {
                 ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
                 Theme weblogTheme = themeMgr.getTheme(weblog.getEditorTheme());
-                resource = weblogTheme.getResource(resourceRequest.getResourcePath());
+                File resource = weblogTheme.getResource(resourceRequest.getResourcePath());
+                resourceLastMod = resource.lastModified();
+                resourceStream = new FileInputStream(resource);
             } catch (Exception ex) {
                 // hmmm, some kind of error getting theme.  that's an error.
                 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -117,10 +119,13 @@
         }
         
         // if not from theme then see if resource is in weblog's upload dir
-        if(resource == null) {
+        if(resourceStream == null) {
             try {
                 FileManager fileMgr = RollerFactory.getRoller().getFileManager();
-                resource = fileMgr.getFile(weblog.getHandle(), resourceRequest.getResourcePath());
+                WeblogResource resource = fileMgr.getFile(weblog, 
+                        resourceRequest.getResourcePath());
+                resourceLastMod = resource.getLastModified();
+                resourceStream = resource.getInputStream();
             } catch (Exception ex) {
                 // still not found? then we don't have it, 404.
                 log.debug("Unable to get resource", ex);
@@ -129,35 +134,31 @@
             }
         }
         
-        log.debug("Real path is ["+resource.getAbsolutePath()+"]");
-        
         // Respond with 304 Not Modified if it is not modified.
-        if (ModDateHeaderUtil.respondIfNotModified(request, response, resource.lastModified())) {
+        if (ModDateHeaderUtil.respondIfNotModified(request, response, resourceLastMod)) {
             return;
         } else {
             // set last-modified date
-            ModDateHeaderUtil.setLastModifiedHeader(response, resource.lastModified());
+            ModDateHeaderUtil.setLastModifiedHeader(response, resourceLastMod);
         }
         
 
         // set the content type based on whatever is in our web.xml mime defs
-        response.setContentType(this.context.getMimeType(resource.getAbsolutePath()));
+        response.setContentType(this.context.getMimeType(resourceRequest.getResourcePath()));
         
         OutputStream out = null;
-        InputStream resource_file = null;
         try {
             // ok, lets serve up the file
             byte[] buf = new byte[8192];
             int length = 0;
             out = response.getOutputStream();
-            resource_file = new FileInputStream(resource);
-            while((length = resource_file.read(buf)) > 0) {
+            while((length = resourceStream.read(buf)) > 0) {
                 out.write(buf, 0, length);
             }
             
             // cleanup
             out.close();
-            resource_file.close();
+            resourceStream.close();
             
         } catch (Exception ex) {
             log.error("Error writing resource file", ex);

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java Thu Oct  5 13:19:28 2006
@@ -66,6 +66,7 @@
 import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.model.WeblogManager;
 import org.apache.roller.pojos.RollerPropertyData;
+import org.apache.roller.pojos.WeblogResource;
 import org.apache.roller.util.URLUtilities;
 import org.apache.roller.util.cache.CacheManager;
 
@@ -360,7 +361,7 @@
                     "ERROR: cannot find specified weblog");
             }
             FileManager fmgr = mRoller.getFileManager();
-            File[] files = fmgr.getFiles(website.getHandle(), null);
+            WeblogResource[] files = fmgr.getFiles(website, null);
                         
             if (canView(website)) {
                 Feed feed = new Feed();
@@ -376,10 +377,10 @@
                 
                 SortedSet sortedSet = new TreeSet(new Comparator() {
                     public int compare(Object o1, Object o2) {
-                        File f1 = (File)o1;
-                        File f2 = (File)o2;
-                        if (f1.lastModified() < f2.lastModified()) return 1;
-                        else if (f1.lastModified() == f2.lastModified()) return 0;
+                        WeblogResource f1 = (WeblogResource)o1;
+                        WeblogResource f2 = (WeblogResource)o2;
+                        if (f1.getLastModified() < f2.getLastModified()) return 1;
+                        else if (f1.getLastModified() == f2.getLastModified()) return 0;
                         else return -1;
                     }
                     public boolean equals(Object obj) {
@@ -393,7 +394,7 @@
                     }
                 }
                 int count = 0;
-                File[] sortedArray = (File[])sortedSet.toArray(new File[sortedSet.size()]);
+                WeblogResource[] sortedArray = (WeblogResource[])sortedSet.toArray(new WeblogResource[sortedSet.size()]);
                 for (int i=start; i<(start + max) && i<(sortedArray.length); i++) {
                     Entry entry = createAtomResourceEntry(website, sortedArray[i]);
                     atomEntries.add(entry);
@@ -503,13 +504,14 @@
                     WebsiteData website = 
                         mRoller.getUserManager().getWebsiteByHandle(handle);
                     
-                    // TODO: this may have broken with 3.0, but i don't know
+                    // TODO: this must have broken with 3.0, but i don't know
                     // how it's supposed to work so i can't really fix it
                     // it's unlikely this was working properly before because
-                    // it probably should have been using FileManager.getUploadsDir()
-                    File resource = 
-                        new File("/resources" + File.separator + fileName);
-                    return createAtomResourceEntry(website, resource);
+                    // it was using an invalid path
+//                    File resource = 
+//                        new File("/resources" + File.separator + fileName);
+//                    return createAtomResourceEntry(website, resource);
+                    return null;
                 }
             }
             throw new AtomNotFoundException(
@@ -594,7 +596,7 @@
                                 fileName = fileName.substring(0, pathInfo[2].length() - ".media-link".length());
                             }
                             FileManager fmgr = mRoller.getFileManager();
-                            fmgr.deleteFile(website.getHandle(), fileName);
+                            fmgr.deleteFile(website, fileName);
                         } catch (Exception e) {
                             String msg = "ERROR in atom.deleteResource";
                             mLogger.error(msg,e);
@@ -642,10 +644,10 @@
 
                     // Try saving file
                     FileInputStream fis = new FileInputStream(tempFile);
-                    fmgr.saveFile(website.getHandle(), fileName, contentType, tempFile.length(), fis);
+                    fmgr.saveFile(website, fileName, contentType, tempFile.length(), fis);
                     fis.close();
                     
-                    File resource = fmgr.getFile(website.getHandle(), fileName);
+                    WeblogResource resource = fmgr.getFile(website, fileName);
                     return createAtomResourceEntry(website, resource);
 
                 } catch (IOException e) {
@@ -985,17 +987,17 @@
         return atomEntry;
     }
     
-    private Entry createAtomResourceEntry(WebsiteData website, File file) {
+    private Entry createAtomResourceEntry(WebsiteData website, WeblogResource file) {
         String absUrl = RollerRuntimeConfig.getAbsoluteContextURL();
         String editURI = 
                 URLUtilities.getAtomProtocolURL(true)+"/"+website.getHandle()
-                + "/resource/" + file.getName() + ".media-link";
+                + "/resource/" + file.getPath() + ".media-link";
         String editMediaURI = 
                 URLUtilities.getAtomProtocolURL(true)+"/"+ website.getHandle()
-                + "/resource/" + file.getName();
+                + "/resource/" + file.getPath();
         String viewURI = absUrl
                 + "/resources/" + website.getHandle()
-                + "/" + file.getName();
+                + "/" + file.getPath();
         
         FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
         // TODO: figure out why PNG is missing from Java MIME types
@@ -1004,12 +1006,12 @@
                 ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
             } catch (Exception ignored) {}
         }
-        String contentType = map.getContentType(file);
+        String contentType = map.getContentType(file.getName());
         
         Entry entry = new Entry();
         entry.setId(editMediaURI);
         entry.setTitle(file.getName());
-        entry.setUpdated(new Date(file.lastModified()));
+        entry.setUpdated(new Date(file.getLastModified()));
         
         List otherlinks = new ArrayList();        
         entry.setOtherLinks(otherlinks);

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java Thu Oct  5 13:19:28 2006
@@ -358,7 +358,7 @@
             RollerMessages msgs = new RollerMessages();
             
             // Try to save file
-            fmgr.saveFile(website.getHandle(), name, type, bits.length, new ByteArrayInputStream(bits));
+            fmgr.saveFile(website, name, type, bits.length, new ByteArrayInputStream(bits));
             
             String fileLink = URLUtilities.getWeblogResourceURL(website, name, true);
             

Modified: incubator/roller/trunk/tests/org/apache/roller/business/FileManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/FileManagerTest.java?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/FileManagerTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/FileManagerTest.java Thu Oct  5 13:19:28 2006
@@ -45,7 +45,7 @@
  */
 public class FileManagerTest extends TestCase {
     
-    public static Log log = LogFactory.getLog(FileManagerTest.class);
+    private static Log log = LogFactory.getLog(FileManagerTest.class);
     
     UserData testUser = null;
     WebsiteData testWeblog = null;
@@ -100,36 +100,38 @@
         FileManager fmgr = RollerFactory.getRoller().getFileManager();
         
         // we should be starting with 0 files
-        assertEquals(0, fmgr.getFiles(testWeblog.getHandle(), null).length);
+        assertEquals(0, fmgr.getFiles(testWeblog, null).length);
         
         // create a directory
-        fmgr.createDirectory(testWeblog.getHandle(), "subdir");
+        fmgr.createDirectory(testWeblog, "subdir");
         
         // make sure directory was created
-        assertEquals(1, fmgr.getFiles(testWeblog.getHandle(), null).length);
+        assertEquals(1, fmgr.getFiles(testWeblog, null).length);
         
         // store a file
         InputStream is = getClass().getResourceAsStream("/bookmarks.opml");
-        fmgr.saveFile(testWeblog.getHandle(), "bookmarks.opml", "text/plain", 1545, is);
+        fmgr.saveFile(testWeblog, "bookmarks.opml", "text/plain", 1545, is);
         
         // make sure file was stored successfully
-        assertEquals(2, fmgr.getFiles(testWeblog.getHandle(), null).length);
+        assertEquals("bookmarks.opml", fmgr.getFile(testWeblog, "bookmarks.opml").getName());
+        assertEquals(2, fmgr.getFiles(testWeblog, null).length);
         
         // store a file into a subdirectory
         is = getClass().getResourceAsStream("/bookmarks.opml");
-        fmgr.saveFile(testWeblog.getHandle(), "subdir/bookmarks.opml", "text/plain", 1545, is);
+        fmgr.saveFile(testWeblog, "subdir/bookmarks.opml", "text/plain", 1545, is);
         
         // make sure file was stored successfully
-        assertEquals(1, fmgr.getFiles(testWeblog.getHandle(), "subdir").length);
+        assertEquals("subdir/bookmarks.opml", 
+                fmgr.getFile(testWeblog, "subdir/bookmarks.opml").getPath());
+        assertEquals(1, fmgr.getFiles(testWeblog, "subdir").length);
         
         // delete files and dirs
-        fmgr.deleteFile(testWeblog.getHandle(), "bookmarks.opml");
-        fmgr.deleteFile(testWeblog.getHandle(), "subdir/bookmarks.opml");
-        fmgr.deleteFile(testWeblog.getHandle(), "subdir");
+        fmgr.deleteFile(testWeblog, "bookmarks.opml");
+        fmgr.deleteFile(testWeblog, "subdir/bookmarks.opml");
+        fmgr.deleteFile(testWeblog, "subdir");
         
         // make sure delete was successful
-        Thread.sleep(2000);
-        assertEquals(0, fmgr.getFiles(testWeblog.getHandle(), null).length);
+        assertEquals(0, fmgr.getFiles(testWeblog, null).length);
     }
     
     
@@ -155,7 +157,7 @@
         
         try {
             // path check should fail
-            fmgr.saveFile(testWeblog.getHandle(), "some/path/foo.gif", "text/plain", 10, is);
+            fmgr.saveFile(testWeblog, "some/path/foo.gif", "text/plain", 10, is);
         } catch (Exception ex) {
             log.error(ex);
             exception = ex;
@@ -170,7 +172,7 @@
         
         try {
             // quota check should fail
-            fmgr.saveFile(testWeblog.getHandle(), "test.gif", "text/plain", 2500000, is);
+            fmgr.saveFile(testWeblog, "test.gif", "text/plain", 2500000, is);
         } catch (Exception ex) {
             log.error(ex);
             exception = ex;
@@ -186,7 +188,7 @@
         
         try {
             // forbidden types check should fail
-            fmgr.saveFile(testWeblog.getHandle(), "test.gif", "text/plain", 10, is);
+            fmgr.saveFile(testWeblog, "test.gif", "text/plain", 10, is);
         } catch (Exception ex) {
             log.error(ex);
             exception = ex;
@@ -202,7 +204,7 @@
         
         try {
             // uploads disabled should fail
-            fmgr.saveFile(testWeblog.getHandle(), "test.gif", "text/plain", 10, is);
+            fmgr.saveFile(testWeblog, "test.gif", "text/plain", 10, is);
         } catch (Exception ex) {
             log.error(ex);
             exception = ex;

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/UploadFile.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/UploadFile.jsp?view=diff&rev=453354&r1=453353&r2=453354
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/UploadFile.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/UploadFile.jsp Thu Oct  5 13:19:28 2006
@@ -100,6 +100,7 @@
                 value='<%= bundle.getString("uploadFiles.upload") %>' /> 
             <input type="hidden" name="method" value="upload" />
             <input type="hidden" name="weblog" value='<%= model.getWebsite().getHandle() %>'>
+            <input type="hidden" name="path" value='<c:out value="${model.path}"/>'>
             <br />
             <br />
             
@@ -113,7 +114,8 @@
 
 <h1><fmt:message key="uploadFiles.manageFiles" /></h1>    
 <html:form action="/roller-ui/authoring/uploadFiles" method="post">
-
+    <html:hidden property="path"/>
+    
     <table class="rollertable">
 
         <tr class="rHeaderTr">
@@ -122,19 +124,49 @@
             <th class="rollertable">Delete</td>
         </tr>
 
+        <c:if test="${!model.showingRoot}">
+            <roller:row oddStyleClass="rollertable_odd" evenStyleClass="rollertable_even">
+                <td class="rollertable">
+                    <c:url var="dirUrl" value="/roller-ui/authoring/uploadFiles.do">
+                        <c:param name="path" value="${model.parentPath}" />
+                    </c:url>
+                    <img src='<c:url value="/images/folder.png"/>' style="padding:0px" />
+                    <a href='<c:out value="${dirUrl}" />'>..</a>
+                </td>
+                <td class="rollertable" align="right">
+                    &nbsp;
+                </td>
+                <td class="rollertable" align="center">
+                    &nbsp;
+                </td>
+           </roller:row>
+        </c:if>
         <c:forEach var="loopfile" items="${model.files}" >
            <roller:row oddStyleClass="rollertable_odd" evenStyleClass="rollertable_even">
                 <td class="rollertable">
-                    <img src='<c:url value="/images/image.png"/>' style="padding:0px" />
-                    <a href='<c:out value="${model.resourcesBaseURL}" /><c:out value="${loopfile.name}" />'>
-                        <c:out value="${loopfile.name}" />
-                    </a>
+                    <c:choose>
+                        <c:when test="${loopfile.directory}">
+                            <c:url var="dirUrl" value="/roller-ui/authoring/uploadFiles.do">
+                                <c:param name="path" value="${loopfile.path}" />
+                            </c:url>
+                            <img src='<c:url value="/images/folder.png"/>' style="padding:0px" />
+                            <a href='<c:out value="${dirUrl}" />'>
+                                <c:out value="${loopfile.name}" />
+                            </a>
+                        </c:when>
+                        <c:otherwise>
+                            <img src='<c:url value="/images/image.png"/>' style="padding:0px" />
+                            <a href='<c:out value="${model.resourcesBaseURL}" /><c:out value="${loopfile.path}" />'>
+                                <c:out value="${loopfile.name}" />
+                            </a>
+                        </c:otherwise>
+                    </c:choose>
                 </td>
                 <td class="rollertable" align="right">
                     <fmt:formatNumber value="${loopfile.length / 1024}" type="number" maxFractionDigits="2" />&nbsp;KB
                 </td>
                 <td class="rollertable" align="center">
-                   <input type="checkbox" name="deleteFiles" value='<c:out value="${loopfile.name}" />' />
+                   <input type="checkbox" name="deleteFiles" value='<c:out value="${loopfile.path}" />' />
                 </td>
            </roller:row>