View Javadoc
1   /*
2    * Copyright (c) 2002-2017, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  
35  package fr.paris.lutece.plugins.transparency.web;
36  
37  import fr.paris.lutece.plugins.transparency.business.Appointment;
38  import fr.paris.lutece.plugins.transparency.business.AppointmentFilter;
39  import fr.paris.lutece.plugins.transparency.business.AppointmentHome;
40  import fr.paris.lutece.plugins.transparency.business.ElectedOfficial;
41  import fr.paris.lutece.plugins.transparency.business.ElectedOfficialAppointment;
42  import fr.paris.lutece.plugins.transparency.business.ElectedOfficialAppointmentHome;
43  import fr.paris.lutece.plugins.transparency.business.ElectedOfficialHome;
44  import fr.paris.lutece.plugins.transparency.business.Lobby;
45  import fr.paris.lutece.plugins.transparency.business.LobbyAppointment;
46  import fr.paris.lutece.plugins.transparency.business.LobbyAppointmentHome;
47  import fr.paris.lutece.plugins.transparency.business.LobbyHome;
48  import fr.paris.lutece.portal.service.i18n.I18nService;
49  import fr.paris.lutece.portal.service.message.SiteMessage;
50  import fr.paris.lutece.portal.service.util.AppPathService;
51  import fr.paris.lutece.portal.util.mvc.commons.annotations.Action;
52  import fr.paris.lutece.portal.web.xpages.XPage;
53  import fr.paris.lutece.portal.util.mvc.xpage.MVCApplication;
54  import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
55  import fr.paris.lutece.portal.util.mvc.xpage.annotations.Controller;
56  import fr.paris.lutece.util.string.StringUtil;
57  import fr.paris.lutece.util.url.UrlItem;
58  import fr.paris.lutece.portal.service.message.SiteMessageException;
59  import fr.paris.lutece.portal.service.message.SiteMessageService;
60  import fr.paris.lutece.portal.service.security.LuteceUser;
61  import fr.paris.lutece.portal.service.security.SecurityService;
62  import fr.paris.lutece.portal.service.security.UserNotSignedException;
63  import fr.paris.lutece.util.ReferenceList;
64  import fr.paris.lutece.util.html.Paginator;
65  import java.sql.Date;
66  import java.util.List;
67  import java.util.Map;
68  import javax.servlet.http.HttpServletRequest;
69  import org.codehaus.plexus.util.StringUtils;
70  
71  /**
72   * This class provides the user interface to manage Appointment xpages ( manage, create, modify, remove )
73   */
74  @Controller( xpageName = "meeting", pageTitleI18nKey = "transparency.xpage.appointment.pageTitle", pagePathI18nKey = "transparency.xpage.appointment.pagePathLabel" )
75  public class AppointmentXPage extends MVCApplication
76  {
77      // Templates
78      private static final String TEMPLATE_MANAGE_APPOINTMENTS = "/skin/plugins/transparency/manage_appointments.html";
79      private static final String TEMPLATE_DETAIL_APPOINTMENT = "/skin/plugins/transparency/detail_appointment.html";
80      private static final String TEMPLATE_CREATE_APPOINTMENT = "/skin/plugins/transparency/create_appointment.html";
81      private static final String TEMPLATE_MODIFY_APPOINTMENT = "/skin/plugins/transparency/modify_appointment.html";
82  
83      // Parameters
84      private static final String PARAMETER_ID_APPOINTMENT = "id";
85      private static final String PARAMETER_SEARCH_PERIOD = "search_period";
86      private static final String PARAMETER_SEARCH_ELECTED_OFFICIAL = "search_elected_official";
87      private static final String PARAMETER_SEARCH_LOBBY = "search_lobby";
88      private static final String PARAMETER_SEARCH_TITLE = "search_title";
89      private static final String PARAMETER_ID_ELECTED_OFFICIAL = "id_elected_official";
90      private static final String PARAMETER_ID_LOBBY = "lobby_id";
91      private static final String PARAMETER_SELECT_LOBBY = "lobby_select";
92      private static final String PARAMETER_SORTED_ATTRIBUTE_NAME = "sorted_attribute_name";
93      private static final String PARAMETER_START_DATE = "start_date";
94      private static final String PARAMETER_ASC = "asc_sort";
95  
96      // Markers
97      private static final String MARK_APPOINTMENT_LIST = "appointment_list";
98      private static final String MARK_APPOINTMENT = "appointment";
99      private static final String MARK_BASE_URL = "base_url";
100     private static final String MARK_IS_AUTHENTICATED = "is_authenticated";
101     private static final String MARK_ELECTEDOFFICIALS_LIST = "electedofficials_list";
102     private static final String MARK_PAGINATOR = "paginator" ;
103     private static final String MARK_SEARCH_FILTER = "search_filter" ;
104 
105     // Views
106     private static final String VIEW_MANAGE_APPOINTMENTS = "manageAppointments";
107     private static final String VIEW_DETAIL_APPOINTMENT = "detailAppointment";
108     private static final String VIEW_CREATE_APPOINTMENT = "createAppointment";
109     private static final String VIEW_MODIFY_APPOINTMENT = "modifyAppointment";
110 
111     // Actions
112     private static final String ACTION_CREATE_APPOINTMENT = "createAppointment";
113     private static final String ACTION_MODIFY_APPOINTMENT = "modifyAppointment";
114     private static final String ACTION_REMOVE_APPOINTMENT = "removeAppointment";
115     private static final String ACTION_CONFIRM_REMOVE_APPOINTMENT = "confirmRemoveAppointment";
116 
117     // Infos
118     private static final String INFO_APPOINTMENT_CREATED = "transparency.info.appointment.created";
119     private static final String INFO_APPOINTMENT_UPDATED = "transparency.info.appointment.updated";
120     private static final String INFO_APPOINTMENT_REMOVED = "transparency.info.appointment.removed";
121     private static final String INFO_ACCESS_DENIED = "transparency.info.appointment.accessdenied";
122 
123     // Errors
124     private static final String ERROR_APPOINTMENT_VALIDATION_LOBBY_MANDATORY = "transparency.validation.appointment.Lobby.notEmpty";
125     
126     
127     // Message
128     private static final String MESSAGE_CONFIRM_REMOVE_APPOINTMENT = "transparency.message.confirmRemoveAppointment";
129 
130     // Session variable to store working values
131     private Appointment _appointment;
132     private List<Integer> _appointmentIdsList;
133     private AppointmentFilter _filter = new AppointmentFilter( );
134     
135     private int _nItemsPerPage = 10;
136     private String _strCurrentPageIndex = "1";
137     
138     // Constants
139     private static int CONSTANT_DEFAULT_SEARCH_PERIOD = 92 ;
140     
141 
142     /**
143      * Build the Manage View
144      *
145      * @param request
146      *            The HTTP request
147      * @return The Xpage
148      */
149     @View( value = VIEW_MANAGE_APPOINTMENTS, defaultView = true )
150     public XPage getManageAppointments( HttpServletRequest request )
151     {
152         _appointment = null;
153         List<Appointment> appointmentList = null;
154         boolean isAuthenticated = false;
155         Paginator<Integer> paginator ;
156                 
157         // check authentification or public mode
158         String idUser = null;
159         try
160         {
161             idUser = checkMyLuteceAuthentication( request );
162             if ( idUser != null )
163                 isAuthenticated = true; // if idUser is null, it should be because authentication is not enable
164         }
165         catch( UserNotSignedException e )
166         {
167             // catch the exception : the appointments will be presented in read only mode
168             isAuthenticated = false;
169         }
170         
171         // check type of request : paginating / sorting / new search
172         if ( request.getParameter( Paginator.PARAMETER_PAGE_INDEX ) != null && _appointmentIdsList != null ) 
173         {
174             // paginate list
175             _strCurrentPageIndex = request.getParameter( Paginator.PARAMETER_PAGE_INDEX );
176             paginator = new Paginator<Integer>( _appointmentIdsList, _nItemsPerPage, getViewFullUrl( VIEW_MANAGE_APPOINTMENTS ),
177                 Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
178             
179             _filter.setListIds( paginator.getPageItems( ) );
180             
181             // get full appointments corresponding to the Ids
182             appointmentList = AppointmentHome.getFullAppointmentsList( _filter );
183         }
184         else if ( request.getParameter( PARAMETER_SORTED_ATTRIBUTE_NAME ) != null && _appointmentIdsList != null )
185         {
186             // sort list
187             if ( request.getParameter( PARAMETER_SORTED_ATTRIBUTE_NAME ).equals( PARAMETER_START_DATE ) )
188             {
189                 if ( request.getParameter( PARAMETER_ASC ) != null && request.getParameter( PARAMETER_ASC ).equals( "true" ) )
190                 {
191                     _filter.setOrderBy( PARAMETER_START_DATE + " ASC " );
192                 }
193                 else
194                 {
195                     _filter.setOrderBy( PARAMETER_START_DATE + " DESC " );
196                 }
197             }
198             
199             // reinitialize
200             _strCurrentPageIndex = "1" ;
201             _filter.setListIds( null ) ;
202             
203             // search all Ids whith the same filter
204             _appointmentIdsList = AppointmentHome.getAppointmentIdsList( _filter );
205             
206             paginator = new Paginator<Integer>( _appointmentIdsList, _nItemsPerPage, getViewFullUrl( VIEW_MANAGE_APPOINTMENTS ) ,
207                 Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
208             
209             _filter.setListIds(  paginator.getPageItems( ) );
210             
211             // get full appointments corresponding to the Ids
212             appointmentList = AppointmentHome.getFullAppointmentsList( _filter );
213         }
214         else
215         {
216             // new search 
217             String strSearchPeriod = request.getParameter( PARAMETER_SEARCH_PERIOD );
218             String strSearchElectedOfficial = request.getParameter( PARAMETER_SEARCH_ELECTED_OFFICIAL );
219             String strSearchLobby = request.getParameter( PARAMETER_SEARCH_LOBBY );
220             String strSearchTitle = request.getParameter( PARAMETER_SEARCH_TITLE );
221 
222             
223             if ( strSearchPeriod != null ) _filter.setNumberOfDays( StringUtil.getIntValue( strSearchPeriod, CONSTANT_DEFAULT_SEARCH_PERIOD ) );
224             _filter.setLobbyName( strSearchLobby );
225             _filter.setElectedOfficialName( strSearchElectedOfficial );
226             _filter.setUserId( idUser );
227             _filter.setTitle( strSearchTitle );
228             
229             // reinitialize
230             _strCurrentPageIndex = "1" ;
231             _filter.setListIds( null ) ;
232             _filter.setOrderBy( null );
233                         
234             // search all Ids 
235             _appointmentIdsList = AppointmentHome.getAppointmentIdsList( _filter );
236             
237             paginator = new Paginator<Integer>( _appointmentIdsList, _nItemsPerPage, getViewFullUrl( VIEW_MANAGE_APPOINTMENTS ) ,
238                 Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
239             
240             _filter.setListIds( paginator.getPageItems( ) );
241             
242             // get full appointments corresponding to the Ids
243             appointmentList = AppointmentHome.getFullAppointmentsList( _filter );
244             
245         }
246 
247         Map<String, Object> model = getModel( );
248         model.put( MARK_APPOINTMENT_LIST, appointmentList );
249         model.put( MARK_BASE_URL, AppPathService.getBaseUrl( request ) );
250         model.put( MARK_IS_AUTHENTICATED, isAuthenticated );
251         model.put( MARK_PAGINATOR, paginator);
252         model.put( MARK_SEARCH_FILTER, _filter);
253 
254         return getXPage( TEMPLATE_MANAGE_APPOINTMENTS, request.getLocale( ), model );
255     }
256 
257     /**
258      * Returns the form to update info about a appointment
259      *
260      * @param request
261      *            The Http request
262      * @return The HTML form to update info
263      */
264     @View( VIEW_DETAIL_APPOINTMENT )
265     public XPage getDetailAppointment( HttpServletRequest request )
266     {
267         int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_APPOINTMENT ) );
268 
269         if ( _appointment == null || ( _appointment.getId( ) != nId ) )
270         {
271             _appointment = AppointmentHome.findByPrimaryKey( nId );
272         }
273 
274         _appointment.setElectedOfficialList( ElectedOfficialHome.getElectedOfficialsListByAppointment( _appointment.getId( ) ) );
275         _appointment.setLobbyList( LobbyHome.getLobbiesListByAppointment( _appointment.getId( ) ) );
276 
277         Map<String, Object> model = getModel( );
278         model.put( MARK_APPOINTMENT, _appointment );
279 
280         return getXPage( TEMPLATE_DETAIL_APPOINTMENT, request.getLocale( ), model );
281     }
282 
283     /**
284      * Returns the form to create a appointment
285      *
286      * @param request
287      *            The Http request
288      * @return the html code of the appointment form
289      * @throws fr.paris.lutece.portal.service.security.UserNotSignedException
290      */
291     @View( VIEW_CREATE_APPOINTMENT )
292     public XPage getCreateAppointment( HttpServletRequest request ) throws UserNotSignedException
293     {
294         _appointment = ( _appointment != null ) ? _appointment : new Appointment( );
295 
296         // check authentification
297         String idUser = checkMyLuteceAuthentication( request );
298 
299         ReferenceList electedOfficialsList = ElectedOfficialHome.getElectedOfficialsReferenceListByDelegation( idUser );
300 
301         Map<String, Object> model = getModel( );
302         model.put( MARK_APPOINTMENT, _appointment );
303         model.put( MARK_ELECTEDOFFICIALS_LIST, electedOfficialsList );
304         model.put( MARK_BASE_URL, AppPathService.getBaseUrl( request ) );
305 
306         return getXPage( TEMPLATE_CREATE_APPOINTMENT, request.getLocale( ), model );
307     }
308 
309     /**
310      * Process the data capture form of a new appointment
311      *
312      * @param request
313      *            The Http Request
314      * @return The Jsp URL of the process result
315      * @throws fr.paris.lutece.portal.service.security.UserNotSignedException
316      */
317     @Action( ACTION_CREATE_APPOINTMENT )
318     public XPage doCreateAppointment( HttpServletRequest request ) throws UserNotSignedException
319     {
320 
321         // check authentification
322         String idUser = checkMyLuteceAuthentication( request );
323 
324         populate( _appointment, request, request.getLocale( ) );
325 
326         // Check constraints
327         if ( !validateBean( _appointment ) )
328         {
329             return redirectView( request, VIEW_CREATE_APPOINTMENT );
330         }
331 
332         // Check if a lobby is selected
333         String strIdLobby = request.getParameter( PARAMETER_ID_LOBBY );
334         String strSelectLobby = request.getParameter( PARAMETER_SELECT_LOBBY );
335 
336         if ( StringUtils.isBlank(strSelectLobby) )
337         {
338             addError( I18nService.getLocalizedString( ERROR_APPOINTMENT_VALIDATION_LOBBY_MANDATORY, request.getLocale( ) ) );
339             return redirectView( request, VIEW_CREATE_APPOINTMENT );
340         }
341         
342         AppointmentHome.create( _appointment );
343 
344         // add elected Official to the appointment
345         String strIdElectedOfficial = request.getParameter( PARAMETER_ID_ELECTED_OFFICIAL );
346 
347         ElectedOfficial electedOfficial = ElectedOfficialHome.findByPrimaryKey( strIdElectedOfficial );
348         if ( electedOfficial != null )
349         {
350             ElectedOfficialAppointmentHome.create( new ElectedOfficialAppointment( strIdElectedOfficial, _appointment.getId( ) ) );
351             _appointment.getElectedOfficialList( ).add( electedOfficial );
352         }
353 
354         // add Lobby to the appointment
355         int idLobby = StringUtil.getIntValue( strIdLobby, -1 );
356 
357         Lobby lobby = LobbyHome.findByPrimaryKey( idLobby );
358         
359         // (the characters '&', '<', '>', '"' of the lobby name are replaced by "" in the xpage to avoid the XSS control)
360         if ( idLobby > 0 && lobby != null && lobby.getName().replaceAll("[&<>\"]","").equals(strSelectLobby) )
361         {
362             LobbyAppointmentHome.create( new LobbyAppointment( lobby.getId( ), _appointment.getId( ) ) );
363             _appointment.getLobbyList( ).add( lobby );
364         }
365         else
366             if ( !StringUtils.isBlank( strSelectLobby ) )
367             {
368                 Lobby newLobby = new Lobby( );
369                 newLobby.setName( strSelectLobby );
370                 newLobby.setVersionDate( new Date( ( new java.util.Date( ) ).getTime( ) ) );
371                 newLobby = LobbyHome.create( newLobby );
372 
373                 LobbyAppointmentHome.create( new LobbyAppointment( newLobby.getId( ), _appointment.getId( ) ) );
374                 _appointment.getLobbyList( ).add( newLobby );
375 
376             }
377         addInfo( INFO_APPOINTMENT_CREATED, getLocale( request ) );
378 
379         return redirectView( request, VIEW_MANAGE_APPOINTMENTS );
380     }
381 
382     /**
383      * Manages the removal form of a appointment whose identifier is in the http request
384      *
385      * @param request
386      *            The Http request
387      * @return the html code to confirm
388      * @throws fr.paris.lutece.portal.service.message.SiteMessageException
389      */
390     @Action( ACTION_CONFIRM_REMOVE_APPOINTMENT )
391     public XPage getConfirmRemoveAppointment( HttpServletRequest request ) throws SiteMessageException
392     {
393         int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_APPOINTMENT ) );
394         
395         UrlItem url = new UrlItem( getActionFullUrl(ACTION_REMOVE_APPOINTMENT) );
396         url.addParameter( PARAMETER_ID_APPOINTMENT, nId );
397         
398         SiteMessageService.setMessage( request, MESSAGE_CONFIRM_REMOVE_APPOINTMENT, SiteMessage.TYPE_CONFIRMATION, url.getUrl( ) );
399         return null;
400     }
401 
402     /**
403      * Handles the removal form of a appointment
404      *
405      * @param request
406      *            The Http request
407      * @return the jsp URL to display the form to manage appointments
408      */
409     @Action( ACTION_REMOVE_APPOINTMENT )
410     public XPage doRemoveAppointment( HttpServletRequest request ) throws UserNotSignedException
411     {
412         // check authentification
413         String idUser = checkMyLuteceAuthentication( request );
414 
415         int nIdAppointment = Integer.parseInt( request.getParameter( PARAMETER_ID_APPOINTMENT ) );
416 
417         // check delegation
418         AppointmentFilter filter = new AppointmentFilter( );
419         filter.setIdAppointment( nIdAppointment );
420         filter.setUserId( idUser );
421 
422         List<Appointment> listAppointment = AppointmentHome.getFullAppointmentsList( filter );
423 
424         if ( listAppointment == null || listAppointment.isEmpty( ) )
425         {
426             // => no delegation for this appointment
427             addInfo( INFO_ACCESS_DENIED, getLocale( request ) );
428             return redirectView( request, VIEW_MANAGE_APPOINTMENTS );
429         }
430 
431         // access granted
432         AppointmentHome.remove( nIdAppointment );
433         addInfo( INFO_APPOINTMENT_REMOVED, getLocale( request ) );
434 
435         return redirectView( request, VIEW_MANAGE_APPOINTMENTS );
436     }
437 
438     /**
439      * Returns the form to update info about a appointment
440      *
441      * @param request
442      *            The Http request
443      * @return The HTML form to update info
444      * @throws fr.paris.lutece.portal.service.security.UserNotSignedException
445      */
446     @View( VIEW_MODIFY_APPOINTMENT )
447     public XPage getModifyAppointment( HttpServletRequest request ) throws UserNotSignedException
448     {
449         int nIdAppointment = Integer.parseInt( request.getParameter( PARAMETER_ID_APPOINTMENT ) );
450 
451         // check authentification
452         String idUser = checkMyLuteceAuthentication( request );
453 
454         // check delegation
455         AppointmentFilter filter = new AppointmentFilter( );
456         filter.setIdAppointment( nIdAppointment );
457         filter.setUserId( idUser );
458 
459         List<Appointment> listAppointment = AppointmentHome.getFullAppointmentsList( filter );
460 
461         if ( listAppointment == null || listAppointment.isEmpty( ) )
462         {
463             // => no delegation for this appointment
464             addInfo( INFO_ACCESS_DENIED, getLocale( request ) );
465             return redirectView( request, VIEW_MANAGE_APPOINTMENTS );
466         }
467 
468         // access granted
469         _appointment = listAppointment.get( 0 );
470 
471         ReferenceList electedOfficialsList = ElectedOfficialHome.getElectedOfficialsReferenceListByDelegation( idUser );
472 
473         Map<String, Object> model = getModel( );
474         model.put( MARK_APPOINTMENT, _appointment );
475         model.put( MARK_ELECTEDOFFICIALS_LIST, electedOfficialsList );
476         model.put( MARK_BASE_URL, AppPathService.getBaseUrl( request ) );
477 
478         return getXPage( TEMPLATE_MODIFY_APPOINTMENT, request.getLocale( ), model );
479     }
480 
481     /**
482      * Process the change form of a appointment
483      *
484      * @param request
485      *            The Http request
486      * @return The Jsp URL of the process result
487      * @throws fr.paris.lutece.portal.service.security.UserNotSignedException
488      */
489     @Action( ACTION_MODIFY_APPOINTMENT )
490     public XPage doModifyAppointment( HttpServletRequest request ) throws UserNotSignedException
491     {
492         // check authentification
493         String idUser = checkMyLuteceAuthentication( request );
494 
495         populate( _appointment, request, request.getLocale( ) );
496 
497         // Check constraints
498         if ( !validateBean( _appointment ) )
499         {
500             return redirect( request, VIEW_MODIFY_APPOINTMENT, PARAMETER_ID_APPOINTMENT, _appointment.getId( ) );
501         }
502 
503         AppointmentHome.update( _appointment );
504 
505         // change Lobby to the appointment
506         String strIdLobby = request.getParameter( PARAMETER_ID_LOBBY );
507         String strSelectLobby = request.getParameter( PARAMETER_SELECT_LOBBY );
508 
509         int idLobby = StringUtil.getIntValue( strIdLobby, -1 );
510 
511         Lobby lobby = LobbyHome.findByPrimaryKey( idLobby );
512 
513         // check if it's not a new lobby to create
514         // (the characters '&', '<', '>', '"' of the lobby name are replaced by "" in the xpage to avoid the XSS control)
515         if ( idLobby > 0 && lobby != null && lobby.getName( ).replaceAll("[&<>\"]","").equals( strSelectLobby ) )
516         {
517             LobbyAppointmentHome.removeByAppointmentId( _appointment.getId( ) );
518             LobbyAppointmentHome.create( new LobbyAppointment( lobby.getId( ), _appointment.getId( ) ) );
519             _appointment.getLobbyList( ).add( lobby );
520         }
521         else
522             if ( !StringUtils.isBlank( strSelectLobby ) )
523             {
524                 Lobby newLobby = new Lobby( );
525                 newLobby.setName( strSelectLobby );
526                 newLobby.setVersionDate( new Date( ( new java.util.Date( ) ).getTime( ) ) );
527                 newLobby = LobbyHome.create( newLobby );
528 
529                 LobbyAppointmentHome.removeByAppointmentId( _appointment.getId( ) );
530                 LobbyAppointmentHome.create( new LobbyAppointment( newLobby.getId( ), _appointment.getId( ) ) );
531                 _appointment.getLobbyList( ).add( newLobby );
532 
533             }
534 
535         addInfo( INFO_APPOINTMENT_UPDATED, getLocale( request ) );
536 
537         return redirectView( request, VIEW_MANAGE_APPOINTMENTS );
538     }
539 
540     /**
541      * check if there is a MyLuteceUser Authenticated
542      * 
543      * @param request
544      * @return the Id of the lutece user
545      * @throws UserNotSignedException
546      */
547     private String checkMyLuteceAuthentication( HttpServletRequest request ) throws UserNotSignedException
548     {
549         // check if authentication is enable
550         if ( !SecurityService.isAuthenticationEnable( ) )
551             return null;
552 
553         LuteceUser luteceUser = SecurityService.getInstance( ).getRegisteredUser( request );
554 
555         // user not registred
556         if ( luteceUser == null )
557             throw new UserNotSignedException( );
558 
559         return luteceUser.getName( );
560     }
561 
562 }