diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/pom.xml b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/pom.xml
index dd4c87fc5..5e1e7f04b 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/pom.xml
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/pom.xml
@@ -125,6 +125,10 @@
org.wso2.carbon.humantask
provided
+
+ org.wso2.carbon.identity.workflow.engine
+ workflow.engine
+
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/ApprovalConstant.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/ApprovalConstant.java
index 0bb8532ab..c51d6d25c 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/ApprovalConstant.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/ApprovalConstant.java
@@ -25,6 +25,8 @@ public class ApprovalConstant {
public static final String USER_APPROVAL_TASK_PATH_COMPONENT = "/%s/approval-tasks";
public static final String V1_API_PATH_COMPONENT = "/v1";
public static final String ME_CONTEXT = "me";
+ public static final String SIMPLE_WORKFLOW_ENGINE_APPROVALS = "WorkflowEngines.SimpleWorkflowEngine.AllowApprovals";
+ public static final String BPEL_ENGINE_APPROVALS = "WorkflowEngines.BPELEngine.AllowApprovals";
/**
* Enum for user's pending approval related errors in the format of
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/UserApprovalServiceHolder.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/UserApprovalServiceHolder.java
index 1ff85a87e..01a17a932 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/UserApprovalServiceHolder.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/UserApprovalServiceHolder.java
@@ -17,6 +17,7 @@
package org.wso2.carbon.identity.api.user.approval.common;
import org.wso2.carbon.humantask.core.TaskOperationService;
+import org.wso2.carbon.identity.workflow.engine.SimpleWorkflowEngineApprovalService;
/**
* Service holder class for user approvals.
@@ -24,18 +25,47 @@
public class UserApprovalServiceHolder {
private static TaskOperationService taskOperationService;
+ private static SimpleWorkflowEngineApprovalService simpleWorkflowEngineApprovalService;
+ /**
+ * Set TaskOperationService as OSGI service.
+ *
+ * @param taskOperationService taskOperationService.
+ */
public static void setTaskOperationService(TaskOperationService taskOperationService) {
+
UserApprovalServiceHolder.taskOperationService = taskOperationService;
}
+ /**
+ * Set ApprovalEventService as OSGI service.
+ *
+ * @param simpleWorkflowEngineApprovalService approvalEventService.
+ */
+ public static void setSimpleWorkflowEngineApprovalService(SimpleWorkflowEngineApprovalService simpleWorkflowEngineApprovalService) {
+
+ UserApprovalServiceHolder.simpleWorkflowEngineApprovalService = simpleWorkflowEngineApprovalService;
+ }
+
/**
* Get TaskOperationService osgi service.
*
* @return TaskOperationService
*/
public static TaskOperationService getTaskOperationService() {
+
return taskOperationService;
}
+
+ /**
+ * Get ApprovalEventService osgi service.
+ *
+ * @return ApprovalEventService
+ */
+ public static SimpleWorkflowEngineApprovalService getSimpleWorkflowEngineApprovalService() {
+
+ return simpleWorkflowEngineApprovalService;
+ }
+
}
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGIServiceFactory.java
index dc37df4a4..9e43bdbce 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGIServiceFactory.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGIServiceFactory.java
@@ -34,7 +34,7 @@ public Class> getObjectType() {
}
@Override
- protected TaskOperationService createInstance() throws Exception {
+ protected TaskOperationService createInstance() throws RuntimeException {
if (this.taskOperationService == null) {
TaskOperationService taskOperationService = (TaskOperationService) PrivilegedCarbonContext.
@@ -42,10 +42,9 @@ protected TaskOperationService createInstance() throws Exception {
if (taskOperationService != null) {
this.taskOperationService = taskOperationService;
} else {
- throw new Exception("Unable to retrieve TaskOperationService service.");
+ throw new RuntimeException("Unable to retrieve TaskOperationService service.");
}
}
return this.taskOperationService;
}
-
}
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGISimpleWorkflowEngineService.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGISimpleWorkflowEngineService.java
new file mode 100644
index 000000000..3da9dc76d
--- /dev/null
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/src/main/java/org/wso2/carbon/identity/api/user/approval/common/factory/OSGISimpleWorkflowEngineService.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.identity.api.user.approval.common.factory;
+
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.workflow.engine.SimpleWorkflowEngineApprovalService;
+
+/**
+ * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
+ * instantiate the ApprovalEventService type of object inside the container.
+ */
+public class OSGISimpleWorkflowEngineService extends AbstractFactoryBean {
+
+ private SimpleWorkflowEngineApprovalService simpleWorkflowEngineApprovalService;
+
+ @Override
+ public Class> getObjectType() {
+
+ return Object.class;
+ }
+
+ @Override
+ protected SimpleWorkflowEngineApprovalService createInstance() throws RuntimeException {
+
+ if (this.simpleWorkflowEngineApprovalService == null) {
+ SimpleWorkflowEngineApprovalService simpleWorkflowEngineApprovalService = (SimpleWorkflowEngineApprovalService) PrivilegedCarbonContext.
+ getThreadLocalCarbonContext().getOSGiService(SimpleWorkflowEngineApprovalService.class, null);
+ if (simpleWorkflowEngineApprovalService != null) {
+ this.simpleWorkflowEngineApprovalService = simpleWorkflowEngineApprovalService;
+ } else {
+ throw new RuntimeException("Unable to retrieve ApprovalEvent service.");
+ }
+ }
+ return this.simpleWorkflowEngineApprovalService;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/pom.xml b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/pom.xml
index c4e3544b6..66b47df18 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/pom.xml
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/pom.xml
@@ -170,5 +170,9 @@
org.wso2.carbon.humantask.skeleton
provided
+
+ org.wso2.carbon.identity.workflow.engine
+ workflow.engine
+
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApi.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApi.java
index 4f9b0a7db..516a95f2c 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApi.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApi.java
@@ -16,26 +16,19 @@
package org.wso2.carbon.identity.rest.api.user.approval.v1;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.*;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.MeApiService;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.factories.MeApiServiceFactory;
-
import io.swagger.annotations.ApiParam;
-
+import org.springframework.beans.factory.annotation.Autowired;
import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskDataDTO;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.ErrorDTO;
import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskSummaryDTO;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO;
+import org.wso2.carbon.identity.workflow.engine.dto.StateDTO;
import java.util.List;
-
-import java.io.InputStream;
-import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.apache.cxf.jaxrs.ext.multipart.Multipart;
-
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import javax.ws.rs.*;
@Path("/me")
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApiService.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApiService.java
index b6f6180b6..52bdfb2d6 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApiService.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/approval/v1/MeApiService.java
@@ -16,24 +16,14 @@
package org.wso2.carbon.identity.rest.api.user.approval.v1;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.*;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.*;
-
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskDataDTO;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.ErrorDTO;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskSummaryDTO;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO;
+import org.wso2.carbon.identity.workflow.engine.dto.StateDTO;
import java.util.List;
-
-import java.io.InputStream;
-import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-
import javax.ws.rs.core.Response;
public abstract class MeApiService {
public abstract Response getApprovalTaskInfo(String taskId);
public abstract Response listApprovalTasksForLoggedInUser(Integer limit,Integer offset,List status);
- public abstract Response updateStateOfTask(String taskId,StateDTO nextState);
+ public abstract Response updateStateOfTask(String taskId, StateDTO nextState);
}
diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/approval/v1/core/UserApprovalService.java b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/approval/v1/core/UserApprovalService.java
index 8b8ca3ae1..b0dff6c8e 100644
--- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/approval/v1/core/UserApprovalService.java
+++ b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/approval/v1/core/UserApprovalService.java
@@ -41,9 +41,9 @@
import org.wso2.carbon.identity.rest.api.user.approval.v1.core.functions.TTaskSimpleQueryResultRowToExternal;
import org.wso2.carbon.identity.rest.api.user.approval.v1.core.functions.TaskModelToExternal;
import org.wso2.carbon.identity.rest.api.user.approval.v1.core.model.TaskModel;
-import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO;
import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskDataDTO;
import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskSummaryDTO;
+import org.wso2.carbon.identity.workflow.engine.dto.StateDTO;
import java.util.Arrays;
import java.util.List;
@@ -60,8 +60,6 @@
import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_NON_EXISTING_TASK_ID;
import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_NOT_ACCEPTABLE_INPUT_FOR_NEXT_STATE;
import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_UNAUTHORIZED_USER;
-import static org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO.ActionEnum.APPROVE;
-import static org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO.ActionEnum.REJECT;
/**
* Call internal osgi services to perform user's approval task related operations
@@ -113,6 +111,7 @@ public List listTasks(Integer limit, Integer offset, List status) {
- return Response.ok().entity(userApprovalService.listTasks(limit, offset, status)).build();
+ if (enableApprovalsFromSimpleWorkflowEngine && !enableApprovalsFromBPEL) {
+ return Response.ok().entity(simpleWorkflowEngineApprovalService.listTasks(limit, offset, status)).build();
+ } else if (enableApprovalsFromBPEL && !enableApprovalsFromSimpleWorkflowEngine) {
+ return Response.ok().entity(userApprovalService.listTasks(limit, offset, status)).build();
+ }
+ List BPELApprovalList = userApprovalService.listTasks(limit, offset, status);
+ List simpleWorkflowEngineApprovalList =
+ simpleWorkflowEngineApprovalService.listTasks(limit, offset, status);
+ List