commit 2c801ad7e9e6b4a3d10dac2b1a2360a1cc7b913c
Author: Christos Stathis <chstath@ebs.gr>
Date:   Thu Mar 22 17:14:54 2012 +0200

    Fixed a race condition duw to which renamed shared folders continued showing in myshared tree

diff --git a/src/gr/grnet/pithos/web/client/DeleteFolderDialog.java b/src/gr/grnet/pithos/web/client/DeleteFolderDialog.java
index 4259689..d80806c 100644
--- a/src/gr/grnet/pithos/web/client/DeleteFolderDialog.java
+++ b/src/gr/grnet/pithos/web/client/DeleteFolderDialog.java
@@ -101,7 +101,7 @@ public class DeleteFolderDialog extends DialogBox {
 		Button ok = new Button("Delete", new ClickHandler() {
 			@Override
 			public void onClick(ClickEvent event) {
-				app.deleteFolder(folder);
+				app.deleteFolder(folder, null);
 				hide();
 			}
 		});
@@ -123,7 +123,7 @@ public class DeleteFolderDialog extends DialogBox {
 			switch (evt.getKeyCode()) {
 				case KeyCodes.KEY_ENTER:
 					hide();
-					app.deleteFolder(folder);
+					app.deleteFolder(folder, null);
 					break;
 				case KeyCodes.KEY_ESCAPE:
 					hide();
diff --git a/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
index 71528a1..9e3e0d8 100644
--- a/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
+++ b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
@@ -213,7 +213,7 @@ public class FolderPermissionsDialog extends DialogBox {
                             app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {
                                 @Override
                                 public void execute() {
-                                    app.deleteFolder(folder);
+                                    app.deleteFolder(folder, null);
                                     updateMetadata(path + "?update=", perms);
                                 }
                             });
diff --git a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java
index 268b7de..ed8828f 100644
--- a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java
+++ b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java
@@ -303,14 +303,19 @@ public class FolderPropertiesDialog extends DialogBox {
                             app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {
                                 @Override
                                 public void execute() {
-                                    app.deleteFolder(folder);
-                                    app.updateFolder(folder.getParent(), false, new Command() {
-                            			
-                            			@Override
-                            			public void execute() {
-                            				app.updateMySharedRoot();
-                            			}
-                            		});
+                                    app.deleteFolder(folder, new Command() {
+										
+										@Override
+										public void execute() {
+		                                    app.updateFolder(folder.getParent(), false, new Command() {
+		                            			
+		                            			@Override
+		                            			public void execute() {
+		                            				app.updateMySharedRoot();
+		                            			}
+		                            		});
+										}
+									});
                                 }
                             });
                         }
diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java
index 3f3e0f3..191a4f5 100644
--- a/src/gr/grnet/pithos/web/client/Pithos.java
+++ b/src/gr/grnet/pithos/web/client/Pithos.java
@@ -813,7 +813,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
 		History.newItem(key);
 	}
 
-    public void deleteFolder(final Folder folder) {
+    public void deleteFolder(final Folder folder, final Command callback) {
         String path = getApiPath() + folder.getOwner() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(folder.getPrefix()) + "&t=" + System.currentTimeMillis();
         RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
         builder.setHeader("X-Auth-Token", getToken());
@@ -826,7 +826,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                         JSONArray array = json.isArray();
                         int i = 0;
                         if (array != null) {
-                            deleteObject(folder, i, array);
+                            deleteObject(folder, i, array, callback);
                         }
                     }
                 }
@@ -842,7 +842,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
         }
     }
 
-    void deleteObject(final Folder folder, final int i, final JSONArray array) {
+    void deleteObject(final Folder folder, final int i, final JSONArray array, final Command callback) {
         if (i < array.size()) {
             JSONObject o = array.get(i).isObject();
             if (o != null && !o.containsKey("subdir")) {
@@ -851,7 +851,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                 DeleteRequest delete = new DeleteRequest(getApiPath(), folder.getOwner(), URL.encode(path)) {
                     @Override
                     public void onSuccess(Resource result) {
-                        deleteObject(folder, i + 1, array);
+                        deleteObject(folder, i + 1, array, callback);
                     }
 
                     @Override
@@ -888,7 +888,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                                         array.set(l++, array2.get(j));
                                     }
                                 }
-                                deleteObject(folder, i + 1, array);
+                                deleteObject(folder, i + 1, array, callback);
                             }
                         }
 
@@ -913,6 +913,8 @@ public class Pithos implements EntryPoint, ResizeHandler {
 						@Override
 						public void execute() {
 							updateStatistics();
+							if (callback != null)
+								callback.execute();
 						}
 					});
                 }
diff --git a/src/gr/grnet/pithos/web/client/commands/PasteCommand.java b/src/gr/grnet/pithos/web/client/commands/PasteCommand.java
index 4d0f188..6ae2669 100644
--- a/src/gr/grnet/pithos/web/client/commands/PasteCommand.java
+++ b/src/gr/grnet/pithos/web/client/commands/PasteCommand.java
@@ -95,7 +95,7 @@ public class PasteCommand implements Command {
                     @Override
                     public void execute() {
                         app.getClipboard().clear();
-                        app.deleteFolder(tobeCopied);
+                        app.deleteFolder(tobeCopied, null);
                         app.updateFolder(folder, true, null);
                     }
                 });
