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 deleted file mode 100644 index 8de09c532..000000000 --- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.api.user.approval.common/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - org.wso2.carbon.identity.api.user.approval - org.wso2.carbon.identity.user.api - 1.3.29-SNAPSHOT - ../pom.xml - - 4.0.0 - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.api.user.approval.common - jar - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - 1.8 - 1.8 - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-rs-service-description - provided - - - org.springframework - spring-web - provided - - - javax.ws.rs - javax.ws.rs-api - provided - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - javax.ws.rs - jsr311-api - - - com.google.guava - guava - - - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - provided - - - org.wso2.carbon.identity.governance - org.wso2.carbon.identity.recovery - provided - - - javax.ws.rs - jsr311-api - - - - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.api.user.common - provided - ${project.version} - - - org.wso2.carbon.business-process - org.wso2.carbon.humantask - provided - - - - 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 deleted file mode 100644 index 0bb8532ab..000000000 --- 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 +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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; - -/** - * Contains all the user's pending tasks related constants - */ -public class ApprovalConstant { - - public static final String USER_APPROVAL_PREFIX = "HTA-"; - 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"; - - /** - * Enum for user's pending approval related errors in the format of - * Error Code - code to identify the error - * Error Message - What went wrong - * Error Description - Why it went wrong - */ - public enum ErrorMessage { - - SERVER_ERROR_RETRIEVING_APPROVALS_FOR_USER("15002", - "Unable to retrieve approvals for the user.", - "Server encountered an error while retrieving approvals for user."), - SERVER_ERROR_RETRIEVING_APPROVAL_OF_USER("15003", - "Unable to retrieve the user approval.", - "Server encountered an error while retrieving information on the approval task."), - SERVER_ERROR_CHANGING_APPROVALS_STATE("15004", - "Unable to update the approval status.", - "Server encountered an error while updating the approval task status."), - USER_ERROR_UNAUTHORIZED_USER("10001", - "Access denied.", - "You are not authorized to perform this task."), - USER_ERROR_INVALID_TASK_ID("10002", - "Invalid input provided.", - "The provided Task ID is not in the correct format."), - USER_ERROR_NON_EXISTING_TASK_ID("10003", - "Task does not exist.", - null), - USER_ERROR_INVALID_INPUT("10004", - "Invalid input data provided.", - null), - USER_ERROR_NOT_ACCEPTABLE_INPUT_FOR_NEXT_STATE("10005", - "Unacceptable input provided", - "Only [CLAIM, RELEASE, APPROVED, REJECTED] are acceptable."), - USER_ERROR_INVALID_STATE_CHANGE("10006", - "Unable to change the approval status.", - "Invalid state change is requested for the given task."), - USER_ERROR_INVALID_OPERATION("10007", - "Unable to update the approval status", - "Invalid state change is requested for the given task."); - - private final String code; - private final String message; - private final String description; - - ErrorMessage(String code, String message, String description) { - this.code = code; - this.message = message; - this.description = description; - } - - public String getCode() { - return USER_APPROVAL_PREFIX + code; - } - - public String getMessage() { - return message; - } - - public String getDescription() { - return description; - } - - @Override - public String toString() { - return code + " | " + message; - } - - } - -} 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 deleted file mode 100644 index 1ff85a87e..000000000 --- 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 +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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; - -import org.wso2.carbon.humantask.core.TaskOperationService; - -/** - * Service holder class for user approvals. - */ -public class UserApprovalServiceHolder { - - private static TaskOperationService taskOperationService; - - public static void setTaskOperationService(TaskOperationService taskOperationService) { - UserApprovalServiceHolder.taskOperationService = taskOperationService; - } - - /** - * Get TaskOperationService osgi service. - * - * @return TaskOperationService - */ - public static TaskOperationService getTaskOperationService() { - return 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/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 deleted file mode 100644 index dc37df4a4..000000000 --- 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 +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.humantask.core.TaskOperationService; - -/** - * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to - * instantiate the TaskOperationService type of object inside the container. - */ -public class OSGIServiceFactory extends AbstractFactoryBean { - - private TaskOperationService taskOperationService; - - @Override - public Class getObjectType() { - return Object.class; - } - - @Override - protected TaskOperationService createInstance() throws Exception { - - if (this.taskOperationService == null) { - TaskOperationService taskOperationService = (TaskOperationService) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService(TaskOperationService.class, null); - if (taskOperationService != null) { - this.taskOperationService = taskOperationService; - } else { - throw new Exception("Unable to retrieve TaskOperationService service."); - } - } - return this.taskOperationService; - } - -} 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 deleted file mode 100644 index 686c13a46..000000000 --- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - org.wso2.carbon.identity.api.user.approval - org.wso2.carbon.identity.user.api - 1.3.29-SNAPSHOT - ../pom.xml - - 4.0.0 - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.rest.api.user.approval.v1 - - jar - WSO2 Identity Server - User Approvals Rest API - WSO2 Identity Server - User Approvals Rest API - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - 1.8 - 1.8 - - - - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.8 - - - add-source - generate-sources - - add-source - - - - src/gen/java - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-rs-service-description - provided - - - org.springframework - spring-web - provided - - - javax.ws.rs - javax.ws.rs-api - provided - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - javax.ws.rs - jsr311-api - - - com.google.guava - guava - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - provided - - - com.fasterxml.jackson.core - jackson-databind - provided - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - provided - - - org.wso2.carbon.business-process - org.wso2.carbon.humantask - provided - - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.api.user.common - provided - ${project.version} - - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.api.user.approval.common - provided - ${project.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.base - provided - - - org.wso2.carbon.business-process - org.wso2.carbon.humantask.skeleton - provided - - - 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 deleted file mode 100644 index 4f9b0a7db..000000000 --- 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 +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.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.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 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.core.Response; -import javax.ws.rs.*; - -@Path("/me") - - -@io.swagger.annotations.Api(value = "/me", description = "the me API") -public class MeApi { - - @Autowired - private MeApiService delegate; - - @GET - @Path("/approval-tasks/{task-id}") - - - @io.swagger.annotations.ApiOperation(value = "Retrieves an approval task by the task-id", notes = "Retrieves information of a specific approval task identified by the task-id
\nPermission required:\n * /permission/admin/manage/humantask/viewtasks\n", response = TaskDataDTO.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "Detailed information of the approval task identified by the task-id"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid input request"), - - @io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized"), - - @io.swagger.annotations.ApiResponse(code = 403, message = "Resource Forbidden"), - - @io.swagger.annotations.ApiResponse(code = 404, message = "The specified resource is not found"), - - @io.swagger.annotations.ApiResponse(code = 409, message = "Element Already Exists"), - - @io.swagger.annotations.ApiResponse(code = 500, message = "Internal Server Error") }) - - public Response getApprovalTaskInfo(@ApiParam(value = "Task ID",required=true ) @PathParam("task-id") String taskId) - { - return delegate.getApprovalTaskInfo(taskId); - } - @GET - @Path("/approval-tasks") - - - @io.swagger.annotations.ApiOperation(value = "Retrieves available approvals for the authenticated user", notes = "Retrieve the available approval tasks in the system for the authenticated user. This API returns the following types of approvals:\n * READY - Tasks that are _claimable_ by the user. User is eligible to assign the task to himself and complete it, if a particular task is in READY state.\n * RESERVED - Tasks that are _assigned_ to the user and to be approved by this user.\n * COMPLETED - Tasks that are already _completed_ (approved or denied) by this user.\n\nPermission required:\n * /permission/admin/manage/humantask/viewtasks\n\n A user can also invoke the endpoint with the following query parameters.\n", response = TaskSummaryDTO.class, responseContainer = "List") - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "Array of approval tasks matching the search criteria"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid input request"), - - @io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized"), - - @io.swagger.annotations.ApiResponse(code = 403, message = "Resource Forbidden"), - - @io.swagger.annotations.ApiResponse(code = 500, message = "Internal Server Error") }) - - public Response listApprovalTasksForLoggedInUser(@ApiParam(value = "Maximum number of records to return") @QueryParam("limit") Integer limit, - @ApiParam(value = "Number of records to skip for pagination") @QueryParam("offset") Integer offset, - @ApiParam(value = "Approval task's status to filter tasks by their status:\n * **RESERVED** - Tasks that are **assigned to** the authenticated user.\n * **READY** - Tasks that **can be assigned to** and **can be approved by** the authenticated user.\n * **COMPLETED** - Tasks that are **completed by** the user\n * \\ - **All** the viewable tasks will be retrieved if this parameter is not specified.\n") @QueryParam("status") List status) - { - return delegate.listApprovalTasksForLoggedInUser(limit,offset,status); - } - @PUT - @Path("/approval-tasks/{task-id}/state") - - - @io.swagger.annotations.ApiOperation(value = "Changes the state of an approval task", notes = "Update the approval task status by defining one of the following actions:\n * CLAIM - Reserve the task for the user. Status of the task will be changed from READY to RESERVED.\n * RELEASE - Release the task for other users to claim. Status of the task will be changed from RESERVED to READY.\n * APPROVE - Approve the task. Status of the task will be changed to COMPLETED.\n * REJECT - Deny the task. Status of the task will be changed to COMPLETED.\n
\n\nPermission required:\n * /permission/admin/manage/humantask/viewtasks\n", response = void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "OK"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid input request"), - - @io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized"), - - @io.swagger.annotations.ApiResponse(code = 403, message = "Resource Forbidden"), - - @io.swagger.annotations.ApiResponse(code = 404, message = "The specified resource is not found"), - - @io.swagger.annotations.ApiResponse(code = 500, message = "Internal Server Error") }) - - public Response updateStateOfTask(@ApiParam(value = "Task ID",required=true ) @PathParam("task-id") String taskId, - @ApiParam(value = "To which state the task should be changed." ) StateDTO nextState) - { - return delegate.updateStateOfTask(taskId,nextState); - } -} - 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 deleted file mode 100644 index b6f6180b6..000000000 --- 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 +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.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 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); -} - 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/dto/ErrorDTO.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/dto/ErrorDTO.java deleted file mode 100644 index f1355c76e..000000000 --- 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/dto/ErrorDTO.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.dto; - - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - - - - - -@ApiModel(description = "") -public class ErrorDTO { - - - @NotNull - private String code = null; - - @NotNull - private String message = null; - - - private String description = null; - - - private String traceId = null; - - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("code") - public String getCode() { - return code; - } - public void setCode(String code) { - this.code = code; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("description") - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("traceId") - public String getTraceId() { - return traceId; - } - public void setTraceId(String traceId) { - this.traceId = traceId; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ErrorDTO {\n"); - - sb.append(" code: ").append(code).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append(" description: ").append(description).append("\n"); - sb.append(" traceId: ").append(traceId).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} 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/dto/PropertyDTO.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/dto/PropertyDTO.java deleted file mode 100644 index 320f8513d..000000000 --- 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/dto/PropertyDTO.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.dto; - - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - - - - - -@ApiModel(description = "") -public class PropertyDTO { - - - - private String key = null; - - - private String value = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("key") - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("value") - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PropertyDTO {\n"); - - sb.append(" key: ").append(key).append("\n"); - sb.append(" value: ").append(value).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} 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/dto/StateDTO.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/dto/StateDTO.java deleted file mode 100644 index 0090c18c8..000000000 --- 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/dto/StateDTO.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.dto; - - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - - - - - -@ApiModel(description = "") -public class StateDTO { - - - public enum ActionEnum { - CLAIM, RELEASE, APPROVE, REJECT, - }; - - private ActionEnum action = null; - - - /** - * Action to perform on the task. - **/ - @ApiModelProperty(value = "Action to perform on the task.") - @JsonProperty("action") - public ActionEnum getAction() { - return action; - } - public void setAction(ActionEnum action) { - this.action = action; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class StateDTO {\n"); - - sb.append(" action: ").append(action).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} 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/dto/TaskDataDTO.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/dto/TaskDataDTO.java deleted file mode 100644 index 38c7efb5e..000000000 --- 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/dto/TaskDataDTO.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.dto; - -import java.util.ArrayList; -import java.util.List; -import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.PropertyDTO; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - - - - - -@ApiModel(description = "") -public class TaskDataDTO { - - - - private String id = null; - - - private String subject = null; - - - private String description = null; - - - private Integer priority = null; - - - private String initiator = null; - - public enum ApprovalStatusEnum { - PENDING, APPROVED, REJECTED, - }; - - private ApprovalStatusEnum approvalStatus = null; - - - private List assignees = new ArrayList(); - - - private List properties = new ArrayList(); - - - /** - * Unique ID to represent a approval task - **/ - @ApiModelProperty(value = "Unique ID to represent a approval task") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - - /** - * Subject of the Approval - **/ - @ApiModelProperty(value = "Subject of the Approval") - @JsonProperty("subject") - public String getSubject() { - return subject; - } - public void setSubject(String subject) { - this.subject = subject; - } - - - /** - * Description on the Approval task - **/ - @ApiModelProperty(value = "Description on the Approval task") - @JsonProperty("description") - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - - /** - * Priority of the Approval task - **/ - @ApiModelProperty(value = "Priority of the Approval task") - @JsonProperty("priority") - public Integer getPriority() { - return priority; - } - public void setPriority(Integer priority) { - this.priority = priority; - } - - - /** - * The user who initiated the task - **/ - @ApiModelProperty(value = "The user who initiated the task") - @JsonProperty("initiator") - public String getInitiator() { - return initiator; - } - public void setInitiator(String initiator) { - this.initiator = initiator; - } - - - /** - * Available only for the completed Tasks, APPROVED or REJECTED if the task has been completed, PENDING otherwise\n - **/ - @ApiModelProperty(value = "Available only for the completed Tasks, APPROVED or REJECTED if the task has been completed, PENDING otherwise\n") - @JsonProperty("approvalStatus") - public ApprovalStatusEnum getApprovalStatus() { - return approvalStatus; - } - public void setApprovalStatus(ApprovalStatusEnum approvalStatus) { - this.approvalStatus = approvalStatus; - } - - - /** - * To whom the task is assigned:\n * user - username(s) if the task is reserved for specific user(s).\n * group - role name(s) if the task is assignable for group(s).\n - **/ - @ApiModelProperty(value = "To whom the task is assigned:\n * user - username(s) if the task is reserved for specific user(s).\n * group - role name(s) if the task is assignable for group(s).\n") - @JsonProperty("assignees") - public List getAssignees() { - return assignees; - } - public void setAssignees(List assignees) { - this.assignees = assignees; - } - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("properties") - public List getProperties() { - return properties; - } - public void setProperties(List properties) { - this.properties = properties; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TaskDataDTO {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" subject: ").append(subject).append("\n"); - sb.append(" description: ").append(description).append("\n"); - sb.append(" priority: ").append(priority).append("\n"); - sb.append(" initiator: ").append(initiator).append("\n"); - sb.append(" approvalStatus: ").append(approvalStatus).append("\n"); - sb.append(" assignees: ").append(assignees).append("\n"); - sb.append(" properties: ").append(properties).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} 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/dto/TaskSummaryDTO.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/dto/TaskSummaryDTO.java deleted file mode 100644 index 919aefde3..000000000 --- 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/dto/TaskSummaryDTO.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.dto; - - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - - - - - -@ApiModel(description = "") -public class TaskSummaryDTO { - - - - private String id = null; - - - private String name = null; - - - private String presentationSubject = null; - - - private String presentationName = null; - - - private String taskType = null; - - public enum StatusEnum { - READY, RESERVED, COMPLETED, - }; - - private StatusEnum status = null; - - - private Integer priority = null; - - - private String createdTimeInMillis = null; - - - /** - * Unique ID to represent an Approval Task - **/ - @ApiModelProperty(value = "Unique ID to represent an Approval Task") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - - /** - * Unique name for the Approval Task - **/ - @ApiModelProperty(value = "Unique name for the Approval Task") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - * Display value for Approval Operation - **/ - @ApiModelProperty(value = "Display value for Approval Operation") - @JsonProperty("presentationSubject") - public String getPresentationSubject() { - return presentationSubject; - } - public void setPresentationSubject(String presentationSubject) { - this.presentationSubject = presentationSubject; - } - - - /** - * Display value for Approval Task - **/ - @ApiModelProperty(value = "Display value for Approval Task") - @JsonProperty("presentationName") - public String getPresentationName() { - return presentationName; - } - public void setPresentationName(String presentationName) { - this.presentationName = presentationName; - } - - - /** - * Type of the Approval - **/ - @ApiModelProperty(value = "Type of the Approval") - @JsonProperty("taskType") - public String getTaskType() { - return taskType; - } - public void setTaskType(String taskType) { - this.taskType = taskType; - } - - - /** - * State of the Approval task - **/ - @ApiModelProperty(value = "State of the Approval task") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - * Priority of the Approval task - **/ - @ApiModelProperty(value = "Priority of the Approval task") - @JsonProperty("priority") - public Integer getPriority() { - return priority; - } - public void setPriority(Integer priority) { - this.priority = priority; - } - - - /** - * The time that the operation for approval initiated - **/ - @ApiModelProperty(value = "The time that the operation for approval initiated") - @JsonProperty("createdTimeInMillis") - public String getCreatedTimeInMillis() { - return createdTimeInMillis; - } - public void setCreatedTimeInMillis(String createdTimeInMillis) { - this.createdTimeInMillis = createdTimeInMillis; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TaskSummaryDTO {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" presentationSubject: ").append(presentationSubject).append("\n"); - sb.append(" presentationName: ").append(presentationName).append("\n"); - sb.append(" taskType: ").append(taskType).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" priority: ").append(priority).append("\n"); - sb.append(" createdTimeInMillis: ").append(createdTimeInMillis).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} 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/factories/MeApiServiceFactory.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/factories/MeApiServiceFactory.java deleted file mode 100644 index 262c15024..000000000 --- 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/factories/MeApiServiceFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.factories; - -import org.wso2.carbon.identity.rest.api.user.approval.v1.MeApiService; -import org.wso2.carbon.identity.rest.api.user.approval.v1.impl.MeApiServiceImpl; - -public class MeApiServiceFactory { - - private final static MeApiService service = new MeApiServiceImpl(); - - public static MeApiService getMeApi() - { - return service; - } -} 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 deleted file mode 100644 index 8b8ca3ae1..000000000 --- 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 +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.rest.api.user.approval.v1.core; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.apache.axis2.databinding.types.URI; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.ListUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.humantask.client.api.IllegalAccessFault; -import org.wso2.carbon.humantask.client.api.IllegalArgumentFault; -import org.wso2.carbon.humantask.client.api.IllegalOperationFault; -import org.wso2.carbon.humantask.client.api.IllegalStateFault; -import org.wso2.carbon.humantask.client.api.types.TSimpleQueryCategory; -import org.wso2.carbon.humantask.client.api.types.TSimpleQueryInput; -import org.wso2.carbon.humantask.client.api.types.TStatus; -import org.wso2.carbon.humantask.client.api.types.TTaskSimpleQueryResultSet; -import org.wso2.carbon.humantask.core.api.client.TaskOperationsImpl; -import org.wso2.carbon.humantask.core.dao.TaskStatus; -import org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant; -import org.wso2.carbon.identity.api.user.approval.common.UserApprovalServiceHolder; -import org.wso2.carbon.identity.api.user.common.error.APIError; -import org.wso2.carbon.identity.api.user.common.error.ErrorResponse; -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 java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; - -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.SERVER_ERROR_CHANGING_APPROVALS_STATE; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.SERVER_ERROR_RETRIEVING_APPROVALS_FOR_USER; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.SERVER_ERROR_RETRIEVING_APPROVAL_OF_USER; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_INVALID_INPUT; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_INVALID_OPERATION; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_INVALID_STATE_CHANGE; -import static org.wso2.carbon.identity.api.user.approval.common.ApprovalConstant.ErrorMessage.USER_ERROR_INVALID_TASK_ID; -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 - */ -public class UserApprovalService { - - private static final String APPROVAL_STATUS = "approvalStatus"; - private static final String PENDING = "PENDING"; - private static final String APPROVED = "APPROVED"; - private static final String REJECTED = "REJECTED"; - private static final Log log = LogFactory.getLog(UserApprovalService.class); - private static final String APPROVAL_DATA_STRING = "%s"; - - /** - * Search available approval tasks for the current authenticated user - * @param limit number of records to be returned - * @param offset start page - * @param status state of the tasks [RESERVED, READY or COMPLETED] - * @return - */ - public List listTasks(Integer limit, Integer offset, List status) { - - try { - TSimpleQueryInput queryInput = new TSimpleQueryInput(); - if (limit != null && limit > 0) { - queryInput.setPageSize(limit); - } - if (offset != null && offset > 0) { - queryInput.setPageNumber(offset); - } - - TStatus[] tStatuses = getRequiredTStatuses(status); - - queryInput.setSimpleQueryCategory(TSimpleQueryCategory.CLAIMABLE); - queryInput.setStatus(tStatuses); - TTaskSimpleQueryResultSet taskResults = UserApprovalServiceHolder.getTaskOperationService() - .simpleQuery(queryInput); - if (taskResults != null && taskResults.getRow() != null) { - return Arrays.stream(taskResults.getRow()).map(new TTaskSimpleQueryResultRowToExternal()) - .collect(Collectors.toList()); - } - return ListUtils.EMPTY_LIST; - - } catch (Exception e) { - throw handleException(e, SERVER_ERROR_RETRIEVING_APPROVALS_FOR_USER); - } - } - - /** - * Get details of a task identified by the taskId - * @param taskId - * @return - */ - public TaskDataDTO getTaskData(String taskId) { - TaskOperationsImpl taskOperations = new TaskOperationsImpl(); - URI taskIdURI = getUri(taskId); - try { - String xml = (String) taskOperations.getInput(taskIdURI, null); - XmlMapper xmlMapper = new XmlMapper(); - TaskModel taskModel = xmlMapper.readValue(xml, TaskModel.class); - taskModel.setId(taskId); - addApprovalStatus(taskOperations, taskIdURI, xmlMapper, taskModel); - return new TaskModelToExternal().apply(taskModel); - } catch (IllegalAccessFault e) { - if (log.isDebugEnabled()) { - log.debug(USER_ERROR_UNAUTHORIZED_USER.getMessage(), e); - } - throw handleError(Response.Status.FORBIDDEN, USER_ERROR_UNAUTHORIZED_USER); - } catch (IllegalArgumentFault e) { - if (log.isDebugEnabled()) { - log.debug(USER_ERROR_NON_EXISTING_TASK_ID.getMessage(), e); - } - throw handleError(Response.Status.NOT_FOUND, USER_ERROR_NON_EXISTING_TASK_ID); - } catch (IllegalStateFault e) { - if (log.isDebugEnabled()) { - log.debug(USER_ERROR_INVALID_TASK_ID.getMessage(), e); - } - throw handleError(Response.Status.BAD_REQUEST, USER_ERROR_INVALID_TASK_ID); - } catch (Exception e) { - throw handleException(e, SERVER_ERROR_RETRIEVING_APPROVAL_OF_USER); - } - } - - private URI getUri(String taskId) { - URI taskIdURI; - try { - taskIdURI = new URI(taskId); - } catch (URI.MalformedURIException e) { - throw handleError(Response.Status.BAD_REQUEST, USER_ERROR_INVALID_TASK_ID); - } - return taskIdURI; - } - - /** - * Update the state of a task identified by the task id - * User can reserve the task by claiming, or release a reserved task to himself - * Or user can approve or reject a task - * @param taskId - * @param nextState - */ - public void updateStatus(String taskId, StateDTO nextState) { - TaskOperationsImpl taskOperations = new TaskOperationsImpl(); - URI taskIdURI = getUri(taskId); - try { - switch (nextState.getAction()) { - case CLAIM: - taskOperations.claim(taskIdURI); - break; - case RELEASE: - taskOperations.release(taskIdURI); - break; - case APPROVE: - completeTask(taskOperations, taskIdURI, APPROVED); - break; - case REJECT: - completeTask(taskOperations, taskIdURI, REJECTED); - break; - default: - handleError(Response.Status.NOT_ACCEPTABLE, USER_ERROR_NOT_ACCEPTABLE_INPUT_FOR_NEXT_STATE); - } - } catch (IllegalAccessFault e) { - throw handleError(Response.Status.FORBIDDEN, USER_ERROR_UNAUTHORIZED_USER); - } catch (IllegalArgumentFault e) { - if (e.getMessage().contains("Task lookup failed for task id")) { - throw handleError(Response.Status.NOT_FOUND, USER_ERROR_NON_EXISTING_TASK_ID); - } - throw handleException(e, USER_ERROR_INVALID_INPUT); - } catch (IllegalOperationFault e) { - throw handleException(e, USER_ERROR_INVALID_OPERATION); - } catch (IllegalStateFault e) { - throw handleException(e, USER_ERROR_INVALID_STATE_CHANGE); - } catch (Exception e) { - throw handleException(e, SERVER_ERROR_CHANGING_APPROVALS_STATE); - } - } - - private void completeTask(TaskOperationsImpl taskOperations, URI taskIdURI, String action) throws - Exception { - taskOperations.start(taskIdURI); - taskOperations.complete(taskIdURI, String.format(APPROVAL_DATA_STRING, action)); - } - - private void addApprovalStatus(TaskOperationsImpl taskOperations, URI taskIdURI, XmlMapper xmlMapper, - TaskModel taskModel) throws Exception { - String approvalStatus = PENDING; - String approvalData = (String) taskOperations.getOutput(taskIdURI, null); - if (StringUtils.isNotEmpty(approvalData)) { - JsonNode node = xmlMapper.readTree(approvalData); - approvalStatus = node.get(APPROVAL_STATUS) != null ? node.get(APPROVAL_STATUS).textValue() : - PENDING; - taskModel.setApprovalStatus(approvalStatus); - } - taskModel.setApprovalStatus(approvalStatus); - - } - - private TStatus[] getRequiredTStatuses(List status) { - List allStatuses = Arrays.asList(TaskStatus.RESERVED.toString(), TaskStatus.READY.toString(), - TaskStatus.COMPLETED.toString()); - TStatus[] tStatuses = getTStatus(allStatuses); - - if (CollectionUtils.isNotEmpty(status)) { - List requestedStatus = status.stream().filter((s) -> allStatuses.contains(s)).collect - (Collectors.toList()); - if (CollectionUtils.isNotEmpty(requestedStatus)) { - tStatuses = getTStatus(requestedStatus); - } - } - return tStatuses; - } - - private TStatus[] getTStatus(List statuses) { - return statuses.stream().map(s -> getTStatus(s)).toArray(TStatus[]::new); - } - - private TStatus getTStatus(String status) { - TStatus tStatus = new TStatus(); - tStatus.setTStatus(status); - return tStatus; - } - - - /** - * Handle Exceptions - * - * @param e - * @param errorEnum - * @return - */ - private APIError handleException(Exception e, ApprovalConstant.ErrorMessage errorEnum) { - - ErrorResponse errorResponse = getErrorBuilder(errorEnum).build(log, e, errorEnum.getDescription()); - - if (e instanceof IllegalAccessFault) { - return handleError(Response.Status.FORBIDDEN, USER_ERROR_UNAUTHORIZED_USER); - } else if (e instanceof IllegalArgumentFault || e instanceof IllegalStateFault || e instanceof - IllegalOperationFault) { - errorResponse.setDescription(e.getMessage()); - return new APIError(Response.Status.BAD_REQUEST, errorResponse); - } else { - return new APIError(Response.Status.INTERNAL_SERVER_ERROR, errorResponse); - } - } - - /** - * Handle User errors - * - * @param status - * @param error - * @return - */ - private APIError handleError(Response.Status status, ApprovalConstant.ErrorMessage error) { - return new APIError(status, getErrorBuilder(error).build()); - - } - - /** - * Get ErrorResponse Builder for Error enum - * - * @param errorEnum - * @return - */ - private ErrorResponse.Builder getErrorBuilder(ApprovalConstant.ErrorMessage errorEnum) { - - return new ErrorResponse.Builder().withCode(errorEnum.getCode()).withMessage(errorEnum.getMessage()) - .withDescription(errorEnum.getDescription()); - } - - -} 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/functions/TTaskSimpleQueryResultRowToExternal.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/functions/TTaskSimpleQueryResultRowToExternal.java deleted file mode 100644 index 3ebef2a9f..000000000 --- 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/functions/TTaskSimpleQueryResultRowToExternal.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.rest.api.user.approval.v1.core.functions; - -import org.wso2.carbon.humantask.client.api.types.TTaskSimpleQueryResultRow; -import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskSummaryDTO; - -import java.util.function.Function; - -/** - * Transform TTaskSimpleQueryResultRow to TaskSummeryDTO - */ -public class TTaskSimpleQueryResultRowToExternal implements Function { - - @Override - public TaskSummaryDTO apply(TTaskSimpleQueryResultRow tTaskSimpleQueryResultRow) { - TaskSummaryDTO summeryDTO = new TaskSummaryDTO(); - summeryDTO.setId(tTaskSimpleQueryResultRow.getId().getPath()); - summeryDTO.setName(tTaskSimpleQueryResultRow.getName().toString()); - summeryDTO.setTaskType(tTaskSimpleQueryResultRow.getTaskType()); - summeryDTO.setPresentationName(tTaskSimpleQueryResultRow.getPresentationName().getTPresentationName()); - summeryDTO.setPresentationSubject(tTaskSimpleQueryResultRow.getPresentationSubject().getTPresentationSubject()); - summeryDTO.setCreatedTimeInMillis(String.valueOf(tTaskSimpleQueryResultRow.getCreatedTime().getTimeInMillis())); - summeryDTO.setPriority(tTaskSimpleQueryResultRow.getPriority().getTPriority().intValue()); - summeryDTO.setStatus(TaskSummaryDTO.StatusEnum.valueOf(tTaskSimpleQueryResultRow.getStatus().getTStatus())); - return summeryDTO; - } -} 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/functions/TaskModelToExternal.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/functions/TaskModelToExternal.java deleted file mode 100644 index 27f4e1bc8..000000000 --- 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/functions/TaskModelToExternal.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.rest.api.user.approval.v1.core.functions; - -import org.wso2.carbon.identity.rest.api.user.approval.v1.core.model.TaskModel; -import org.wso2.carbon.identity.rest.api.user.approval.v1.core.model.TaskParam; -import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.PropertyDTO; -import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.TaskDataDTO; - -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * Transform TaskModel to TaskDataDTO - */ -public class TaskModelToExternal implements Function { - - @Override - public TaskDataDTO apply(TaskModel taskModel) { - - TaskDataDTO taskDataDTO = new TaskDataDTO(); - taskDataDTO.setId(taskModel.getId()); - taskDataDTO.setSubject(taskModel.getTaskSubject()); - taskDataDTO.setDescription(taskModel.getTaskDescription()); - taskDataDTO.setApprovalStatus(TaskDataDTO.ApprovalStatusEnum.valueOf(taskModel.getApprovalStatus())); - taskDataDTO.setInitiator(taskModel.getHtInitiator()); - taskDataDTO.setPriority(Integer.parseInt(taskModel.getPriority())); - taskDataDTO.setAssignees(getPropertyDTOs(taskModel.getAssignees())); - taskDataDTO.setProperties(getPropertyDTOs(taskModel.getParametersList())); - return taskDataDTO; - } - - private List getPropertyDTOs(Map props) { - - return props.entrySet().stream().map(p -> getPropertyDTO(p.getKey(), p.getValue())) - .collect(Collectors.toList()); - } - - - private List getPropertyDTOs(List props) { - - return props.stream().map(p -> getPropertyDTO(p.getItemName(), p.getItemValue())) - .collect(Collectors.toList()); - } - - private PropertyDTO getPropertyDTO(String key, String value) { - - PropertyDTO prop = new PropertyDTO(); - prop.setKey(key); - prop.setValue(value); - return prop; - } -} 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/model/TaskModel.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/model/TaskModel.java deleted file mode 100644 index b7e2ee9ef..000000000 --- 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/model/TaskModel.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.rest.api.user.approval.v1.core.model; - -import java.util.List; -import java.util.Map; -import javax.xml.bind.annotation.XmlElement; - -/** - * Model Class for task - */ -public class TaskModel { - - private String id; - private String taskSubject; - private String taskDescription; - private String priority; - private String htInitiator; - private String approvalStatus; - private Map assignees; - - @XmlElement(name = "xsd-complex-type-wrapper") - private List parameters; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTaskSubject() { - return taskSubject; - } - - public void setTaskSubject(String taskSubject) { - this.taskSubject = taskSubject; - } - - public String getTaskDescription() { - return taskDescription; - } - - public void setTaskDescription(String taskDescription) { - this.taskDescription = taskDescription; - } - - public String getPriority() { - return priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public String getHtInitiator() { - return htInitiator; - } - - public void setHtInitiator(String htInitiator) { - this.htInitiator = htInitiator; - } - - public String getApprovalStatus() { - return approvalStatus; - } - - public void setApprovalStatus(String approvalStatus) { - this.approvalStatus = approvalStatus; - } - - public Map getAssignees() { - return assignees; - } - - public void setAssignees(Map assignees) { - this.assignees = assignees; - } - - public List getParametersList() { - return parameters; - } - - public void setParametersList(List parametersList) { - this.parameters = parametersList; - } -} 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/model/TaskParam.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/model/TaskParam.java deleted file mode 100644 index 76d9b1cdf..000000000 --- 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/model/TaskParam.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed 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.rest.api.user.approval.v1.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Task Param model - */ -@XmlRootElement(name = "xsd-complex-type-wrapper") -public class TaskParam { - - - private String itemName; - private String itemValue; - - public String getItemName() { - return itemName; - } - - public void setItemName(String itemName) { - this.itemName = itemName; - } - - public String getItemValue() { - return itemValue; - } - - public void setItemValue(String itemValue) { - this.itemValue = itemValue; - } -} 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/impl/MeApiServiceImpl.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/impl/MeApiServiceImpl.java deleted file mode 100644 index ade491351..000000000 --- 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/impl/MeApiServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.rest.api.user.approval.v1.impl; - -import org.springframework.beans.factory.annotation.Autowired; -import org.wso2.carbon.identity.rest.api.user.approval.v1.MeApiService; -import org.wso2.carbon.identity.rest.api.user.approval.v1.core.UserApprovalService; -import org.wso2.carbon.identity.rest.api.user.approval.v1.dto.StateDTO; - -import java.util.List; -import javax.ws.rs.core.Response; - -/** - * API service implementation of a logged in user's approval operations - */ -public class MeApiServiceImpl extends MeApiService { - - @Autowired - UserApprovalService userApprovalService; - - @Override - public Response getApprovalTaskInfo(String taskId) { - - return Response.ok().entity(userApprovalService.getTaskData(taskId)).build(); - } - - @Override - public Response listApprovalTasksForLoggedInUser(Integer limit, Integer offset, List status) { - - return Response.ok().entity(userApprovalService.listTasks(limit, offset, status)).build(); - } - - @Override - public Response updateStateOfTask(String taskId, StateDTO nextState) { - - userApprovalService.updateStatus(taskId, nextState); - return Response.ok().build(); - } -} diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/META-INF/cxf/user-approval-v1-cxf.xml b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/META-INF/cxf/user-approval-v1-cxf.xml deleted file mode 100644 index b99bf8dca..000000000 --- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/META-INF/cxf/user-approval-v1-cxf.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - diff --git a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/approval.yaml b/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/approval.yaml deleted file mode 100644 index f08aa9411..000000000 --- a/components/org.wso2.carbon.identity.api.user.approval/org.wso2.carbon.identity.rest.api.user.approval.v1/src/main/resources/approval.yaml +++ /dev/null @@ -1,411 +0,0 @@ -swagger: '2.0' -info: - description: > - This is the RESTful API for a user to manage his/her pending approvals in WSO2 Identity Server. This API can be used to - retrieve pending approvals and update the status of the approval tasks for the authenticated user. - version: "v1" - title: WSO2 Identity Server - Workflow Approval API Definition - contact: - name: "WSO2 Identity Server" - url: "https://wso2.com/identity-and-access-management/" - email: "architecture@wso2.org" - license: - name: Apache 2.0 - url: 'http://www.apache.org/licenses/LICENSE-2.0.html' - -schemes: - - https - -# Tags are used for organizing operations. -tags: -- name: me - description: Operations for the authenticated user. - -# Applicable authentication mechanisms. -security: - - OAuth2: [] - - BasicAuth: [] - -paths: - /me/approval-tasks: - get: - tags: - - me - summary: Retrieves available approvals for the authenticated user - operationId: listApprovalTasksForLoggedInUser - description: > - Retrieve the available approval tasks in the system for the authenticated user. This API returns the following types of approvals: - * READY - Tasks that are _claimable_ by the user. If a particular task is in the READY state, the user is eligible to self-assign the task and complete it. - * RESERVED - Tasks that are _assigned_ to the user and to be approved by this user. - * COMPLETED - Tasks that are already _completed_ (approved or denied) by this user. - - Permission required: - * /permission/admin/manage/humantask/viewtasks - Scope required: - * internal_humantask_view - - A user can also invoke the endpoint with the following query parameters. - parameters: - - $ref: '#/parameters/limitQueryParam' - - $ref: '#/parameters/offsetQueryParam' - - $ref: '#/parameters/statusQueryParam' - responses: - 200: - description: Array of approval tasks matching the search criteria - schema: - type: array - items: - $ref: '#/definitions/TaskSummary' - examples: - application/json: - [ - { - "id": "453", - "name": "{http://ht.bpel.mgt.workflow.identity.carbon.wso2.org}testTask", - "presentationSubject": "Update Claims", - "presentationName": "SampleWorkflowTask", - "taskType": "TASK", - "status": "RESERVED", - "priority": 0, - "createdTimeInMillis": "1565597712157" - }, - { - "id": "452", - "name": "{http://ht.bpel.mgt.workflow.identity.carbon.wso2.org}testTask", - "presentationSubject": "Update Claims", - "presentationName": "SampleWorkflowTask", - "taskType": "TASK", - "status": "COMPLETED", - "priority": 0, - "createdTimeInMillis": "1565597675414" - }, - { - "id": "451", - "name": "{http://ht.bpel.mgt.workflow.identity.carbon.wso2.org}testTask", - "presentationSubject": "Update Claims", - "presentationName": "SampleWorkflowTask", - "taskType": "TASK", - "status": "READY", - "priority": 0, - "createdTimeInMillis": "1565597569021" - } - ] - 400: - $ref: '#/responses/InvalidInput' - 401: - $ref: '#/responses/Unauthorized' - 403: - $ref: '#/responses/Forbidden' - 500: - $ref: '#/responses/ServerError' - /me/approval-tasks/{task-id}: - get: - tags: - - me - summary: "Retrieves an approval task by the task-id" - operationId: getApprovalTaskInfo - description: > - Retrieves information of a specific approval task identified by the task-id -
- - Permission required: - * /permission/admin/manage/humantask/viewtasks - Scope required: - * internal_humantask_view - parameters: - - $ref: '#/parameters/taskIdPathParam' - responses: - 200: - description: Detailed information of the approval task identified by the task-id - schema: - $ref: '#/definitions/TaskData' - examples: - application/json: - { - "id": "452", - "subject": "Update Claims", - "description": "You have a request to approve claim update action of a user.", - "priority": 0, - "initiator": "admin", - "approvalStatus": "APPROVE", - "assignees": [ - { - "key": "group", - "value": "admin" - } - ], - "properties": [ - { - "key": "REQUEST ID", - "value": "34172334-fccb-4ef4-9830-08c3caeaab9e," - }, - { - "key": "Username", - "value": "aysh234," - }, - { - "key": "User Store Domain", - "value": "PRIMARY," - }, - { - "key": "Profile", - "value": "default," - }, - { - "key": "Claims", - "value": "http://wso2.org/claims/organization:,http://wso2.org/claims/telephone:,http://wso2.org/claims/im:,http://wso2.org/claims/country:Sri Lanka,http://wso2.org/claims/mobile:,http://wso2.org/claims/emailaddress:ayesha@wso2.com,profileConfiguration:default,http://wso2.org/claims/lastname:Dissanayaka,http://wso2.org/claims/url:,http://wso2.org/claims/givenname:Ayesha," - } - ] - } - 400: - $ref: '#/responses/InvalidInput' - 401: - $ref: '#/responses/Unauthorized' - 403: - $ref: '#/responses/Forbidden' - 404: - $ref: '#/responses/NotFound' - 409: - $ref: '#/responses/Conflict' - 500: - $ref: '#/responses/ServerError' - /me/approval-tasks/{task-id}/state: - put: - tags: - - me - summary: "Changes the state of an approval task" - operationId: updateStateOfTask - description: | - Update the approval task status by defining one of the following actions: - * CLAIM - Reserve the task for the user. Status of the task will be changed from READY to RESERVED. - * RELEASE - Release the task for other users to claim. Status of the task will be changed from RESERVED to READY. - * APPROVE - Approve the task. Status of the task will be changed to COMPLETED. - * REJECT - Deny the task. Status of the task will be changed to COMPLETED. -
- - Permission required: - * /permission/admin/manage/humantask/viewtasks - Scope required: - * internal_humantask_view - parameters: - - $ref: '#/parameters/taskIdPathParam' - - in: body - name: next-state - description: To which state the task should be changed. - schema: - $ref: '#/definitions/State' - responses: - 200: - $ref: '#/responses/OK' - 400: - $ref: '#/responses/InvalidInput' - 401: - $ref: '#/responses/Unauthorized' - 403: - $ref: '#/responses/Forbidden' - 404: - $ref: '#/responses/NotFound' - 500: - $ref: '#/responses/ServerError' -parameters: - taskIdPathParam: - in: path - name: task-id - required: true - type: string - description: Task ID - offsetQueryParam: - in: query - name: offset - description: Number of records to skip for pagination - type: integer - format: int32 - minimum: 0 - limitQueryParam: - in: query - name: limit - description: Maximum number of records to return - type: integer - format: int32 - minimum: 0 - statusQueryParam: - in: query - name: status - type: array - items: - enum: [READY, RESERVED, COMPLETED] - description: > - Approval task's status to filter tasks by their status: - * **RESERVED** - Tasks that are **assigned to** the authenticated user. - * **READY** - Tasks that **can be assigned to** and **can be approved by** the authenticated user. - * **COMPLETED** - Tasks that are **completed by** the user - * \ - **All** the viewable tasks will be retrieved if this parameter is not specified. -definitions: - TaskSummary: - type: object - properties: - id: - type: string - example: "451" - description: Unique ID to represent an Approval Task - name: - type: string - example: "s367:testTask" - description: Unique name for the Approval Task - presentationSubject: - type: string - example: "Add new Role" - description: Display value for Approval Operation - presentationName: - type: string - example: "sampleTask" - description: Display value for Approval Task - taskType: - type: string - example: "TASK" - description: Type of the Approval - status: - type: string - example: "READY" - enum: [READY, RESERVED, COMPLETED] - description: State of the Approval task - priority: - type: integer - example: 0 - description: Priority of the Approval task - createdTimeInMillis: - type: string - example: '1565597569021' - description: The time that the operation for approval initiated - - #----------------------------------------------------- - # The Task Data Oject - #----------------------------------------------------- - TaskData: - type: object - properties: - id: - type: string - example: "451" - description: Unique ID to represent a approval task - subject: - type: string - example: "Add new Role" - description: Subject of the Approval - description: - type: string - example: "Addes a new role to the system" - description: Description on the Approval task - priority: - type: integer - example: 0 - description: Priority of the Approval task - initiator: - type: string - example: "some-user-name" - description: The user who initiated the task - approvalStatus: - type: string - example: "APPROVE" - description: > - Available only for the completed Tasks, APPROVED or REJECTED if the task has been completed, - PENDING otherwise - enum: [PENDING, APPROVED, REJECTED] - assignees: - type: array - items: - $ref: '#/definitions/Property' - description: > - To whom the task is assigned: - * user - username(s) if the task is reserved for specific user(s). - * group - role name(s) if the task is assignable for group(s). - properties: - type: array - items: - $ref: '#/definitions/Property' - - #----------------------------------------------------- - # The Property object - #----------------------------------------------------- - Property: - type: object - properties: - key: - type: string - value: - type: string - #----------------------------------------------------- - # The Task State object - #----------------------------------------------------- - State: - type: object - properties: - action: - type: string - example: "APPROVE" - description: Action to perform on the task. - enum: [CLAIM, RELEASE, APPROVE, REJECT] - - #----------------------------------------------------- - # The Error Response object - #----------------------------------------------------- - Error: - type: object - required: - - code - - message - properties: - code: - type: string - example: "some_error_code" - message: - type: string - example: "Some Error Message" - description: - type: string - example: "Some Error Description" - traceId: - type: string - example: "Some Correlation for Error Instance" -securityDefinitions: - BasicAuth: - type: basic - OAuth2: - type: oauth2 - flow: accessCode - authorizationUrl: https://localhost:9443/oauth2/authorize - tokenUrl: https://localhost:9443/oauth2/token - -#----------------------------------------------------- -# Descriptions of common responses -#----------------------------------------------------- -responses: - NotFound: - description: The specified resource is not found - schema: - $ref: '#/definitions/Error' - Unauthorized: - description: Unauthorized - ServerError: - description: Internal Server Error - schema: - $ref: '#/definitions/Error' - InvalidInput: - description: Invalid input request - schema: - $ref: '#/definitions/Error' - Conflict: - description: Element Already Exists - schema: - $ref: '#/definitions/Error' - Created: - description: Item Created - OK: - description: OK - Deleted: - description: Item Deleted - Forbidden: - description: Resource Forbidden - -host: localhost:9443 -basePath: /t/{tenant-domain}/api/users/v1 diff --git a/components/org.wso2.carbon.identity.api.user.approval/pom.xml b/components/org.wso2.carbon.identity.api.user.approval/pom.xml deleted file mode 100644 index e2cfc7765..000000000 --- a/components/org.wso2.carbon.identity.api.user.approval/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - identity-api-user - org.wso2.carbon.identity.user.api - 1.3.29-SNAPSHOT - ../../pom.xml - - 4.0.0 - - org.wso2.carbon.identity.user.api - org.wso2.carbon.identity.api.user.approval - pom - - org.wso2.carbon.identity.api.user.approval.common - org.wso2.carbon.identity.rest.api.user.approval.v1 - - - diff --git a/pom.xml b/pom.xml index d7b0584ff..dbfcff885 100644 --- a/pom.xml +++ b/pom.xml @@ -147,11 +147,6 @@ provided ${project.version} - - org.wso2.carbon.business-process - org.wso2.carbon.humantask - ${carbon.business-process.version} - org.wso2.carbon.identity.framework org.wso2.carbon.identity.base @@ -164,12 +159,6 @@ ${carbon.identity.framework.version} provided - - org.wso2.carbon.business-process - org.wso2.carbon.humantask.skeleton - ${carbon.business-process.version} - provided - org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.authentication.framework @@ -425,7 +414,6 @@ 5.25.380 5.3.7 3.0.5 - 4.5.2 6.7.71 1.0.85 6.9.10 @@ -443,7 +431,6 @@ components/org.wso2.carbon.identity.api.user.common components/org.wso2.carbon.identity.api.user.association components/org.wso2.carbon.identity.api.user.authorized.apps - components/org.wso2.carbon.identity.api.user.approval components/org.wso2.carbon.identity.api.user.session components/org.wso2.carbon.identity.api.user.fido2 components/org.wso2.carbon.identity.api.user.totp