Use an exponential backoff strategy for retrying rolled back transactions.
[pithos] / src / gr / ebs / gss / client / FileUploadDialog.java
index b3d8ad3..fa261c6 100644 (file)
@@ -44,6 +44,7 @@ import com.google.gwt.user.client.ui.FormPanel;
 import com.google.gwt.user.client.ui.FormSubmitCompleteEvent;\r
 import com.google.gwt.user.client.ui.FormSubmitEvent;\r
 import com.google.gwt.user.client.ui.Grid;\r
+import com.google.gwt.user.client.ui.HTML;\r
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
 import com.google.gwt.user.client.ui.Hidden;\r
 import com.google.gwt.user.client.ui.HorizontalPanel;\r
@@ -59,7 +60,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
 \r
        protected int prgBarInterval = 1500;\r
 \r
-       protected ProgressBar progressBar;\r
+       private ProgressBar progressBar;\r
 \r
        protected RepeatingTimer repeater = new RepeatingTimer(this, prgBarInterval);\r
 \r
@@ -97,6 +98,11 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                // Create a panel to hold all of the form widgets.\r
                VerticalPanel panel = new VerticalPanel();\r
                form.setWidget(panel);\r
+               final HTML info = new HTML("You may select a file to upload. Install" +\r
+                               " <a href='http://gears.google.com/' target='_blank'>Google " +\r
+                               "Gears</a><br> for uploading multiple files simultaneously.");\r
+               info.addStyleName("gss-uploadNote");\r
+               panel.add(info);\r
                final Hidden date = new Hidden("Date", "");\r
                panel.add(date);\r
                final Hidden auth = new Hidden("Authorization", "");\r
@@ -249,8 +255,10 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                return true;\r
        }\r
 \r
-\r
-       public void prepareAndSubmit(){\r
+       /**\r
+        * Make any last minute checks and start the upload.\r
+        */\r
+       public void prepareAndSubmit() {\r
                final String fname = getFilename(upload.getFilename());\r
                if (getFileForName(fname) == null) {\r
                        //we are going to create a file, so we check to see if there is a trashed file with the same name\r
@@ -436,6 +444,9 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                return filename + " " + i;\r
        }\r
 \r
+       /**\r
+        * Rename the conflicting trashed file with the supplied new name.\r
+        */\r
        private void updateTrashedFile(String newName, FileResource trashedFile) {\r
                JSONObject json = new JSONObject();\r
                json.put("name", new JSONString(newName));\r
@@ -448,21 +459,22 @@ public class FileUploadDialog extends DialogBox implements Updateable {
 \r
                        @Override\r
                        public void onError(Throwable t) {\r
+                               GSS app = GSS.get();\r
                                GWT.log("", t);\r
                                if (t instanceof RestException) {\r
                                        int statusCode = ((RestException) t).getHttpStatusCode();\r
                                        if (statusCode == 405)\r
-                                               GSS.get().displayError("You don't have the necessary permissions");\r
+                                               app.displayError("You don't have the necessary permissions");\r
                                        else if (statusCode == 404)\r
-                                               GSS.get().displayError("User in permissions does not exist");\r
+                                               app.displayError("User in permissions does not exist");\r
                                        else if (statusCode == 409)\r
-                                               GSS.get().displayError("A file with the same name already exists");\r
+                                               app.displayError("A file with the same name already exists");\r
                                        else if (statusCode == 413)\r
-                                               GSS.get().displayError("Your quota has been exceeded");\r
+                                               app.displayError("Your quota has been exceeded");\r
                                        else\r
-                                               GSS.get().displayError("Unable to modify file:" +((RestException)t).getHttpStatusText());\r
+                                               app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
                                } else\r
-                                       GSS.get().displayError("System error modifying file:" + t.getMessage());\r
+                                       app.displayError("System error modifying file:" + t.getMessage());\r
                        }\r
 \r
                };\r