From 5a0d8f91ae89bc14b43711dd33884236a2a9f13c Mon Sep 17 00:00:00 2001 From: meg Date: Tue, 6 Nov 2018 14:02:14 +0100 Subject: [PATCH 1/2] Provides instead of setting languages from the Web/UserContext to the CallContext so already set languages will not be overridden --- src/main/java/sirius/web/http/WebServerHandler.java | 2 +- src/main/java/sirius/web/security/UserContext.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/sirius/web/http/WebServerHandler.java b/src/main/java/sirius/web/http/WebServerHandler.java index a9d9ccfc6..2cee0d76e 100644 --- a/src/main/java/sirius/web/http/WebServerHandler.java +++ b/src/main/java/sirius/web/http/WebServerHandler.java @@ -175,7 +175,7 @@ private WebContext setupContext(ChannelHandlerContext ctx, HttpRequest req) { // if everything else fails, parse the lang header. currentCall.deferredSetLang(callContext -> { if (!callContext.get(UserContext.class).bindUserIfPresent(wc).isPresent()) { - callContext.setLang(NLS.makeLang(wc.getLang())); + callContext.provideLang(NLS.makeLang(wc.getLang())); } }); diff --git a/src/main/java/sirius/web/security/UserContext.java b/src/main/java/sirius/web/security/UserContext.java index 968b3977e..3af19e519 100644 --- a/src/main/java/sirius/web/security/UserContext.java +++ b/src/main/java/sirius/web/security/UserContext.java @@ -197,7 +197,7 @@ private void bindScopeToRequest(WebContext ctx) { if (ctx != null && ctx.isValid() && detector != null) { ScopeInfo scope = detector.detectScope(ctx); setCurrentScope(scope); - CallContext.getCurrent().setLang(scope.getLang()); + CallContext.getCurrent().provideLang(scope.getLang()); } else { setCurrentScope(ScopeInfo.DEFAULT_SCOPE); } @@ -274,7 +274,7 @@ public void setCurrentUser(@Nullable UserInfo user) { CallContext call = CallContext.getCurrent(); call.addToMDC(MDC_USER_ID, () -> currentUser.getUserId()); call.addToMDC(MDC_USER_NAME, () -> currentUser.getUserName()); - call.setLang(user.getLang()); + call.provideLang(currentUser.getLang()); } /** From dcf4495908ee5bc725870ec0f7cf06b772b98507 Mon Sep 17 00:00:00 2001 From: meg Date: Tue, 6 Nov 2018 15:48:05 +0100 Subject: [PATCH 2/2] sirius-kernel update --- pom.xml | 2 +- src/main/java/sirius/web/http/WebServerHandler.java | 2 +- src/main/java/sirius/web/security/UserContext.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4e4aad13d..81ee9780e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ Provides a modern and scalable web server as SIRIUS module - 12.0-rc30 + 12.0-rc31 diff --git a/src/main/java/sirius/web/http/WebServerHandler.java b/src/main/java/sirius/web/http/WebServerHandler.java index 2cee0d76e..cc8775f84 100644 --- a/src/main/java/sirius/web/http/WebServerHandler.java +++ b/src/main/java/sirius/web/http/WebServerHandler.java @@ -175,7 +175,7 @@ private WebContext setupContext(ChannelHandlerContext ctx, HttpRequest req) { // if everything else fails, parse the lang header. currentCall.deferredSetLang(callContext -> { if (!callContext.get(UserContext.class).bindUserIfPresent(wc).isPresent()) { - callContext.provideLang(NLS.makeLang(wc.getLang())); + callContext.setLangIfEmpty(NLS.makeLang(wc.getLang())); } }); diff --git a/src/main/java/sirius/web/security/UserContext.java b/src/main/java/sirius/web/security/UserContext.java index 3af19e519..3919a9c2e 100644 --- a/src/main/java/sirius/web/security/UserContext.java +++ b/src/main/java/sirius/web/security/UserContext.java @@ -197,7 +197,7 @@ private void bindScopeToRequest(WebContext ctx) { if (ctx != null && ctx.isValid() && detector != null) { ScopeInfo scope = detector.detectScope(ctx); setCurrentScope(scope); - CallContext.getCurrent().provideLang(scope.getLang()); + CallContext.getCurrent().setLangIfEmpty(scope.getLang()); } else { setCurrentScope(ScopeInfo.DEFAULT_SCOPE); } @@ -274,7 +274,7 @@ public void setCurrentUser(@Nullable UserInfo user) { CallContext call = CallContext.getCurrent(); call.addToMDC(MDC_USER_ID, () -> currentUser.getUserId()); call.addToMDC(MDC_USER_NAME, () -> currentUser.getUserName()); - call.provideLang(currentUser.getLang()); + call.setLangIfEmpty(currentUser.getLang()); } /**