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.portal.service.workflow;
35  
36  import fr.paris.lutece.plugins.workflowcore.business.action.Action;
37  import fr.paris.lutece.plugins.workflowcore.business.state.State;
38  import fr.paris.lutece.portal.business.user.AdminUser;
39  import fr.paris.lutece.util.ReferenceList;
40  
41  import java.util.Collection;
42  import java.util.List;
43  import java.util.Locale;
44  import java.util.Map;
45  
46  import javax.servlet.http.HttpServletRequest;
47  
48  
49  /**
50   * IWorkflowProvider.
51   */
52  public interface IWorkflowProvider
53  {
54      // GET
55  
56      /**
57       * returns a list of actions possible for a given document based on the status
58       * of the document in the workflow and the user role.
59       *
60       * @param listActions the list actions
61       * @param user the adminUser
62       * @return a list of Action
63       */
64      Collection<Action> getActions( Collection<Action> listActions, AdminUser user );
65  
66      /**
67       * returns a list of actions possible for a given document based on the status
68       * of the document in the workflow and the user role.
69       *
70       * @param mapActions the map actions
71       * @param user the adminUser
72       * @return a list of Action
73       */
74      Map<Integer, List<Action>> getActions( Map<Integer, List<Action>> mapActions, AdminUser user );
75  
76      /**
77       * returns the  actions history performed on a resource.
78       *
79       * @param nIdResource the resource id
80       * @param strResourceType the resource type
81       * @param nIdWorkflow the workflow id
82       * @param request the request
83       * @param locale the locale
84       * @return the history of actions performed on a resource
85       */
86      String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow,
87          HttpServletRequest request, Locale locale );
88  
89      /**
90       * returns the  actions history performed on a resource.
91       *
92       * @param nIdResource the resource id
93       * @param strResourceType the resource type
94       * @param nIdWorkflow the workflow id
95       * @param request the request
96       * @param locale the locale
97       * @param strTemplate The template
98       * @return the history of actions performed on a resource
99       */
100     @Deprecated
101     String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow,
102         HttpServletRequest request, Locale locale, String strTemplate );
103 
104     /**
105      * returns the  actions history performed on a resource.
106      *
107      * @param nIdResource the resource id
108      * @param strResourceType the resource type
109      * @param nIdWorkflow the workflow id
110      * @param request the request
111      * @param locale the locale
112      * @param model The model to add to the default model
113      * @param strTemplate The template
114      * @return the history of actions performed on a resource
115      */
116     String getDisplayDocumentHistory( int nIdResource, String strResourceType, int nIdWorkflow,
117         HttpServletRequest request, Locale locale, Map<String, Object> model, String strTemplate );
118 
119     /**
120      * returns a xml wich contains the  actions history performed on a resource.
121      *
122      * @param nIdResource the resource id
123      * @param strResourceType the resource type
124      * @param nIdWorkflow the workflow id
125      * @param request the request
126      * @param locale the locale
127      * @return a xml wich contains  the history of actions performed on a resource
128      */
129     String getDocumentHistoryXml( int nIdResource, String strResourceType, int nIdWorkflow, HttpServletRequest request,
130         Locale locale );
131 
132     /**
133      * returns the tasks form.
134      *
135      * @param nIdResource the resource id
136      * @param strResourceType the resource type
137      * @param nIdAction the action id
138      * @param request the request
139      * @param locale the locale
140      * @return the tasks form associated to the action
141      */
142     String getDisplayTasksForm( int nIdResource, String strResourceType, int nIdAction, HttpServletRequest request,
143         Locale locale );
144 
145     /**
146      * Get all authorized resource Id.
147      *
148      * @param strResourceType the resource type
149      * @param nIdWorkflow the workflow id
150      * @param nIdWorkflowState The workflow state id
151      * @param nExternalParentId The external parent id
152      * @param user the AdminUser
153      * @return The list
154      */
155     List<Integer> getAuthorizedResourceList( String strResourceType, int nIdWorkflow, int nIdWorkflowState,
156         Integer nExternalParentId, AdminUser user );
157 
158     /**
159      * Get all authorized resource Id.
160      *
161      * @param strResourceType the resource type
162      * @param nIdWorkflow the workflow id
163      * @param lListIdWorkflowState The list workflow state id
164      * @param nExternalParentId he external parent id
165      * @param user the AdminUser
166      * @return The list
167      */
168     List<Integer> getAuthorizedResourceList( String strResourceType, int nIdWorkflow,
169         List<Integer> lListIdWorkflowState, Integer nExternalParentId, AdminUser user );
170 
171     /**
172      * return a referencelist wich contains a list enabled workflow.
173      *
174      * @param user the AdminUser
175      * @param locale the locale
176      * @return a referencelist wich contains a list enabled workflow
177      */
178     ReferenceList getWorkflowsEnabled( AdminUser user, Locale locale );
179 
180     /**
181      * returns all state of a  given workflow.
182      *
183      * @param listStates the list states
184      * @param user the adminUser
185      * @return the state of a given document
186      */
187     Collection<State> getAllStateByWorkflow( Collection<State> listStates, AdminUser user );
188 
189     /**
190      * The user access code.
191      *
192      * @param request the HTTP request
193      * @return the user access code
194      */
195     String getUserAccessCode( HttpServletRequest request );
196 
197     // CHECK
198 
199     /**
200      * Check that a given user is allowed to view a resource depending the state of the resource.
201      *
202      * @param nIdResource the document id
203      * @param strResourceType the document type
204      * @param nIdWorkflow the workflow id*
205      * @param user the user
206      * @return a list of Action
207      */
208     boolean isAuthorized( int nIdResource, String strResourceType, int nIdWorkflow, AdminUser user );
209 
210     /**
211      * Check if the action can be proceed for the given resource.
212      *
213      * @param nIdAction the id action
214      * @param request the HTTP request
215      * @return true if the action can proceed, false otherwise
216      */
217     boolean canProcessAction( int nIdAction, HttpServletRequest request );
218 
219     // DO
220 
221     /**
222      * Test if the information relating to various tasks associated with action are validated.
223      *
224      * @param nIdResource the resource id
225      * @param strResourceType the resource type
226      * @param nIdAction the action id
227      * @param request the request
228      * @param locale the locale
229      * @return null if there is no error in the tasks form, return the error message otherwise
230      */
231     String doValidateTasksForm( int nIdResource, String strResourceType, int nIdAction, HttpServletRequest request,
232         Locale locale );
233 
234     /**
235      * Perform the information on the various tasks associated with the given
236      * action specified in parameter.
237      *
238      * @param nIdResource the resource id
239      * @param strResourceType the resource type
240      * @param nIdAction the action id
241      * @param nExternalParentId the external parent id
242      * @param request the request
243      * @param locale the locale
244      * @param strUserAccessCode the user access code
245      * @deprecated This method should not be used. Use
246      *             {@link WorkflowService#doProcessAction(int, String, int, Integer, HttpServletRequest, Locale, boolean)
247      *             WorkflowService.doProcessAction } instead.
248      */
249     @Deprecated
250     void doSaveTasksForm( int nIdResource, String strResourceType, int nIdAction, Integer nExternalParentId,
251         HttpServletRequest request, Locale locale, String strUserAccessCode );
252 }