mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-29 23:37:10 +00:00
The client locale can be obtained through DispatchContext on the server
side
This commit is contained in:
1 parent
591f0aaf3c
commit
923d3b520f
6 files changed
+39
-7
No files matched your search
+2
-1
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.home.client.shared.dispatch;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.LocaleInfo;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.sap.sailing.gwt.ui.client.RemoteServiceMappingConstants;
|
||||
@@ -32,7 +33,7 @@ public class SimpleDispatch implements DispatchAsync {
|
||||
|
||||
@Override
|
||||
public <R extends Result, A extends Action<R>> void execute(A action, final AsyncCallback<R> callback) {
|
||||
dispatchRPC.execute(new RequestWrapper<R, A>(action), new AsyncCallback<ResultWrapper<R>>() {
|
||||
dispatchRPC.execute(new RequestWrapper<R, A>(action, LocaleInfo.getCurrentLocale().getLocaleName()), new AsyncCallback<ResultWrapper<R>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class DispatchRPCImpl extends ProxiedRemoteServiceServlet implements Disp
|
||||
|
||||
@Override
|
||||
public <R extends Result, A extends Action<R>> ResultWrapper<R> execute(RequestWrapper<R, A> request) throws DispatchException {
|
||||
R executionResult = request.getAction().execute(new DispatchContextImpl(request.getCurrentClientTime(), racingEventServiceTracker.getService()));
|
||||
R executionResult = request.getAction().execute(new DispatchContextImpl(request.getCurrentClientTime(), racingEventServiceTracker.getService(), request.getClientLocaleName()));
|
||||
return new ResultWrapper<R>(executionResult);
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -1,9 +1,18 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
|
||||
public interface DispatchContext {
|
||||
|
||||
RacingEventService getRacingEventService();
|
||||
|
||||
String getClientLocaleName();
|
||||
|
||||
Locale getClientLocale();
|
||||
|
||||
Date getCurrentClientTime();
|
||||
}
|
||||
+18
-4
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
@@ -8,11 +9,13 @@ import com.sap.sailing.server.RacingEventService;
|
||||
public class DispatchContextImpl implements DispatchContext {
|
||||
private final RacingEventService racingEventService;
|
||||
private final Date currentClientTime;
|
||||
private final Date currentServerTime = new Date();
|
||||
// private final Date currentServerTime = new Date();
|
||||
private String clientLocaleName;
|
||||
|
||||
public DispatchContextImpl(Date currentClientTime, RacingEventService racingEventService) {
|
||||
public DispatchContextImpl(Date currentClientTime, RacingEventService racingEventService, String clientLocaleName) {
|
||||
this.currentClientTime = currentClientTime;
|
||||
this.racingEventService = racingEventService;
|
||||
this.clientLocaleName = clientLocaleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,11 +23,22 @@ public class DispatchContextImpl implements DispatchContext {
|
||||
return racingEventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCurrentClientTime() {
|
||||
return currentClientTime;
|
||||
}
|
||||
|
||||
public Date getCurrentServerTime() {
|
||||
return currentServerTime;
|
||||
// public Date getCurrentServerTime() {
|
||||
// return currentServerTime;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getClientLocaleName() {
|
||||
return clientLocaleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getClientLocale() {
|
||||
return Locale.forLanguageTag(clientLocaleName);
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -8,15 +8,18 @@ public class RequestWrapper<R extends Result, A extends Action<R>> implements Is
|
||||
|
||||
private Date currentClientTime = new Date();
|
||||
|
||||
private String clientLocaleName;
|
||||
|
||||
private A action;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private RequestWrapper() {
|
||||
}
|
||||
|
||||
public RequestWrapper(A action) {
|
||||
public RequestWrapper(A action, String clientLocaleName) {
|
||||
super();
|
||||
this.action = action;
|
||||
this.clientLocaleName = clientLocaleName;
|
||||
}
|
||||
|
||||
public A getAction() {
|
||||
@@ -26,4 +29,8 @@ public class RequestWrapper<R extends Result, A extends Action<R>> implements Is
|
||||
public Date getCurrentClientTime() {
|
||||
return currentClientTime;
|
||||
}
|
||||
|
||||
public String getClientLocaleName() {
|
||||
return clientLocaleName;
|
||||
}
|
||||
}
|
||||
+1
@@ -52,6 +52,7 @@ public class GetEventOverviewStageAction implements Action<ResultWithTTL<EventOv
|
||||
|
||||
Iterable<URL> videoURLs = event.getVideoURLs();
|
||||
for (int i = Util.size(videoURLs) - 1; i >= 0; i--) {
|
||||
// TODO fmittag/pgt: implement locale specific live stream using context.getClientLocaleName() or context.getClientLocale()
|
||||
String videoUrl = Util.get(videoURLs, i).toString();
|
||||
MimeType type = MediaUtils.detectMimeTypeFromUrl(videoUrl);
|
||||
if (type == MimeType.youtube || type == MimeType.vimeo || type == MimeType.mp4) {
|
||||
|
||||
Reference in new issue
Block a user