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