package gr.grnet.pithos.web.client.foldertree;
+import com.google.gwt.http.client.Header;
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.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
+import java.io.StringWriter;
+import java.security.Key;
import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
public class File extends Resource {
private String name;
private String container;
+ private Folder parent;
+
+ private Set<String> tags = new HashSet<String>();
+
public String getContentType() {
return contentType;
}
return versionTimestamp;
}
- @Override
- public String getLastModifiedSince() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
public String getUri() {
- return path + "/" + name;
+ return "/" + container + "/" + path;
}
public String getOwner() {
return inTrash;
}
- public void populate(JSONObject o, String container) {
+ public void populate(Folder parent, JSONObject o, String container) {
+ this.parent = parent;
path = unmarshallString(o, "name");
if (path.contains("/"))
name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
modifiedBy = unmarshallString(o, "modified_by");
versionTimestamp = unmarshallDate(o, "version_timestamp");
this.container = container;
+
+ for (String key : o.keySet())
+ if (key.startsWith("x_object_meta_") && !key.equals("x_object_meta_trash"))
+ tags.add(key.substring("x_object_meta_".length()).trim().toLowerCase());
}
public boolean equals(Object other) {
}
private void populate(Response response) {
+ for (Header h : response.getHeaders()) {
+ String header = h.getName();
+ if (header.startsWith("X-Object-Meta-") && !header.equals("X-Object-Meta-Trash"))
+ tags.add(header.substring("X-Object-Meta-".length()).trim().toLowerCase());
+
+ }
String header = response.getHeader("X-Object-Meta-Trash");
if (header != null)
inTrash = Boolean.valueOf(header);
JSONValue json = JSONParser.parseStrict(response.getText());
JSONObject o = json.isObject();
}
+
+ public Folder getParent() {
+ return parent;
+ }
+
+ public Set<String> getTags() {
+ return tags;
+ }
}