### Eclipse Workspace Patch 1.0
#P fluid-components
Index: src/webapp/fluid-components/html/templates/Uploader.html
===================================================================
--- src/webapp/fluid-components/html/templates/Uploader.html	(revision 6183)
+++ src/webapp/fluid-components/html/templates/Uploader.html	(working copy)
@@ -122,7 +122,12 @@
             
         <script type="text/javascript">
             var myUploader = fluid.progressiveEnhanceableUploader(".fluid-uploader", ".fl-progressive-enhanceable", {
-                uploadManager: "fluid.demoUploadManager"
+                uploadManager: "fluid.demoUploadManager",
+                            
+                        options: {
+                      
+                            debug: true
+                        }
             });
         </script> 
     </body>
Index: src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js
===================================================================
--- src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js	(revision 6183)
+++ src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js	(working copy)
@@ -32,7 +32,7 @@
         
         var resetStatusForAllFiles = function () {
             for (var i = 0; i < allFiles.length; i++) {
-                allFiles[i].filestatus = fluid.fileQueue.fileStatusConstants.QUEUED;
+                allFiles[i].filestatus = fluid.uploader.fileStatusConstants.QUEUED;
             }
         };
         
Index: src/webapp/fluid-components/js/fluid/uploader/FileQueue.js
===================================================================
--- src/webapp/fluid-components/js/fluid/uploader/FileQueue.js	(revision 6183)
+++ src/webapp/fluid-components/js/fluid/uploader/FileQueue.js	(working copy)
@@ -32,13 +32,13 @@
     
     var getUploadedFiles = function (that) {
         return filterFiles(that.files, function (file) {
-            return (file.filestatus === fluid.fileQueue.fileStatusConstants.COMPLETE);
+            return (file.filestatus === fluid.uploader.fileStatusConstants.COMPLETE);
         });
     };
     
     var getReadyFiles = function (that) {
         return filterFiles(that.files, function (file) {
-            return (file.filestatus === fluid.fileQueue.fileStatusConstants.QUEUED);
+            return (file.filestatus === fluid.uploader.fileStatusConstants.QUEUED || file.filestatus === fluid.uploader.fileStatusConstants.CANCELLED);
         });
     };
 
@@ -54,6 +54,7 @@
             files: [],
             totalBytes: 0,
             numFilesCompleted: 0,
+            numFilesErrored: 0,
             bytesUploadedForFile: 0,
             previousBytesUploadedForFile: 0,
             totalBytesUploaded: 0
@@ -127,13 +128,5 @@
         }        
         return totalBytes;
     };
-    
-    fluid.fileQueue.fileStatusConstants = {
-        QUEUED: -1,
-	    IN_PROGRESS: -2,
-	    ERROR: -3,
-        COMPLETE: -4,
-        CANCELLED: -5
-    };
           
 })(jQuery, fluid_0_6);
