@@ -63,22 +63,22 @@ public abstract class AbstractController {
63
63
@ Autowired
64
64
protected BreadcrumbService breadcrumbService ;
65
65
66
- //TODO: rename allCategories to allProjects
67
66
@ ModelAttribute ("allProjects" )
68
67
public final List <Project > getAllCategories (
69
68
@ ModelAttribute ("userSession" ) UserSessionBean userSession ,
70
69
BindingResult result , //TODO: remove
71
70
Model model //TODO: remove
72
71
) {
72
+ userSession = updateUserSession (userSession );
73
73
Context context = this .getContext (userSession );
74
74
return projectService .findAllProjectsByContext (context );
75
75
}
76
76
77
- //TODO: rename rootCategories to rootProjects
78
77
@ ModelAttribute ("rootProjects" )
79
78
public final List <Project > getRootCategories (
80
79
@ ModelAttribute ("userSession" ) UserSessionBean userSession
81
80
) {
81
+ userSession = updateUserSession (userSession );
82
82
Context context = this .getContext (userSession );
83
83
return projectService .findRootProjectsByContext (context );
84
84
}
@@ -117,11 +117,10 @@ public final List<TaskState> getTaskStates(){
117
117
@ ModelAttribute ("context" )
118
118
public final String getCurrentContext (
119
119
@ ModelAttribute ("userSession" ) UserSessionBean userSession ,
120
- Locale locale
120
+ Locale locale ,
121
+ Model model
121
122
){
122
- if (userSession == null ){
123
- userSession = new UserSessionBean ();
124
- }
123
+ userSession = updateUserSession (userSession );
125
124
Context context = getContext (userSession );
126
125
if (locale == null ){
127
126
locale = Locale .ENGLISH ;
@@ -154,6 +153,26 @@ protected Context getContext(@NotNull final UserSessionBean userSession){
154
153
return context ;
155
154
}
156
155
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
+
157
176
/*
158
177
protected Context getContext(UserSessionBean userSession){
159
178
UserAccount thisUser = this.getUser();
0 commit comments