Context menu and toolbar has returned to shared by me view
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / ToTrashCommand.java
index 614b8ed..90f159b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or
  * without modification, are permitted provided that the following
@@ -81,7 +81,13 @@ public class ToTrashCommand implements Command{
                 @SuppressWarnings("unchecked")
                                @Override
                 public void execute() {
-                    app.updateFolder(((List<File>) resource).get(0).getParent(), true, null);
+                    app.updateFolder(((List<File>) resource).get(0).getParent(), true, new Command() {
+                                               
+                                               @Override
+                                               public void execute() {
+                                                       app.updateTrash(false, null);
+                                               }
+                                       }, true);
                 }
             });
         }
@@ -90,7 +96,13 @@ public class ToTrashCommand implements Command{
             trashFolder(toBeTrashed, new Command() {
                 @Override
                 public void execute() {
-                    app.updateFolder(toBeTrashed.getParent(), true, null);
+                    app.updateFolder(toBeTrashed.getParent(), true, new Command() {
+                                               
+                                               @Override
+                                               public void execute() {
+                                                       app.updateTrash(false, null);
+                                               }
+                                       }, true);
                 }
             });
 
@@ -101,7 +113,7 @@ public class ToTrashCommand implements Command{
         String path = "/" + Pithos.TRASH_CONTAINER + "/" + f.getPrefix();
         PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {
             @Override
-            public void onSuccess(@SuppressWarnings("unused") Resource result) {
+            public void onSuccess(Resource result) {
                GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
 
                                        @Override
@@ -115,10 +127,10 @@ public class ToTrashCommand implements Command{
                                                                        
                                                                        @Override
                                                                        public void execute() {
-                                                                               DeleteRequest deleteFolder = new DeleteRequest(app.getApiPath(), _f.getOwner(), _f.getUri()) {
+                                                                               DeleteRequest deleteFolder = new DeleteRequest(app.getApiPath(), _f.getOwner(), URL.encode(_f.getUri())) {
                                                                                        
                                                                                        @Override
-                                                                                       public void onSuccess(@SuppressWarnings("unused") Resource _result) {
+                                                                                       public void onSuccess(Resource _result) {
                                                                                                if (callback != null)
                                                                                                        callback.execute();
                                                                                        }
@@ -201,7 +213,7 @@ public class ToTrashCommand implements Command{
             String path = "/" + Pithos.TRASH_CONTAINER + "/" + file.getPath();
             PutRequest trashFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
                 @Override
-                public void onSuccess(@SuppressWarnings("unused") Resource result) {
+                public void onSuccess(Resource result) {
                     trashFiles(iter, callback);
                 }