@@ -63,22 +63,22 @@ public abstract class AbstractController {
6363 @ Autowired
6464 protected BreadcrumbService breadcrumbService ;
6565
66- //TODO: rename allCategories to allProjects
6766 @ ModelAttribute ("allProjects" )
6867 public final List <Project > getAllCategories (
6968 @ ModelAttribute ("userSession" ) UserSessionBean userSession ,
7069 BindingResult result , //TODO: remove
7170 Model model //TODO: remove
7271 ) {
72+ userSession = updateUserSession (userSession );
7373 Context context = this .getContext (userSession );
7474 return projectService .findAllProjectsByContext (context );
7575 }
7676
77- //TODO: rename rootCategories to rootProjects
7877 @ ModelAttribute ("rootProjects" )
7978 public final List <Project > getRootCategories (
8079 @ ModelAttribute ("userSession" ) UserSessionBean userSession
8180 ) {
81+ userSession = updateUserSession (userSession );
8282 Context context = this .getContext (userSession );
8383 return projectService .findRootProjectsByContext (context );
8484 }
@@ -117,11 +117,10 @@ public final List<TaskState> getTaskStates(){
117117 @ ModelAttribute ("context" )
118118 public final String getCurrentContext (
119119 @ ModelAttribute ("userSession" ) UserSessionBean userSession ,
120- Locale locale
120+ Locale locale ,
121+ Model model
121122 ){
122- if (userSession == null ){
123- userSession = new UserSessionBean ();
124- }
123+ userSession = updateUserSession (userSession );
125124 Context context = getContext (userSession );
126125 if (locale == null ){
127126 locale = Locale .ENGLISH ;
@@ -154,6 +153,26 @@ protected Context getContext(@NotNull final UserSessionBean userSession){
154153 return context ;
155154 }
156155
156+ protected UserSessionBean getNewUserSession (){
157+ UserAccount thisUser = this .getUser ();
158+ long userAccountid = thisUser .getId ();
159+ long contextId = thisUser .getDefaultContext ().getId ();
160+ UserSessionBean userSession = new UserSessionBean (userAccountid ,contextId );
161+ return userSession ;
162+ }
163+
164+ protected UserSessionBean updateUserSession (UserSessionBean userSession ){
165+ if (userSession == null ){
166+ userSession = getNewUserSession ();
167+ } else {
168+ UserAccount thisUser = this .getUser ();
169+ long contextId = thisUser .getDefaultContext ().getId ();
170+ long userAccountid = thisUser .getId ();
171+ userSession .update (userAccountid ,contextId );
172+ }
173+ return userSession ;
174+ }
175+
157176 /*
158177 protected Context getContext(UserSessionBean userSession){
159178 UserAccount thisUser = this.getUser();
0 commit comments