Revision b51c628b src/gr/grnet/pithos/web/client/FilePropertiesDialog.java
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 |
|
Also available in: Unified diff