Revision b1001100 src/gr/grnet/pithos/web/client/Pithos.java
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
55 | 55 |
import gr.grnet.pithos.web.client.rest.RestException; |
56 | 56 |
|
57 | 57 |
import java.util.ArrayList; |
58 |
import java.util.Date; |
|
58 | 59 |
import java.util.HashMap; |
59 | 60 |
import java.util.Iterator; |
60 | 61 |
import java.util.List; |
61 | 62 |
import java.util.Set; |
62 | 63 |
|
64 |
import org.apache.http.HttpStatus; |
|
65 |
|
|
63 | 66 |
import com.google.gwt.core.client.EntryPoint; |
64 | 67 |
import com.google.gwt.core.client.GWT; |
65 | 68 |
import com.google.gwt.core.client.JsArrayString; |
... | ... | |
76 | 79 |
import com.google.gwt.http.client.RequestException; |
77 | 80 |
import com.google.gwt.http.client.Response; |
78 | 81 |
import com.google.gwt.http.client.URL; |
82 |
import com.google.gwt.i18n.client.DateTimeFormat; |
|
83 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
|
79 | 84 |
import com.google.gwt.i18n.client.Dictionary; |
85 |
import com.google.gwt.i18n.client.TimeZone; |
|
86 |
import com.google.gwt.i18n.client.TimeZoneInfo; |
|
87 |
import com.google.gwt.i18n.client.constants.TimeZoneConstants; |
|
80 | 88 |
import com.google.gwt.json.client.JSONArray; |
81 | 89 |
import com.google.gwt.json.client.JSONObject; |
82 | 90 |
import com.google.gwt.json.client.JSONParser; |
... | ... | |
295 | 303 |
private FileUploadDialog fileUploadDialog = new FileUploadDialog(this); |
296 | 304 |
|
297 | 305 |
UploadAlert uploadAlert; |
306 |
|
|
307 |
Date lastModified; |
|
298 | 308 |
|
299 | 309 |
@Override |
300 | 310 |
public void onModuleLoad() { |
... | ... | |
303 | 313 |
} |
304 | 314 |
|
305 | 315 |
private void initialize() { |
316 |
lastModified = new Date(); //Initialize if-modified-since value with now. |
|
306 | 317 |
resources.pithosCss().ensureInjected(); |
307 | 318 |
boolean bareContent = Window.Location.getParameter("noframe") != null; |
308 | 319 |
String contentWidth = bareContent ? "100%" : "75%"; |
... | ... | |
487 | 498 |
}); |
488 | 499 |
} |
489 | 500 |
}); |
490 |
|
|
491 |
// Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { |
|
492 |
// |
|
493 |
// @Override |
|
494 |
// public boolean execute() { |
|
495 |
// Folder f = getSelection(); |
|
496 |
// if (f != null) { |
|
497 |
// if (getSelectedTree().equals(folderTreeView)) |
|
498 |
// updateFolder(f, true, null, false); |
|
499 |
// else if (getSelectedTree().equals(mysharedTreeView)) |
|
500 |
// updateSharedFolder(f, true); |
|
501 |
// } |
|
502 |
// return true; |
|
503 |
// } |
|
504 |
// }, 3000); |
|
501 |
} |
|
502 |
|
|
503 |
public void scheduleResfresh() { |
|
504 |
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { |
|
505 |
|
|
506 |
@Override |
|
507 |
public boolean execute() { |
|
508 |
final Folder f = getSelection(); |
|
509 |
if (f == null) |
|
510 |
return true; |
|
511 |
|
|
512 |
HeadRequest<Folder> head = new HeadRequest<Folder>(Folder.class, getApiPath(), getUsername(), "/" + f.getContainer()) { |
|
513 |
|
|
514 |
@Override |
|
515 |
public void onSuccess(Folder _result) { |
|
516 |
lastModified = new Date(); |
|
517 |
if (getSelectedTree().equals(folderTreeView)) |
|
518 |
updateFolder(f, true, new Command() { |
|
519 |
|
|
520 |
@Override |
|
521 |
public void execute() { |
|
522 |
scheduleResfresh(); |
|
523 |
} |
|
524 |
|
|
525 |
}, false); |
|
526 |
else if (getSelectedTree().equals(mysharedTreeView)) |
|
527 |
updateSharedFolder(f, true, new Command() { |
|
528 |
|
|
529 |
@Override |
|
530 |
public void execute() { |
|
531 |
scheduleResfresh(); |
|
532 |
} |
|
533 |
}); |
|
534 |
} |
|
535 |
|
|
536 |
@Override |
|
537 |
public void onError(Throwable t) { |
|
538 |
if (t instanceof RestException && ((RestException) t).getHttpStatusCode() == HttpStatus.SC_NOT_MODIFIED) |
|
539 |
scheduleResfresh(); |
|
540 |
else if (retries >= MAX_RETRIES) { |
|
541 |
GWT.log("Error heading folder", t); |
|
542 |
setError(t); |
|
543 |
if (t instanceof RestException) |
|
544 |
displayError("Error heading folder: " + ((RestException) t).getHttpStatusText()); |
|
545 |
else |
|
546 |
displayError("System error heading folder: " + t.getMessage()); |
|
547 |
} |
|
548 |
else {//retry |
|
549 |
GWT.log("Retry " + retries); |
|
550 |
Scheduler.get().scheduleDeferred(this); |
|
551 |
} |
|
552 |
} |
|
553 |
|
|
554 |
@Override |
|
555 |
protected void onUnauthorized(Response response) { |
|
556 |
if (retries >= MAX_RETRIES) |
|
557 |
sessionExpired(); |
|
558 |
else //retry |
|
559 |
Scheduler.get().scheduleDeferred(this); |
|
560 |
} |
|
561 |
}; |
|
562 |
head.setHeader("X-Auth-Token", getToken()); |
|
563 |
head.setHeader("If-Modified-Since", DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss").format(lastModified, TimeZone.createTimeZone(0)) + " GMT"); |
|
564 |
Scheduler.get().scheduleDeferred(head); |
|
565 |
|
|
566 |
return false; |
|
567 |
} |
|
568 |
}, 3000); |
|
505 | 569 |
} |
506 | 570 |
|
507 | 571 |
public void applyPermissions(Folder f) { |
... | ... | |
803 | 867 |
} |
804 | 868 |
|
805 | 869 |
public static native void preventIESelection() /*-{ |
806 |
$doc.body.onselectstart = function () { return false; }; |
|
870 |
$doc.body.onselectstart = function() { |
|
871 |
return false; |
|
872 |
}; |
|
807 | 873 |
}-*/; |
808 | 874 |
|
809 | 875 |
public static native void enableIESelection() /*-{ |
810 | 876 |
if ($doc.body.onselectstart != null) |
811 |
$doc.body.onselectstart = null; |
|
877 |
$doc.body.onselectstart = null;
|
|
812 | 878 |
}-*/; |
813 | 879 |
|
814 | 880 |
/** |
... | ... | |
1217 | 1283 |
otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel); |
1218 | 1284 |
trees.insert(otherSharedTreeView, 1); |
1219 | 1285 |
treeViews.add(otherSharedTreeView); |
1286 |
scheduleResfresh(); |
|
1220 | 1287 |
} |
1221 | 1288 |
}); |
1222 | 1289 |
} |
Also available in: Unified diff