1 package org.kuali.student.common.ui.client.security;
2
3 import org.kuali.student.common.ui.client.service.exceptions.VersionMismatchClientException;
4 import org.kuali.student.common.ui.client.widgets.KSErrorDialog;
5
6 import com.google.gwt.core.client.GWT;
7 import com.google.gwt.user.client.Window;
8
9
10
11
12
13
14
15 public class AsyncCallbackFailureHandler {
16
17
18
19
20 protected static final SessionTimeoutHandler sessionTimeoutHandler = GWT.create(SpringSecurityLoginDialogHandler.class);
21
22 public void onFailure(Throwable caught) {
23
24
25
26
27
28
29
30
31
32
33 if (sessionTimeoutHandler.isSessionTimeout(caught)){
34 handleTimeout(caught);
35 sessionTimeoutHandler.handleSessionTimeout();
36 } else if (caught instanceof VersionMismatchClientException){
37 handleVersionMismatch(caught);
38 }else {
39 handleFailure(caught);
40 }
41 }
42
43
44
45
46
47
48
49 public void handleFailure(Throwable caught){
50 if (!sessionTimeoutHandler.isSessionTimeout(caught)){
51 KSErrorDialog.show(caught);
52 }
53 GWT.log("Exception:", caught);
54 }
55
56
57
58
59
60
61
62 public void handleTimeout(Throwable caught){
63 handleFailure(caught);
64 }
65
66 public void handleVersionMismatch(Throwable caught){
67 String message = null;
68 if (caught.getMessage() != null){
69 message = "Version Error: " + caught.getMessage() + "\n\n";
70 }
71 message += "This page has been updated by another user since you loaded it. Please refresh and re-apply changes before saving.";
72 Window.alert(message);
73 }
74
75 }