Revision b51c628b
b/src/gr/grnet/pithos/web/client/DeleteFileDialog.java | ||
---|---|---|
129 | 129 |
private void deleteFile(final Iterator<File> iter) { |
130 | 130 |
if (iter.hasNext()) { |
131 | 131 |
File f = iter.next(); |
132 |
String path = Pithos.get().getApiPath() + Pithos.get().getUsername() + f.getUri();
|
|
133 |
DeleteRequest deleteFile = new DeleteRequest(path) { |
|
132 |
String path = f.getUri(); |
|
133 |
DeleteRequest deleteFile = new DeleteRequest(Pithos.get().getApiPath(), Pithos.get().getUsername(), path) {
|
|
134 | 134 |
@Override |
135 | 135 |
public void onSuccess(Resource result) { |
136 | 136 |
deleteFile(iter); |
b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java | ||
---|---|---|
286 | 286 |
// permButtons.addStyleName("pithos-TabPanelBottom"); |
287 | 287 |
// permPanel.add(permButtons); |
288 | 288 |
// |
289 |
// final Label readForAllNote = new Label("When this option is enabled, the file will be readable" + |
|
290 |
// " by everyone. By checking this option, you are certifying that you have the right to " + |
|
291 |
// "distribute this file and that it does not violate the Terms of Use.", true); |
|
292 |
// readForAllNote.setVisible(false); |
|
293 |
// readForAllNote.setStylePrimaryName("pithos-readForAllNote"); |
|
294 |
// |
|
295 |
// readForAll = new CheckBox(); |
|
296 |
// readForAll.setValue(file.isReadForAll()); |
|
297 |
// readForAll.addClickHandler(new ClickHandler() { |
|
298 |
// @Override |
|
299 |
// public void onClick(ClickEvent event) { |
|
300 |
// readForAllNote.setVisible(readForAll.getValue()); |
|
301 |
// } |
|
302 |
// |
|
303 |
// }); |
|
304 |
// |
|
305 |
// // Only show the read for all permission if the user is the owner. |
|
306 |
// if (file.getOwner().equals(app.getUsername())) { |
|
307 |
// final HorizontalPanel permForAll = new HorizontalPanel(); |
|
308 |
// permForAll.add(new Label("Public")); |
|
309 |
// permForAll.add(readForAll); |
|
310 |
// permForAll.setSpacing(8); |
|
311 |
// permForAll.addStyleName("pithos-TabPanelBottom"); |
|
312 |
// permForAll.add(readForAllNote); |
|
313 |
// permPanel.add(permForAll); |
|
314 |
// } |
|
315 |
// |
|
316 |
// |
|
317 |
// final HorizontalPanel pathPanel = new HorizontalPanel(); |
|
318 |
// pathPanel.setWidth("100%"); |
|
319 |
// pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
|
320 |
// pathPanel.add(new Label("Link")); |
|
321 |
// pathPanel.setSpacing(8); |
|
322 |
// pathPanel.addStyleName("pithos-TabPanelBottom"); |
|
323 |
// |
|
324 |
// TextBox path = new TextBox(); |
|
325 |
// path.setWidth("100%"); |
|
326 |
// path.addClickHandler(new ClickHandler() { |
|
327 |
// @Override |
|
328 |
// public void onClick(ClickEvent event) { |
|
329 |
// Pithos.enableIESelection(); |
|
330 |
// ((TextBox) event.getSource()).selectAll(); |
|
331 |
// Pithos.preventIESelection(); |
|
332 |
// } |
|
333 |
// }); |
|
334 |
// path.setText(file.getUri()); |
|
335 |
// path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)"); |
|
336 |
// path.setWidth("100%"); |
|
337 |
// path.setReadOnly(true); |
|
338 |
// pathPanel.add(path); |
|
339 |
// permPanel.add(pathPanel); |
|
289 |
final Label readForAllNote = new Label("When this option is enabled, the file will be readable" + |
|
290 |
" by everyone. By checking this option, you are certifying that you have the right to " + |
|
291 |
"distribute this file and that it does not violate the Terms of Use.", true); |
|
292 |
readForAllNote.setVisible(false); |
|
293 |
readForAllNote.setStylePrimaryName("pithos-readForAllNote"); |
|
294 |
|
|
295 |
readForAll = new CheckBox(); |
|
296 |
readForAll.setValue(file.isPublished()); |
|
297 |
readForAll.addClickHandler(new ClickHandler() { |
|
298 |
@Override |
|
299 |
public void onClick(ClickEvent event) { |
|
300 |
readForAllNote.setVisible(readForAll.getValue()); |
|
301 |
} |
|
302 |
}); |
|
303 |
|
|
304 |
// Only show the read for all permission if the user is the owner. |
|
305 |
if (file.getOwner().equals(app.getUsername())) { |
|
306 |
final HorizontalPanel permForAll = new HorizontalPanel(); |
|
307 |
permForAll.add(new Label("Public")); |
|
308 |
permForAll.add(readForAll); |
|
309 |
permForAll.setSpacing(8); |
|
310 |
permForAll.addStyleName("pithos-TabPanelBottom"); |
|
311 |
permForAll.add(readForAllNote); |
|
312 |
permPanel.add(permForAll); |
|
313 |
} |
|
314 |
|
|
315 |
final HorizontalPanel pathPanel = new HorizontalPanel(); |
|
316 |
pathPanel.setWidth("100%"); |
|
317 |
pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
|
318 |
pathPanel.add(new Label("Link")); |
|
319 |
pathPanel.setSpacing(8); |
|
320 |
pathPanel.addStyleName("pithos-TabPanelBottom"); |
|
321 |
|
|
322 |
TextBox path = new TextBox(); |
|
323 |
path.setWidth("100%"); |
|
324 |
path.addClickHandler(new ClickHandler() { |
|
325 |
@Override |
|
326 |
public void onClick(ClickEvent event) { |
|
327 |
Pithos.enableIESelection(); |
|
328 |
((TextBox) event.getSource()).selectAll(); |
|
329 |
Pithos.preventIESelection(); |
|
330 |
} |
|
331 |
}); |
|
332 |
path.setText(file.getUri()); |
|
333 |
path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)"); |
|
334 |
path.setWidth("100%"); |
|
335 |
path.setReadOnly(true); |
|
336 |
pathPanel.add(path); |
|
337 |
permPanel.add(pathPanel); |
|
340 | 338 |
|
341 | 339 |
return permPanel; |
342 | 340 |
} |
... | ... | |
411 | 409 |
// if (versioned.getValue() != file.isVersioned()) |
412 | 410 |
// json.put("versioned", JSONBoolean.getInstance(versioned.getValue())); |
413 | 411 |
//only update the read for all perm if the user is the owner |
414 |
// if (readForAll.getValue() != file.isReadForAll()) |
|
415 |
// if (file.getOwner().equals(Pithos.get().getCurrentUserResource().getUsername())) |
|
412 |
Boolean published = null; |
|
413 |
if (readForAll.getValue() != file.isPublished()) |
|
414 |
if (file.getOwner().equals(Pithos.get().getUsername())) |
|
415 |
published = readForAll.getValue(); |
|
416 |
final Boolean finalPublished = published; |
|
416 | 417 |
// json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue())); |
417 | 418 |
// int i = 0; |
418 | 419 |
// if (permList.hasChanges()) { |
... | ... | |
444 | 445 |
final String[] newTags = tagset; |
445 | 446 |
|
446 | 447 |
if (newFilename != null) { |
447 |
final String path = app.getApiPath() + app.getUsername() + file.getParent().getUri() + "/" + newFilename;
|
|
448 |
PutRequest updateFile = new PutRequest(path) { |
|
448 |
final String path = file.getParent().getUri() + "/" + newFilename; |
|
449 |
PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
|
|
449 | 450 |
@Override |
450 | 451 |
public void onSuccess(Resource result) { |
451 |
if (newTags != null) |
|
452 |
updateMetaData(path + "?update=", newTags);
|
|
452 |
if (newTags != null || finalPublished != null)
|
|
453 |
updateMetaData(app.getApiPath(), app.getUsername(), path + "?update=", newTags, finalPublished);
|
|
453 | 454 |
else |
454 | 455 |
app.updateFolder(file.getParent()); |
455 | 456 |
} |
... | ... | |
465 | 466 |
updateFile.setHeader("Content-Type", file.getContentType()); |
466 | 467 |
Scheduler.get().scheduleDeferred(updateFile); |
467 | 468 |
} |
468 |
else if (newTags != null) |
|
469 |
updateMetaData(app.getApiPath() + app.getUsername() + file.getUri() + "?update=", newTags);
|
|
469 |
else if (newTags != null || finalPublished != null)
|
|
470 |
updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", newTags, finalPublished);
|
|
470 | 471 |
} |
471 | 472 |
|
472 |
private void updateMetaData(String path, String[] newTags) {
|
|
473 |
PostRequest updateFile = new PostRequest(path) { |
|
473 |
private void updateMetaData(String api, String owner, String path, String[] newTags, Boolean published) {
|
|
474 |
PostRequest updateFile = new PostRequest(api, owner, path) {
|
|
474 | 475 |
@Override |
475 | 476 |
public void onSuccess(Resource result) { |
476 | 477 |
app.updateFolder(file.getParent()); |
... | ... | |
483 | 484 |
} |
484 | 485 |
}; |
485 | 486 |
updateFile.setHeader("X-Auth-Token", app.getToken()); |
486 |
for (String t : newTags) |
|
487 |
updateFile.setHeader("X-Object-Meta-" + t.trim(), "true"); |
|
487 |
if (newTags != null) |
|
488 |
for (String t : newTags) |
|
489 |
updateFile.setHeader("X-Object-Meta-" + t.trim(), "true"); |
|
490 |
if (published != null) |
|
491 |
updateFile.setHeader("X-Object-Public", published.toString()); |
|
488 | 492 |
Scheduler.get().scheduleDeferred(updateFile); |
489 | 493 |
} |
490 | 494 |
|
b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java | ||
---|---|---|
236 | 236 |
*/ |
237 | 237 |
private void createFolder() { |
238 | 238 |
String name = folderName.getText(); |
239 |
String prefix = folder.getPrefix(); |
|
240 |
String path = app.getApiPath() + app.getUsername() + "/" + folder.getContainer() + "/" + (prefix.length() == 0 ? "" : prefix + "/") + name; |
|
241 |
PutRequest createFolder = new PutRequest(path) { |
|
239 |
String path = folder.getUri() + "/" + name; |
|
240 |
PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) { |
|
242 | 241 |
@Override |
243 | 242 |
public void onSuccess(Resource result) { |
244 | 243 |
app.updateFolder(folder); |
... | ... | |
354 | 353 |
// DeferredCommand.addCommand(ep); |
355 | 354 |
final String newName = folderName.getText(); |
356 | 355 |
if (!folder.isContainer() && !folder.getName().equals(newName)) { |
357 |
final String path = app.getApiPath() + app.getUsername() + folder.getParent().getUri() + "/" + newName;
|
|
358 |
PutRequest newFolder = new PutRequest(path) { |
|
356 |
final String path = folder.getParent().getUri() + "/" + newName; |
|
357 |
PutRequest newFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {
|
|
359 | 358 |
@Override |
360 | 359 |
public void onSuccess(Resource result) { |
361 | 360 |
Iterator<File> iter = folder.getFiles().iterator(); |
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
416 | 416 |
private void fetchFile(final Iterator<File> iter, final Set<File> files) { |
417 | 417 |
if (iter.hasNext()) { |
418 | 418 |
File file = iter.next(); |
419 |
String path = getApiPath() + username + "/" + file.getContainer() + "/" + file.getPath() + "?format=json";
|
|
420 |
GetRequest<File> getFile = new GetRequest<File>(File.class, path, file) { |
|
419 |
String path = file.getUri() + "?format=json";
|
|
420 |
GetRequest<File> getFile = new GetRequest<File>(File.class, getApiPath(), username, path, file) {
|
|
421 | 421 |
@Override |
422 | 422 |
public void onSuccess(File result) { |
423 | 423 |
fetchFile(iter, files); |
... | ... | |
476 | 476 |
} |
477 | 477 |
|
478 | 478 |
private void fetchAccount() { |
479 |
String path = getApiPath() + username + "?format=json";
|
|
479 |
String path = "?format=json"; |
|
480 | 480 |
|
481 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, path) { |
|
481 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, getApiPath(), username, path) {
|
|
482 | 482 |
@Override |
483 | 483 |
public void onSuccess(AccountResource result) { |
484 | 484 |
account = result; |
... | ... | |
504 | 504 |
} |
505 | 505 |
|
506 | 506 |
private void createHomeContainers() { |
507 |
String path = getApiPath() + getUsername() + "/pithos";
|
|
508 |
PutRequest createPithos = new PutRequest(path) { |
|
507 |
String path = "/pithos"; |
|
508 |
PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) {
|
|
509 | 509 |
@Override |
510 | 510 |
public void onSuccess(Resource result) { |
511 | 511 |
fetchAccount(); |
... | ... | |
924 | 924 |
JSONObject o = array.get(i).isObject(); |
925 | 925 |
if (o != null && !o.containsKey("subdir")) { |
926 | 926 |
JSONString name = o.get("name").isString(); |
927 |
String path = getApiPath() + getUsername() + "/" + folder.getContainer() + "/" + name.stringValue();
|
|
928 |
DeleteRequest delete = new DeleteRequest(path) { |
|
927 |
String path = "/" + folder.getContainer() + "/" + name.stringValue(); |
|
928 |
DeleteRequest delete = new DeleteRequest(getApiPath(), getUsername(), path) {
|
|
929 | 929 |
@Override |
930 | 930 |
public void onSuccess(Resource result) { |
931 | 931 |
deleteObject(folder, i + 1, array); |
... | ... | |
975 | 975 |
} |
976 | 976 |
} |
977 | 977 |
else { |
978 |
String prefix = folder.getPrefix(); |
|
979 |
String path = getApiPath() + getUsername() + "/" + folder.getContainer() + (prefix.length() == 0 ? "" : "/" + prefix); |
|
980 |
DeleteRequest deleteFolder = new DeleteRequest(path) { |
|
978 |
String path = folder.getUri(); |
|
979 |
DeleteRequest deleteFolder = new DeleteRequest(getApiPath(), getUsername(), path) { |
|
981 | 980 |
@Override |
982 | 981 |
public void onSuccess(Resource result) { |
983 | 982 |
updateFolder(folder.getParent()); |
... | ... | |
1005 | 1004 |
public void copyFiles(final Iterator<File> iter, final String targetUri, final Command callback) { |
1006 | 1005 |
if (iter.hasNext()) { |
1007 | 1006 |
File file = iter.next(); |
1008 |
String path = getApiPath() + getUsername() + targetUri + "/" + file.getName();
|
|
1009 |
PutRequest copyFile = new PutRequest(path) { |
|
1007 |
String path = targetUri + "/" + file.getName(); |
|
1008 |
PutRequest copyFile = new PutRequest(getApiPath(), getUsername(), path) {
|
|
1010 | 1009 |
@Override |
1011 | 1010 |
public void onSuccess(Resource result) { |
1012 | 1011 |
copyFiles(iter, targetUri, callback); |
... | ... | |
1042 | 1041 |
} |
1043 | 1042 |
|
1044 | 1043 |
public void copyFolder(final Folder f, final String targetUri, final Command callback) { |
1045 |
String path = getApiPath() + getUsername() + targetUri + "/" + f.getName();
|
|
1046 |
PutRequest createFolder = new PutRequest(path) { |
|
1044 |
String path = targetUri + "/" + f.getName(); |
|
1045 |
PutRequest createFolder = new PutRequest(getApiPath(), getUsername(), path) {
|
|
1047 | 1046 |
@Override |
1048 | 1047 |
public void onSuccess(Resource result) { |
1049 | 1048 |
Iterator<File> iter = f.getFiles().iterator(); |
b/src/gr/grnet/pithos/web/client/StatusPanel.java | ||
---|---|---|
167 | 167 |
//TODO: This should not be done here |
168 | 168 |
public void updateStats() { |
169 | 169 |
final Pithos app = Pithos.get(); |
170 |
String path = app.getApiPath() + app.getUsername(); |
|
171 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, path) { |
|
170 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), app.getUsername(), "") { |
|
172 | 171 |
@Override |
173 | 172 |
public void onSuccess(AccountResource result) { |
174 | 173 |
displayStats(result); |
b/src/gr/grnet/pithos/web/client/commands/PasteCommand.java | ||
---|---|---|
120 | 120 |
private void moveFiles(final Iterator<File> iter, final Command callback) { |
121 | 121 |
if (iter.hasNext()) { |
122 | 122 |
File file = iter.next(); |
123 |
String path = app.getApiPath() + app.getUsername() + folder.getUri() + "/" + file.getName();
|
|
124 |
PutRequest copyFile = new PutRequest(path) { |
|
123 |
String path = folder.getUri() + "/" + file.getName(); |
|
124 |
PutRequest copyFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
|
|
125 | 125 |
@Override |
126 | 126 |
public void onSuccess(Resource result) { |
127 | 127 |
moveFiles(iter, callback); |
b/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java | ||
---|---|---|
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
private void trashFolder(final Folder f, final Command callback) { |
96 |
String path = app.getApiPath() + app.getUsername() + f.getUri() + "?update=";
|
|
97 |
PostRequest trashFolder = new PostRequest(path) { |
|
96 |
String path = f.getUri() + "?update="; |
|
97 |
PostRequest trashFolder = new PostRequest(app.getApiPath(), app.getUsername(), path) {
|
|
98 | 98 |
@Override |
99 | 99 |
public void onSuccess(Resource result) { |
100 | 100 |
Iterator<File> iter = f.getFiles().iterator(); |
... | ... | |
130 | 130 |
private void trashFiles(final Iterator<File> iter, final Command callback) { |
131 | 131 |
if (iter.hasNext()) { |
132 | 132 |
File file = iter.next(); |
133 |
String path = app.getApiPath() + app.getUsername() + file.getUri() + "?update=";
|
|
134 |
PostRequest trashFile = new PostRequest(path) { |
|
133 |
String path = file.getUri() + "?update="; |
|
134 |
PostRequest trashFile = new PostRequest(app.getApiPath(), app.getUsername(), path) {
|
|
135 | 135 |
@Override |
136 | 136 |
public void onSuccess(Resource result) { |
137 | 137 |
trashFiles(iter, callback); |
b/src/gr/grnet/pithos/web/client/foldertree/AccountResource.java | ||
---|---|---|
133 | 133 |
this.currentLogin = currentLogin; |
134 | 134 |
} |
135 | 135 |
|
136 |
public void populate(Response response) { |
|
136 |
public void populate(String owner, Response response) {
|
|
137 | 137 |
String header = response.getHeader("X-Account-Container-Count"); |
138 | 138 |
if (header != null) |
139 | 139 |
numberOfContainers = Long.valueOf(header); |
... | ... | |
166 | 166 |
JSONObject o = array.get(i).isObject(); |
167 | 167 |
if (o != null) { |
168 | 168 |
Folder f = new Folder(); |
169 |
f.populate(null, o, null); |
|
169 |
f.populate(null, o, owner, null);
|
|
170 | 170 |
containers.add(f); |
171 | 171 |
} |
172 | 172 |
} |
173 | 173 |
} |
174 | 174 |
} |
175 | 175 |
|
176 |
public static AccountResource createFromResponse(Response response) { |
|
176 |
public static AccountResource createFromResponse(String owner, Response response) {
|
|
177 | 177 |
AccountResource a = new AccountResource(); |
178 |
a.populate(response); |
|
178 |
a.populate(owner, response);
|
|
179 | 179 |
return a; |
180 | 180 |
} |
181 | 181 |
|
b/src/gr/grnet/pithos/web/client/foldertree/File.java | ||
---|---|---|
78 | 78 |
|
79 | 79 |
private Set<String> tags = new HashSet<String>(); |
80 | 80 |
|
81 |
private boolean published; |
|
82 |
|
|
81 | 83 |
public String getContentType() { |
82 | 84 |
return contentType; |
83 | 85 |
} |
... | ... | |
141 | 143 |
return inTrash; |
142 | 144 |
} |
143 | 145 |
|
144 |
public void populate(Folder parent, JSONObject o, String container) { |
|
146 |
public void populate(Folder parent, JSONObject o, String owner, String container) {
|
|
145 | 147 |
this.parent = parent; |
146 | 148 |
path = unmarshallString(o, "name"); |
147 | 149 |
if (path.contains("/")) |
148 | 150 |
name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix |
149 | 151 |
else |
150 | 152 |
name = path; |
153 |
this.owner = owner; |
|
151 | 154 |
hash = unmarshallString(o, "hash"); |
152 | 155 |
bytes = unmarshallLong(o, "bytes"); |
153 | 156 |
version = unmarshallInt(o, "version"); |
... | ... | |
155 | 158 |
lastModified = unmarshallDate(o, "last_modified"); |
156 | 159 |
modifiedBy = unmarshallString(o, "modified_by"); |
157 | 160 |
versionTimestamp = unmarshallDate(o, "version_timestamp"); |
161 |
published = unmarshallBoolean(o, "x_object_public"); |
|
158 | 162 |
this.container = container; |
159 | 163 |
|
160 | 164 |
for (String key : o.keySet()) |
161 | 165 |
if (key.startsWith("x_object_meta_") && !key.equals("x_object_meta_trash")) |
162 | 166 |
tags.add(key.substring("x_object_meta_".length()).trim().toLowerCase()); |
167 |
|
|
168 |
|
|
163 | 169 |
} |
164 | 170 |
|
165 | 171 |
public boolean equals(Object other) { |
... | ... | |
178 | 184 |
return container; |
179 | 185 |
} |
180 | 186 |
|
181 |
public static File createFromResponse(Response response, File result) { |
|
182 |
result.populate(response); |
|
187 |
public static File createFromResponse(String owner, Response response, File result) {
|
|
188 |
result.populate(owner, response);
|
|
183 | 189 |
return result; |
184 | 190 |
} |
185 | 191 |
|
186 |
private void populate(Response response) { |
|
192 |
private void populate(String owner, Response response) { |
|
193 |
this.owner = owner; |
|
187 | 194 |
for (Header h : response.getHeaders()) { |
188 | 195 |
String header = h.getName(); |
189 | 196 |
if (header.startsWith("X-Object-Meta-") && !header.equals("X-Object-Meta-Trash")) |
... | ... | |
195 | 202 |
inTrash = Boolean.valueOf(header); |
196 | 203 |
else |
197 | 204 |
inTrash = false; |
198 |
|
|
199 |
JSONValue json = JSONParser.parseStrict(response.getText()); |
|
200 |
JSONObject o = json.isObject(); |
|
201 | 205 |
} |
202 | 206 |
|
203 | 207 |
public Folder getParent() { |
... | ... | |
207 | 211 |
public Set<String> getTags() { |
208 | 212 |
return tags; |
209 | 213 |
} |
214 |
|
|
215 |
public boolean isPublished() { |
|
216 |
return published; |
|
217 |
} |
|
210 | 218 |
} |
b/src/gr/grnet/pithos/web/client/foldertree/Folder.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
private Set<String> tags = new LinkedHashSet<String>(); |
88 | 88 |
|
89 |
private String owner; |
|
90 |
|
|
89 | 91 |
public Folder() {}; |
90 | 92 |
|
91 | 93 |
public Folder(String name) { |
... | ... | |
128 | 130 |
this.prefix = prefix; |
129 | 131 |
} |
130 | 132 |
|
131 |
public void populate(Response response) { |
|
133 |
public void populate(String owner, Response response) { |
|
134 |
this.owner = owner; |
|
132 | 135 |
String header = response.getHeader("Last-Modified"); |
133 | 136 |
if (header != null) |
134 | 137 |
lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header); |
... | ... | |
159 | 162 |
String contentType = unmarshallString(o, "content_type"); |
160 | 163 |
if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) { |
161 | 164 |
Folder f = new Folder(); |
162 |
f.populate(this, o, container); |
|
165 |
f.populate(this, o, owner, container);
|
|
163 | 166 |
subfolders.add(f); |
164 | 167 |
} |
165 | 168 |
else if (!(o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true"))) { |
166 | 169 |
File file = new File(); |
167 |
file.populate(this, o, container); |
|
170 |
file.populate(this, o, owner, container);
|
|
168 | 171 |
files.add(file); |
169 | 172 |
} |
170 | 173 |
} |
... | ... | |
180 | 183 |
} |
181 | 184 |
} |
182 | 185 |
|
183 |
public void populate(Folder parent, JSONObject o, String aContainer) { |
|
186 |
public void populate(Folder parent, JSONObject o, String owner, String aContainer) {
|
|
184 | 187 |
this.parent = parent; |
185 | 188 |
String path = null; |
186 | 189 |
if (o.containsKey("subdir")) { |
... | ... | |
204 | 207 |
container = name; |
205 | 208 |
prefix = ""; |
206 | 209 |
} |
210 |
this.owner = owner; |
|
207 | 211 |
if (o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true")) |
208 | 212 |
inTrash = true; |
209 | 213 |
} |
210 | 214 |
|
211 |
public static Folder createFromResponse(Response response, Folder result) { |
|
215 |
public static Folder createFromResponse(String owner, Response response, Folder result) {
|
|
212 | 216 |
Folder f = null; |
213 | 217 |
if (result == null) |
214 | 218 |
f = new Folder(); |
215 | 219 |
else |
216 | 220 |
f = result; |
217 | 221 |
|
218 |
f.populate(response); |
|
222 |
f.populate(owner, response);
|
|
219 | 223 |
return f; |
220 | 224 |
} |
221 | 225 |
|
b/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java | ||
---|---|---|
126 | 126 |
if (iter.hasNext()) { |
127 | 127 |
final Folder f = iter.next(); |
128 | 128 |
|
129 |
String path = app.getApiPath() + app.getUsername() + "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
|
|
130 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, path, f) { |
|
129 |
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix(); |
|
130 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path, f) {
|
|
131 | 131 |
@Override |
132 | 132 |
public void onSuccess(Folder result) { |
133 | 133 |
fetchFolder(iter, dataProvider, folders); |
... | ... | |
185 | 185 |
@Override |
186 | 186 |
public void execute() { |
187 | 187 |
final Pithos app = Pithos.get(); |
188 |
String path = app.getApiPath() + app.getUsername() + "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
|
|
189 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, path, f) { |
|
188 |
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix(); |
|
189 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path, f) {
|
|
190 | 190 |
@Override |
191 | 191 |
public void onSuccess(Folder result) { |
192 | 192 |
app.showFiles(result); |
b/src/gr/grnet/pithos/web/client/foldertree/Resource.java | ||
---|---|---|
93 | 93 |
return (new Date(ms)).toUTCString(); |
94 | 94 |
}-*/; |
95 | 95 |
|
96 |
public static <T> T createFromResponse(Class<T> aClass, Response response, T result) { |
|
96 |
public static <T> T createFromResponse(Class<T> aClass, String owner, Response response, T result) {
|
|
97 | 97 |
if (aClass.equals(AccountResource.class)) { |
98 |
result = (T) AccountResource.createFromResponse(response); |
|
98 |
result = (T) AccountResource.createFromResponse(owner, response);
|
|
99 | 99 |
} |
100 | 100 |
else if (aClass.equals(Folder.class)) { |
101 |
result = (T) Folder.createFromResponse(response, (Folder) result); |
|
101 |
result = (T) Folder.createFromResponse(owner, response, (Folder) result);
|
|
102 | 102 |
} |
103 | 103 |
else if (aClass.equals(File.class)) { |
104 |
result = (T) File.createFromResponse(response, (File) result); |
|
104 |
result = (T) File.createFromResponse(owner, response, (File) result);
|
|
105 | 105 |
} |
106 | 106 |
return result; |
107 | 107 |
} |
b/src/gr/grnet/pithos/web/client/rest/DeleteRequest.java | ||
---|---|---|
49 | 49 |
* Templates. |
50 | 50 |
*/ |
51 | 51 |
public abstract class DeleteRequest implements ScheduledCommand { |
52 |
private String api; |
|
53 |
|
|
54 |
private String owner; |
|
55 |
|
|
52 | 56 |
private String path; |
53 | 57 |
|
54 | 58 |
private Map<String, String> headers = new HashMap<String, String>(); |
... | ... | |
57 | 61 |
|
58 | 62 |
public abstract void onError(Throwable t); |
59 | 63 |
|
60 |
public DeleteRequest(String path) { |
|
64 |
public DeleteRequest(String api, String owner, String path) { |
|
65 |
this.api = api; |
|
66 |
this.owner = owner; |
|
61 | 67 |
this.path = path; |
62 | 68 |
} |
63 | 69 |
|
64 | 70 |
@Override |
65 | 71 |
public void execute() { |
66 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, path); |
|
72 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, api + owner + path);
|
|
67 | 73 |
for (String header : headers.keySet()) { |
68 | 74 |
builder.setHeader(header, headers.get(header)); |
69 | 75 |
} |
70 | 76 |
try { |
71 |
builder.sendRequest("", new RestRequestCallback(path, Response.SC_NO_CONTENT) { |
|
77 |
builder.sendRequest("", new RestRequestCallback(api + owner + path, Response.SC_NO_CONTENT) {
|
|
72 | 78 |
@Override |
73 | 79 |
public void onSuccess(Resource object) { |
74 | 80 |
DeleteRequest.this.onSuccess(object); |
... | ... | |
76 | 82 |
|
77 | 83 |
@Override |
78 | 84 |
public Resource deserialize(Response response) { |
79 |
return Resource.createFromResponse(Resource.class, response, null); |
|
85 |
return Resource.createFromResponse(Resource.class, owner, response, null);
|
|
80 | 86 |
} |
81 | 87 |
|
82 | 88 |
@Override |
b/src/gr/grnet/pithos/web/client/rest/GetRequest.java | ||
---|---|---|
41 | 41 |
import com.google.gwt.http.client.RequestBuilder; |
42 | 42 |
import com.google.gwt.http.client.RequestException; |
43 | 43 |
import com.google.gwt.http.client.Response; |
44 |
import gr.grnet.pithos.web.client.Pithos; |
|
44 | 45 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
45 | 46 |
import java.util.HashMap; |
46 | 47 |
import java.util.Map; |
... | ... | |
49 | 50 |
|
50 | 51 |
private Class<T> aClass; |
51 | 52 |
|
53 |
private String api; |
|
54 |
|
|
55 |
private String owner; |
|
56 |
|
|
52 | 57 |
private String path; |
53 | 58 |
|
54 | 59 |
private int okCode; |
... | ... | |
63 | 68 |
|
64 | 69 |
public abstract void onError(Throwable t); |
65 | 70 |
|
66 |
public GetRequest(Class<T> aClass, String path, int okCode, T result) { |
|
71 |
public GetRequest(Class<T> aClass, String api, String owner, String path, int okCode, T result) {
|
|
67 | 72 |
this.aClass = aClass; |
73 |
this.api = api; |
|
74 |
this.owner = owner; |
|
68 | 75 |
this.path = path; |
69 | 76 |
this.okCode = okCode; |
70 | 77 |
this.result = result; |
71 | 78 |
} |
72 | 79 |
|
73 |
public GetRequest(Class<T> aClass, String path) { |
|
74 |
this(aClass, path, -1, null); |
|
80 |
public GetRequest(Class<T> aClass, String api, String owner, String path) {
|
|
81 |
this(aClass, api, owner, path, -1, null);
|
|
75 | 82 |
} |
76 | 83 |
|
77 |
public GetRequest(Class<T> aClass, String path, T result) { |
|
78 |
this(aClass, path, -1, result); |
|
84 |
public GetRequest(Class<T> aClass, String api, String owner, String path, T result) {
|
|
85 |
this(aClass, api, owner, path, -1, result);
|
|
79 | 86 |
} |
80 | 87 |
|
81 | 88 |
@Override |
82 | 89 |
public void execute() { |
83 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path); |
|
90 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, api + owner + path);
|
|
84 | 91 |
builder.setHeader("If-Modified-Since", "0"); |
85 | 92 |
for (String header : headers.keySet()) { |
86 | 93 |
builder.setHeader(header, headers.get(header)); |
87 | 94 |
} |
88 | 95 |
try { |
89 |
builder.sendRequest("", new RestRequestCallback<T>(path, okCode) { |
|
96 |
builder.sendRequest("", new RestRequestCallback<T>(api + owner + path, okCode) {
|
|
90 | 97 |
@Override |
91 | 98 |
public void onSuccess(T object) { |
92 | 99 |
GetRequest.this.onSuccess(object); |
... | ... | |
94 | 101 |
|
95 | 102 |
@Override |
96 | 103 |
public T deserialize(Response response) { |
97 |
return Resource.createFromResponse(aClass, response, result); |
|
104 |
return Resource.createFromResponse(aClass, owner, response, result);
|
|
98 | 105 |
} |
99 | 106 |
|
100 | 107 |
@Override |
b/src/gr/grnet/pithos/web/client/rest/PostRequest.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
public abstract class PostRequest implements ScheduledCommand { |
48 | 48 |
|
49 |
private String api; |
|
50 |
|
|
51 |
private String owner; |
|
52 |
|
|
49 | 53 |
private String path; |
50 | 54 |
|
51 | 55 |
private Map<String, String> headers = new HashMap<String, String>(); |
... | ... | |
54 | 58 |
|
55 | 59 |
public abstract void onError(Throwable t); |
56 | 60 |
|
57 |
public PostRequest(String path) { |
|
61 |
public PostRequest(String api, String owner, String path) { |
|
62 |
this.api = api; |
|
63 |
this.owner = owner; |
|
58 | 64 |
this.path = path; |
59 | 65 |
} |
60 | 66 |
|
61 | 67 |
@Override |
62 | 68 |
public void execute() { |
63 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, path); |
|
69 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, api + owner + path);
|
|
64 | 70 |
for (String header : headers.keySet()) { |
65 | 71 |
builder.setHeader(header, headers.get(header)); |
66 | 72 |
} |
67 | 73 |
try { |
68 |
builder.sendRequest("", new RestRequestCallback(path, Response.SC_ACCEPTED) { |
|
74 |
builder.sendRequest("", new RestRequestCallback(api + owner + path, Response.SC_ACCEPTED) {
|
|
69 | 75 |
@Override |
70 | 76 |
public void onSuccess(Resource object) { |
71 | 77 |
PostRequest.this.onSuccess(object); |
... | ... | |
73 | 79 |
|
74 | 80 |
@Override |
75 | 81 |
public Resource deserialize(Response response) { |
76 |
return Resource.createFromResponse(Resource.class, response, null); |
|
82 |
return Resource.createFromResponse(Resource.class, owner, response, null);
|
|
77 | 83 |
} |
78 | 84 |
|
79 | 85 |
@Override |
b/src/gr/grnet/pithos/web/client/rest/PutRequest.java | ||
---|---|---|
81 | 81 |
|
82 | 82 |
public abstract class PutRequest implements ScheduledCommand { |
83 | 83 |
|
84 |
private String api; |
|
85 |
|
|
86 |
private String owner; |
|
87 |
|
|
84 | 88 |
private String path; |
85 | 89 |
|
86 | 90 |
private Map<String, String> headers = new HashMap<String, String>(); |
... | ... | |
89 | 93 |
|
90 | 94 |
public abstract void onError(Throwable t); |
91 | 95 |
|
92 |
public PutRequest(String path) { |
|
96 |
public PutRequest(String api, String owner, String path) { |
|
97 |
this.api = api; |
|
98 |
this.owner = owner; |
|
93 | 99 |
this.path = path; |
94 | 100 |
} |
95 | 101 |
|
96 | 102 |
@Override |
97 | 103 |
public void execute() { |
98 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, path); |
|
104 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, api + owner + path);
|
|
99 | 105 |
for (String header : headers.keySet()) { |
100 | 106 |
builder.setHeader(header, headers.get(header)); |
101 | 107 |
} |
102 | 108 |
try { |
103 |
builder.sendRequest("", new RestRequestCallback(path, Response.SC_CREATED) { |
|
109 |
builder.sendRequest("", new RestRequestCallback(api + owner + path, Response.SC_CREATED) {
|
|
104 | 110 |
@Override |
105 | 111 |
public void onSuccess(Resource object) { |
106 | 112 |
PutRequest.this.onSuccess(object); |
... | ... | |
108 | 114 |
|
109 | 115 |
@Override |
110 | 116 |
public Resource deserialize(Response response) { |
111 |
return Resource.createFromResponse(Resource.class, response, null); |
|
117 |
return Resource.createFromResponse(Resource.class, owner, response, null);
|
|
112 | 118 |
} |
113 | 119 |
|
114 | 120 |
@Override |
b/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java | ||
---|---|---|
178 | 178 |
final Pithos app = Pithos.get(); |
179 | 179 |
if (iter.hasNext()) { |
180 | 180 |
Folder f = iter.next(); |
181 |
String path = app.getApiPath() + app.getUsername() + f.getUri() + "?format=json&meta=" + t.getName();
|
|
182 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, path) { |
|
181 |
String path = f.getUri() + "?format=json&meta=" + t.getName(); |
|
182 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path) {
|
|
183 | 183 |
@Override |
184 | 184 |
public void onSuccess(Folder result) { |
185 | 185 |
files.addAll(result.getFiles()); |
Also available in: Unified diff