Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fbe7b22d
authored
Oct 24, 2018
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change LocaleRestViewV3 to change also the jsf session locale
1 parent
d46285db
Pipeline
#158
failed
in 0 seconds
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/LocaleRestViewV3.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/LocaleRestViewV3.java
View file @
fbe7b22
...
@@ -3,15 +3,19 @@ package fi.codecrew.moya.rest.v3;
...
@@ -3,15 +3,19 @@ package fi.codecrew.moya.rest.v3;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.handler.SessionHandler
;
import
fi.codecrew.moya.handler.SessionStore
;
import
fi.codecrew.moya.rest.v3.pojo.LocalePojoV3
;
import
fi.codecrew.moya.rest.v3.pojo.LocalePojoV3
;
import
io.swagger.v3.oas.annotations.OpenAPIDefinition
;
import
io.swagger.v3.oas.annotations.OpenAPIDefinition
;
import
io.swagger.v3.oas.annotations.info.Info
;
import
io.swagger.v3.oas.annotations.info.Info
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.ws.rs.*
;
import
javax.ws.rs.*
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
java.util.Locale
;
@RequestScoped
@RequestScoped
@Path
(
"/v3/locale"
)
@Path
(
"/v3/locale"
)
...
@@ -27,6 +31,9 @@ public class LocaleRestViewV3 {
...
@@ -27,6 +31,9 @@ public class LocaleRestViewV3 {
@EJB
@EJB
private
EventBeanLocal
eventBean
;
private
EventBeanLocal
eventBean
;
@Inject
private
SessionStore
sessionStore
;
@GET
@GET
@Path
(
"/"
)
@Path
(
"/"
)
public
Response
getCurrentLocale
()
{
public
Response
getCurrentLocale
()
{
...
@@ -36,11 +43,22 @@ public class LocaleRestViewV3 {
...
@@ -36,11 +43,22 @@ public class LocaleRestViewV3 {
@POST
@POST
@Path
(
"/"
)
@Path
(
"/"
)
public
Response
setCurrentLocale
(
LocalePojoV3
locale
)
{
public
Response
setCurrentLocale
(
LocalePojoV3
localePojo
)
{
if
(
userBean
.
setUsersLocale
(
locale
.
userLocale
))
{
Locale
locale
=
Locale
.
forLanguageTag
(
localePojo
.
userLocale
);
if
(
userBean
.
setUsersLocale
(
localePojo
.
userLocale
))
{
sessionStore
.
setLocale
(
locale
);
return
Response
.
ok
().
build
();
return
Response
.
ok
().
build
();
}
}
return
Response
.
status
(
420
).
build
();
return
Response
.
status
(
420
).
build
();
}
}
public
SessionStore
getSessionStore
()
{
return
sessionStore
;
}
public
void
setSessionStore
(
SessionStore
sessionStore
)
{
this
.
sessionStore
=
sessionStore
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment