Revision fa68c84d src/gr/grnet/pithos/web/client/Pithos.java
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
79 | 79 |
*/ |
80 | 80 |
public class Pithos implements EntryPoint, ResizeHandler { |
81 | 81 |
|
82 |
public static final String HOME_CONTAINER = "pithos"; |
|
83 |
|
|
84 |
public static final String TRASH_CONTAINER = "trash"; |
|
85 |
|
|
86 | 82 |
public static final Configuration config = GWT.create(Configuration.class); |
87 | 83 |
|
88 | 84 |
public interface Style extends CssResource { |
... | ... | |
350 | 346 |
lastModified = new Date(); //Initialize if-modified-since value with now. |
351 | 347 |
resources.pithosCss().ensureInjected(); |
352 | 348 |
boolean bareContent = Window.Location.getParameter("noframe") != null; |
353 |
String contentWidth = bareContent ? "100%" : "75%";
|
|
349 |
String contentWidth = bareContent ? Const.PERCENT_100 : "75%";
|
|
354 | 350 |
|
355 | 351 |
VerticalPanel outer = new VerticalPanel(); |
356 |
outer.setWidth("100%");
|
|
352 |
outer.setWidth(Const.PERCENT_100);
|
|
357 | 353 |
if(!bareContent) { |
358 | 354 |
outer.addStyleName("pithos-outer"); |
359 | 355 |
} |
360 | 356 |
|
361 | 357 |
if(!bareContent) { |
362 | 358 |
topPanel = new TopPanel(this, Pithos.images); |
363 |
topPanel.setWidth("100%");
|
|
359 |
topPanel.setWidth(Const.PERCENT_100);
|
|
364 | 360 |
outer.add(topPanel); |
365 | 361 |
outer.setCellHorizontalAlignment(topPanel, HasHorizontalAlignment.ALIGN_CENTER); |
366 | 362 |
} |
... | ... | |
410 | 406 |
outer.setCellHorizontalAlignment(header, HasHorizontalAlignment.ALIGN_CENTER); |
411 | 407 |
// Inner contains the various lists |
412 | 408 |
inner.sinkEvents(Event.ONCONTEXTMENU); |
413 |
inner.setWidth("100%");
|
|
409 |
inner.setWidth(Const.PERCENT_100);
|
|
414 | 410 |
|
415 | 411 |
folderTreeSelectionModel = new SingleSelectionModel<Folder>(); |
416 | 412 |
folderTreeSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { |
... | ... | |
449 | 445 |
inner.add(fileList); |
450 | 446 |
|
451 | 447 |
trees = new VerticalPanel(); |
452 |
trees.setWidth("100%");
|
|
448 |
trees.setWidth(Const.PERCENT_100);
|
|
453 | 449 |
|
454 | 450 |
// Add the left and right panels to the split panel. |
455 | 451 |
splitPanel.setLeftWidget(trees); |
... | ... | |
458 | 454 |
right.add(inner); |
459 | 455 |
splitPanel.setRightWidget(right); |
460 | 456 |
splitPanel.setSplitPosition("219px"); |
461 |
splitPanel.setSize("100%", "100%");
|
|
457 |
splitPanel.setSize(Const.PERCENT_100, Const.PERCENT_100);
|
|
462 | 458 |
splitPanel.addStyleName("pithos-splitPanel"); |
463 | 459 |
splitPanel.setWidth(contentWidth); |
464 | 460 |
outer.add(splitPanel); |
... | ... | |
466 | 462 |
|
467 | 463 |
if(!bareContent) { |
468 | 464 |
statusPanel = new StatusPanel(); |
469 |
statusPanel.setWidth("100%");
|
|
465 |
statusPanel.setWidth(Const.PERCENT_100);
|
|
470 | 466 |
outer.add(statusPanel); |
471 | 467 |
outer.setCellHorizontalAlignment(statusPanel, HasHorizontalAlignment.ALIGN_CENTER); |
472 | 468 |
} |
... | ... | |
512 | 508 |
} |
513 | 509 |
else { |
514 | 510 |
for(Folder f : account.getContainers()) { |
515 |
if(f.getName().equals(Pithos.TRASH_CONTAINER)) {
|
|
511 |
if(f.getName().equals(Const.TRASH_CONTAINER)) {
|
|
516 | 512 |
trash = f; |
517 | 513 |
break; |
518 | 514 |
} |
... | ... | |
615 | 611 |
} |
616 | 612 |
}; |
617 | 613 |
head.setHeader(Const.X_AUTH_TOKEN, getUserToken()); |
618 |
head.setHeader("If-Modified-Since", DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss").format(lastModified, TimeZone.createTimeZone(0)) + " GMT");
|
|
614 |
head.setHeader(Const.IF_MODIFIED_SINCE, DateTimeFormat.getFormat(Const.DATE_FORMAT_1).format(lastModified, TimeZone.createTimeZone(0)) + " GMT");
|
|
619 | 615 |
Scheduler.get().scheduleDeferred(head); |
620 | 616 |
|
621 | 617 |
return false; |
... | ... | |
672 | 668 |
*/ |
673 | 669 |
private boolean parseUserCredentials() { |
674 | 670 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
675 |
Dictionary otherProperties = Dictionary.getDictionary("otherProperties");
|
|
676 |
String cookie = otherProperties.get("authCookie");
|
|
671 |
Dictionary otherProperties = Dictionary.getDictionary(Const.OTHER_PROPERTIES);
|
|
672 |
String cookie = otherProperties.get(Const.AUTH_COOKIE);
|
|
677 | 673 |
String auth = Cookies.getCookie(cookie); |
678 | 674 |
if(auth == null) { |
679 | 675 |
authenticateUser(); |
... | ... | |
705 | 701 |
* Redirect the user to the login page for authentication. |
706 | 702 |
*/ |
707 | 703 |
protected void authenticateUser() { |
708 |
Dictionary otherProperties = Dictionary.getDictionary("otherProperties");
|
|
709 |
Window.Location.assign(otherProperties.get("loginUrl") + Window.Location.getHref());
|
|
704 |
Dictionary otherProperties = Dictionary.getDictionary(Const.OTHER_PROPERTIES);
|
|
705 |
Window.Location.assign(otherProperties.get(Const.LOGIN_URL) + Window.Location.getHref());
|
|
710 | 706 |
} |
711 | 707 |
|
712 | 708 |
public void fetchAccount(final Command callback) { |
... | ... | |
774 | 770 |
} |
775 | 771 |
|
776 | 772 |
protected void createHomeContainer(final AccountResource _account, final Command callback) { |
777 |
String path = "/" + Pithos.HOME_CONTAINER;
|
|
773 |
String path = "/" + Const.HOME_CONTAINER;
|
|
778 | 774 |
PutRequest createPithos = new PutRequest(getApiPath(), getUserID(), path) { |
779 | 775 |
@Override |
780 | 776 |
public void onSuccess(Resource result) { |
... | ... | |
808 | 804 |
} |
809 | 805 |
|
810 | 806 |
protected void createTrashContainer(final Command callback) { |
811 |
String path = "/" + Pithos.TRASH_CONTAINER;
|
|
807 |
String path = "/" + Const.TRASH_CONTAINER;
|
|
812 | 808 |
PutRequest createPithos = new PutRequest(getApiPath(), getUserID(), path) { |
813 | 809 |
@Override |
814 | 810 |
public void onSuccess(Resource result) { |
... | ... | |
1054 | 1050 |
} |
1055 | 1051 |
}; |
1056 | 1052 |
copyFile.setHeader(Const.X_AUTH_TOKEN, getUserToken()); |
1057 |
copyFile.setHeader("X-Copy-From", URL.encodePathSegment(file.getUri()));
|
|
1053 |
copyFile.setHeader(Const.X_COPY_FROM, URL.encodePathSegment(file.getUri()));
|
|
1058 | 1054 |
if(!file.getOwnerID().equals(targetUsername)) { |
1059 |
copyFile.setHeader("X-Source-Account", URL.encodePathSegment(file.getOwnerID()));
|
|
1055 |
copyFile.setHeader(Const.X_SOURCE_ACCOUNT, URL.encodePathSegment(file.getOwnerID()));
|
|
1060 | 1056 |
} |
1061 |
copyFile.setHeader("Content-Type", file.getContentType());
|
|
1057 |
copyFile.setHeader(Const.CONTENT_TYPE, file.getContentType());
|
|
1062 | 1058 |
Scheduler.get().scheduleDeferred(copyFile); |
1063 | 1059 |
} |
1064 | 1060 |
else if(callback != null) { |
... | ... | |
1094 | 1090 |
} |
1095 | 1091 |
}; |
1096 | 1092 |
copyFolder.setHeader(Const.X_AUTH_TOKEN, getUserToken()); |
1097 |
copyFolder.setHeader("Accept", "*/*");
|
|
1098 |
copyFolder.setHeader("Content-Length", "0");
|
|
1099 |
copyFolder.setHeader("Content-Type", "application/directory");
|
|
1093 |
copyFolder.setHeader(Const.ACCEPT, "*/*");
|
|
1094 |
copyFolder.setHeader(Const.CONTENT_LENGTH, "0");
|
|
1095 |
copyFolder.setHeader(Const.CONTENT_TYPE, "application/directory");
|
|
1100 | 1096 |
if(!f.getOwnerID().equals(targetUsername)) { |
1101 |
copyFolder.setHeader("X-Source-Account", f.getOwnerID());
|
|
1097 |
copyFolder.setHeader(Const.X_SOURCE_ACCOUNT, f.getOwnerID());
|
|
1102 | 1098 |
} |
1103 | 1099 |
if(move) { |
1104 |
copyFolder.setHeader("X-Move-From", URL.encodePathSegment(f.getUri()));
|
|
1100 |
copyFolder.setHeader(Const.X_MOVE_FROM, URL.encodePathSegment(f.getUri()));
|
|
1105 | 1101 |
} |
1106 | 1102 |
else { |
1107 |
copyFolder.setHeader("X-Copy-From", URL.encodePathSegment(f.getUri()));
|
|
1103 |
copyFolder.setHeader(Const.X_COPY_FROM, URL.encodePathSegment(f.getUri()));
|
|
1108 | 1104 |
} |
1109 | 1105 |
Scheduler.get().scheduleDeferred(copyFolder); |
1110 | 1106 |
} |
... | ... | |
1320 | 1316 |
} |
1321 | 1317 |
}; |
1322 | 1318 |
newFolder.setHeader(Const.X_AUTH_TOKEN, getUserToken()); |
1323 |
newFolder.setHeader("Content-Type", "application/folder");
|
|
1324 |
newFolder.setHeader("Accept", "*/*");
|
|
1325 |
newFolder.setHeader("Content-Length", "0");
|
|
1319 |
newFolder.setHeader(Const.CONTENT_TYPE, "application/folder");
|
|
1320 |
newFolder.setHeader(Const.ACCEPT, "*/*");
|
|
1321 |
newFolder.setHeader(Const.CONTENT_LENGTH, "0");
|
|
1326 | 1322 |
Scheduler.get().scheduleDeferred(newFolder); |
1327 | 1323 |
} |
1328 | 1324 |
else if(((RestException) t).getHttpStatusCode() == Response.SC_FORBIDDEN) { |
Also available in: Unified diff