View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.flowable.api;
20  
21  import java.util.List;
22  import org.apache.commons.lang3.tuple.Pair;
23  import org.apache.syncope.common.lib.request.UserUR;
24  import org.apache.syncope.common.lib.to.UserRequest;
25  import org.apache.syncope.common.lib.to.UserRequestForm;
26  import org.apache.syncope.common.lib.to.WorkflowTaskExecInput;
27  import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
28  import org.apache.syncope.core.persistence.api.entity.Entity;
29  import org.apache.syncope.core.persistence.api.entity.user.User;
30  import org.apache.syncope.core.provisioning.api.UserWorkflowResult;
31  import org.apache.syncope.core.provisioning.api.event.EntityLifecycleEvent;
32  import org.flowable.engine.runtime.ProcessInstance;
33  import org.springframework.transaction.event.TransactionalEventListener;
34  
35  public interface UserRequestHandler {
36  
37      /**
38       * Get the running user requests matching the provided parameters.
39       *
40       * @param userKey user key (optional)
41       * @param page result page
42       * @param size items per page
43       * @param orderByClauses sort conditions
44       * @return total number of user requests, list of user requests matching the provided parameters
45       */
46      Pair<Integer, List<UserRequest>> getUserRequests(
47              String userKey, int page, int size, List<OrderByClause> orderByClauses);
48  
49      /**
50       * Starts a new user request, for the given BPMN process and user.
51       *
52       * @param bpmnProcess BPMN process
53       * @param user user
54       * @param inputVariables variables
55       * @return data about the started request service, including execution id
56       */
57      UserRequest start(String bpmnProcess, User user, WorkflowTaskExecInput inputVariables);
58  
59      /**
60       * Parses the given execution id to find matching user request and owner.
61       *
62       * @param executionId execution id
63       * @return matching user request and owner
64       */
65      Pair<ProcessInstance, String> parse(String executionId);
66  
67      /**
68       * Cancel a running user request.
69       *
70       * @param procInst process instance for user request
71       * @param reason reason to cancel the user request
72       */
73      void cancel(ProcessInstance procInst, String reason);
74  
75      /**
76       * Cancel all running user requests for the given process definition id.
77       *
78       * @param processDefinitionId process definition id
79       */
80      void cancelByProcessDefinition(String processDefinitionId);
81  
82      /**
83       * Cancel all running user requests for the user in the given delete event.
84       *
85       * @param event delete event
86       */
87      @TransactionalEventListener
88      void cancelByUser(EntityLifecycleEvent<Entity> event);
89  
90      /**
91       * Get the form matching the provided task id.
92       *
93       * @param userKey user key
94       * @param taskId task id
95       * @return the form for the given task id
96       */
97      UserRequestForm getForm(String userKey, String taskId);
98  
99      /**
100      * Get the forms matching the provided parameters.
101      *
102      * @param userKey user key (optional)
103      * @param page result page
104      * @param size items per page
105      * @param orderByClauses sort conditions
106      * @return total number of forms, list of forms matching the provided parameters
107      */
108     Pair<Integer, List<UserRequestForm>> getForms(
109             String userKey, int page, int size, List<OrderByClause> orderByClauses);
110 
111     /**
112      * Claim a form for a given object.
113      *
114      * @param taskId Workflow task to which the form is associated
115      * @return updated form
116      */
117     UserRequestForm claimForm(String taskId);
118 
119     /**
120      * Unclaim a form for a given object.
121      *
122      * @param taskId Workflow task to which the form is associated
123      * @return updated form
124      */
125     UserRequestForm unclaimForm(String taskId);
126 
127     /**
128      * Submit a form.
129      *
130      * @param form to be submitted
131      * @return user updated by this form submit
132      */
133     UserWorkflowResult<UserUR> submitForm(UserRequestForm form);
134 }