66import org .springframework .stereotype .Service ;
77import org .springframework .transaction .annotation .Propagation ;
88import org .springframework .transaction .annotation .Transactional ;
9- import org .woehlke .simpleworklist .domain .breadcrumb .Breadcrumb ;
10- import org .woehlke .simpleworklist .domain .breadcrumb .BreadcrumbService ;
119import org .woehlke .simpleworklist .domain .context .Context ;
10+ import org .woehlke .simpleworklist .domain .context .ContextService ;
1211import org .woehlke .simpleworklist .domain .project .Project ;
1312import org .woehlke .simpleworklist .domain .task .Task ;
1413import org .woehlke .simpleworklist .domain .task .TaskState ;
14+ import org .woehlke .simpleworklist .user .session .UserSessionBean ;
1515
1616import java .util .Locale ;
17+ import java .util .Optional ;
1718import java .util .Stack ;
1819
1920@ Slf4j
2223public class BreadcrumbServiceImpl implements BreadcrumbService {
2324
2425 private final MessageSource messageSource ;
26+ private final ContextService contextService ;
2527
2628 @ Autowired
27- public BreadcrumbServiceImpl (MessageSource messageSource ) {
29+ public BreadcrumbServiceImpl (MessageSource messageSource , ContextService contextService ) {
2830 this .messageSource =messageSource ;
31+ this .contextService = contextService ;
2932 }
3033
3134 @ Override
32- public Breadcrumb getBreadcrumbForShowRootProject (Locale locale ) {
35+ public Breadcrumb getBreadcrumbForShowRootProject (Locale locale , UserSessionBean userSession ) {
3336 log .debug ("getBreadcrumbForShowRootProject" );
34- Breadcrumb breadcrumb = new Breadcrumb (locale );
37+ Optional <Context > context = contextService .getContextFor (userSession );
38+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
3539 breadcrumb .addProjectRoot ();
3640 return breadcrumb ;
3741 }
3842
3943 @ Override
40- public Breadcrumb getBreadcrumbForShowOneProject (Project thisProject , Locale locale ) {
44+ public Breadcrumb getBreadcrumbForShowOneProject (Project thisProject , Locale locale , UserSessionBean userSession ) {
4145 log .debug ("getBreadcrumbForShowOneProject" );
42- Breadcrumb breadcrumb = new Breadcrumb (locale );
46+ Optional <Context > context = contextService .getContextFor (userSession );
47+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
4348 breadcrumb .addProjectRoot ();
4449 if (thisProject == null ){
4550 return breadcrumb ;
@@ -60,28 +65,31 @@ public Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale loc
6065 }
6166
6267 @ Override
63- public Breadcrumb getBreadcrumbForTaskstate (TaskState taskstate , Locale locale ) {
68+ public Breadcrumb getBreadcrumbForTaskstate (TaskState taskstate , Locale locale , UserSessionBean userSession ) {
6469 log .debug ("getBreadcrumbForTaskstate" );
65- Breadcrumb breadcrumb = new Breadcrumb (locale );
70+ Optional <Context > context = contextService .getContextFor (userSession );
71+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
6672 String code = taskstate .getCode ();
6773 String name = messageSource .getMessage (code ,null ,locale );
6874 breadcrumb .addTaskstate (name ,taskstate .getUrl ());
6975 return breadcrumb ;
7076 }
7177
7278 @ Override
73- public Breadcrumb getBreadcrumbForTaskInTaskstate (String taskstate , Task task , Locale locale ) {
79+ public Breadcrumb getBreadcrumbForTaskInTaskstate (String taskstate , Task task , Locale locale , UserSessionBean userSession ) {
7480 log .debug ("getBreadcrumbForTaskInTaskstate" );
75- Breadcrumb breadcrumb = new Breadcrumb (locale );
81+ Optional <Context > context = contextService .getContextFor (userSession );
82+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
7683 breadcrumb .addTaskstate (taskstate );
7784 breadcrumb .addTask (task );
7885 return breadcrumb ;
7986 }
8087
8188 @ Override
82- public Breadcrumb getBreadcrumbForTaskstateAll (Locale locale ) {
89+ public Breadcrumb getBreadcrumbForTaskstateAll (Locale locale , UserSessionBean userSession ) {
8390 log .debug ("getBreadcrumbForTaskstateAll" );
84- Breadcrumb breadcrumb = new Breadcrumb (locale );
91+ Optional <Context > context = contextService .getContextFor (userSession );
92+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
8593 String code ="layout.page.all" ;
8694 String name = messageSource .getMessage (code ,null ,locale );
8795 String url ="/taskstate/all" ;
@@ -90,18 +98,19 @@ public Breadcrumb getBreadcrumbForTaskstateAll(Locale locale) {
9098 }
9199
92100 @ Override
93- public Breadcrumb getBreadcrumbForTaskInProject (Project thisProject , Task task , Locale locale ) {
101+ public Breadcrumb getBreadcrumbForTaskInProject (Project thisProject , Task task , Locale locale , UserSessionBean userSession ) {
94102 log .debug ("getBreadcrumbForTaskInProject" );
95- Breadcrumb breadcrumb = new Breadcrumb (locale );
103+ Breadcrumb breadcrumb = new Breadcrumb (locale , thisProject . getContext () );
96104 breadcrumb .addProject (thisProject );
97105 breadcrumb .addTask (task );
98106 return breadcrumb ;
99107 }
100108
101109 @ Override
102- public Breadcrumb getBreadcrumbForUserProfileAndMenu (Locale locale ) {
110+ public Breadcrumb getBreadcrumbForUserProfileAndMenu (Locale locale , UserSessionBean userSession ) {
103111 log .debug ("getBreadcrumbForUserProfileAndMenu" );
104- Breadcrumb breadcrumb = new Breadcrumb (locale );
112+ Optional <Context > context = contextService .getContextFor (userSession );
113+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
105114 String code ="pages.user.profile" ;
106115 String name = messageSource .getMessage (code ,null ,locale );
107116 String url ="/user/selfservice/profile" ;
@@ -110,9 +119,10 @@ public Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale) {
110119 }
111120
112121 @ Override
113- public Breadcrumb getBreadcrumbForUserChangeName (Locale locale ) {
122+ public Breadcrumb getBreadcrumbForUserChangeName (Locale locale , UserSessionBean userSession ) {
114123 log .debug ("getBreadcrumbForUserChangeName" );
115- Breadcrumb breadcrumb = new Breadcrumb (locale );
124+ Optional <Context > context = contextService .getContextFor (userSession );
125+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
116126 String code ="pages.user.profile" ;
117127 String name = messageSource .getMessage (code ,null ,locale );
118128 String url ="/user/selfservice/profile" ;
@@ -125,9 +135,10 @@ public Breadcrumb getBreadcrumbForUserChangeName(Locale locale) {
125135 }
126136
127137 @ Override
128- public Breadcrumb getBreadcrumbForUserChangePassword (Locale locale ) {
138+ public Breadcrumb getBreadcrumbForUserChangePassword (Locale locale , UserSessionBean userSession ) {
129139 log .debug ("getBreadcrumbForUserChangePassword" );
130- Breadcrumb breadcrumb = new Breadcrumb (locale );
140+ Optional <Context > context = contextService .getContextFor (userSession );
141+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
131142 String code ="pages.user.profile" ;
132143 String name = messageSource .getMessage (code ,null ,locale );
133144 String url ="/user/selfservice/profile" ;
@@ -140,9 +151,10 @@ public Breadcrumb getBreadcrumbForUserChangePassword(Locale locale) {
140151 }
141152
142153 @ Override
143- public Breadcrumb getBreadcrumbForUserContexts (Locale locale ) {
154+ public Breadcrumb getBreadcrumbForUserContexts (Locale locale , UserSessionBean userSession ) {
144155 log .debug ("getBreadcrumbForUserContexts" );
145- Breadcrumb breadcrumb = new Breadcrumb (locale );
156+ Optional <Context > context = contextService .getContextFor (userSession );
157+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
146158 String code ="pages.user.profile" ;
147159 String name = messageSource .getMessage (code ,null ,locale );
148160 String url ="/user/selfservice/profile" ;
@@ -155,9 +167,10 @@ public Breadcrumb getBreadcrumbForUserContexts(Locale locale) {
155167 }
156168
157169 @ Override
158- public Breadcrumb getBreadcrumbForUserContextAdd (Locale locale ) {
170+ public Breadcrumb getBreadcrumbForUserContextAdd (Locale locale , UserSessionBean userSession ) {
159171 log .debug ("getBreadcrumbForUserContextAdd" );
160- Breadcrumb breadcrumb = new Breadcrumb (locale );
172+ Optional <Context > context = contextService .getContextFor (userSession );
173+ Breadcrumb breadcrumb = new Breadcrumb (locale , context .get ());
161174 String code ="pages.user.profile" ;
162175 String name = messageSource .getMessage (code ,null ,locale );
163176 String url ="/user/selfservice/profile" ;
@@ -170,9 +183,10 @@ public Breadcrumb getBreadcrumbForUserContextAdd(Locale locale) {
170183 }
171184
172185 @ Override
173- public Breadcrumb getBreadcrumbForUserContextEdit (Locale locale , Context context ) {
186+ public Breadcrumb getBreadcrumbForUserContextEdit (Locale locale , Context context , UserSessionBean userSession ) {
174187 log .debug ("getBreadcrumbForUserContextEdit" );
175- Breadcrumb breadcrumb = new Breadcrumb (locale );
188+ Optional <Context > contextFromSession = contextService .getContextFor (userSession );
189+ Breadcrumb breadcrumb = new Breadcrumb (locale , contextFromSession .get ());
176190 String code ="pages.user.profile" ;
177191 String name = messageSource .getMessage (code ,null ,locale );
178192 String url ="/user/selfservice/profile" ;
@@ -185,9 +199,10 @@ public Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context
185199 }
186200
187201 @ Override
188- public Breadcrumb getBreadcrumbForUserContextDelete (Locale locale , Context context ) {
202+ public Breadcrumb getBreadcrumbForUserContextDelete (Locale locale , Context context , UserSessionBean userSession ) {
189203 log .debug ("getBreadcrumbForUserContextDelete" );
190- Breadcrumb breadcrumb = new Breadcrumb (locale );
204+ Optional <Context > contextFromSession = contextService .getContextFor (userSession );
205+ Breadcrumb breadcrumb = new Breadcrumb (locale , contextFromSession .get ());
191206 String code ="pages.user.profile" ;
192207 String name = messageSource .getMessage (code ,null ,locale );
193208 String url ="/user/selfservice/profile" ;
@@ -200,9 +215,10 @@ public Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context conte
200215 }
201216
202217 @ Override
203- public Breadcrumb getBreadcrumbForUserChangeLanguage (Locale locale ) {
218+ public Breadcrumb getBreadcrumbForUserChangeLanguage (Locale locale , UserSessionBean userSession ) {
204219 log .debug ("getBreadcrumbForUserChangeLanguage" );
205- Breadcrumb breadcrumb = new Breadcrumb (locale );
220+ Optional <Context > contextFromSession = contextService .getContextFor (userSession );
221+ Breadcrumb breadcrumb = new Breadcrumb (locale , contextFromSession .get ());
206222 String code ="pages.user.profile" ;
207223 String name = messageSource .getMessage (code ,null ,locale );
208224 String url ="/user/selfservice/profile" ;
@@ -215,9 +231,10 @@ public Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale) {
215231 }
216232
217233 @ Override
218- public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser (Locale locale ) {
234+ public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser (Locale locale , UserSessionBean userSession ) {
219235 log .debug ("getBreadcrumbForMessagesBetweenCurrentAndOtherUser" );
220- Breadcrumb breadcrumb = new Breadcrumb (locale );
236+ Optional <Context > contextFromSession = contextService .getContextFor (userSession );
237+ Breadcrumb breadcrumb = new Breadcrumb (locale , contextFromSession .get ());
221238 String code ="pages.user.profile" ;
222239 String name = messageSource .getMessage (code ,null ,locale );
223240 String url ="/user/selfservice/profile" ;
@@ -230,9 +247,10 @@ public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale loca
230247 }
231248
232249 @ Override
233- public Breadcrumb getBreadcrumbForSearchResults (Locale locale ) {
250+ public Breadcrumb getBreadcrumbForSearchResults (Locale locale , UserSessionBean userSession ) {
234251 log .debug ("getBreadcrumbForSearchResults" );
235- Breadcrumb breadcrumb = new Breadcrumb (locale );
252+ Optional <Context > contextFromSession = contextService .getContextFor (userSession );
253+ Breadcrumb breadcrumb = new Breadcrumb (locale , contextFromSession .get ());
236254 String code ="pages.user.profile" ;
237255 String name = messageSource .getMessage (code ,null ,locale );
238256 String url ="/user/selfservice/profile" ;
0 commit comments