View Javadoc

1   /*
2    * Copyright (c) 2002-2014, 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  package fr.paris.lutece.plugins.formengine.web.notice;
35  
36  import fr.paris.lutece.plugins.formengine.business.Notice;
37  import fr.paris.lutece.plugins.formengine.business.NoticeFilter;
38  import fr.paris.lutece.plugins.formengine.business.NoticeGroup;
39  import fr.paris.lutece.plugins.formengine.business.NoticeGroupFilter;
40  import fr.paris.lutece.plugins.formengine.business.NoticeGroupHome;
41  import fr.paris.lutece.plugins.formengine.business.NoticeHome;
42  import fr.paris.lutece.plugins.formengine.service.FormsRegistrationService;
43  import fr.paris.lutece.plugins.formengine.util.NoticeUtils;
44  import fr.paris.lutece.portal.business.mailinglist.MailingList;
45  import fr.paris.lutece.portal.business.mailinglist.MailingListHome;
46  import fr.paris.lutece.portal.service.admin.AdminUserService;
47  import fr.paris.lutece.portal.service.i18n.I18nService;
48  import fr.paris.lutece.portal.service.message.AdminMessage;
49  import fr.paris.lutece.portal.service.message.AdminMessageService;
50  import fr.paris.lutece.portal.service.plugin.Plugin;
51  import fr.paris.lutece.portal.service.template.AppTemplateService;
52  import fr.paris.lutece.portal.service.util.AppLogService;
53  import fr.paris.lutece.portal.service.util.AppPathService;
54  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupService;
55  import fr.paris.lutece.portal.web.admin.PluginAdminPageJspBean;
56  import fr.paris.lutece.util.ReferenceItem;
57  import fr.paris.lutece.util.ReferenceList;
58  import fr.paris.lutece.util.html.HtmlTemplate;
59  import fr.paris.lutece.util.html.Paginator;
60  import fr.paris.lutece.util.url.UrlItem;
61  
62  import org.apache.commons.lang.StringUtils;
63  
64  import java.sql.Timestamp;
65  
66  import java.text.SimpleDateFormat;
67  
68  import java.util.Collection;
69  import java.util.HashMap;
70  import java.util.List;
71  import java.util.Locale;
72  import java.util.Map;
73  
74  import javax.servlet.http.HttpServletRequest;
75  
76  
77  /**
78   * NoticeJspbean
79   *
80   */
81  public class NoticeJspBean extends PluginAdminPageJspBean
82  {
83      // RIGHT
84      public static final String RIGHT_NOTICE_MANAGEMENT = "NOTICE_MANAGEMENT";
85  
86      // MARKERS
87      private static final String MARK_WEBAPP_URL = "webapp_url";
88      private static final String MARK_LOCALE = "locale";
89      private static final String MARK_LIST_STATUT = "notice_statut";
90      private static final String MARK_LIST_USER_GROUP = "notice_user_group";
91      private static final String MARK_PAGINATOR = "paginator";
92      private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page";
93      private static final String MARK_NOTICE_LIST = "notice_list";
94      private static final String MARK_NOTICE_GROUP_LIST = "notice_group_list";
95      private static final String MARK_WORKGROUP_LIST = "user_workgroup_list";
96      private static final String MARK_MAILING_LIST = "mailing_list";
97      private static final String MARK_FORM = "form_list";
98      private static final String MARK_NOTICE = "notice";
99      private static final String MARK_NOTICE_GROUP = "notice_group";
100     private static final String MARK_NOTICE_GROUP_ID = "notice_group_id";
101     private static final String MARK_DATE_DU_JOUR = "date_du_jour";
102     private static final String MARK_USER_WORKGROUP_SELECTED = "user_workgroup_selected";
103     private static final String MARK_ACTIVE_SELECTED = "active_selected";
104     private static final String MARK_FORM_SELECTED = "form_selected";
105     private static final String MARK_FORM_MAP = "form_map";
106 
107     // PARAMETERS
108     private static final String PARAMETER_CANCEL = "cancel";
109     private static final String PARAMETER_ACTIVE = "active";
110     private static final String PARAMETER_WORKGROUP = "workgroup";
111     private static final String PARAMETER_TITLE = "title";
112     private static final String PARAMETER_MESSAGE = "message";
113     private static final String PARAMETER_DATE_DEBUT = "date_begin_disponibility";
114     private static final String PARAMETER_DATE_FIN = "date_end_disponibility";
115     private static final String PARAMETER_ID_MAILINIG_LIST = "mailing";
116     private static final String PARAMETER_FORM = "form";
117     private static final String PARAMETER_ID_NOTICE = "id_notice";
118     private static final String PARAMETER_ID_NOTICE_GROUP = "id_notice_group";
119     private static final String PARAMETER_ORDER = "order";
120 
121     // PROPERTIES
122     private static final String PROPERTY_CREATE_NOTICE_PAGE_TITLE = "formengine.adminFeature.notice_create.name";
123     private static final String PROPERTY_CREATE_NOTICE_GROUP_PAGE_TITLE = "formengine.adminFeature.notice_group_create.name";
124     private static final String PROPERTY_COPY_NOTICE_TITLE = "formengine.adminFeature.notice_copy.name";
125     private static final String PROPERTY_COPY_NOTICE_GROUP_TITLE = "formengine.adminFeature.notice_copy_notice_group.name";
126     private static final String PROPERTY_MODIFY_NOTICE_TITLE = "formengine.notice.label.modify_notice.title";
127     private static final String PROPERTY_MODIFY_NOTICE_GROUP_TITLE = "formengine.adminFeature.notice_group_modify.name";
128     private static final String PROPERTY_MANAGE_NOTICE_GROUP_TITLE = "formengine.notice_group.label.manage.title";
129 
130     // JSP
131     private static final String JSP_MANAGE_NOTICE_GROUP = "jsp/admin/plugins/formengine/ManageNoticeGroup.jsp";
132     private static final String JSP_MANAGE_NOTICE = "jsp/admin/plugins/formengine/ManageNotice.jsp";
133     private static final String JSP_DO_REMOVE_NOTICE = "jsp/admin/plugins/formengine/DoRemoveNotice.jsp";
134     private static final String JSP_DO_REMOVE_NOTICE_GROUP = "jsp/admin/plugins/formengine/DoRemoveNoticeGroup.jsp";
135 
136     // TEMPLATES
137     private static final String TEMPLATE_FORMENGINE_NOTICE = "/admin/plugins/formengine/notice/manage_formengine_notice.html";
138     private static final String TEMPLATE_FORMENGINE_CREATE_NOTICE = "/admin/plugins/formengine/notice/create_notice.html";
139     private static final String TEMPLATE_MODIFY_NOTICE = "/admin/plugins/formengine/notice/modify_notice.html";
140     private static final String TEMPLATE_MANAGE_NOTICE_GROUP = "/admin/plugins/formengine/notice/manage_formengine_notice_group.html";
141     private static final String TEMPLATE_CREATE_NOTICE_GROUP = "/admin/plugins/formengine/notice/create_notice_group.html";
142     private static final String TEMPLATE_MODIFY_NOTICE_GROUP = "/admin/plugins/formengine/notice/modify_notice_group.html";
143 
144     // MESSAGES
145     private static final String MESSAGE_NOTICE_MANDATORY = "formengine.notice.message.mandatory.field";
146     private static final String MESSAGE_FIELD_TITLE = "formengine.notice.message.title";
147     private static final String MESSAGE_FIELD_MESSAGE = "formengine.notice.message.message";
148     private static final String MESSAGE_ERROR_DATE = "formengine.notice.message.error_date";
149     private static final String MESSAGE_ERROR_NOTICE_GROUP = "formengine.notice.message.noticegroup";
150     private static final String MESSAGE_CONFIRM_REMOVE_NOTICE = "formengine.notice.message.remove_notice";
151     private static final String MESSAGE_CONFIRM_REMOVE_NOTICE_GROUP = "formengine.notice_group.message.remove_notice_group";
152     private static final String MESSAGE_ALL = "formengine.notice.message.all";
153     private static final String MESSAGE_ACTIVATED = "formengine.notice.message.activated";
154     private static final String MESSAGE_NOT_ACTIVATED = "formengine.notice.message.notActivated";
155     private static final String MESSAGE_NONE = "formengine.notice.message.none";
156     private static final String MESSAGE_FIELD_FORM = "formengine.notice.message.form";
157 
158     // CONSTANTS
159     private static final String CONSTANT_NO_FORM = "-1";
160 
161     // ATTRIBUTES
162     private static final int DEFAULT_ITEMS_PER_PAGE = 10;
163     private int _nItemsPerPage;
164     private String _strCurrentPageIndex;
165     private int _nIdActive = -1;
166     private String _strWorkGroup = AdminWorkgroupService.ALL_GROUPS;
167     private int _nIdNoticeGroup;
168     private String _strForm = NoticeGroupFilter.ALL_STRING;
169 
170     /**
171      * Return the reference list of statut
172      * @return the referenclist of statut
173      */
174     private ReferenceList initRefListStatut(  )
175     {
176         ReferenceList refListStatut = new ReferenceList(  );
177 
178         refListStatut.addItem( -1, I18nService.getLocalizedString( MESSAGE_ALL, getLocale(  ) ) );
179         refListStatut.addItem( 0, I18nService.getLocalizedString( MESSAGE_NOT_ACTIVATED, getLocale(  ) ) );
180         refListStatut.addItem( 1, I18nService.getLocalizedString( MESSAGE_ACTIVATED, getLocale(  ) ) );
181 
182         return refListStatut;
183     }
184 
185     /**
186      * Return the reference list of user group
187      * @return the referenclist of user group
188      */
189     private ReferenceList initRefListUserGroup(  )
190     {
191         return AdminWorkgroupService.getUserWorkgroups( getUser(  ), getLocale(  ) );
192     }
193 
194     /**
195      * Return the reference list of mailing list
196      * @return the referenclist of mailing list
197      */
198     private ReferenceList initRefListMailingList(  )
199     {
200         ReferenceList refListMailingList = new ReferenceList(  );
201         Collection<MailingList> colMailingList = MailingListHome.findAll(  );
202         int count = 0;
203         refListMailingList.addItem( -1, I18nService.getLocalizedString( MESSAGE_NONE, getLocale(  ) ) );
204 
205         for ( MailingList mailingList : colMailingList )
206         {
207             refListMailingList.addItem( count, mailingList.getName(  ) );
208             count++;
209         }
210 
211         return refListMailingList;
212     }
213 
214     /**
215      * Gets form list
216      * @return the form list
217      */
218     private ReferenceList initRefListFormsList(  )
219     {
220         ReferenceList refListForms = FormsRegistrationService.getListForm(  );
221         ReferenceItem refItem = new ReferenceItem(  );
222         refItem.setCode( NoticeGroupFilter.ALL_STRING );
223         refItem.setName( I18nService.getLocalizedString( MESSAGE_ALL, getLocale(  ) ) );
224         refListForms.add( 0, refItem );
225 
226         return refListForms;
227     }
228 
229     /**
230      * Return the reference list of rss feeds
231      * @return the referenclist of rss feeds
232      */
233 
234     /*private ReferenceList initRefListRssFeeds(  )
235     {
236         ReferenceList refListRss = new ReferenceList(  );
237     
238         if ( RssLibraryService.getInstance(  ).isAvailable(  ) )
239         {
240             refListRss = RssLibraryService.getInstance(  ).getRefListRssFeed(  );
241         }
242     
243         refListRss.addItem( -1, CONSTANTE_RSS_LIST_NONE );
244     
245         return refListRss;
246     }*/
247 
248     /**
249      * Manages notice group
250      * @param request the request
251      * @return html code
252      */
253     public String getManageNoticeGroup( HttpServletRequest request )
254     {
255         setPageTitleProperty( PROPERTY_MANAGE_NOTICE_GROUP_TITLE );
256 
257         String strFilterForm = request.getParameter( PARAMETER_FORM );
258         String strFilterWorkgroup = request.getParameter( PARAMETER_WORKGROUP );
259         String strFilterStatus = request.getParameter( PARAMETER_ACTIVE );
260 
261         if ( StringUtils.isNotBlank( strFilterForm ) )
262         {
263             _strForm = strFilterForm;
264         }
265 
266         if ( StringUtils.isNotBlank( strFilterWorkgroup ) )
267         {
268             _strWorkGroup = strFilterWorkgroup;
269         }
270 
271         if ( StringUtils.isNotBlank( strFilterStatus ) )
272         {
273             _nIdActive = NoticeUtils.convertStringToInt( strFilterStatus );
274         }
275 
276         NoticeGroupFilter filter = new NoticeGroupFilter(  );
277         filter.setForm( _strForm );
278         filter.setIsEnbled( _nIdActive );
279         filter.setWorkGroup( _strWorkGroup );
280 
281         _strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
282         _nItemsPerPage = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage,
283                 DEFAULT_ITEMS_PER_PAGE );
284 
285         List<NoticeGroup> listNoticeGroup = NoticeGroupHome.findByFilter( filter, getPlugin(  ) );
286 
287         listNoticeGroup = (List<NoticeGroup>) AdminWorkgroupService.getAuthorizedCollection( listNoticeGroup,
288                 getUser(  ) );
289 
290         Paginator<NoticeGroup> paginator = new Paginator<NoticeGroup>( listNoticeGroup, _nItemsPerPage,
291                 getJspManageNoticeGroup( request ), Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
292 
293         Map<String, Object> model = new HashMap<String, Object>(  );
294 
295         model.put( MARK_LIST_STATUT, initRefListStatut(  ) );
296         model.put( MARK_ACTIVE_SELECTED, _nIdActive );
297         model.put( MARK_LIST_USER_GROUP, initRefListUserGroup(  ) );
298         model.put( MARK_USER_WORKGROUP_SELECTED, _strWorkGroup );
299         model.put( MARK_PAGINATOR, paginator );
300         model.put( MARK_FORM, initRefListFormsList(  ) );
301         model.put( MARK_FORM_SELECTED, _strForm );
302         model.put( MARK_NOTICE_GROUP_LIST, paginator.getPageItems(  ) );
303         model.put( MARK_FORM_MAP, FormsRegistrationService.getMapForm(  ) );
304         model.put( MARK_NB_ITEMS_PER_PAGE, "" + _nItemsPerPage );
305 
306         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_NOTICE_GROUP, getLocale(  ), model );
307 
308         return getAdminPage( template.getHtml(  ) );
309     }
310 
311     /**
312      * Show create notice group form
313      * @param request the request
314      * @return html code
315      */
316     public String getCreateNoticeGroup( HttpServletRequest request )
317     {
318         Map<String, Object> model = new HashMap<String, Object>(  );
319         setPageTitleProperty( PROPERTY_CREATE_NOTICE_GROUP_PAGE_TITLE );
320 
321         model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
322         model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage(  ) );
323         model.put( MARK_MAILING_LIST, initRefListMailingList(  ) );
324         model.put( MARK_WORKGROUP_LIST, initRefListUserGroup(  ) );
325         model.put( MARK_FORM, FormsRegistrationService.getListForm(  ) );
326 
327         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_NOTICE_GROUP, getLocale(  ), model );
328 
329         return getAdminPage( template.getHtml(  ) );
330     }
331 
332     /**
333      * Gets modify notice group html code
334      * @param request the request
335      * @return html code
336      */
337     public String getModifyNoticeGroup( HttpServletRequest request )
338     {
339         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
340 
341         if ( StringUtils.isBlank( strIdNoticeGroup ) )
342         {
343             return getNoticeManagement( request );
344         }
345 
346         int nIdNotice = NoticeUtils.convertStringToInt( strIdNoticeGroup );
347 
348         if ( nIdNotice == -1 )
349         {
350             return getNoticeManagement( request );
351         }
352 
353         NoticeGroup noticeGroup = NoticeGroupHome.findByPrimaryKey( nIdNotice, getPlugin(  ) );
354 
355         if ( ( noticeGroup == null ) )
356         {
357             return getNoticeManagement( request );
358         }
359 
360         Locale locale = getLocale(  );
361 
362         Map<String, Object> model = new HashMap<String, Object>(  );
363 
364         model.put( MARK_WORKGROUP_LIST, initRefListUserGroup(  ) );
365         model.put( MARK_MAILING_LIST, initRefListMailingList(  ) );
366         model.put( MARK_NOTICE_GROUP, noticeGroup );
367         model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
368         model.put( MARK_LOCALE, getLocale(  ) );
369         model.put( MARK_FORM, FormsRegistrationService.getListForm(  ) );
370 
371         setPageTitleProperty( PROPERTY_MODIFY_NOTICE_GROUP_TITLE );
372 
373         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_NOTICE_GROUP, locale, model );
374 
375         return getAdminPage( template.getHtml(  ) );
376     }
377 
378     /**
379      * Gets fields from request
380      * @param noticeGroup the notice group
381      * @param request the request
382      * @return error message url if any, <code>null</code> otherwise.
383      */
384     private String getFields( NoticeGroup noticeGroup, HttpServletRequest request )
385     {
386         String strForm = request.getParameter( PARAMETER_FORM );
387         String strTitle = request.getParameter( PARAMETER_TITLE );
388         String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP );
389 
390         if ( StringUtils.isBlank( strForm ) || CONSTANT_NO_FORM.equals( strForm ) )
391         {
392             return buildUrlMessageMissingField( I18nService.getLocalizedString( MESSAGE_FIELD_FORM, getLocale(  ) ),
393                 request );
394         }
395 
396         if ( StringUtils.isBlank( strTitle ) )
397         {
398             return buildUrlMessageMissingField( I18nService.getLocalizedString( MESSAGE_FIELD_TITLE, getLocale(  ) ),
399                 request );
400         }
401 
402         noticeGroup.setForm( strForm );
403         noticeGroup.setTitle( strTitle );
404         noticeGroup.setWorkgroupKey( strWorkgroupKey );
405 
406         return null;
407     }
408 
409     /**
410      * Builds missing field message
411      * @param strField the I18n field key
412      * @param request the request
413      * @return url
414      */
415     private String buildUrlMessageMissingField( String strField, HttpServletRequest request )
416     {
417         Object[] messageArgs = { strField, };
418 
419         return AdminMessageService.getMessageUrl( request, MESSAGE_NOTICE_MANDATORY, messageArgs, AdminMessage.TYPE_STOP );
420     }
421 
422     /**
423      * Creates the notice group
424      * @param request the reques
425      * @return url
426      */
427     public String doCreateNoticeGroup( HttpServletRequest request )
428     {
429         if ( request.getParameter( PARAMETER_CANCEL ) != null )
430         {
431             return getJspManageNoticeGroup( request );
432         }
433 
434         NoticeGroup noticeGroup = new NoticeGroup(  );
435         String strError = getFields( noticeGroup, request );
436 
437         if ( strError != null )
438         {
439             return strError;
440         }
441 
442         NoticeGroupHome.create( noticeGroup, getPlugin(  ) );
443 
444         return getHomeUrl( request );
445     }
446 
447     /**
448      * Modifies the notice group
449      * @param request the request
450      * @return url
451      */
452     public String doModifyNoticeGroup( HttpServletRequest request )
453     {
454         if ( request.getParameter( PARAMETER_CANCEL ) != null )
455         {
456             return getJspManageNoticeGroup( request );
457         }
458 
459         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
460 
461         if ( StringUtils.isBlank( strIdNoticeGroup ) )
462         {
463             return getJspManageNoticeGroup( request );
464         }
465 
466         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
467 
468         if ( nIdNoticeGroup == -1 )
469         {
470             return getJspManageNoticeGroup( request );
471         }
472 
473         NoticeGroup noticeGroup = NoticeGroupHome.findByPrimaryKey( nIdNoticeGroup, getPlugin(  ) );
474         String strError = getFields( noticeGroup, request );
475 
476         if ( strError != null )
477         {
478             return strError;
479         }
480 
481         NoticeGroupHome.update( noticeGroup, getPlugin(  ) );
482 
483         return getHomeUrl( request );
484     }
485 
486     /**
487      * Gets confirme message before removing the notice group
488      * @param request the request
489      * @return message url
490      */
491     public String getConfirmRemoveNoticeGroup( HttpServletRequest request )
492     {
493         UrlItem urlItem = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_DO_REMOVE_NOTICE_GROUP );
494 
495         Map<Object, Object> requestParameters = new HashMap<Object, Object>(  );
496         requestParameters.put( PARAMETER_ID_NOTICE_GROUP, request.getParameter( PARAMETER_ID_NOTICE_GROUP ) );
497 
498         return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_NOTICE_GROUP, urlItem.getUrl(  ),
499             AdminMessage.TYPE_CONFIRMATION, requestParameters );
500     }
501 
502     /**
503      * Actually removes the notice group
504      * @param request the request
505      * @return manage url
506      */
507     public String doRemoveNoticeGroup( HttpServletRequest request )
508     {
509         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
510 
511         if ( StringUtils.isBlank( strIdNoticeGroup ) )
512         {
513             return getJspManageNoticeGroup( request );
514         }
515 
516         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
517 
518         if ( nIdNoticeGroup == -1 )
519         {
520             return getJspManageNoticeGroup( request );
521         }
522 
523         NoticeGroupHome.remove( nIdNoticeGroup, getPlugin(  ) );
524 
525         return getHomeUrl( request );
526     }
527 
528     /**
529      * Gets the notice management page
530      * @param request The HTTP request
531      * @return The notice management page
532      */
533     public String getNoticeManagement( HttpServletRequest request )
534     {
535         List<Notice> listNotice;
536         String strWorkGroup = request.getParameter( PARAMETER_WORKGROUP );
537         String strActive = request.getParameter( PARAMETER_ACTIVE );
538         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
539 
540         _strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
541         _nItemsPerPage = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage,
542                 DEFAULT_ITEMS_PER_PAGE );
543 
544         if ( ( strActive != null ) && !strActive.equals( NoticeUtils.EMPTY_STRING ) )
545         {
546             _nIdActive = NoticeUtils.convertStringToInt( strActive );
547         }
548 
549         if ( ( strWorkGroup != null ) && !strWorkGroup.equals( NoticeUtils.EMPTY_STRING ) )
550         {
551             _strWorkGroup = strWorkGroup;
552         }
553 
554         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
555 
556         if ( nIdNoticeGroup != -1 )
557         {
558             _nIdNoticeGroup = nIdNoticeGroup;
559         }
560 
561         //String format = "dd/MM/yyyy";
562 
563         //java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat( format );
564         //java.util.Date date = new java.util.Date(  );
565         NoticeFilter filter = new NoticeFilter(  );
566         filter.setIsEnabled( _nIdActive );
567         filter.setWorkGroup( _strWorkGroup );
568         filter.setIdNoticeGroup( _nIdNoticeGroup );
569 
570         listNotice = NoticeHome.getNoticeList( filter, getPlugin(  ) );
571         listNotice = (List<Notice>) AdminWorkgroupService.getAuthorizedCollection( listNotice, getUser(  ) );
572 
573         String strURL = getJspManageNotice( request );
574 
575         /*if ( strAscSort != null )
576         {
577             strURL += ( "&" + Parameters.SORTED_ASC + "=" + strAscSort );
578         }*/
579         Paginator<Notice> paginator = new Paginator<Notice>( listNotice, _nItemsPerPage, strURL,
580                 Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
581 
582         Map<String, Object> model = new HashMap<String, Object>(  );
583 
584         model.put( MARK_LIST_STATUT, initRefListStatut(  ) );
585         model.put( MARK_ACTIVE_SELECTED, _nIdActive );
586         model.put( MARK_LIST_USER_GROUP, initRefListUserGroup(  ) );
587         model.put( MARK_USER_WORKGROUP_SELECTED, _strWorkGroup );
588         model.put( MARK_PAGINATOR, paginator );
589         model.put( MARK_NB_ITEMS_PER_PAGE, "" + _nItemsPerPage );
590         model.put( MARK_NOTICE_LIST, paginator.getPageItems(  ) );
591         model.put( MARK_DATE_DU_JOUR, "" + NoticeUtils.getDate( NoticeUtils.getCurrentDate(  ), null ) );
592 
593         //setPageTitleProperty( PROPERTY_MANAGE_NOTICE_PAGE_TITLE );
594         setPageTitleProperty( NoticeUtils.EMPTY_STRING );
595 
596         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_FORMENGINE_NOTICE, getLocale(  ), model );
597 
598         return getAdminPage( template.getHtml(  ) );
599     }
600 
601     /**
602      * Changes notice order
603      * @param request the request
604      * @return the url
605      */
606     public String doChangeNoticeOrder( HttpServletRequest request )
607     {
608         String strOrder = request.getParameter( PARAMETER_ORDER );
609         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
610 
611         if ( StringUtils.isBlank( strOrder ) || StringUtils.isBlank( strIdNotice ) )
612         {
613             return getJspManageNotice( request );
614         }
615 
616         int nIdNotice = NoticeUtils.convertStringToInt( strIdNotice );
617         int nOrder = NoticeUtils.convertStringToInt( strOrder );
618 
619         if ( ( nIdNotice == -1 ) || ( nOrder == -1 ) )
620         {
621             return getJspManageNotice( request );
622         }
623 
624         Notice notice = NoticeHome.findByPrimaryKey( nIdNotice, getPlugin(  ) );
625 
626         if ( notice == null )
627         {
628             return getJspManageNotice( request );
629         }
630 
631         // save old order to reorder list
632         int nOldOrder = notice.getOrder(  );
633 
634         // get noticegroup notices
635         NoticeFilter filter = new NoticeFilter(  );
636         filter.setIdNoticeGroup( notice.getIdNoticeGroup(  ) );
637 
638         List<Notice> listNotices = NoticeHome.getNoticeList( filter, getPlugin(  ) );
639 
640         if ( nOrder < nOldOrder )
641         {
642             for ( Notice currentNotice : listNotices )
643             {
644                 if ( !notice.equals( currentNotice ) )
645                 {
646                     int nCurrentOrder = currentNotice.getOrder(  );
647 
648                     if ( ( nCurrentOrder >= nOrder ) && ( nCurrentOrder < nOldOrder ) )
649                     {
650                         currentNotice.setOrder( nCurrentOrder + 1 );
651                         NoticeHome.update( currentNotice, getPlugin(  ) );
652                     }
653                 }
654             }
655         }
656         else if ( nOrder > nOldOrder )
657         {
658             for ( Notice currentNotice : listNotices )
659             {
660                 if ( !notice.equals( currentNotice ) )
661                 {
662                     int nCurrentOrder = currentNotice.getOrder(  );
663 
664                     if ( ( nCurrentOrder <= nOrder ) && ( nCurrentOrder > nOldOrder ) )
665                     {
666                         currentNotice.setOrder( nCurrentOrder - 1 );
667                         NoticeHome.update( currentNotice, getPlugin(  ) );
668                     }
669                 }
670             }
671         }
672 
673         notice.setOrder( nOrder );
674         NoticeHome.update( notice, getPlugin(  ) );
675 
676         return getJspManageNotice( request );
677     }
678 
679     /**
680      * Gets the create notice page
681      * @param request The HTTP request
682      * @return The create notice page
683      */
684     public String getCreateNotice( HttpServletRequest request )
685     {
686         Map<String, Object> model = new HashMap<String, Object>(  );
687         setPageTitleProperty( PROPERTY_CREATE_NOTICE_PAGE_TITLE );
688 
689         model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
690         model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage(  ) );
691         model.put( MARK_MAILING_LIST, initRefListMailingList(  ) );
692         model.put( MARK_WORKGROUP_LIST, initRefListUserGroup(  ) );
693         /*model.put( MARK_RSS_AVAILABLE, RssLibraryService.getInstance(  ).isAvailable(  ) );
694         model.put( MARK_RSS_LIST, initRefListRssFeeds(  ) );*/
695         model.put( MARK_FORM, FormsRegistrationService.getListForm(  ) );
696         model.put( MARK_NOTICE_GROUP_ID, _nIdNoticeGroup );
697 
698         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_FORMENGINE_CREATE_NOTICE, getLocale(  ), model );
699 
700         return getAdminPage( template.getHtml(  ) );
701     }
702 
703     /**
704     * Perform the notice creation
705     * @param request The HTTP request
706     * @return The URL to go after performing the action
707     */
708     public String doCreateNotice( HttpServletRequest request )
709     {
710         if ( ( request.getParameter( PARAMETER_CANCEL ) == null ) )
711         {
712             Notice notice = new Notice(  );
713             String strError = getNoticeData( request, notice );
714 
715             if ( strError != null )
716             {
717                 return strError;
718             }
719 
720             notice.setOrder( NoticeHome.findMaxOrderForNoticeGroup( notice.getIdNoticeGroup(  ), getPlugin(  ) ) + 1 );
721 
722             NoticeHome.create( notice, getPlugin(  ) );
723         }
724 
725         return getJspManageNotice( request );
726     }
727 
728     /**
729      * Gets the notice modification page
730      * @param request The HTTP request
731      * @return The  notice modification page
732      */
733     public String getModifyNotice( HttpServletRequest request )
734     {
735         Plugin plugin = getPlugin(  );
736         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
737         int nIdNotice = -1;
738         Notice notice;
739 
740         if ( ( strIdNotice != null ) && !strIdNotice.equals( NoticeUtils.EMPTY_STRING ) )
741         {
742             try
743             {
744                 nIdNotice = Integer.parseInt( strIdNotice );
745             }
746             catch ( NumberFormatException ne )
747             {
748                 AppLogService.error( ne );
749 
750                 return getNoticeManagement( request );
751             }
752         }
753 
754         notice = NoticeHome.findByPrimaryKey( nIdNotice, plugin );
755 
756         if ( ( notice == null ) )
757         {
758             return getNoticeManagement( request );
759         }
760 
761         Locale locale = getLocale(  );
762 
763         Map<String, Object> model = new HashMap<String, Object>(  );
764 
765         model.put( MARK_WORKGROUP_LIST, initRefListUserGroup(  ) );
766         model.put( MARK_MAILING_LIST, initRefListMailingList(  ) );
767         /*model.put( MARK_RSS_LIST, initRefListRssFeeds(  ) );
768         model.put( MARK_RSS_AVAILABLE, RssLibraryService.getInstance(  ).isAvailable(  ) );*/
769         model.put( MARK_NOTICE, notice );
770         model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
771         model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage(  ) );
772         model.put( MARK_FORM, FormsRegistrationService.getListForm(  ) );
773 
774         setPageTitleProperty( PROPERTY_MODIFY_NOTICE_TITLE );
775 
776         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_NOTICE, locale, model );
777 
778         return getAdminPage( template.getHtml(  ) );
779     }
780 
781     /**
782      * Perform the notice modification
783      * @param request The HTTP request
784      * @return The URL to go after performing the action
785      */
786     public String doModifyNotice( HttpServletRequest request )
787     {
788         if ( request.getParameter( PARAMETER_CANCEL ) == null )
789         {
790             Plugin plugin = getPlugin(  );
791             String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
792             int nIdNotice = -1;
793             Notice notice;
794 
795             if ( ( strIdNotice != null ) && !strIdNotice.equals( NoticeUtils.EMPTY_STRING ) )
796             {
797                 try
798                 {
799                     nIdNotice = Integer.parseInt( strIdNotice );
800                 }
801                 catch ( NumberFormatException ne )
802                 {
803                     AppLogService.error( ne );
804                 }
805             }
806 
807             if ( nIdNotice != -1 )
808             {
809                 notice = NoticeHome.findByPrimaryKey( nIdNotice, plugin );
810 
811                 if ( ( notice == null ) )
812                 {
813                     return getJspManageNotice( request );
814                 }
815 
816                 String strError = getNoticeData( request, notice );
817 
818                 if ( strError != null )
819                 {
820                     return strError;
821                 }
822 
823                 notice.setIdNotice( nIdNotice );
824 
825                 NoticeHome.update( notice, getPlugin(  ) );
826 
827                 /*if ( request.getParameter( PARAMETER_APPLY ) != null )
828                 {
829                     return getJspModifyNotice( request, nIdNotice );
830                 }*/
831             }
832         }
833 
834         return getJspManageNotice( request );
835     }
836 
837     /**
838      * Copy the notice group
839      * @param request The HTTP request
840      * @return The forward URL
841      */
842     public String doCopyNoticeGroup( HttpServletRequest request )
843     {
844         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
845 
846         if ( StringUtils.isBlank( strIdNotice ) )
847         {
848             return getHomeUrl( request );
849         }
850 
851         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNotice );
852 
853         if ( nIdNoticeGroup != -1 )
854         {
855             NoticeGroup noticeGroup = NoticeGroupHome.findByPrimaryKey( nIdNoticeGroup, getPlugin(  ) );
856 
857             Object[] tabFormTileCopy = { noticeGroup.getTitle(  ) };
858             String strTitleCopyForm = I18nService.getLocalizedString( PROPERTY_COPY_NOTICE_GROUP_TITLE,
859                     tabFormTileCopy, getLocale(  ) );
860 
861             if ( strTitleCopyForm != null )
862             {
863                 noticeGroup.setTitle( strTitleCopyForm );
864             }
865 
866             NoticeGroupHome.create( noticeGroup, getPlugin(  ) );
867         }
868 
869         return getHomeUrl( request );
870     }
871 
872     /**
873      * copy the notice whose key is specified in the Http request
874      * @param request The HTTP request
875      * @return The URL to go after performing the action
876      */
877     public String doCopyNotice( HttpServletRequest request )
878     {
879         Plugin plugin = getPlugin(  );
880         Notice notice;
881         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
882         int nIdNotice = -1;
883 
884         if ( request.getParameter( PARAMETER_ID_NOTICE ) == null )
885         {
886             return getHomeUrl( request );
887         }
888 
889         try
890         {
891             nIdNotice = Integer.parseInt( strIdNotice );
892         }
893         catch ( NumberFormatException ne )
894         {
895             AppLogService.error( ne );
896         }
897 
898         if ( ( nIdNotice != -1 ) )
899         {
900             notice = NoticeHome.findByPrimaryKey( nIdNotice, plugin );
901 
902             Object[] tabFormTileCopy = { notice.getTitle(  ) };
903             String strTitleCopyForm = I18nService.getLocalizedString( PROPERTY_COPY_NOTICE_TITLE, tabFormTileCopy,
904                     getLocale(  ) );
905 
906             if ( strTitleCopyForm != null )
907             {
908                 notice.setTitle( strTitleCopyForm );
909             }
910 
911             notice.setOrder( NoticeHome.findMaxOrderForNoticeGroup( notice.getIdNoticeGroup(  ), getPlugin(  ) ) + 1 );
912 
913             NoticeHome.create( notice, plugin );
914         }
915 
916         return getJspManageNotice( request );
917     }
918 
919     /**
920      * Perform disable notice
921      * @param request The HTTP request
922      * @return The URL to go after performing the action
923      */
924     public String doDisableNotice( HttpServletRequest request )
925     {
926         Notice notice;
927         Plugin plugin = getPlugin(  );
928         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
929         int nIdNotice = -1;
930 
931         if ( ( strIdNotice == null ) )
932         {
933             return getHomeUrl( request );
934         }
935 
936         try
937         {
938             nIdNotice = Integer.parseInt( strIdNotice );
939             notice = NoticeHome.findByPrimaryKey( nIdNotice, plugin );
940         }
941         catch ( NumberFormatException ne )
942         {
943             AppLogService.error( ne );
944 
945             return getHomeUrl( request );
946         }
947 
948         if ( nIdNotice != -1 )
949         {
950             notice.setEnabled( false );
951             NoticeHome.update( notice, getPlugin(  ) );
952         }
953 
954         return getJspManageNotice( request );
955     }
956 
957     /**
958      * Enables the notice group
959      * @param request the request
960      * @return home url
961      */
962     public String doEnableNoticeGroup( HttpServletRequest request )
963     {
964         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
965 
966         if ( StringUtils.isBlank( strIdNoticeGroup ) )
967         {
968             return getHomeUrl( request );
969         }
970 
971         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
972 
973         if ( nIdNoticeGroup == -1 )
974         {
975             return getHomeUrl( request );
976         }
977 
978         NoticeGroup noticeGroup = NoticeGroupHome.findByPrimaryKey( nIdNoticeGroup, getPlugin(  ) );
979 
980         if ( noticeGroup == null )
981         {
982             AppLogService.error( "Formengine : No notice group found for id=" + nIdNoticeGroup );
983 
984             return getHomeUrl( request );
985         }
986 
987         if ( !noticeGroup.isEnabled(  ) )
988         {
989             noticeGroup.setEnabled( true );
990             NoticeGroupHome.update( noticeGroup, getPlugin(  ) );
991         }
992 
993         return getHomeUrl( request );
994     }
995 
996     /**
997      * Disables the notice group
998      * @param request the request
999      * @return home url
1000      */
1001     public String doDisableNoticeGroup( HttpServletRequest request )
1002     {
1003         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
1004 
1005         if ( StringUtils.isBlank( strIdNoticeGroup ) )
1006         {
1007             return getHomeUrl( request );
1008         }
1009 
1010         int nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
1011 
1012         if ( nIdNoticeGroup == -1 )
1013         {
1014             return getHomeUrl( request );
1015         }
1016 
1017         NoticeGroup noticeGroup = NoticeGroupHome.findByPrimaryKey( nIdNoticeGroup, getPlugin(  ) );
1018 
1019         if ( noticeGroup == null )
1020         {
1021             AppLogService.error( "Formengine : No notice group found for id=" + nIdNoticeGroup );
1022 
1023             return getHomeUrl( request );
1024         }
1025 
1026         if ( noticeGroup.isEnabled(  ) )
1027         {
1028             noticeGroup.setEnabled( false );
1029             NoticeGroupHome.update( noticeGroup, getPlugin(  ) );
1030         }
1031 
1032         return getHomeUrl( request );
1033     }
1034 
1035     /**
1036      * Perform enable notice
1037      * @param request The HTTP request
1038      * @return The URL to go after performing the action
1039      */
1040     public String doEnableNotice( HttpServletRequest request )
1041     {
1042         Notice notice;
1043         Plugin plugin = getPlugin(  );
1044         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
1045         int nIdNotice = -1;
1046 
1047         if ( ( strIdNotice == null ) )
1048         {
1049             return getHomeUrl( request );
1050         }
1051 
1052         try
1053         {
1054             nIdNotice = Integer.parseInt( strIdNotice );
1055             notice = NoticeHome.findByPrimaryKey( nIdNotice, plugin );
1056         }
1057         catch ( NumberFormatException ne )
1058         {
1059             AppLogService.error( ne );
1060 
1061             return getHomeUrl( request );
1062         }
1063 
1064         if ( nIdNotice != -1 )
1065         {
1066             /*if ( ( notice.getDateEndDisponibility(  ) != null ) &&
1067                     notice.getDateEndDisponibility(  ).before( NoticeUtils.getCurrentDate(  ) ) )
1068             {
1069                 return AdminMessageService.getMessageUrl( request,
1070                     MESSAGE_CANT_ENABLE_FORM_DATE_END_DISPONIBILITY_BEFORE_CURRENT_DATE, AdminMessage.TYPE_STOP );
1071             }*/
1072             notice.setEnabled( true );
1073             NoticeHome.update( notice, getPlugin(  ) );
1074         }
1075 
1076         return getJspManageNotice( request );
1077     }
1078 
1079     /**
1080      * Gets the notice data
1081      * @param request The HTTP request
1082      * @param notice Notice
1083      * @return The notice data
1084      */
1085     private String getNoticeData( HttpServletRequest request, Notice notice )
1086     {
1087         String strTitle = request.getParameter( PARAMETER_TITLE );
1088         String strMessage = request.getParameter( PARAMETER_MESSAGE );
1089         String strWorkgroup = request.getParameter( PARAMETER_WORKGROUP );
1090         String strMailingList = request.getParameter( PARAMETER_ID_MAILINIG_LIST );
1091         String strDateDebut = request.getParameter( PARAMETER_DATE_DEBUT );
1092         String strDateFin = request.getParameter( PARAMETER_DATE_FIN );
1093         String strIdNoticeGroup = request.getParameter( PARAMETER_ID_NOTICE_GROUP );
1094 
1095         // String strOrder = request.getParameter( PARAMETER_ORDER );
1096 
1097         //String strRss = request.getParameter( PARAMETER_RSS );
1098         String strFieldError = NoticeUtils.EMPTY_STRING;
1099 
1100         /*if ( !RssLibraryService.getInstance(  ).isAvailable(  ) )
1101         {
1102             strRss = CONSTANTE_EMPTY_RSS;
1103         }*/
1104         if ( ( strTitle == null ) || strTitle.trim(  ).equals( NoticeUtils.EMPTY_STRING ) )
1105         {
1106             strFieldError = MESSAGE_FIELD_TITLE;
1107         }
1108 
1109         else if ( ( ( strMessage == null ) || strMessage.trim(  ).equals( NoticeUtils.EMPTY_STRING ) ) /* &&
1110             strRss.equals( CONSTANTE_EMPTY_RSS )*/ )
1111         {
1112             strFieldError = MESSAGE_FIELD_MESSAGE;
1113         }
1114 
1115         int nIdNoticeGroup = -1;
1116 
1117         if ( StringUtils.isBlank( strIdNoticeGroup ) )
1118         {
1119             strFieldError = MESSAGE_ERROR_NOTICE_GROUP;
1120         }
1121         else
1122         {
1123             nIdNoticeGroup = NoticeUtils.convertStringToInt( strIdNoticeGroup );
1124 
1125             if ( nIdNoticeGroup == -1 )
1126             {
1127                 strFieldError = MESSAGE_ERROR_NOTICE_GROUP;
1128             }
1129         }
1130 
1131         if ( !strFieldError.equals( NoticeUtils.EMPTY_STRING ) )
1132         {
1133             Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, getLocale(  ) ) };
1134 
1135             return AdminMessageService.getMessageUrl( request, MESSAGE_NOTICE_MANDATORY, tabRequiredFields,
1136                 AdminMessage.TYPE_STOP );
1137         }
1138 
1139         notice.setTitle( strTitle );
1140         notice.setMessage( strMessage );
1141         notice.setWorkgroupKey( strWorkgroup );
1142         notice.setIdNoticeGroup( nIdNoticeGroup );
1143 
1144         try
1145         {
1146             int nMailingListId = Integer.parseInt( strMailingList );
1147             notice.setIdDiffusion( nMailingListId );
1148         }
1149         catch ( NumberFormatException ne )
1150         {
1151             AppLogService.error( ne );
1152 
1153             return getHomeUrl( request );
1154         }
1155 
1156         /*try
1157         {
1158             int nRssId = Integer.parseInt( strRss );
1159             notice.setIdRss( nRssId );
1160         }
1161         catch ( NumberFormatException ne )
1162         {
1163             AppLogService.error( ne );
1164         
1165             return getHomeUrl( request );
1166         }*/
1167 
1168         /*if ( ( notice.getIdRss(  ) != -1 ) && RssLibraryService.getInstance(  ).isAvailable(  ) )
1169         {
1170             String rssContent = RssLibraryService.getInstance(  ).getRssContent( notice.getIdRss(  ) );
1171             String strXslTransform = "";
1172             Properties outputProperties = XslOutputPropertiesLoader.getOutputProperties(  );
1173         
1174             String strXslDirectory = AppPathService.getPath( CONSTANTE_XSL_PATH );
1175             String strXslPath = strXslDirectory + "/" + CONSTANTE_XSL_RSS;
1176         
1177             File fileXsl = new File( strXslPath );
1178             StreamSource sourceStyleSheet = new StreamSource( fileXsl );
1179             StringReader srInput = new StringReader( rssContent );
1180             StreamSource sourceDocument = new StreamSource( srInput );
1181         
1182             try
1183             {
1184                 XmlTransformerService xmlTransformerService = new XmlTransformerService(  );
1185                 strXslTransform = xmlTransformerService.transformBySourceWithXslCache( sourceDocument,
1186                         sourceStyleSheet, strXslPath, null, outputProperties );
1187             }
1188             catch ( Exception e )
1189             {
1190                 AppLogService.error( e.getMessage(  ) );
1191             }
1192         
1193             notice.setMessage( strXslTransform );
1194         }*/
1195         Timestamp tDateDebut = null;
1196         Timestamp tDateFin = null;
1197 
1198         if ( ( strDateDebut != null ) && !strDateDebut.equals( NoticeUtils.EMPTY_STRING ) )
1199         {
1200             tDateDebut = NoticeUtils.getDate( strDateDebut, true );
1201             notice.setDateDebut( tDateDebut );
1202         }
1203 
1204         if ( ( strDateFin != null ) && !strDateFin.equals( NoticeUtils.EMPTY_STRING ) )
1205         {
1206             tDateFin = NoticeUtils.getDate( strDateFin, false );
1207             notice.setDateFin( tDateFin );
1208             NoticeUtils.getTime( tDateFin );
1209         }
1210 
1211         if ( ( tDateFin != null ) && ( tDateDebut != null ) )
1212         {
1213             if ( tDateFin.compareTo( tDateDebut ) < 0 )
1214             {
1215                 Object[] tabErrorDate = null;
1216 
1217                 return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DATE, tabErrorDate,
1218                     AdminMessage.TYPE_STOP );
1219             }
1220         }
1221 
1222         return null; // No error
1223     }
1224 
1225     /**
1226      * Returns the confirmation to remove the notice
1227      *
1228      * @param request The Http request
1229      * @return the confirmation page
1230      */
1231     public String getRemoveNotice( HttpServletRequest request )
1232     {
1233         UrlItem url = new UrlItem( JSP_DO_REMOVE_NOTICE );
1234         url.addParameter( PARAMETER_ID_NOTICE, request.getParameter( PARAMETER_ID_NOTICE ) );
1235 
1236         return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_NOTICE, url.getUrl(  ),
1237             AdminMessage.TYPE_CONFIRMATION );
1238     }
1239 
1240     /**
1241      * Perform the notice supression
1242      * @param request The HTTP request
1243      * @return The URL to go after performing the action
1244      */
1245     public String doRemoveNotice( HttpServletRequest request )
1246     {
1247         String strIdNotice = request.getParameter( PARAMETER_ID_NOTICE );
1248         Plugin plugin = getPlugin(  );
1249         int nIdNotice = -1;
1250 
1251         if ( request.getParameter( PARAMETER_ID_NOTICE ) == null )
1252         {
1253             return getHomeUrl( request );
1254         }
1255 
1256         try
1257         {
1258             nIdNotice = Integer.parseInt( strIdNotice );
1259         }
1260         catch ( NumberFormatException ne )
1261         {
1262             AppLogService.error( ne );
1263         }
1264 
1265         if ( ( nIdNotice != -1 ) )
1266         {
1267             NoticeHome.remove( nIdNotice, plugin );
1268         }
1269 
1270         return getJspManageNotice( request );
1271     }
1272 
1273     /**
1274     * return url of the jsp manage notice
1275     * @param request The HTTP request
1276     * @return url of the jsp manage notice
1277     */
1278     private String getJspManageNotice( HttpServletRequest request )
1279     {
1280         return AppPathService.getBaseUrl( request ) + JSP_MANAGE_NOTICE;
1281     }
1282 
1283     /**
1284      * JSP notice group management url
1285      * @param request the request
1286      * @return the url
1287      */
1288     private String getJspManageNoticeGroup( HttpServletRequest request )
1289     {
1290         return AppPathService.getBaseUrl( request ) + JSP_MANAGE_NOTICE_GROUP;
1291     }
1292 
1293     /**
1294      * convert string to date
1295      * @param sDate the date to format
1296      * @return the date
1297      */
1298     public static java.util.Date stringToDate( String sDate )
1299     {
1300         SimpleDateFormat sdf = new SimpleDateFormat( "dd/MM/yyyy" );
1301         java.util.Date date = null;
1302 
1303         try
1304         {
1305             date = sdf.parse( sDate );
1306         }
1307         catch ( Exception e )
1308         {
1309             AppLogService.error( e );
1310         }
1311 
1312         return date;
1313     }
1314 }