/*
- * 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
package gr.grnet.pithos.web.client.commands;
import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.rest.DeleteCommand;
+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.DeleteRequest;
+import gr.grnet.pithos.web.client.rest.GetRequest;
import gr.grnet.pithos.web.client.rest.RestException;
+import java.util.Iterator;
+
import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.PopupPanel;
public class EmptyTrashCommand implements Command{
private PopupPanel containerPanel;
- private Pithos app;
+ Pithos app;
public EmptyTrashCommand(Pithos _app, PopupPanel _containerPanel){
app = _app;
@Override
public void execute() {
- containerPanel.hide();
- DeleteCommand df = new DeleteCommand(app, app.getTreeView().getTrash().getUri()){
-
- @Override
- public void onComplete() {
- app.getTreeView().updateTrashNode();
- app.showFileList(true);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if(t instanceof RestException){
- int statusCode = ((RestException)t).getHttpStatusCode();
- if(statusCode == 405)
- app.displayError("You don't have the necessary permissions");
- else if(statusCode == 404)
- app.displayError("Resource does not exist");
- else
- app.displayError("Unable to empty trash:"+((RestException)t).getHttpStatusText());
- }
- else
- app.displayError("System error emptying trash:"+t.getMessage());
- }
- };
- DeferredCommand.addCommand(df);
+ if (containerPanel != null)
+ containerPanel.hide();
+
+ app.emptyTrash();
}
-
}