java/com.sap.sailing.dashboards.gwt/.settings/com.gwtplugins.gwt.eclipse.core.prefs
... ...
@@ -1,5 +1,5 @@
1 1
//gwtVersion_/com.google.gwt.servlet/lib=
2
-//gwtVersion_/com.google.gwt.user/lib=
2
+//gwtVersion_/com.google.gwt.user/lib=2.11.1
3 3
//gwtVersion_/opt/gwt-2.11.0=2.11.0
4 4
//gwtVersion_/opt/gwt-2.11.1=2.11.1
5 5
//gwtVersion_/usr/local/gwt-2.11.0=2.11.0
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/tractrac/TracTracConnectionDialog.java
... ...
@@ -1,5 +1,16 @@
1 1
package com.sap.sailing.gwt.ui.adminconsole.tractrac;
2 2
3
+import com.google.gwt.http.client.Request;
4
+import com.google.gwt.http.client.RequestBuilder;
5
+import com.google.gwt.http.client.RequestCallback;
6
+import com.google.gwt.http.client.RequestException;
7
+import com.google.gwt.http.client.Response;
8
+import com.google.gwt.json.client.JSONObject;
9
+import com.google.gwt.json.client.JSONParser;
10
+import com.google.gwt.json.client.JSONString;
11
+import com.google.gwt.json.client.JSONValue;
12
+import com.google.gwt.user.client.Window;
13
+import com.google.gwt.user.client.ui.Button;
3 14
import com.google.gwt.user.client.ui.Focusable;
4 15
import com.google.gwt.user.client.ui.Grid;
5 16
import com.google.gwt.user.client.ui.Label;
... ...
@@ -34,6 +45,7 @@ public class TracTracConnectionDialog extends DataEntryDialog<TracTracConfigurat
34 45
protected TextBox tracTracApiTokenTextBox;
35 46
protected boolean tracTracApiTokenAvailable;
36 47
protected PasswordTextBox tractracPasswordTextBox;
48
+ private final ErrorReporter errorReporter;
37 49
protected String creatorName;
38 50
protected String name;
39 51
... ...
@@ -45,12 +57,13 @@ public class TracTracConnectionDialog extends DataEntryDialog<TracTracConfigurat
45 57
final ErrorReporter errorReporter) {
46 58
super(stringMessages.tracTracConnection(), /* message */null, stringMessages.ok(), stringMessages.cancel(),
47 59
/* validator */ null, /* animationEnabled */true, callback);
60
+ this.errorReporter = errorReporter;
48 61
this.ensureDebugId("TracTracConnectionDialog");
49 62
createUi();
50 63
}
51 64
52 65
private void createUi() {
53
- grid = new Grid(6, 2);
66
+ grid = new Grid(6, 3);
54 67
grid.setWidget(0, 0, new Label(stringMessages.details() + ":"));
55 68
Label liveURILabel = new Label(stringMessages.liveUri() + ":");
56 69
liveURILabel.setTitle(stringMessages.leaveEmptyForDefault());
... ...
@@ -91,8 +104,87 @@ public class TracTracConnectionDialog extends DataEntryDialog<TracTracConfigurat
91 104
tracTracApiTokenTextBox.setVisibleLength(40);
92 105
grid.setWidget(5, 0, new Label(stringMessages.tractracApiToken() + ":"));
93 106
grid.setWidget(5, 1, tracTracApiTokenTextBox);
107
+ final Button testConnectionButton = new Button(stringMessages.testConnection());
108
+ testConnectionButton.addClickHandler(e->testTracTracConnection());
109
+ testConnectionButton.setEnabled(false); // need active entry of API token
110
+ tracTracApiTokenTextBox.addKeyUpHandler(e -> testConnectionButton.setEnabled(Util.hasLength(tracTracApiTokenTextBox.getValue())));
111
+ grid.setWidget(5, 2, testConnectionButton);
94 112
}
95 113
114
+ private void testTracTracConnection() {
115
+ // need to obtain event ID and perhaps server_update_uri from document referenced by JSON URL
116
+ final RequestBuilder rbJsonUrl = new RequestBuilder(RequestBuilder.GET, jsonURLTextBox.getValue());
117
+ try {
118
+ rbJsonUrl.sendRequest(/* request data */ null, new RequestCallback() {
119
+ @Override
120
+ public void onResponseReceived(Request request, Response response) {
121
+ if (200 == response.getStatusCode()) {
122
+ // Success
123
+ final String responseText = response.getText();
124
+ final JSONValue jsonResult = JSONParser.parseStrict(responseText);
125
+ if (jsonResult instanceof JSONObject) {
126
+ final JSONObject jsonObject = (JSONObject) jsonResult;
127
+ final JSONObject eventJson = (JSONObject) jsonObject.get("event");
128
+ final String eventId = eventJson.get("id").isString().stringValue();
129
+ String serverUpdateURI = null;
130
+ if (!Util.hasLength(tracTracUpdateURITextBox.getValue())) {
131
+ final JSONString serverUpdateURIJSONString = eventJson.get("server_update_uri").isString();
132
+ if (serverUpdateURIJSONString == null) {
133
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed("server_update_uri"));
134
+ serverUpdateURI = null;
135
+ } else {
136
+ serverUpdateURI = serverUpdateURIJSONString.stringValue();
137
+ }
138
+ } else {
139
+ serverUpdateURI = tracTracUpdateURITextBox.getValue();
140
+ }
141
+ if (serverUpdateURI == null) {
142
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed("server_update_uri"));
143
+ } else {
144
+ testTracTracConnectionWithUpdateURI(serverUpdateURI, eventId);
145
+ }
146
+ } else {
147
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(jsonResult.getClass().getName()));
148
+ }
149
+ } else {
150
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(response.getStatusText()));
151
+ }
152
+ }
153
+
154
+ @Override
155
+ public void onError(Request request, Throwable exception) {
156
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(exception.getMessage()));
157
+ }
158
+ });
159
+ } catch (RequestException e) {
160
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(e.getMessage()));
161
+ }
162
+ }
163
+
164
+ private void testTracTracConnectionWithUpdateURI(String serverUpdateURI, String eventId) {
165
+ final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUpdateURI+"/api/v3/valid?eventId="+eventId);
166
+ rb.setHeader("Authorization", "Bearer " + tracTracApiTokenTextBox.getValue());
167
+ try {
168
+ rb.sendRequest(/* request data */ null, new RequestCallback() {
169
+ @Override
170
+ public void onResponseReceived(Request request, Response response) {
171
+ if (200 == response.getStatusCode()) {
172
+ Window.alert(stringMessages.ok()+"\n"+response.getText());
173
+ } else {
174
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(response.getStatusText()));
175
+ }
176
+ }
177
+
178
+ @Override
179
+ public void onError(Request request, Throwable exception) {
180
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(exception.getMessage()));
181
+ }
182
+ });
183
+ } catch (RequestException e) {
184
+ errorReporter.reportError(stringMessages.tracTracConnectionTestFailed(e.getMessage()));
185
+ }
186
+ }
187
+
96 188
@Override
97 189
protected Focusable getInitialFocusWidget() {
98 190
return jsonURLTextBox;
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java
... ...
@@ -2562,4 +2562,6 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages,
2562 2562
String exportTWAHistogramToCsv();
2563 2563
String exportWindSpeedHistogramToCsv();
2564 2564
String optionalBearerTokenForWindImport();
2565
+ String testConnection();
2566
+ String tracTracConnectionTestFailed(String message);
2565 2567
}
... ...
\ No newline at end of file
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties
... ...
@@ -2599,4 +2599,6 @@ selectFromRaceColumn=Select race column from where to start copying pairings
2599 2599
selectToRaceColumn=Select race colunm to where to copy pairings
2600 2600
exportTWAHistogramToCsv=Export True Wind Angle histogram to CSV
2601 2601
exportWindSpeedHistogramToCsv=Export Wind Speed histogram to CSV
2602
-optionalBearerTokenForWindImport=Optional bearer token for wind import
... ...
\ No newline at end of file
0
+optionalBearerTokenForWindImport=Optional bearer token for wind import
1
+testConnection=Test Connection
2
+tracTracConnectionTestFailed=TracTrac connection test failed: {0}
... ...
\ No newline at end of file
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties
... ...
@@ -2593,4 +2593,6 @@ selectFromRaceColumn=Spalte auswählen, ab der die Zuordnungen kopiert werden so
2593 2593
selectToRaceColumn=Spalte auswählen, bis zu der die Zuordnungen kopiert werden sollen
2594 2594
exportTWAHistogramToCsv=Histogramm der wahren Windwinkel in CSV exportieren
2595 2595
exportWindSpeedHistogramToCsv=Histogramm der wahren Windgeschwindigkeiten in CSV exportieren
2596
-optionalBearerTokenForWindImport=Optionales Bearer Token für Wind-Import
... ...
\ No newline at end of file
0
+optionalBearerTokenForWindImport=Optionales Bearer Token für Wind-Import
1
+testConnection=Verbindung testen
2
+tracTracConnectionTestFailed=TracTrac-Verbindungstest fehlgeschlagen: {0}
... ...
\ No newline at end of file
java/com.sap.sse.gwt.test/.settings/com.gwtplugins.gwt.eclipse.core.prefs
... ...
@@ -1,4 +1,4 @@
1
-//gwtVersion_/com.google.gwt.user/lib=
1
+//gwtVersion_/com.google.gwt.user/lib=2.11.1
2 2
//gwtVersion_/opt/gwt-2.11.0=2.11.0
3 3
//gwtVersion_/opt/gwt-2.11.1=2.11.1
4 4
//gwtVersion_/usr/local/gwt-2.11.0=2.11.0
java/com.sap.sse.gwt/.settings/com.gwtplugins.gwt.eclipse.core.prefs
... ...
@@ -1,4 +1,4 @@
1
-//gwtVersion_/com.google.gwt.user/lib=
1
+//gwtVersion_/com.google.gwt.user/lib=2.11.1
2 2
//gwtVersion_/opt/gwt-2.11.0=2.11.0
3 3
//gwtVersion_/opt/gwt-2.11.1=2.11.1
4 4
//gwtVersion_/usr/local/gwt-2.11.0=2.11.0
java/com.sap.sse.security.ui/.settings/com.gwtplugins.gwt.eclipse.core.prefs
... ...
@@ -1,4 +1,4 @@
1
-//gwtVersion_/com.google.gwt.user/lib=
1
+//gwtVersion_/com.google.gwt.user/lib=2.11.1
2 2
//gwtVersion_/opt/gwt-2.11.0=2.11.0
3 3
//gwtVersion_/opt/gwt-2.11.1=2.11.1
4 4
//gwtVersion_/usr/local/gwt-2.11.0=2.11.0