Index: src/webapp/fluid-components/js/fluid/uploader/Uploader.js
===================================================================
--- src/webapp/fluid-components/js/fluid/uploader/Uploader.js	(revision 6183)
+++ src/webapp/fluid-components/js/fluid/uploader/Uploader.js	(working copy)
@@ -190,8 +190,7 @@
     
     var showErrorForFile = function (that, file, error) {
         hideFileProgress(that, file);
-        if (file.filestatus === fluid.fileQueue.fileStatusConstants.ERROR) {
-         
+        if (file.filestatus === fluid.uploader.fileStatusConstants.ERROR) {
             // file errored
             var fileRowElm = rowForFile(that, file);
             changeRowState(fileRowElm, that.options.styles.error);
@@ -368,6 +367,8 @@
 
     var setStateLoaded = function (that) {
         that.locate("browseButton").text(that.options.strings.buttons.addMore);
+        hideElement(that, that.locate("pauseButton"));
+        showElement(that, that.locate("uploadButton"));
         enableElement(that, that.locate("uploadButton"));
         enableElement(that, that.locate("browseButton"));
         hideElement(that, that.locate("instructions"));
@@ -397,7 +398,7 @@
     };
         
     var updateTotalProgress = function (that) {
-        var batch = that.uploadManager.queue.currentBatch;        
+        var batch = that.uploadManager.queue.currentBatch;
         var totalPercent = fluid.uploader.derivePercent(batch.totalBytesUploaded, batch.totalBytes);
              
         var totalProgressStr = fluid.stringTemplate(that.options.strings.progress.totalProgressLabel, {
@@ -451,7 +452,11 @@
     
     var updateStateAfterCompletion = function (that) {
         hideTotalProgress(that);
-        setStateDone(that);
+        if (that.uploadManager.queue.getReadyFiles().length === 0) {
+            setStateDone(that);
+        } else {
+            setStateLoaded(that);
+        }
     };
     
     var bindModelEvents = function (that) {
@@ -471,8 +476,8 @@
             updateTotalProgress(that); 
         });
         
-        that.events.onFileError.addListener(function (file, error) {
-            if (error === SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
+        that.events.onFileError.addListener(function (file, error, message) {
+            if (error === fluid.uploader.errorConstants.UPLOAD_STOPPED) {
                 // user stopped
                 updateStateAfterCompletion(that);
             }
@@ -646,4 +651,25 @@
         }
     });
     
+    fluid.uploader.errorConstants = {
+        HTTP_ERROR: -200,
+	    MISSING_UPLOAD_URL: -210,
+	    IO_ERROR: -220,
+	    SECURITY_ERROR: -230,
+	    UPLOAD_LIMIT_EXCEEDED: -240,
+	    UPLOAD_FAILED: -250,
+	    SPECIFIED_FILE_ID_NOT_FOUND: -260,
+	    FILE_VALIDATION_FAILED: -270,
+	    FILE_CANCELLED: -280,
+	    UPLOAD_STOPPED: -290
+    };
+    
+    fluid.uploader.fileStatusConstants = {
+        QUEUED: -1,
+	    IN_PROGRESS: -2,
+	    ERROR: -3,
+        COMPLETE: -4,
+        CANCELLED: -5
+    };
+    
 })(jQuery, fluid_0_6);
Index: src/webapp/tests/fluid-tests/uploader/js/FileQueueTests.js
===================================================================
--- src/webapp/tests/fluid-tests/uploader/js/FileQueueTests.js	(revision 6183)
+++ src/webapp/tests/fluid-tests/uploader/js/FileQueueTests.js	(working copy)
@@ -10,7 +10,7 @@
              index : 0, // The index of this file for use in getFile(i) 
              name : "Mountain.jpg", // The file name. The path is not included. 
              size : 400000, // The file size in bytes   
-             filestatus: fluid.fileQueue.fileStatusConstants.QUEUED // initial file queued status
+             filestatus: fluid.uploader.fileStatusConstants.QUEUED // initial file queued status
         };
         
         var oceanTestFile = {
@@ -18,7 +18,7 @@
              index : 1, // The index of this file for use in getFile(i) 
              name : "Ocean.jpg", // The file name. The path is not included. 
              size : 950000000, // The file size in bytes   
-             filestatus: fluid.fileQueue.fileStatusConstants.QUEUED // initial file queued status
+             filestatus: fluid.uploader.fileStatusConstants.QUEUED // initial file queued status
         };
         
         // More test files
@@ -53,7 +53,7 @@
         var loadQueue = function (fileArray, queue) {
             for (var i = 0; i < fileArray.length; i++) {
                 queue.addFile(fileArray[i]);
-                queue.files[i].filestatus = fluid.fileQueue.fileStatusConstants.QUEUED;
+                queue.files[i].filestatus = fluid.uploader.fileStatusConstants.QUEUED;
             }
         };
         
@@ -158,7 +158,7 @@
         });
         
         fileQueueViewTests.test("fileQueue: getUploadedFiles() and sizeOfUploadedFiles()", function () {
-            jqUnit.expect(16);
+            jqUnit.expect(24);
             
             var testQueue = fluid.fileQueue();
             jqUnit.assertEquals("getReadyFiles() should contain 0 files at the start",
@@ -190,8 +190,23 @@
                                 0,
                                 testQueue.sizeOfUploadedFiles());
             
-            testQueue.files[0].filestatus = fluid.fileQueue.fileStatusConstants.COMPLETE;
+            testQueue.files[0].filestatus = fluid.uploader.fileStatusConstants.CANCELLED;
             
+            jqUnit.assertEquals("changed status of Mountain to CANCELLED, getReadyFiles() should contain 2 files",
+                                2,
+                                testQueue.getReadyFiles().length);
+            jqUnit.assertEquals("----- and sizeOfReadyFiles() should now return 950400000",
+                                950400000,
+                                testQueue.sizeOfReadyFiles());
+            jqUnit.assertEquals("----- and getUploadedFiles() should contain 0 file",
+                                0,
+                                testQueue.getUploadedFiles().length);
+            jqUnit.assertEquals("----- and sizeOfUploadedFiles() should contain 0",
+                                0,
+                                testQueue.sizeOfUploadedFiles());
+
+            testQueue.files[0].filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
+
             jqUnit.assertEquals("changed status of Mountain to COMPLETE, getReadyFiles() should contain 1 files",
                                 1,
                                 testQueue.getReadyFiles().length);
@@ -205,8 +220,23 @@
                                 400000,
                                 testQueue.sizeOfUploadedFiles());
                                                          
-            testQueue.files[1].filestatus = fluid.fileQueue.fileStatusConstants.COMPLETE;
+            testQueue.files[1].filestatus = fluid.uploader.fileStatusConstants.CANCELLED;
             
+            jqUnit.assertEquals("changed status of Ocean to CANCELLED, getReadyFiles() should contain 1 files",
+                                1,
+                                testQueue.getReadyFiles().length);
+            jqUnit.assertEquals("----- and sizeOfReadyFiles() should now return 950000000",
+                                950000000,
+                                testQueue.sizeOfReadyFiles());
+            jqUnit.assertEquals("----- and getUploadedFiles() should contain 1 files",
+                                1,
+                                testQueue.getUploadedFiles().length);
+            jqUnit.assertEquals("----- and sizeOfUploadedFiles() should contain 400000",
+                                400000,
+                                testQueue.sizeOfUploadedFiles());
+
+            testQueue.files[1].filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
+            
             jqUnit.assertEquals("changed status of Ocean to COMPLETE, getReadyFiles() should contain 0 files",
                                 0,
                                 testQueue.getReadyFiles().length);
@@ -258,14 +288,14 @@
                                 0,
                                 testQueue.currentBatch.totalBytes);
             
-            testQueue.files[0].filestatus = fluid.fileQueue.fileStatusConstants.COMPLETE;
+            testQueue.files[0].filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
             testQueue.updateCurrentBatch();
             
             jqUnit.assertEquals("first file COMPLETE, setupCurrentBatch(), currentBatch should contain 4 files",
                                 4,
                                 testQueue.currentBatch.files.length);
                                 
-            testQueue.files[1].filestatus = fluid.fileQueue.fileStatusConstants.COMPLETE;
+            testQueue.files[1].filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
             testQueue.setupCurrentBatch();
             
             jqUnit.assertEquals("second file COMPLETE, updateCurrentBatch(), currentBatch should contain 3 files",
Index: src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js
===================================================================
--- src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js	(revision 6183)
+++ src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js	(working copy)
@@ -75,7 +75,7 @@
             
             fireAfterFileComplete(file);
             if (that.queue.isUploading && batch.numFilesCompleted < batch.files.length) {
-                that.uploadNextFile();
+                that.uploadNextFile(batch.files[0].id);
             } else {
                 finishUploading(that);
             }
@@ -146,10 +146,12 @@
         });
         
         that.events.onFileError.addListener(function (file, error) {
-            if (error === SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
+            if (error === fluid.uploader.errorConstants.UPLOAD_STOPPED) {
                 that.queue.isUploading = false;
+            } else {
+                that.queue.currentBatch.numFilesErrored++;
             }
-            fileStatusUpdater(file, error);
+            fileStatusUpdater(file);
         });
         
         that.events.onFileSuccess.addListener(function (file) {
@@ -249,6 +251,7 @@
         fileQueueLimit: 0,
         debug: false
     });
+    
 })(jQuery, fluid_0_6);
 
 
