1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.web.workgroup;
35
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42 import java.util.stream.Collectors;
43
44 import javax.servlet.http.HttpServletRequest;
45
46 import org.apache.commons.collections.CollectionUtils;
47 import org.apache.commons.lang3.StringUtils;
48
49 import fr.paris.lutece.portal.business.right.Level;
50 import fr.paris.lutece.portal.business.right.LevelHome;
51 import fr.paris.lutece.portal.business.user.AdminUser;
52 import fr.paris.lutece.portal.business.user.AdminUserHome;
53 import fr.paris.lutece.portal.business.workgroup.AdminWorkgroup;
54 import fr.paris.lutece.portal.business.workgroup.AdminWorkgroupFilter;
55 import fr.paris.lutece.portal.business.workgroup.AdminWorkgroupHome;
56 import fr.paris.lutece.portal.service.admin.AccessDeniedException;
57 import fr.paris.lutece.portal.service.admin.AdminUserService;
58 import fr.paris.lutece.portal.service.message.AdminMessage;
59 import fr.paris.lutece.portal.service.message.AdminMessageService;
60 import fr.paris.lutece.portal.service.security.SecurityTokenService;
61 import fr.paris.lutece.portal.service.template.AppTemplateService;
62 import fr.paris.lutece.portal.service.util.AppPathService;
63 import fr.paris.lutece.portal.service.util.AppPropertiesService;
64 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupService;
65 import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService;
66 import fr.paris.lutece.portal.web.admin.AdminFeaturesPageJspBean;
67 import fr.paris.lutece.portal.web.constants.Messages;
68 import fr.paris.lutece.portal.web.constants.Parameters;
69 import fr.paris.lutece.portal.web.util.LocalizedPaginator;
70 import fr.paris.lutece.util.ReferenceItem;
71 import fr.paris.lutece.util.ReferenceList;
72 import fr.paris.lutece.util.html.AbstractPaginator;
73 import fr.paris.lutece.util.html.HtmlTemplate;
74 import fr.paris.lutece.util.html.ItemNavigator;
75 import fr.paris.lutece.util.sort.AttributeComparator;
76 import fr.paris.lutece.util.string.StringUtil;
77 import fr.paris.lutece.util.url.UrlItem;
78
79
80
81
82 public class AdminWorkgroupJspBean extends AdminFeaturesPageJspBean
83 {
84
85
86
87
88 public static final String RIGHT_MANAGE_WORKGROUPS = "CORE_WORKGROUPS_MANAGEMENT";
89
90
91
92
93 private static final long serialVersionUID = 5945178935890410656L;
94
95
96 private static final String TEMPLATE_MANAGE_WORGROUPS = "admin/workgroup/manage_workgroups.html";
97 private static final String TEMPLATE_CREATE_WORKGROUP = "admin/workgroup/create_workgroup.html";
98 private static final String TEMPLATE_MODIFY_WORKGROUP = "admin/workgroup/modify_workgroup.html";
99 private static final String TEMPLATE_ASSIGN_USERS = "admin/workgroup/assign_users_workgroup.html";
100
101
102 private static final String MARK_WORKGROUPS_LIST = "workgroups_list";
103 private static final String MARK_WORKGROUP = "workgroup";
104 private static final String MARK_USERS_LIST = "users_list";
105 private static final String MARK_ASSIGNED_USERS_LIST = "assigned_users_list";
106 private static final String MARK_ASSIGNED_USERS_NUMBER = "assigned_users_number";
107 private static final String MARK_SEARCH_IS_SEARCH = "search_is_search";
108 private static final String MARK_SEARCH_ADMIN_WORKGROUP_FILTER = "search_admin_workgroup_filter";
109 private static final String MARK_USER_LEVELS_LIST = "user_levels";
110 private static final String MARK_ITEM_NAVIGATOR = "item_navigator";
111 private static final String MARK_PAGINATOR = "paginator";
112 private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page";
113 private static final String MARK_SORT_SEARCH_ATTRIBUTE = "sort_search_attribute";
114
115
116 private static final String PROPERTY_CREATE_WORKGROUP_PAGETITLE = "portal.workgroup.create_workgroup.pageTitle";
117 private static final String PROPERTY_MODIFY_WORKGROUP_PAGETITLE = "portal.workgroup.modify_workgroup.pageTitle";
118 private static final String PROPERTY_ASSIGN_USERS_PAGETITLE = "portal.workgroup.assign_users.pageTitle";
119 private static final String PROPERTY_MANAGE_WORKGROUPS_PAGETITLE = "portal.workgroup.manage_workgroups.pageTitle";
120 private static final String PROPERTY_USERS_PER_PAGE = "paginator.user.itemsPerPage";
121
122
123 private static final String PARAMETER_WORKGROUP_KEY = "workgroup_key";
124 private static final String PARAMETER_WORKGROUP_DESCRIPTION = "workgroup_description";
125 private static final String PARAMETER_USERS_LIST = "list_users";
126 private static final String PARAMETER_ID_USER = "id_user";
127 private static final String PARAMETER_ANCHOR = "anchor";
128
129
130 private static final String JSP_MANAGE_WORKGROUPS = "ManageWorkgroups.jsp";
131 private static final String JSP_ASSIGN_USERS_TO_WORKGROUPS = "AssignUsersWorkgroup.jsp";
132 private static final String JSP_URL_REMOVE_WORKGROUP = "jsp/admin/workgroup/DoRemoveWorkgroup.jsp";
133 private static final String JSP_URL_ASSIGN_USERS_TO_WORKGROUPS = "jsp/admin/workgroup/AssignUsersWorkgroup.jsp";
134
135
136 private static final String MESSAGE_WORKGROUP_ALREADY_EXIST = "portal.workgroup.message.workgroupAlreadyExist";
137 private static final String MESSAGE_CONFIRM_REMOVE = "portal.workgroup.message.confirmRemove";
138 private static final String MESSAGE_WORKGROUP_ALREADY_USED = "portal.workgroup.message.workgroupAlreadyUsed";
139 private static final String MESSAGE_CANNOT_REMOVE_WORKGROUP = "portal.workgroup.message.cannotRemoveWorkgroup";
140 private static final String MESSAGE_WORKGROUP_ACCENTUATED_CHARACTER = "portal.workgroup.message.accentuatedCharacter";
141 private int _nItemsPerPage;
142 private int _nDefaultItemsPerPage;
143 private String _strCurrentPageIndex;
144 private ItemNavigator _itemNavigator;
145
146
147
148
149
150
151
152
153 public String getManageWorkgroups( HttpServletRequest request )
154 {
155 setPageTitleProperty( PROPERTY_MANAGE_WORKGROUPS_PAGETITLE );
156
157
158 reinitItemNavigator( );
159
160
161 AdminWorkgroupFilteroup/AdminWorkgroupFilter.html#AdminWorkgroupFilter">AdminWorkgroupFilter awFilter = new AdminWorkgroupFilter( );
162 boolean bIsSearch = awFilter.setAdminWorkgroupFilter( request );
163
164 List<AdminWorkgroup> listFilteredWorkgroups = (List<AdminWorkgroup>) AdminWorkgroupHome.findByFilter( awFilter );
165
166 HashMap<String, Object> model = new HashMap<>( );
167
168 if ( !getUser( ).isAdmin( ) )
169 {
170 listFilteredWorkgroups = (List<AdminWorkgroup>) AdminWorkgroupService.getAuthorizedCollection( listFilteredWorkgroups, getUser( ) );
171 }
172
173
174 String strSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME );
175 String strAscSort = null;
176
177 if ( strSortedAttributeName != null )
178 {
179 strAscSort = request.getParameter( Parameters.SORTED_ASC );
180
181 boolean bIsAscSort = Boolean.parseBoolean( strAscSort );
182
183 Collections.sort( listFilteredWorkgroups, new AttributeComparator( strSortedAttributeName, bIsAscSort ) );
184 }
185
186 _strCurrentPageIndex = AbstractPaginator.getPageIndex( request, AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
187 _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_USERS_PER_PAGE, 50 );
188 _nItemsPerPage = AbstractPaginator.getItemsPerPage( request, AbstractPaginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage );
189
190 String strURL = getHomeUrl( request );
191 UrlItem/url/UrlItem.html#UrlItem">UrlItem url = new UrlItem( strURL );
192
193 if ( strSortedAttributeName != null )
194 {
195 url.addParameter( Parameters.SORTED_ATTRIBUTE_NAME, strSortedAttributeName );
196 }
197
198 if ( strAscSort != null )
199 {
200 url.addParameter( Parameters.SORTED_ASC, strAscSort );
201 }
202
203 String strSortSearchAttribute = "";
204
205 if ( bIsSearch )
206 {
207 awFilter.setUrlAttributes( url );
208
209 if ( !awFilter.getUrlAttributes( ).equals( "" ) )
210 {
211 strSortSearchAttribute = "&" + awFilter.getUrlAttributes( );
212 }
213 }
214
215
216 LocalizedPaginator<AdminWorkgroup> paginator = new LocalizedPaginator<>( listFilteredWorkgroups, _nItemsPerPage, url.getUrl( ),
217 AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex, getLocale( ) );
218
219 model.put( MARK_NB_ITEMS_PER_PAGE, "" + _nItemsPerPage );
220 model.put( MARK_PAGINATOR, paginator );
221 model.put( MARK_WORKGROUPS_LIST, paginator.getPageItems( ) );
222 model.put( MARK_SEARCH_IS_SEARCH, bIsSearch );
223 model.put( MARK_SEARCH_ADMIN_WORKGROUP_FILTER, awFilter );
224 model.put( MARK_SORT_SEARCH_ATTRIBUTE, strSortSearchAttribute );
225
226 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_WORGROUPS, getLocale( ), model );
227
228 return getAdminPage( template.getHtml( ) );
229 }
230
231
232
233
234
235
236
237
238 public String getCreateWorkgroup( HttpServletRequest request )
239 {
240 setPageTitleProperty( PROPERTY_CREATE_WORKGROUP_PAGETITLE );
241
242 Map<String, Object> model = new HashMap<>( 1 );
243 model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_CREATE_WORKGROUP ) );
244
245 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_WORKGROUP, getLocale( ), model );
246
247 return getAdminPage( template.getHtml( ) );
248 }
249
250
251
252
253
254
255
256
257
258
259 public String doCreateWorkgroup( HttpServletRequest request ) throws AccessDeniedException
260 {
261 String strKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
262 String strDescription = request.getParameter( PARAMETER_WORKGROUP_DESCRIPTION );
263
264 if ( ( strKey == null ) || ( strKey.equals( "" ) ) )
265 {
266 return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP );
267 }
268
269 if ( ( strDescription == null ) || ( strDescription.equals( "" ) ) )
270 {
271 return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP );
272 }
273
274
275 if ( Boolean.TRUE.equals( AdminWorkgroupHome.checkExistWorkgroup( strKey ) ) )
276 {
277 return AdminMessageService.getMessageUrl( request, MESSAGE_WORKGROUP_ALREADY_EXIST, AdminMessage.TYPE_STOP );
278 }
279
280
281 if ( !StringUtil.checkCodeKey( strKey ) )
282 {
283 return AdminMessageService.getMessageUrl( request, MESSAGE_WORKGROUP_ACCENTUATED_CHARACTER, AdminMessage.TYPE_STOP );
284 }
285 if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_CREATE_WORKGROUP ) )
286 {
287 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
288 }
289
290 AdminWorkgroupoup/AdminWorkgroup.html#AdminWorkgroup">AdminWorkgroup adminWorkgroup = new AdminWorkgroup( );
291 adminWorkgroup.setKey( strKey.trim( ) );
292 adminWorkgroup.setDescription( strDescription );
293 AdminWorkgroupHome.create( adminWorkgroup );
294 AdminWorkgroupHome.addUserForWorkgroup( getUser( ), strKey );
295
296 return JSP_MANAGE_WORKGROUPS;
297 }
298
299
300
301
302
303
304
305
306 public String getConfirmRemoveWorkgroup( HttpServletRequest request )
307 {
308 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
309 String strUrlRemove = JSP_URL_REMOVE_WORKGROUP;
310 Map<String, String> parameters = new HashMap<>( );
311 parameters.put( PARAMETER_WORKGROUP_KEY, strWorkgroupKey );
312 parameters.put( SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance( ).getToken( request, JSP_URL_REMOVE_WORKGROUP ) );
313
314 return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE, strUrlRemove, AdminMessage.TYPE_CONFIRMATION, parameters );
315 }
316
317
318
319
320
321
322
323
324
325
326 public String doRemoveWorkgroup( HttpServletRequest request ) throws AccessDeniedException
327 {
328 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
329 ArrayList<String> listErrors = new ArrayList<>( );
330
331 if ( CollectionUtils.isNotEmpty( AdminWorkgroupHome.getUserListForWorkgroup( strWorkgroupKey ) ) )
332 {
333 return AdminMessageService.getMessageUrl( request, MESSAGE_WORKGROUP_ALREADY_USED, AdminMessage.TYPE_STOP );
334 }
335
336 if ( !WorkgroupRemovalListenerService.getService( ).checkForRemoval( strWorkgroupKey, listErrors, getLocale( ) ) )
337 {
338 String strCause = AdminMessageService.getFormattedList( listErrors, getLocale( ) );
339 Object [ ] args = {
340 strCause
341 };
342
343 return AdminMessageService.getMessageUrl( request, MESSAGE_CANNOT_REMOVE_WORKGROUP, args, AdminMessage.TYPE_STOP );
344 }
345 if ( !SecurityTokenService.getInstance( ).validate( request, JSP_URL_REMOVE_WORKGROUP ) )
346 {
347 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
348 }
349
350 AdminWorkgroupHome.remove( strWorkgroupKey );
351
352 return JSP_MANAGE_WORKGROUPS;
353 }
354
355
356
357
358
359
360
361
362 public String getModifyWorkgroup( HttpServletRequest request )
363 {
364 setPageTitleProperty( PROPERTY_MODIFY_WORKGROUP_PAGETITLE );
365
366 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
367
368 AdminWorkgroup workgroup = AdminWorkgroupHome.findByPrimaryKey( strWorkgroupKey );
369
370 if ( workgroup == null )
371 {
372 return getManageWorkgroups( request );
373 }
374
375 HashMap<String, Object> model = new HashMap<>( );
376 model.put( MARK_WORKGROUP, workgroup );
377 model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_MODIFY_WORKGROUP ) );
378 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_WORKGROUP, getLocale( ), model );
379
380 return getAdminPage( template.getHtml( ) );
381 }
382
383
384
385
386
387
388
389
390
391
392 public String doModifyWorkgroup( HttpServletRequest request ) throws AccessDeniedException
393 {
394 String strWorgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
395 String strDescription = request.getParameter( PARAMETER_WORKGROUP_DESCRIPTION );
396
397 if ( StringUtils.isEmpty( strDescription ) )
398 {
399 return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP );
400 }
401 if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_MODIFY_WORKGROUP ) )
402 {
403 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
404 }
405
406 AdminWorkgroupoup/AdminWorkgroup.html#AdminWorkgroup">AdminWorkgroup adminWorkgroup = new AdminWorkgroup( );
407 adminWorkgroup.setKey( strWorgroupKey );
408 adminWorkgroup.setDescription( strDescription );
409 AdminWorkgroupHome.update( adminWorkgroup );
410
411 return JSP_MANAGE_WORKGROUPS;
412 }
413
414
415
416
417
418
419
420
421 public String getAssignUsers( HttpServletRequest request )
422 {
423 Map<String, Object> model = new HashMap<>( );
424 setPageTitleProperty( PROPERTY_ASSIGN_USERS_PAGETITLE );
425
426 String strBaseUrl = AppPathService.getBaseUrl( request ) + JSP_URL_ASSIGN_USERS_TO_WORKGROUPS;
427 UrlItem/url/UrlItem.html#UrlItem">UrlItem url = new UrlItem( strBaseUrl );
428
429
430 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
431 AdminWorkgroup adminWorkgroup = AdminWorkgroupHome.findByPrimaryKey( strWorkgroupKey );
432
433 if ( adminWorkgroup == null )
434 {
435 return getManageWorkgroups( request );
436 }
437
438
439
440
441 List<AdminUser> listAssignedUsers = AdminWorkgroupHome.getUserListForWorkgroup( strWorkgroupKey ).stream( )
442 .filter( this::isUserHigherThanConnectedUser ).collect( Collectors.toList( ) );
443
444 List<AdminUser> listFilteredUsers = AdminUserService.getFilteredUsersInterface( listAssignedUsers, request, model, url );
445
446
447 ReferenceListst.html#ReferenceList">ReferenceList listUsers = new ReferenceList( );
448
449 for ( AdminUser user : AdminUserHome.findUserList( ) )
450 {
451 final ReferenceItemtem.html#ReferenceItem">ReferenceItem itemUser = new ReferenceItem( );
452 itemUser.setCode( Integer.toString( user.getUserId( ) ) );
453 itemUser.setName( user.getLastName( ) + " " + user.getFirstName( ) + " (" + user.getAccessCode( ) + ")" );
454
455 boolean bAssigned = listAssignedUsers.stream( )
456 .anyMatch( assignedUser -> Integer.toString( assignedUser.getUserId( ) ).equals( itemUser.getCode( ) ) );
457
458
459
460 if ( !bAssigned && isUserHigherThanConnectedUser( user ) )
461 {
462 listUsers.add( itemUser );
463 }
464 }
465
466
467 String strSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME );
468 String strAscSort = null;
469
470 if ( strSortedAttributeName != null )
471 {
472 url.addParameter( Parameters.SORTED_ATTRIBUTE_NAME, strSortedAttributeName );
473
474 strAscSort = request.getParameter( Parameters.SORTED_ASC );
475
476 boolean bIsAscSort = Boolean.parseBoolean( strAscSort );
477
478 Collections.sort( listFilteredUsers, new AttributeComparator( strSortedAttributeName, bIsAscSort ) );
479 }
480
481 _strCurrentPageIndex = AbstractPaginator.getPageIndex( request, AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
482 _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_USERS_PER_PAGE, 50 );
483 _nItemsPerPage = AbstractPaginator.getItemsPerPage( request, AbstractPaginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage );
484
485 if ( strAscSort != null )
486 {
487 url.addParameter( Parameters.SORTED_ASC, strAscSort );
488 }
489
490
491 setItemNavigator( strWorkgroupKey, url.getUrl( ) );
492
493
494 url.addParameter( PARAMETER_WORKGROUP_KEY, adminWorkgroup.getKey( ) );
495
496 LocalizedPaginator<AdminUser> paginator = new LocalizedPaginator<>( listFilteredUsers, _nItemsPerPage, url.getUrl( ),
497 AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex, getLocale( ) );
498
499
500 Collection<Level> filteredLevels = new ArrayList<>( );
501
502 for ( Level level : LevelHome.getLevelsList( ) )
503 {
504 if ( getUser( ).isAdmin( ) || getUser( ).hasRights( level.getId( ) ) )
505 {
506 filteredLevels.add( level );
507 }
508 }
509
510 model.put( MARK_WORKGROUP, adminWorkgroup );
511 model.put( MARK_USERS_LIST, listUsers );
512 model.put( MARK_ASSIGNED_USERS_LIST, paginator.getPageItems( ) );
513 model.put( MARK_ASSIGNED_USERS_NUMBER, listAssignedUsers.size( ) );
514 model.put( MARK_USER_LEVELS_LIST, filteredLevels );
515 model.put( MARK_ITEM_NAVIGATOR, _itemNavigator );
516 model.put( MARK_PAGINATOR, paginator );
517 model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( _nItemsPerPage ) );
518 model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_ASSIGN_USERS ) );
519
520 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_ASSIGN_USERS, getLocale( ), model );
521
522 return getAdminPage( template.getHtml( ) );
523 }
524
525
526
527
528
529
530
531
532
533
534 public String doAssignUsers( HttpServletRequest request ) throws AccessDeniedException
535 {
536 if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_ASSIGN_USERS ) )
537 {
538 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
539 }
540 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
541
542
543 String [ ] arrayUsersIds = request.getParameterValues( PARAMETER_USERS_LIST );
544
545 if ( ( arrayUsersIds != null ) )
546 {
547 for ( int i = 0; i < arrayUsersIds.length; i++ )
548 {
549 int nUserId = Integer.parseInt( arrayUsersIds [i] );
550 AdminUser user = AdminUserHome.findByPrimaryKey( nUserId );
551
552 if ( !AdminWorkgroupHome.isUserInWorkgroup( user, strWorkgroupKey ) )
553 {
554 AdminWorkgroupHome.addUserForWorkgroup( user, strWorkgroupKey );
555 }
556 }
557 }
558
559 return JSP_ASSIGN_USERS_TO_WORKGROUPS + "?" + PARAMETER_WORKGROUP_KEY + "=" + strWorkgroupKey;
560 }
561
562
563
564
565
566
567
568
569
570
571 public String doUnAssignUser( HttpServletRequest request ) throws AccessDeniedException
572 {
573 if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_ASSIGN_USERS ) )
574 {
575 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
576 }
577 String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP_KEY );
578 int nIdUser = Integer.parseInt( request.getParameter( PARAMETER_ID_USER ) );
579 String strAnchor = request.getParameter( PARAMETER_ANCHOR );
580
581 AdminUser adminUser = AdminUserHome.findByPrimaryKey( nIdUser );
582
583 if ( adminUser != null )
584 {
585 AdminWorkgroupHome.removeUserFromWorkgroup( adminUser, strWorkgroupKey );
586 }
587
588 return JSP_ASSIGN_USERS_TO_WORKGROUPS + "?" + PARAMETER_WORKGROUP_KEY + "=" + strWorkgroupKey + "#" + strAnchor;
589 }
590
591
592
593
594
595
596
597
598
599 private void setItemNavigator( String strWorkgroupKey, String strUrl )
600 {
601 if ( _itemNavigator == null )
602 {
603 List<String> listWorkgroupKeys = new ArrayList<>( );
604 int nCurrentItemId = 0;
605 int nIndex = 0;
606
607 for ( AdminWorkgroup workgroup : AdminWorkgroupHome.findAll( ) )
608 {
609 if ( ( workgroup != null ) && StringUtils.isNotBlank( workgroup.getKey( ) ) )
610 {
611 listWorkgroupKeys.add( workgroup.getKey( ) );
612
613 if ( workgroup.getKey( ).equals( strWorkgroupKey ) )
614 {
615 nCurrentItemId = nIndex;
616 }
617
618 nIndex++;
619 }
620 }
621
622 _itemNavigator = new ItemNavigator( listWorkgroupKeys, nCurrentItemId, strUrl, PARAMETER_WORKGROUP_KEY );
623 }
624 else
625 {
626 _itemNavigator.setCurrentItemId( strWorkgroupKey );
627 }
628 }
629
630
631
632
633 private void reinitItemNavigator( )
634 {
635 _itemNavigator = null;
636 }
637 }