View Javadoc
1   /*
2    * Copyright (c) 2002-2020, City of 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.appcenter.modules.fastdeployapplication.service;
35  
36  import fr.paris.lutece.plugins.workflow.service.ActionResourceIdService;
37  import fr.paris.lutece.plugins.workflow.service.StateResourceIdService;
38  import fr.paris.lutece.plugins.workflow.utils.WorkflowUtils;
39  import fr.paris.lutece.plugins.workflowcore.business.action.Action;
40  import fr.paris.lutece.plugins.workflowcore.business.resource.IResourceHistoryFactory;
41  import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceHistory;
42  import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceWorkflow;
43  import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceWorkflowFilter;
44  import fr.paris.lutece.plugins.workflowcore.business.state.State;
45  import fr.paris.lutece.plugins.workflowcore.business.state.StateFilter;
46  import fr.paris.lutece.plugins.workflowcore.business.workflow.Workflow;
47  import fr.paris.lutece.plugins.workflowcore.business.workflow.WorkflowFilter;
48  import fr.paris.lutece.plugins.workflowcore.service.action.IActionService;
49  import fr.paris.lutece.plugins.workflowcore.service.resource.IResourceHistoryService;
50  import fr.paris.lutece.plugins.workflowcore.service.resource.IResourceWorkflowService;
51  import fr.paris.lutece.plugins.workflowcore.service.state.IStateService;
52  import fr.paris.lutece.plugins.workflowcore.service.task.ITask;
53  import fr.paris.lutece.plugins.workflowcore.service.task.ITaskService;
54  import fr.paris.lutece.plugins.workflowcore.service.workflow.IWorkflowService;
55  import fr.paris.lutece.plugins.workflowcore.web.task.ITaskComponentManager;
56  import fr.paris.lutece.portal.business.user.AdminUser;
57  import fr.paris.lutece.portal.business.user.AdminUserHome;
58  import fr.paris.lutece.portal.business.workgroup.AdminWorkgroupHome;
59  import fr.paris.lutece.portal.service.admin.AdminUserService;
60  import fr.paris.lutece.portal.service.plugin.PluginService;
61  import fr.paris.lutece.portal.service.rbac.RBACService;
62  import fr.paris.lutece.portal.service.template.AppTemplateService;
63  import fr.paris.lutece.portal.service.workflow.IWorkflowProvider;
64  import fr.paris.lutece.portal.service.workflow.WorkflowService;
65  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupService;
66  import fr.paris.lutece.util.ReferenceList;
67  import fr.paris.lutece.util.date.DateUtil;
68  import fr.paris.lutece.util.html.HtmlTemplate;
69  import fr.paris.lutece.util.xml.XmlUtil;
70  
71  import java.util.ArrayList;
72  import java.util.Collection;
73  import java.util.HashMap;
74  import java.util.List;
75  import java.util.Locale;
76  import java.util.Map;
77  import java.util.Map.Entry;
78  
79  import javax.inject.Inject;
80  
81  import javax.servlet.http.HttpServletRequest;
82  
83  /**
84   *
85   * WorkflowProvider
86   *
87   */
88  public class FrontWorkflowProvider implements IWorkflowProvider
89  {
90      // MARKS
91      private static final String MARK_RESOURCE_HISTORY = "resource_history";
92      private static final String MARK_TASK_INFORMATION_LIST = "task_information_list";
93      private static final String MARK_ADMIN_USER_HISTORY = "admin_user_history";
94      private static final String MARK_HISTORY_INFORMATION_LIST = "history_information_list";
95      private static final String MARK_TASK_FORM_ENTRY_LIST = "task_form_entry_list";
96      private static final String MARK_ADMIN_AVATAR = "adminAvatar";
97  
98      // TEMPLATES
99      private static final String TEMPLATE_RESOURCE_HISTORY = "admin/plugins/workflow/resource_history.html";
100     private static final String TEMPLATE_TASKS_FORM = "admin/plugins/workflow/tasks_form.html";
101 
102     // XML TAGS
103     private static final String TAG_HISTORY = "history";
104     private static final String TAG_LIST_RESOURCE_HISTORY = "list-resource-history";
105     private static final String TAG_RESOURCE_HISTORY = "resource-history";
106     private static final String TAG_CREATION_DATE = "creation-date";
107     private static final String TAG_USER = "user";
108     private static final String TAG_FIRST_NAME = "first-name";
109     private static final String TAG_LAST_NAME = "last-name";
110     private static final String TAG_LIST_TASK_INFORMATION = "list-task-information";
111     private static final String TAG_TASK_INFORMATION = "task-information";
112 
113     // SERVICES
114     @Inject
115     private IActionService _actionService;
116     @Inject
117     private IResourceWorkflowService _resourceWorkflowService;
118     @Inject
119     private IResourceHistoryService _resourceHistoryService;
120     @Inject
121     private IResourceHistoryFactory _resourceHistoryFactory;
122     @Inject
123     private IStateService _stateService;
124     @Inject
125     private ITaskService _taskService;
126     @Inject
127     private IWorkflowService _workflowService;
128     @Inject
129     private ITaskComponentManager _taskComponentManager;
130 
131     /**
132      * {@inheritDoc}
133      */
134     @Deprecated
135     public Collection<Action> getActions( Collection<Action> listActions, AdminUser user )
136     {
137         if ( user != null )
138         {
139             return RBACService.getAuthorizedCollection( listActions, ActionResourceIdService.PERMISSION_VIEW, user );
140         }
141         else
142         {
143             return listActions;
144         }
145     }
146 
147     /**
148      * {@inheritDoc}
149      */
150     @Deprecated
151     public Map<Integer, List<Action>> getActions( Map<Integer, List<Action>> mapActions, AdminUser user )
152     {
153         for ( Entry<Integer, List<Action>> entry : mapActions.entrySet( ) )
154         {
155             List<Action> listActions = entry.getValue( );
156             if ( user != null )
157             {
158                 listActions = (List<Action>) RBACService.getAuthorizedCollection( listActions, ActionResourceIdService.PERMISSION_VIEW, user );
159             }
160             mapActions.put( entry.getKey( ), listActions );
161         }
162 
163         return mapActions;
164     }
165 
166     /**
167      * {@inheritDoc}
168      */
169     @Override
170     public Collection<State> getAllStateByWorkflow( Collection<State> listStates, AdminUser user )
171     {
172         if ( user != null )
173         {
174             return RBACService.getAuthorizedCollection( listStates, StateResourceIdService.PERMISSION_VIEW, user );
175         }
176         return listStates;
177     }
178 
179     /**
180      * {@inheritDoc}
181      */
182     @Override
183     public List<Integer> getAuthorizedResourceList( String strResourceType, int nIdWorkflow, int nIdWorkflowState, Integer nExternalParentId, AdminUser user )
184     {
185         if ( nIdWorkflowState < 1 )
186         {
187             return this.getAuthorizedResourceList( strResourceType, nIdWorkflowState, null, nExternalParentId, user );
188         }
189 
190         List<Integer> resourceIdList = new ArrayList<Integer>( );
191 
192         State state = _stateService.findByPrimaryKey( nIdWorkflowState );
193 
194         ResourceWorkflowFilter resourceWorkflowFilter = new ResourceWorkflowFilter( );
195 
196         if ( user != null )
197         {
198             if ( RBACService.isAuthorized( state, StateResourceIdService.PERMISSION_VIEW, user ) )
199             {
200                 if ( state.isRequiredWorkgroupAssigned( ) )
201                 {
202                     ReferenceList refWorkgroupKey = AdminWorkgroupService.getUserWorkgroups( user, user.getLocale( ) );
203 
204                     if ( refWorkgroupKey != null )
205                     {
206                         resourceWorkflowFilter.setWorkgroupKeyList( refWorkgroupKey.toMap( ) );
207                     }
208                 }
209 
210                 resourceWorkflowFilter.setIdState( state.getId( ) );
211                 resourceWorkflowFilter.setIdWorkflow( nIdWorkflow );
212                 resourceWorkflowFilter.setResourceType( strResourceType );
213                 resourceWorkflowFilter.setExternalParentId( nExternalParentId );
214                 resourceIdList = _resourceWorkflowService.getListResourceIdWorkflowByFilter( resourceWorkflowFilter );
215             }
216         }
217         else
218         // WARNING : if content "user!=null" because for the batch the user is null, for the other case the user is not null
219         {
220             resourceWorkflowFilter.setIdState( state.getId( ) );
221             resourceWorkflowFilter.setIdWorkflow( nIdWorkflow );
222             resourceWorkflowFilter.setResourceType( strResourceType );
223             resourceWorkflowFilter.setExternalParentId( nExternalParentId );
224             resourceIdList = _resourceWorkflowService.getListResourceIdWorkflowByFilter( resourceWorkflowFilter );
225         }
226 
227         return resourceIdList;
228     }
229 
230     /**
231      * {@inheritDoc}
232      */
233     @Override
234     public List<Integer> getAuthorizedResourceList( String strResourceType, int nIdWorkflow, List<Integer> lListIdWorkflowState, Integer nExternalParentId,
235             AdminUser user )
236     {
237         List<Integer> lListAutorizedIdSate = new ArrayList<Integer>( );
238 
239         StateFilter stateFilter = new StateFilter( );
240         stateFilter.setIdWorkflow( nIdWorkflow );
241 
242         Collection<State> listState = _stateService.getListStateByFilter( stateFilter );
243 
244         if ( lListIdWorkflowState == null )
245         {
246             for ( State state : listState )
247             {
248                 if ( user != null )
249                 {
250                     if ( RBACService.isAuthorized( state, StateResourceIdService.PERMISSION_VIEW, user ) )
251                     {
252                         lListAutorizedIdSate.add( state.getId( ) );
253                     }
254                 }
255                 else
256                 // WARNING : if content "user!=null" because for the batch the user is null, for the other case the user is not null
257                 {
258                     lListAutorizedIdSate.add( state.getId( ) );
259                 }
260             }
261         }
262         else
263         {
264             for ( State state : listState )
265             {
266                 Integer nIdState = state.getId( );
267 
268                 if ( lListIdWorkflowState.contains( nIdState ) )
269                 {
270                     if ( user != null )
271                     {
272                         if ( RBACService.isAuthorized( state, StateResourceIdService.PERMISSION_VIEW, user ) )
273                         {
274                             lListAutorizedIdSate.add( nIdState );
275                         }
276                     }
277                     else
278                     // WARNING : if content "user!=null" because for the batch the user is null, for the other case the user is not null
279                     {
280                         lListAutorizedIdSate.add( nIdState );
281                     }
282                 }
283             }
284         }
285 
286         ResourceWorkflowFilter resourceWorkflowFilter = new ResourceWorkflowFilter( );
287         resourceWorkflowFilter.setIdState( ResourceWorkflowFilter.ALL_INT );
288         resourceWorkflowFilter.setIdWorkflow( nIdWorkflow );
289         resourceWorkflowFilter.setResourceType( strResourceType );
290         resourceWorkflowFilter.setExternalParentId( nExternalParentId );
291 
292         if ( user != null )
293         {
294             ReferenceList refWorkgroupKey = AdminWorkgroupService.getUserWorkgroups( user, user.getLocale( ) );
295 
296             if ( refWorkgroupKey != null )
297             {
298                 resourceWorkflowFilter.setWorkgroupKeyList( refWorkgroupKey.toMap( ) );
299             }
300         }
301 
302         return _resourceWorkflowService.getListResourceIdWorkflowByFilter( resourceWorkflowFilter, lListAutorizedIdSate );
303     }
304 
305     /**
306      * {@inheritDoc}
307      */
308     @Override
309     public String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request, Locale locale )
310     {
311         return getDisplayDocumentHistory( nIdResource, strResourceType, nIdWorkflow, request, locale, null, TEMPLATE_RESOURCE_HISTORY );
312     }
313 
314     /**
315      * Implements IWorkflowProvider of Lutece Core version 5.1
316      * 
317      * @param nIdResource
318      *            The resource
319      * @param strResourceType
320      *            The resource type
321      * @param nIdWorkflow
322      *            the workflow id
323      * @param request
324      *            The request
325      * @param locale
326      *            The locale
327      * @param strTemplate
328      *            The template
329      * @return The HTML code to display
330      */
331 
332     // @Override don't declare as Override to be compatible with older Lutece Core version
333     @Deprecated
334     public String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request, Locale locale,
335             String strTemplate )
336     {
337         Map<String, Object> defaultModel = getDefaultModelDocumentHistory( nIdResource, strResourceType, nIdWorkflow, request, locale );
338 
339         HtmlTemplate templateList = AppTemplateService.getTemplate( strTemplate, locale, defaultModel );
340 
341         return templateList.getHtml( );
342     }
343 
344     /**
345      * Implements IWorkflowProvider of Lutece Core version 5.1
346      * 
347      * @param nIdResource
348      *            The resource
349      * @param strResourceType
350      *            The resource type
351      * @param nIdWorkflow
352      *            the workflow id
353      * @param request
354      *            The request
355      * @param locale
356      *            The locale
357      * @param model
358      *            The model to add to the default model
359      * @param strTemplate
360      *            The template
361      * @return The HTML code to display
362      */
363 
364     // @Override don't declare as Override to be compatible with older Lutece Core version
365     public String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request, Locale locale,
366             Map<String, Object> model, String strTemplate )
367     {
368         Map<String, Object> defaultModel = getDefaultModelDocumentHistory( nIdResource, strResourceType, nIdWorkflow, request, locale );
369 
370         if ( model != null )
371         {
372             defaultModel.putAll( model );
373         }
374 
375         HtmlTemplate templateList = AppTemplateService.getTemplate( strTemplate, locale, defaultModel );
376 
377         return templateList.getHtml( );
378     }
379 
380     /**
381      * {@inheritDoc}
382      */
383     @Override
384     public String getDisplayTasksForm( int nIdResource, String strResourceType, int nIdAction, HttpServletRequest request, Locale locale )
385     {
386         List<ITask> listTasks = _taskService.getListTaskByIdAction( nIdAction, locale );
387         List<String> listFormEntry = new ArrayList<String>( );
388         String strFormEntry;
389 
390         for ( ITask task : listTasks )
391         {
392             strFormEntry = _taskComponentManager.getDisplayTaskForm( nIdResource, strResourceType, request, locale, task );
393 
394             if ( strFormEntry != null )
395             {
396                 listFormEntry.add( strFormEntry );
397             }
398         }
399 
400         Map<String, Object> model = new HashMap<String, Object>( );
401 
402         model.put( MARK_TASK_FORM_ENTRY_LIST, listFormEntry );
403 
404         HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_TASKS_FORM, locale, model );
405 
406         return templateList.getHtml( );
407     }
408 
409     /**
410      * {@inheritDoc}
411      */
412     @Override
413     public String getDocumentHistoryXml( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request, Locale locale )
414     {
415         List<ResourceHistory> listResourceHistory = _resourceHistoryService.getAllHistoryByResource( nIdResource, strResourceType, nIdWorkflow );
416         List<ITask> listActionTasks;
417         String strTaskinformation;
418         StringBuffer strXml = new StringBuffer( );
419         AdminUser user;
420 
421         XmlUtil.beginElement( strXml, TAG_HISTORY );
422         XmlUtil.beginElement( strXml, TAG_LIST_RESOURCE_HISTORY );
423 
424         for ( ResourceHistory resourceHistory : listResourceHistory )
425         {
426             user = ( resourceHistory.getUserAccessCode( ) != null ) ? AdminUserHome.findUserByLogin( resourceHistory.getUserAccessCode( ) ) : null;
427             listActionTasks = _taskService.getListTaskByIdAction( resourceHistory.getAction( ).getId( ), locale );
428 
429             XmlUtil.beginElement( strXml, TAG_RESOURCE_HISTORY );
430             XmlUtil.addElement( strXml, TAG_CREATION_DATE, DateUtil.getDateString( resourceHistory.getCreationDate( ), locale ) );
431             XmlUtil.beginElement( strXml, TAG_USER );
432 
433             if ( user != null )
434             {
435                 XmlUtil.addElementHtml( strXml, TAG_FIRST_NAME, user.getFirstName( ) );
436                 XmlUtil.addElementHtml( strXml, TAG_LAST_NAME, user.getLastName( ) );
437             }
438             else
439             {
440                 XmlUtil.addEmptyElement( strXml, TAG_FIRST_NAME, null );
441                 XmlUtil.addEmptyElement( strXml, TAG_LAST_NAME, null );
442 
443                 XmlUtil.endElement( strXml, TAG_USER );
444 
445                 XmlUtil.beginElement( strXml, TAG_LIST_TASK_INFORMATION );
446 
447                 for ( ITask task : listActionTasks )
448                 {
449                     XmlUtil.beginElement( strXml, TAG_TASK_INFORMATION );
450                     strTaskinformation = _taskComponentManager.getTaskInformationXml( resourceHistory.getId( ), request, locale, task );
451 
452                     if ( strTaskinformation != null )
453                     {
454                         strXml.append( strTaskinformation );
455                     }
456 
457                     XmlUtil.endElement( strXml, TAG_TASK_INFORMATION );
458                 }
459 
460                 XmlUtil.endElement( strXml, TAG_LIST_TASK_INFORMATION );
461 
462                 XmlUtil.endElement( strXml, TAG_RESOURCE_HISTORY );
463             }
464         }
465 
466         XmlUtil.endElement( strXml, TAG_LIST_RESOURCE_HISTORY );
467         XmlUtil.endElement( strXml, TAG_HISTORY );
468 
469         return strXml.toString( );
470     }
471 
472     /**
473      * {@inheritDoc}
474      */
475     @Override
476     public ReferenceList getWorkflowsEnabled( AdminUser user, Locale locale )
477     {
478         return WorkflowUtils.getRefList( getWorkflowsEnabled( user ), true, locale );
479     }
480 
481     /**
482      * {@inheritDoc}
483      */
484     @Override
485     public String getUserAccessCode( HttpServletRequest request )
486     {
487         AdminUser user = AdminUserService.getAdminUser( request );
488 
489         if ( user != null )
490         {
491             return user.getAccessCode( );
492         }
493 
494         return null;
495     }
496 
497     // CHECK
498 
499     /**
500      * {@inheritDoc}
501      */
502     @Deprecated
503     public boolean canProcessAction( int nIdAction, HttpServletRequest request )
504     {
505         if ( request != null )
506         {
507             Action action = _actionService.findByPrimaryKey( nIdAction );
508             AdminUser user = AdminUserService.getAdminUser( request );
509 
510             if ( user != null )
511             {
512                 return RBACService.isAuthorized( action, ActionResourceIdService.PERMISSION_VIEW, user );
513             }
514             else
515             {
516                 return true;
517             }
518         }
519 
520         return false;
521     }
522 
523     /**
524      * {@inheritDoc}
525      */
526     @Override
527     public boolean isAuthorized( int nIdResource, String strResourceType, int nIdWorkflow, AdminUser user )
528     {
529         boolean bReturn = false;
530         State resourceState = null;
531         ResourceWorkflow resourceWorkflow = _resourceWorkflowService.findByPrimaryKey( nIdResource, strResourceType, nIdWorkflow );
532 
533         if ( resourceWorkflow != null )
534         {
535             resourceState = _stateService.findByPrimaryKey( resourceWorkflow.getState( ).getId( ) );
536         }
537         else
538         {
539             // Get initial state
540             StateFilter filter = new StateFilter( );
541             filter.setIsInitialState( StateFilter.FILTER_TRUE );
542             filter.setIdWorkflow( nIdWorkflow );
543 
544             List<State> listState = _stateService.getListStateByFilter( filter );
545 
546             if ( listState.size( ) > 0 )
547             {
548                 resourceState = listState.get( 0 );
549             }
550         }
551 
552         if ( resourceState != null )
553         {
554             if ( user != null )
555             {
556                 if ( RBACService.isAuthorized( resourceState, StateResourceIdService.PERMISSION_VIEW, user ) )
557                 {
558                     if ( resourceState.isRequiredWorkgroupAssigned( ) && ( resourceWorkflow != null ) )
559                     {
560                         for ( String strWorkgroup : resourceWorkflow.getWorkgroups( ) )
561                         {
562                             if ( AdminWorkgroupHome.isUserInWorkgroup( user, strWorkgroup )
563                                     || RBACService.isAuthorized( resourceState, StateResourceIdService.PERMISSION_VIEW_ALL_WORKGROUP, user ) )
564                             {
565                                 bReturn = true;
566 
567                                 break;
568                             }
569                         }
570                     }
571                     else
572                     {
573                         bReturn = true;
574                     }
575                 }
576             }
577             else
578             {
579                 bReturn = true;
580             }
581 
582         }
583 
584         return bReturn;
585     }
586 
587     // DO
588 
589     /**
590      * {@inheritDoc}
591      */
592     @Override
593     public String doValidateTasksForm( int nIdResource, String strResourceType, int nIdAction, HttpServletRequest request, Locale locale )
594     {
595         List<ITask> listTasks = _taskService.getListTaskByIdAction( nIdAction, locale );
596         String strError = null;
597 
598         for ( ITask task : listTasks )
599         {
600             strError = _taskComponentManager.doValidateTask( nIdResource, strResourceType, request, locale, task );
601 
602             if ( strError != null )
603             {
604                 return strError;
605             }
606         }
607 
608         return null;
609     }
610 
611     /**
612      * {@inheritDoc}
613      */
614     @Deprecated
615     public void doSaveTasksForm( int nIdResource, String strResourceType, int nIdAction, Integer nExternalParentId, HttpServletRequest request, Locale locale,
616             String strUserAccessCode )
617     {
618         WorkflowService.getInstance( ).doProcessAction( nIdResource, strResourceType, nIdAction, nExternalParentId, request, locale, false );
619     }
620 
621     // PRIVATE METHODS
622 
623     /**
624      * Return a collection witch contains a list enabled workflow
625      * 
626      * @param user
627      *            the AdminUser
628      * @return a collection witch contains a list enabled workflow
629      */
630     private Collection<Workflow> getWorkflowsEnabled( AdminUser user )
631     {
632         WorkflowFilter filter = new WorkflowFilter( );
633         filter.setIsEnabled( WorkflowFilter.FILTER_TRUE );
634 
635         List<Workflow> listWorkflow = _workflowService.getListWorkflowsByFilter( filter );
636 
637         if ( user != null )
638         {
639             return AdminWorkgroupService.getAuthorizedCollection( listWorkflow, user );
640         }
641         else
642         {
643             return listWorkflow;
644         }
645     }
646 
647     /**
648      * returns the default model to build history performed on a resource.
649      *
650      * @param nIdResource
651      *            the resource id
652      * @param strResourceType
653      *            the resource type
654      * @param nIdWorkflow
655      *            the workflow id
656      * @param request
657      *            the request
658      * @param locale
659      *            the locale
660      * @return the default model
661      */
662     private Map<String, Object> getDefaultModelDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request,
663             Locale locale )
664     {
665         List<ResourceHistory> listResourceHistory = _resourceHistoryService.getAllHistoryByResource( nIdResource, strResourceType, nIdWorkflow );
666         List<ITask> listActionTasks;
667         List<String> listTaskInformation;
668         Map<String, Object> model = new HashMap<String, Object>( );
669         Map<String, Object> resourceHistoryTaskInformation;
670         List<Map<String, Object>> listResourceHistoryTaskInformation = new ArrayList<Map<String, Object>>( );
671         String strTaskinformation;
672 
673         for ( ResourceHistory resourceHistory : listResourceHistory )
674         {
675             resourceHistoryTaskInformation = new HashMap<String, Object>( );
676             resourceHistoryTaskInformation.put( MARK_RESOURCE_HISTORY, resourceHistory );
677 
678             if ( resourceHistory.getUserAccessCode( ) != null )
679             {
680                 resourceHistoryTaskInformation.put( MARK_ADMIN_USER_HISTORY, AdminUserHome.findUserByLogin( resourceHistory.getUserAccessCode( ) ) );
681             }
682 
683             listTaskInformation = new ArrayList<String>( );
684             listActionTasks = _taskService.getListTaskByIdAction( resourceHistory.getAction( ).getId( ), locale );
685 
686             for ( ITask task : listActionTasks )
687             {
688                 strTaskinformation = _taskComponentManager.getDisplayTaskInformation( resourceHistory.getId( ), request, locale, task );
689 
690                 if ( strTaskinformation != null )
691                 {
692                     listTaskInformation.add( strTaskinformation );
693                 }
694             }
695 
696             resourceHistoryTaskInformation.put( MARK_TASK_INFORMATION_LIST, listTaskInformation );
697 
698             listResourceHistoryTaskInformation.add( resourceHistoryTaskInformation );
699         }
700 
701         model.put( MARK_HISTORY_INFORMATION_LIST, listResourceHistoryTaskInformation );
702         model.put( MARK_ADMIN_AVATAR, PluginService.isPluginEnable( "adminavatar" ) );
703 
704         return model;
705     }
706 
707     @Override
708     public boolean canProcessAction( int arg0, String arg1, int arg2, HttpServletRequest arg3 )
709     {
710         // TODO Auto-generated method stub
711         return false;
712     }
713 
714     @Override
715     public Map<Integer, List<Action>> getActions( String arg0, Map<Integer, List<Action>> arg1, AdminUser arg2 )
716     {
717         // TODO Auto-generated method stub
718         return null;
719     }
720 
721     @Override
722     public Collection<Action> getActions( int arg0, String arg1, Collection<Action> arg2, AdminUser arg3 )
723     {
724         // TODO Auto-generated method stub
725         return null;
726     }
727 }