View Javadoc
1   /*
2    * Copyright (c) 2002-2018, 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.managewferror.web;
35  
36  
37  import fr.paris.lutece.plugins.managewferror.business.Config;
38  import fr.paris.lutece.plugins.managewferror.business.ConfigHome;
39  import fr.paris.lutece.plugins.managewferror.business.MappingAction;
40  import fr.paris.lutece.plugins.managewferror.business.service.ConfigService;
41  import fr.paris.lutece.plugins.workflowcore.business.action.ActionFilter;
42  import fr.paris.lutece.plugins.workflowcore.service.action.ActionService;
43  import fr.paris.lutece.plugins.workflowcore.service.action.IActionService;
44  import fr.paris.lutece.portal.business.rbac.RBAC;
45  import fr.paris.lutece.portal.service.admin.AccessDeniedException;
46  import fr.paris.lutece.portal.service.admin.AdminUserService;
47  import fr.paris.lutece.portal.service.message.AdminMessage;
48  import fr.paris.lutece.portal.service.message.AdminMessageService;
49  import fr.paris.lutece.portal.service.rbac.RBACService;
50  import fr.paris.lutece.portal.service.spring.SpringContextService;
51  import fr.paris.lutece.portal.service.workflow.WorkflowService;
52  import fr.paris.lutece.portal.util.mvc.admin.annotations.Controller;
53  import fr.paris.lutece.portal.util.mvc.commons.annotations.Action;
54  import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
55  import fr.paris.lutece.util.url.UrlItem;
56  
57  import java.util.ArrayList;
58  import java.util.Collection;
59  import java.util.List;
60  import java.util.Locale;
61  import java.util.Map;
62  
63  import javax.servlet.http.HttpServletRequest;
64  
65  import org.apache.commons.lang.StringUtils;
66  
67  /**
68   * This class provides the user interface to manage Config features ( manage, create, modify, remove )
69   */
70  @Controller( controllerJsp = "ManageConfigs.jsp", controllerPath = "jsp/admin/plugins/managewferror/", right = "WFERROR_MANAGEMENT" )
71  public class ConfigJspBean extends ConfigurationJspBean
72  {
73      /**
74  	 * UID
75  	 */
76  	private static final long serialVersionUID = 3371104954947583628L;
77  	// Templates
78      private static final String TEMPLATE_MANAGE_CONFIGS = "/admin/plugins/managewferror/manage_configs.html";
79      private static final String TEMPLATE_CREATE_CONFIG = "/admin/plugins/managewferror/create_config.html";
80      private static final String TEMPLATE_MODIFY_CONFIG = "/admin/plugins/managewferror/modify_config.html";
81  
82      // Parameters
83      private static final String PARAMETER_ID_CONFIG = "id";
84      private static final String PARAMETER_ID_WORKFLOW = "idWorkflow";
85      private static final String PARAMETER_ID_WORKFLOW_BEGIN = "idWorkflowBegin";
86      private static final String PARAMETER_REMOVED_ACTION = "removedAction";
87      // Properties for page titles
88      private static final String PROPERTY_PAGE_TITLE_MANAGE_CONFIGS = "managewferror.manage_configs.pageTitle";
89      private static final String PROPERTY_PAGE_TITLE_MODIFY_CONFIG = "managewferror.modify_config.pageTitle";
90      private static final String PROPERTY_PAGE_TITLE_CREATE_CONFIG = "managewferror.create_config.pageTitle";
91  
92      // Markers
93      private static final String MARK_CONFIG_LIST = "config_list";
94      private static final String MARK_CONFIG = "config";
95  
96      private static final String JSP_MANAGE_CONFIGS = "jsp/admin/plugins/managewferror/ManageConfigs.jsp";
97  
98      // Properties
99      private static final String MESSAGE_CONFIRM_REMOVE_CONFIG = "managewferror.message.confirmRemoveConfig";
100 
101     // Validations
102     private static final String VALIDATION_ATTRIBUTES_PREFIX = "managewferror.model.entity.config.attribute.";
103 
104     // Views
105     private static final String VIEW_MANAGE_CONFIGS = "manageConfigs";
106     private static final String VIEW_CREATE_CONFIG = "createConfig";
107     private static final String VIEW_MODIFY_CONFIG = "modifyConfig";
108 
109     // Actions
110     private static final String ACTION_CREATE_CONFIG = "createConfig";
111     private static final String ACTION_MODIFY_CONFIG = "modifyConfig";
112     private static final String ACTION_REMOVE_CONFIG = "removeConfig";
113     private static final String ACTION_CONFIRM_REMOVE_CONFIG = "confirmRemoveConfig";
114     private static final String ACTION_REMOVE_CONFIG_MAPPING = "removeMaping";
115     private static final String ACTION_ADD__MAPPING = "addMaping";
116     private static final String ACTION_SELECT_WF = "selectWorkflow";
117     // Infos
118     private static final String INFO_CONFIG_CREATED = "managewferror.info.config.created";
119     private static final String INFO_CONFIG_UPDATED = "managewferror.info.config.updated";
120     private static final String INFO_CONFIG_REMOVED = "managewferror.info.config.removed";
121 
122     private static final String MARK_RESOURCEFORM_LIST = "resourceform_list";
123     private static final String MARK_RESOURCEFORM_CONFIG_LIST = "resourceform_configlist";
124     private static final String MARK_LIST_WORKFLOWS = "listWorkflows";
125     private static final String MARK_ACTION_LIST_BEGIN = "listActionsBegin";
126     private static final String MARK_ACTION_LIST_RELAUNCH = "listActionsRelaunch";
127     private static final String MARK_ID_WORKFLOW = "idWorkflow";
128     private static final String MARK_ID_WORKFLOW_BEGIN = "idWorkflowBegin";
129     private static final String MARK_REMOVED_LIST_ACTION_BEGIN = "removedListActionsBegin";
130     private static final String MARK_REMOVED_LIST_ACTION_RELAUNCH = "removedListActionsRelaunch";
131 
132     // Session variable to store working values
133     private Config _config;
134     private MappingAction _mapping;
135     private IActionService _actionService = SpringContextService.getBean( ActionService.BEAN_SERVICE );
136 
137     /**
138      * Build the Manage View
139      * 
140      * @param request
141      *            The HTTP request
142      * @return The page
143      * @throws AccessDeniedException
144      */
145     @View( value = VIEW_MANAGE_CONFIGS, defaultView = true )
146     public String getManageConfigs( HttpServletRequest request ) throws AccessDeniedException
147     {
148         _config = null;
149         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, RBAC.WILDCARD_RESOURCES_ID, Config.PERMISSION_MANAGE, getUser( ) ) )
150         {
151             throw new AccessDeniedException( );
152             // return getManageConfigs( request );
153         }
154         List<Config> listConfigs = ConfigHome.getConfigsList( );
155         listConfigs = (List<Config>) RBACService.getAuthorizedCollection( listConfigs, Config.PERMISSION_MANAGE, getUser( ) );
156 
157         Map<String, Object> model = getPaginatedListModel( request, MARK_CONFIG_LIST, listConfigs, JSP_MANAGE_CONFIGS );
158 
159         return getPage( PROPERTY_PAGE_TITLE_MANAGE_CONFIGS, TEMPLATE_MANAGE_CONFIGS, model );
160     }
161 
162     /**
163      * Returns the form to create a config
164      *
165      * @param request
166      *            The Http request
167      * @return the html code of the config form
168      * @throws AccessDeniedException
169      */
170     @View( VIEW_CREATE_CONFIG )
171     public String getCreateConfig( HttpServletRequest request ) throws AccessDeniedException
172     {
173         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, RBAC.WILDCARD_RESOURCES_ID, Config.PERMISSION_MANAGE, getUser( ) ) )
174         {
175             throw new AccessDeniedException( );
176             // return getManageConfigs( request );
177         }
178 
179         _config = ( _config != null ) ? _config : new Config( );
180         MappingAction mapping = new MappingAction( );
181         String idWorkflowBegin = request.getParameter( PARAMETER_ID_WORKFLOW_BEGIN );
182         String idWorkflow = request.getParameter( PARAMETER_ID_WORKFLOW );
183         String action = request.getParameter( "view_createConfig" );
184         String removedAction = request.getParameter( PARAMETER_REMOVED_ACTION );
185 
186         Map<String, Object> model = getModel( );
187         model.put( MARK_ID_WORKFLOW_BEGIN, idWorkflowBegin );
188         model.put( MARK_ID_WORKFLOW, idWorkflow );
189 
190         if ( action != null && action.equals( ACTION_ADD__MAPPING ) )
191         {
192             populate( mapping, request );
193             if ( !contain( mapping, _config.getListActionMapping( ) ) )
194                 _config.addActionMapping( mapping );
195 
196         }
197         else
198             if ( action != null && action.equals( ACTION_REMOVE_CONFIG_MAPPING ) )
199             {
200 
201                 _config.removeActionMapping( Integer.parseInt( removedAction ) );
202             }
203             else
204                 if ( action != null && action.equals( ACTION_SELECT_WF ) )
205                 {
206 
207                     _config.getListActionMapping( ).clear( );
208 
209                 }
210 
211         if ( idWorkflowBegin != null && StringUtils.isNotEmpty( idWorkflowBegin ) && Integer.parseInt( idWorkflowBegin ) != -1 )
212         {
213 
214             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listAction = getAction( Integer.parseInt( idWorkflowBegin ) );
215             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> removedListAction = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
216             for ( fr.paris.lutece.plugins.workflowcore.business.action.Action act : listAction )
217             {
218                 for ( MappingAction mpg : _config.getListActionMapping( ) )
219                 {
220                     if ( act.getId( ) == mpg.getIdActionBegin( ) )
221                     {
222 
223                         removedListAction.add( act );
224                     }
225                 }
226 
227             }
228             // listAction.removeAll(removedListAction);
229             model.put( MARK_ACTION_LIST_BEGIN, listAction );
230             model.put( MARK_REMOVED_LIST_ACTION_BEGIN, removedListAction );
231 
232         }
233         if ( idWorkflow != null && StringUtils.isNotEmpty( idWorkflow ) && Integer.parseInt( idWorkflow ) != -1 )
234         {
235             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listAction = getAction( Integer.parseInt( idWorkflow ) );
236             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> removedListAction = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
237 
238             for ( fr.paris.lutece.plugins.workflowcore.business.action.Action act : listAction )
239             {
240                 for ( MappingAction mpg : _config.getListActionMapping( ) )
241                 {
242                     if ( act.getId( ) == mpg.getIdActionRelaunch( ) )
243                     {
244 
245                         removedListAction.add( act );
246                     }
247                 }
248 
249             }
250             // listAction.removeAll(removedListAction);
251             model.put( MARK_ACTION_LIST_RELAUNCH, listAction );
252             model.put( MARK_REMOVED_LIST_ACTION_RELAUNCH, removedListAction );
253 
254         }
255 
256         populate( _config, request );
257         model.put( MARK_CONFIG, _config );
258         addElementsToModelForLeftColumn( request, request.getLocale( ), model );
259 
260         return getPage( PROPERTY_PAGE_TITLE_CREATE_CONFIG, TEMPLATE_CREATE_CONFIG, model );
261     }
262 
263     /**
264      * Process the data capture form of a new config
265      *
266      * @param request
267      *            The Http Request
268      * @return The Jsp URL of the process result
269      * @throws AccessDeniedException
270      */
271     @Action( ACTION_CREATE_CONFIG )
272     public String doCreateConfig( HttpServletRequest request ) throws AccessDeniedException
273     {
274         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, RBAC.WILDCARD_RESOURCES_ID, Config.PERMISSION_MANAGE, getUser( ) ) )
275         {
276             throw new AccessDeniedException( );
277             // return getManageConfigs( request );
278         }
279         populate( _config, request );
280         // Check constraints
281         if ( !validateBean( _config, VALIDATION_ATTRIBUTES_PREFIX ) )
282         {
283             return redirectView( request, VIEW_CREATE_CONFIG );
284         }
285 
286         ConfigService.getService( ).createConfig( _config );
287         addInfo( INFO_CONFIG_CREATED, getLocale( ) );
288 
289         return redirectView( request, VIEW_MANAGE_CONFIGS );
290     }
291 
292     /**
293      * Manages the removal form of a config whose identifier is in the http request
294      *
295      * @param request
296      *            The Http request
297      * @return the html code to confirm
298      * @throws AccessDeniedException
299      */
300     @Action( ACTION_CONFIRM_REMOVE_CONFIG )
301     public String getConfirmRemoveConfig( HttpServletRequest request ) throws AccessDeniedException
302     {
303 
304         int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_CONFIG ) );
305         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, String.valueOf( nId ), Config.PERMISSION_MANAGE, getUser( ) ) )
306         {
307             throw new AccessDeniedException( );
308             // return getManageConfigs( request );
309         }
310         UrlItem url = new UrlItem( getActionUrl( ACTION_REMOVE_CONFIG ) );
311         url.addParameter( PARAMETER_ID_CONFIG, nId );
312 
313         String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_CONFIG, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
314 
315         return redirect( request, strMessageUrl );
316     }
317 
318     /**
319      * Handles the removal form of a config
320      *
321      * @param request
322      *            The Http request
323      * @return the jsp URL to display the form to manage configs
324      * @throws AccessDeniedException
325      */
326     @Action( ACTION_REMOVE_CONFIG )
327     public String doRemoveConfig( HttpServletRequest request ) throws AccessDeniedException
328     {
329         int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_CONFIG ) );
330         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, String.valueOf( nId ), Config.PERMISSION_MANAGE, getUser( ) ) )
331         {
332             throw new AccessDeniedException( );
333             // return getManageConfigs( request );
334         }
335         ConfigService.getService( ).removeConfig( nId );
336         addInfo( INFO_CONFIG_REMOVED, getLocale( ) );
337 
338         return redirectView( request, VIEW_MANAGE_CONFIGS );
339     }
340 
341     /**
342      * Returns the form to update info about a config
343      *
344      * @param request
345      *            The Http request
346      * @return The HTML form to update info
347      * @throws AccessDeniedException
348      */
349     @View( VIEW_MODIFY_CONFIG )
350     public String getModifyConfig( HttpServletRequest request ) throws AccessDeniedException
351     {
352 
353         int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_CONFIG ) );
354         _mapping = ( _mapping != null ) ? _mapping : new MappingAction( );
355         String idWorkflowBegin = request.getParameter( PARAMETER_ID_WORKFLOW_BEGIN );
356         String idWorkflow = request.getParameter( PARAMETER_ID_WORKFLOW );
357         String action = request.getParameter( "view_modifyConfig" );
358         String removedAction = request.getParameter( PARAMETER_REMOVED_ACTION );
359 
360         MappingAction mapping = new MappingAction( );
361         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, request.getParameter( PARAMETER_ID_CONFIG ), Config.PERMISSION_MANAGE, getUser( ) ) )
362         {
363             throw new AccessDeniedException( );
364             // return getManageConfigs( request );
365         }
366 
367         if ( _config == null || ( _config.getId( ) != nId ) )
368         {
369             _config = ConfigService.getService( ).findConfigByID( nId );
370         }
371 
372         Map<String, Object> model = getModel( );
373        
374 
375         if ( action != null && action.equals( ACTION_ADD__MAPPING ) )
376         {
377             populate( mapping, request );
378             mapping.setIdConfig(nId);
379             if ( !contain( mapping, _config.getListActionMapping( ) ) )
380                 _config.addActionMapping( mapping );
381         }
382         else
383             if ( action != null && action.equals( ACTION_REMOVE_CONFIG_MAPPING ) )
384             {
385             	populate( mapping, request );
386             	mapping.setIdConfig(nId);
387                 _config.removeActionMapping( mapping );
388                 List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listActionBegin = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
389                 for ( MappingAction mp : _config.getListActionMapping( ) )
390                 {
391                     fr.paris.lutece.plugins.workflowcore.business.action.Action act = _actionService.findByPrimaryKey( mp.getIdActionBegin( ) );
392                     if ( act != null )
393                     {
394                         listActionBegin.add( act );
395                     }
396 
397                 }
398                 model.put( MARK_REMOVED_LIST_ACTION_BEGIN, listActionBegin );
399             }
400 
401             else
402                 if ( action != null && action.equals( ACTION_SELECT_WF ) )
403                 {
404 
405                     if ( _config.getListActionMapping( ).size( ) != 0 && _config.getListActionMapping( ) != null )
406                     {
407                         for ( MappingAction MapAction : _config.getListActionMapping( ) )
408                         {
409                             fr.paris.lutece.plugins.workflowcore.business.action.Action actionBegin = _actionService.findByPrimaryKey( MapAction
410                                     .getIdActionBegin( ) );
411                             fr.paris.lutece.plugins.workflowcore.business.action.Action actionRelanch = _actionService.findByPrimaryKey( MapAction
412                                     .getIdActionRelaunch( ) );
413 
414                             if ( idWorkflowBegin == null
415                                     || idWorkflow == null
416                                     || ( actionBegin.getWorkflow( ).getId( ) != Integer.parseInt( idWorkflowBegin ) || actionRelanch.getWorkflow( ).getId( ) != Integer
417                                             .parseInt( idWorkflow ) ) )
418                             {
419                                 _config.getListActionMapping( ).clear( );
420                             }
421                             break;
422                         }
423                     }
424 
425                 }
426                 else
427                 {
428                     List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listActionBegin = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
429                     List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listActionRelaunch = getAction( _config.getIdWorkflow( ) );
430 
431                     for ( MappingAction mp : _config.getListActionMapping( ) )
432                     {
433                         fr.paris.lutece.plugins.workflowcore.business.action.Action act = _actionService.findByPrimaryKey( mp.getIdActionBegin( ) );
434                         if ( act != null )
435                         {
436                             listActionBegin.add( act );
437                             idWorkflowBegin= String.valueOf( act.getWorkflow().getId());
438                         }
439 
440                     }
441                     model.put( MARK_REMOVED_LIST_ACTION_BEGIN, listActionBegin );
442                     model.put( MARK_REMOVED_LIST_ACTION_RELAUNCH, listActionRelaunch );
443 
444                 }
445         if ( idWorkflowBegin != null && StringUtils.isNotEmpty( idWorkflowBegin ) && Integer.parseInt( idWorkflowBegin ) != -1 )
446         {
447 
448             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listAction = getAction( Integer.parseInt( idWorkflowBegin ) );
449             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> removedListAction = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
450 
451             for ( fr.paris.lutece.plugins.workflowcore.business.action.Action act : listAction )
452             {
453                 for ( MappingAction mpg : _config.getListActionMapping( ) )
454                 {
455                     if ( act.getId( ) == mpg.getIdActionBegin( ) )
456                     {
457 
458                         removedListAction.add( act );
459                     }
460                 }
461 
462             }
463             // listAction.removeAll(removedListAction);
464             model.put( MARK_ACTION_LIST_BEGIN, listAction );
465             model.put( MARK_REMOVED_LIST_ACTION_BEGIN, removedListAction );
466 
467         }
468         if ( idWorkflow != null && StringUtils.isNotEmpty( idWorkflow ) && Integer.parseInt( idWorkflow ) != -1 )
469         {
470             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> listAction = getAction( Integer.parseInt( idWorkflow ) );
471             List<fr.paris.lutece.plugins.workflowcore.business.action.Action> removedListAction = new ArrayList<fr.paris.lutece.plugins.workflowcore.business.action.Action>( );
472 
473             for ( fr.paris.lutece.plugins.workflowcore.business.action.Action act : listAction )
474             {
475                 for ( MappingAction mpg : _config.getListActionMapping( ) )
476                 {
477                     if ( act.getId( ) == mpg.getIdActionRelaunch( ) )
478                     {
479 
480                         removedListAction.add( act );
481                     }
482                 }
483 
484             }
485             // listAction.removeAll(removedListAction);
486             model.put( MARK_ACTION_LIST_RELAUNCH, listAction );
487             model.put( MARK_REMOVED_LIST_ACTION_RELAUNCH, removedListAction );
488 
489         }
490 
491         populate( _config, request );
492         model.put( MARK_CONFIG, _config );
493         model.put( MARK_ID_WORKFLOW_BEGIN, idWorkflowBegin );
494         model.put( MARK_ID_WORKFLOW, idWorkflow );
495         // model.put(MARK_ACTION_LIST, getAction(_config.getIdWorkflow( )));
496         addElementsToModelForLeftColumn( request, request.getLocale( ), model );
497 
498         return getPage( PROPERTY_PAGE_TITLE_MODIFY_CONFIG, TEMPLATE_MODIFY_CONFIG, model );
499     }
500 
501     /**
502      * Process the change form of a config
503      *
504      * @param request
505      *            The Http request
506      * @return The Jsp URL of the process result
507      * @throws AccessDeniedException
508      */
509     @Action( ACTION_MODIFY_CONFIG )
510     public String doModifyConfig( HttpServletRequest request ) throws AccessDeniedException
511     {
512         populate( _config, request );
513 
514         if ( !RBACService.isAuthorized( Config.CONFIG_RESOURCE, String.valueOf( _config.getId( ) ), Config.PERMISSION_MANAGE, getUser( ) ) )
515         {
516             throw new AccessDeniedException( );
517             // return getManageConfigs( request );
518         }
519         // Check constraints
520         if ( !validateBean( _config, VALIDATION_ATTRIBUTES_PREFIX ) )
521         {
522             return redirect( request, VIEW_MODIFY_CONFIG, PARAMETER_ID_CONFIG, _config.getId( ) );
523         }
524 
525         ConfigService.getService( ).updateConfig( _config );
526         addInfo( INFO_CONFIG_UPDATED, getLocale( ) );
527 
528         return redirectView( request, VIEW_MANAGE_CONFIGS );
529     }
530 
531     /**
532      * Handles the removal form of a config
533      *
534      * @param request
535      *            The Http request
536      * @return the jsp URL to display the form to manage configs
537      */
538     @Action( ACTION_REMOVE_CONFIG_MAPPING )
539     public String doRemoveConfigMapping( HttpServletRequest request )
540     {
541         populate( _mapping, request );
542         ConfigHome.removeMapping( _mapping );
543 
544         return redirect( request, VIEW_MODIFY_CONFIG, PARAMETER_ID_CONFIG, _config.getId( ) );
545     }
546 
547    /**
548     * Add elements to the model to display the left column to modify a resource form
549     * @param request
550     * @param locale
551     * @param model
552     */
553     public static void addElementsToModelForLeftColumn( HttpServletRequest request, Locale locale, Map<String, Object> model )
554     {
555       /*  List<AppointmentForm> listApptForm = FormService.buildAllActiveAppointmentForm( );
556         List<AppointmentForm> listApptFormConf = new ArrayList<AppointmentForm>( listApptForm );
557         List<Config> listConfig = ConfigHome.getConfigsList( );
558 
559         for ( AppointmentForm form : listApptForm )
560         {
561             for ( Config conf : listConfig )
562             {
563                 if ( conf.getIdForm( ) == form.getIdForm( ) )
564                 {
565                     listApptFormConf.remove( form );
566                 }
567             }
568 
569         }
570 
571         model.put( MARK_APPOINTMENTFORM_CONFIG_LIST, listApptFormConf );
572         model.put( MARK_APPOINTMENTFORM_LIST, listApptForm );*/
573         model.put( MARK_LIST_WORKFLOWS, WorkflowService.getInstance( ).getWorkflowsEnabled( AdminUserService.getAdminUser( request ), locale ) );
574 
575     }
576     /*
577     public static void addElementsToModelForLeftColumn( HttpServletRequest request, Locale locale, Map<String, Object> model )
578     {
579         List<AppointmentForm> listApptForm = FormService.buildAllActiveAppointmentForm( );
580         List<AppointmentForm> listApptFormConf = new ArrayList<AppointmentForm>( listApptForm );
581         List<Config> listConfig = ConfigHome.getConfigsList( );
582 
583         for ( AppointmentForm form : listApptForm )
584         {
585             for ( Config conf : listConfig )
586             {
587                 if ( conf.getIdForm( ) == form.getIdForm( ) )
588                 {
589                     listApptFormConf.remove( form );
590                 }
591             }
592 
593         }
594 
595         model.put( MARK_APPOINTMENTFORM_CONFIG_LIST, listApptFormConf );
596         model.put( MARK_APPOINTMENTFORM_LIST, listApptForm );
597         model.put( MARK_LIST_WORKFLOWS, WorkflowService.getInstance( ).getWorkflowsEnabled( AdminUserService.getAdminUser( request ), locale ) );
598 
599     }*/
600 
601     public List<fr.paris.lutece.plugins.workflowcore.business.action.Action> getAction( int nIdWorkflow )
602     {
603 
604         ActionFilter actionFilter = new ActionFilter( );
605         actionFilter.setIdWorkflow( nIdWorkflow );
606         List<fr.paris.lutece.plugins.workflowcore.business.action.Action> actionsList = _actionService.getListActionByFilter( actionFilter );
607 
608         return actionsList;
609     }
610 
611     public boolean contain( MappingAction mapping, Collection<MappingAction> collection )
612     {
613 
614         for ( MappingAction mpg : collection )
615         {
616             if ( mpg.getIdActionRelaunch( ) == mapping.getIdActionRelaunch( ) && mapping.getIdActionBegin( ) == mpg.getIdActionBegin( ) )
617                 return true;
618 
619         }
620         return false;
621     }
622 
623 }