import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.user.client.ui.DockPanel;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SelectionChangeEvent.Handler;
import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel.NodeInfo;
import gr.grnet.pithos.web.client.clipboard.Clipboard;
import gr.grnet.pithos.web.client.commands.GetUserCommand;
import gr.grnet.pithos.web.client.foldertree.AccountResource;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
}
private void showFiles(Folder f) {
- Set<File> files = f.getFiles();
- fileList.setFiles(new ArrayList<File>(files));
inner.selectTab(0);
+ Set<File> files = f.getFiles();
+ Iterator<File> iter = files.iterator();
+ fetchFile(iter, files);
+ }
+
+ private void fetchFile(final Iterator<File> iter, final Set<File> files) {
+ if (iter.hasNext()) {
+ File file = iter.next();
+ String path = getApiPath() + username + "/" + file.getContainer() + "/" + file.getPath() + "?format=json";
+ GetRequest<File> getFile = new GetRequest<File>(File.class, path, file) {
+ @Override
+ public void onSuccess(File result) {
+ fetchFile(iter, files);
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ GWT.log("Error getting file", t);
+ if (t instanceof RestException)
+ GSS.get().displayError("Error getting file: " + ((RestException) t).getHttpStatusText());
+ else
+ GSS.get().displayError("System error fetching file: " + t.getMessage());
+ }
+ };
+ getFile.setHeader("X-Auth-Token", "0000");
+ Scheduler.get().scheduleDeferred(getFile);
+ }
+ else
+ fileList.setFiles(new ArrayList<File>(files));
}
/**
package gr.grnet.pithos.web.client.foldertree;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONValue;
import java.util.Date;
public class File extends Resource {
private boolean inTrash;
+ private String container;
+
public String getContentType() {
return contentType;
}
return inTrash;
}
- public void populate(JSONObject o) {
- String path = unmarshallString(o, "name");
+ public void populate(JSONObject o, String container) {
+ path = unmarshallString(o, "name");
if (path.contains("/"))
name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
else
lastModified = unmarshallDate(o, "last_modified");
modifiedBy = unmarshallString(o, "modified_by");
versionTimestamp = unmarshallDate(o, "version_timestamp");
+ this.container = container;
}
public boolean equals(Object other) {
public int hashCode() {
return name.hashCode();
}
+
+ public String getContainer() {
+ return container;
+ }
+
+ public static File createFromResponse(Response response, File result) {
+ result.populate(response);
+ return result;
+ }
+
+ private void populate(Response response) {
+ String header = response.getHeader("X-Object-Meta-Trash");
+ if (header != null)
+ inTrash = Boolean.valueOf(header);
+ else
+ inTrash = false;
+
+ JSONValue json = JSONParser.parseStrict(response.getText());
+ JSONObject o = json.isObject();
+ }
}