@@ -270,7 +273,7 @@
     
     var finishUploading = function (that) {
         var file = that.demoState.currentFile;
-        file.filestatus = fluid.fileQueue.fileStatusConstants.COMPLETE;
+        file.filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
         that.events.onFileSuccess.fire(file);
         that.invokeAfterRandomDelay(function () {
             that.demoState.fileIdx++;
@@ -301,17 +304,17 @@
         that.demoState.shouldPause = false;
         
         that.events.onFileStart.fire(that.demoState.currentFile);
-        that.demoState.currentFile.filestatus = fluid.fileQueue.fileStatusConstants.IN_PROGRESS;
+        that.demoState.currentFile.filestatus = fluid.uploader.fileStatusConstants.IN_PROGRESS;
         simulateUpload(that);
     };
 
     var pauseDemo = function (that) {
         that.demoState.shouldPause = true;
-        that.demoState.currentFile.filestatus = fluid.fileQueue.fileStatusConstants.CANCELLED;
+        that.demoState.currentFile.filestatus = fluid.uploader.fileStatusConstants.CANCELLED;
         
         // In SWFUpload's world, pausing is a combinination of an UPLOAD_STOPPED error and a complete.
         that.events.onFileError.fire(that.demoState.currentFile, 
-                                       SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED, 
+                                       fluid.uploader.errorConstants.UPLOAD_STOPPED, 
                                        "The demo upload was paused by the user.");
         // This is a hack that needs to be addressed.
         that.swfUploadSettings.upload_complete_handler(that.demoState.currentFile);
Index: src/webapp/tests/fluid-tests/uploader/FileQueue-test.html
===================================================================
--- src/webapp/tests/fluid-tests/uploader/FileQueue-test.html	(revision 6183)
+++ src/webapp/tests/fluid-tests/uploader/FileQueue-test.html	(working copy)
@@ -11,6 +11,7 @@
     <script type="text/javascript" src="../../jqUnit/jqUnit.js"></script>
     
     <script src="../../../fluid-components/js/fluid/Fluid.js" type="text/javascript"></script>
+    <script type="text/javascript" src="../../../fluid-components/js/fluid/uploader/Uploader.js"></script>
     <script type="text/javascript" src="../../../fluid-components/js/fluid/uploader/FileQueue.js"></script>
     
     <script type="text/javascript" src="js/FileQueueTests.js"></script>
