From 68e165a96aeedc285bb0b14e75712e90576e4bd4 Mon Sep 17 00:00:00 2001 From: Christos Stathis Date: Wed, 15 Feb 2012 17:32:14 +0200 Subject: [PATCH] Meta for files is requested just before showing the propeties dialog (issue #2052) --- .../web/client/commands/PropertiesCommand.java | 36 ++++++++++++++++++-- .../grnet/pithos/web/client/foldertree/File.java | 1 - .../pithos/web/client/foldertree/Resource.java | 1 - 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java b/src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java index fc40b7e..4cf6938 100644 --- a/src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java +++ b/src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java @@ -43,9 +43,15 @@ import gr.grnet.pithos.web.client.FolderPropertiesDialog; 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.HeadRequest; +import gr.grnet.pithos.web.client.rest.RestException; import java.util.List; +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.user.client.Command; import com.google.gwt.user.client.ui.PopupPanel; @@ -66,7 +72,7 @@ public class PropertiesCommand implements Command { private Object resource; - private Pithos app; + Pithos app; /** * @param _containerPanel @@ -109,8 +115,32 @@ public class PropertiesCommand implements Command { else { switch (tabToShow) { case PROPERTIES: - FilePropertiesDialog dlg = new FilePropertiesDialog(app, files.get(0)); - dlg.center(); + File f = files.get(0); + final FilePropertiesDialog dlg = new FilePropertiesDialog(app, f); + HeadRequest headFile = new HeadRequest(File.class, app.getApiPath(), f.getOwner(), f.getUri(), f) { + + @Override + public void onSuccess(File _result) { + dlg.center(); + } + + @Override + public void onError(Throwable t) { + GWT.log("Error heading file", t); + app.setError(t); + if (t instanceof RestException) + app.displayError("Error heading file: " + ((RestException) t).getHttpStatusText()); + else + app.displayError("System error heading folder: " + t.getMessage()); + } + + @Override + protected void onUnauthorized(Response response) { + app.sessionExpired(); + } + }; + headFile.setHeader("X-Auth-Token", app.getToken()); + Scheduler.get().scheduleDeferred(headFile); break; case PERMISSIONS: FilePermissionsDialog dlg1 = new FilePermissionsDialog(app, files.get(0)); diff --git a/src/gr/grnet/pithos/web/client/foldertree/File.java b/src/gr/grnet/pithos/web/client/foldertree/File.java index 2f0c56e..4956981 100644 --- a/src/gr/grnet/pithos/web/client/foldertree/File.java +++ b/src/gr/grnet/pithos/web/client/foldertree/File.java @@ -217,7 +217,6 @@ public class File extends Resource { return container; } - //Never called public static File createFromResponse(String owner, Response response, File result) { result.populate(owner, response); return result; diff --git a/src/gr/grnet/pithos/web/client/foldertree/Resource.java b/src/gr/grnet/pithos/web/client/foldertree/Resource.java index 2e97018..9c1a482 100644 --- a/src/gr/grnet/pithos/web/client/foldertree/Resource.java +++ b/src/gr/grnet/pithos/web/client/foldertree/Resource.java @@ -109,7 +109,6 @@ public abstract class Resource { result1 = (T) Folder.createFromResponse(owner, response, (Folder) result); } else if (aClass.equals(File.class)) { - //This case cannot happen since we never GET a file directly. Files are always fetch through their parent Folder result1 = (T) File.createFromResponse(owner, response, (File) result); } else if (aClass.equals(SharingUsers.class)) { -- 1.7.10.4