Revision 07a1b5fe src/gr/grnet/pithos/web/client/foldertree/File.java
b/src/gr/grnet/pithos/web/client/foldertree/File.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
package gr.grnet.pithos.web.client.foldertree; |
6 | 6 |
|
7 |
import com.google.gwt.http.client.Response; |
|
8 |
import com.google.gwt.i18n.client.DateTimeFormat; |
|
9 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
|
7 | 10 |
import com.google.gwt.i18n.client.NumberFormat; |
8 | 11 |
import com.google.gwt.json.client.JSONObject; |
12 |
import com.google.gwt.json.client.JSONParser; |
|
13 |
import com.google.gwt.json.client.JSONValue; |
|
9 | 14 |
import java.util.Date; |
10 | 15 |
|
11 | 16 |
public class File extends Resource { |
... | ... | |
31 | 36 |
|
32 | 37 |
private boolean inTrash; |
33 | 38 |
|
39 |
private String container; |
|
40 |
|
|
34 | 41 |
public String getContentType() { |
35 | 42 |
return contentType; |
36 | 43 |
} |
... | ... | |
99 | 106 |
return inTrash; |
100 | 107 |
} |
101 | 108 |
|
102 |
public void populate(JSONObject o) { |
|
103 |
String path = unmarshallString(o, "name");
|
|
109 |
public void populate(JSONObject o, String container) {
|
|
110 |
path = unmarshallString(o, "name"); |
|
104 | 111 |
if (path.contains("/")) |
105 | 112 |
name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix |
106 | 113 |
else |
... | ... | |
112 | 119 |
lastModified = unmarshallDate(o, "last_modified"); |
113 | 120 |
modifiedBy = unmarshallString(o, "modified_by"); |
114 | 121 |
versionTimestamp = unmarshallDate(o, "version_timestamp"); |
122 |
this.container = container; |
|
115 | 123 |
} |
116 | 124 |
|
117 | 125 |
public boolean equals(Object other) { |
... | ... | |
125 | 133 |
public int hashCode() { |
126 | 134 |
return name.hashCode(); |
127 | 135 |
} |
136 |
|
|
137 |
public String getContainer() { |
|
138 |
return container; |
|
139 |
} |
|
140 |
|
|
141 |
public static File createFromResponse(Response response, File result) { |
|
142 |
result.populate(response); |
|
143 |
return result; |
|
144 |
} |
|
145 |
|
|
146 |
private void populate(Response response) { |
|
147 |
String header = response.getHeader("X-Object-Meta-Trash"); |
|
148 |
if (header != null) |
|
149 |
inTrash = Boolean.valueOf(header); |
|
150 |
else |
|
151 |
inTrash = false; |
|
152 |
|
|
153 |
JSONValue json = JSONParser.parseStrict(response.getText()); |
|
154 |
JSONObject o = json.isObject(); |
|
155 |
} |
|
128 | 156 |
} |
Also available in: Unified diff