Removed all static references to the Pithos class
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / ToTrashCommand.java
index 32946d9..6795ac8 100644 (file)
 package gr.grnet.pithos.web.client.commands;
 
 import com.google.gwt.core.client.Scheduler;
-import gr.grnet.pithos.web.client.GSS;
+import gr.grnet.pithos.web.client.Pithos;
 import gr.grnet.pithos.web.client.foldertree.File;
 import gr.grnet.pithos.web.client.foldertree.Folder;
 import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.MultiplePostCommand;
-import gr.grnet.pithos.web.client.rest.PostCommand;
 import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.PutRequest;
 import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.FolderResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
 import com.google.gwt.user.client.ui.PopupPanel;
 
 /**
@@ -66,10 +58,10 @@ import com.google.gwt.user.client.ui.PopupPanel;
  */
 public class ToTrashCommand implements Command{
        private PopupPanel containerPanel;
-    private GSS app;
+    private Pithos app;
     private Object resource;
 
-       public ToTrashCommand(GSS _app, PopupPanel _containerPanel, Object _resource){
+       public ToTrashCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
                containerPanel = _containerPanel;
         app = _app;
         resource = _resource;
@@ -84,7 +76,7 @@ public class ToTrashCommand implements Command{
             trashFiles(iter, new Command() {
                 @Override
                 public void execute() {
-                    app.get().updateFolder(((List<File>) resource).get(0).getParent());
+                    app.updateFolder(((List<File>) resource).get(0).getParent());
                 }
             });
         }
@@ -101,8 +93,8 @@ public class ToTrashCommand implements Command{
        }
 
     private void trashFolder(final Folder f, final Command callback) {
-        String path = app.getApiPath() + app.getUsername() + f.getUri() + "?update=";
-        PostRequest trashFolder = new PostRequest(path) {
+        String path = f.getUri() + "?update=";
+        PostRequest trashFolder = new PostRequest(app.getApiPath(), app.getUsername(), path) {
             @Override
             public void onSuccess(Resource result) {
                 Iterator<File> iter = f.getFiles().iterator();
@@ -138,8 +130,8 @@ public class ToTrashCommand implements Command{
     private void trashFiles(final Iterator<File> iter, final Command callback) {
         if (iter.hasNext()) {
             File file = iter.next();
-            String path = app.getApiPath() + app.getUsername() + file.getUri() + "?update=";
-            PostRequest trashFile = new PostRequest(path) {
+            String path = file.getUri() + "?update=";
+            PostRequest trashFile = new PostRequest(app.getApiPath(), app.getUsername(), path) {
                 @Override
                 public void onSuccess(Resource result) {
                     trashFiles(iter, callback);
@@ -149,10 +141,10 @@ public class ToTrashCommand implements Command{
                 public void onError(Throwable t) {
                     GWT.log("", t);
                     if (t instanceof RestException) {
-                        GSS.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
                     }
                     else
-                        GSS.get().displayError("System error unable to copy file: "+t.getMessage());
+                        app.displayError("System error unable to copy file: "+t.getMessage());
                 }
             };
             trashFile.setHeader("X-Auth-Token", app.getToken());