Fixed various compilation warnings
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / ToTrashCommand.java
index 32946d9..c28b01b 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 Object resource;
+       protected Pithos app;
+       protected Object resource;
 
-       public ToTrashCommand(GSS _app, PopupPanel _containerPanel, Object _resource){
+       public ToTrashCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
                containerPanel = _containerPanel;
         app = _app;
         resource = _resource;
@@ -80,11 +72,13 @@ public class ToTrashCommand implements Command{
         if (containerPanel != null)
                containerPanel.hide();
         if (resource instanceof List) {
-            Iterator<File> iter = ((List<File>) resource).iterator();
+            @SuppressWarnings("unchecked")
+                       Iterator<File> iter = ((List<File>) resource).iterator();
             trashFiles(iter, new Command() {
-                @Override
+                @SuppressWarnings("unchecked")
+                               @Override
                 public void execute() {
-                    app.get().updateFolder(((List<File>) resource).get(0).getParent());
+                    app.updateFolder(((List<File>) resource).get(0).getParent(), true);
                 }
             });
         }
@@ -93,7 +87,7 @@ public class ToTrashCommand implements Command{
             trashFolder(toBeTrashed, new Command() {
                 @Override
                 public void execute() {
-                    app.updateFolder(toBeTrashed.getParent());
+                    app.updateFolder(toBeTrashed.getParent(), true);
                 }
             });
 
@@ -101,10 +95,10 @@ 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) {
+            public void onSuccess(@SuppressWarnings("unused") Resource result) {
                 Iterator<File> iter = f.getFiles().iterator();
                 trashFiles(iter, new Command() {
                     @Override
@@ -135,13 +129,13 @@ public class ToTrashCommand implements Command{
         Scheduler.get().scheduleDeferred(trashFolder);
     }
 
-    private void trashFiles(final Iterator<File> iter, final Command callback) {
+    protected 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) {
+                public void onSuccess(@SuppressWarnings("unused") Resource result) {
                     trashFiles(iter, callback);
                 }
 
@@ -149,10 +143,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());
@@ -164,7 +158,7 @@ public class ToTrashCommand implements Command{
         }
     }
 
-    private void trashSubfolders(final Iterator<Folder> iter, final Command callback) {
+    protected void trashSubfolders(final Iterator<Folder> iter, final Command callback) {
         if (iter.hasNext()) {
             final Folder f = iter.next();
             trashFolder(f, callback);