Skip to content

Commit 5d36bad

Browse files
authored
Add flow type to the execution response (#982)
* Add flow type to the execution response * bump framework version
1 parent 52cf4a9 commit 5d36bad

File tree

6 files changed

+97
-10
lines changed

6 files changed

+97
-10
lines changed

components/org.wso2.carbon.identity.api.server.flow.execution/org.wso2.carbon.identity.api.server.flow.execution.v1/src/gen/java/org/wso2/carbon/identity/api/server/flow/execution/v1/FlowExecutionResponse.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
public class FlowExecutionResponse {
3535

3636
private String flowId;
37+
private String flowType;
3738
private String flowStatus;
3839

3940
@XmlType(name="TypeEnum")
@@ -92,6 +93,27 @@ public void setFlowId(String flowId) {
9293
this.flowId = flowId;
9394
}
9495

96+
/**
97+
* Unique identifier to identify the flow type
98+
**/
99+
public FlowExecutionResponse flowType(String flowType) {
100+
101+
this.flowType = flowType;
102+
return this;
103+
}
104+
105+
@ApiModelProperty(example = "REGISTRATION", required = true, value = "Unique identifier to identify the flow type")
106+
@JsonProperty("flowType")
107+
@Valid
108+
@NotNull(message = "Property flowType cannot be null.")
109+
110+
public String getFlowType() {
111+
return flowType;
112+
}
113+
public void setFlowType(String flowType) {
114+
this.flowType = flowType;
115+
}
116+
95117
/**
96118
**/
97119
public FlowExecutionResponse flowStatus(String flowStatus) {
@@ -163,14 +185,15 @@ public boolean equals(java.lang.Object o) {
163185
}
164186
FlowExecutionResponse flowExecutionResponse = (FlowExecutionResponse) o;
165187
return Objects.equals(this.flowId, flowExecutionResponse.flowId) &&
188+
Objects.equals(this.flowType, flowExecutionResponse.flowType) &&
166189
Objects.equals(this.flowStatus, flowExecutionResponse.flowStatus) &&
167190
Objects.equals(this.type, flowExecutionResponse.type) &&
168191
Objects.equals(this.data, flowExecutionResponse.data);
169192
}
170193

171194
@Override
172195
public int hashCode() {
173-
return Objects.hash(flowId, flowStatus, type, data);
196+
return Objects.hash(flowId, flowType, flowStatus, type, data);
174197
}
175198

176199
@Override
@@ -180,6 +203,7 @@ public String toString() {
180203
sb.append("class FlowExecutionResponse {\n");
181204

182205
sb.append(" flowId: ").append(toIndentedString(flowId)).append("\n");
206+
sb.append(" flowType: ").append(toIndentedString(flowType)).append("\n");
183207
sb.append(" flowStatus: ").append(toIndentedString(flowStatus)).append("\n");
184208
sb.append(" type: ").append(toIndentedString(type)).append("\n");
185209
sb.append(" data: ").append(toIndentedString(data)).append("\n");

components/org.wso2.carbon.identity.api.server.flow.execution/org.wso2.carbon.identity.api.server.flow.execution.v1/src/main/java/org/wso2/carbon/identity/api/server/flow/execution/v1/core/FlowExecutionServiceCore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public FlowExecutionResponse processFlowExecution(FlowExecutionRequest flowExecu
7474

7575
return flowExecutionResponse
7676
.flowId(flowExecutionStep.getFlowId())
77+
.flowType(flowExecutionStep.getFlowType())
7778
.flowStatus(flowExecutionStep.getFlowStatus())
7879
.type(FlowExecutionResponse.TypeEnum.valueOf(flowExecutionStep.getStepType()))
7980
.data(Utils.convertToData(flowExecutionStep.getData(), flowExecutionStep.getStepType()));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
package org.wso2.carbon.identity.api.server.flow.execution.v1.model;
20+
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import org.wso2.carbon.identity.api.server.common.error.ErrorDTO;
23+
24+
/**
25+
* Flow execution error DTO for the flow execution API related error responses.
26+
*/
27+
public class FlowExecutionErrorDTO extends ErrorDTO {
28+
29+
private static final long serialVersionUID = 6169725164223318439L;
30+
private String flowType = null;
31+
32+
public FlowExecutionErrorDTO() {
33+
34+
super();
35+
}
36+
37+
public FlowExecutionErrorDTO(ErrorDTO errorDTO) {
38+
39+
this.setCode(errorDTO.getCode());
40+
this.setMessage(errorDTO.getMessage());
41+
this.setDescription(errorDTO.getDescription());
42+
this.setRef(errorDTO.getRef());
43+
}
44+
45+
@JsonProperty("flowType")
46+
public String getFlowType() {
47+
48+
return flowType;
49+
}
50+
51+
public void setFlowType(String flowType) {
52+
53+
this.flowType = flowType;
54+
}
55+
}

components/org.wso2.carbon.identity.api.server.flow.execution/org.wso2.carbon.identity.api.server.flow.execution.v1/src/main/java/org/wso2/carbon/identity/api/server/flow/execution/v1/utils/Utils.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import org.apache.commons.logging.LogFactory;
2626
import org.wso2.carbon.context.PrivilegedCarbonContext;
2727
import org.wso2.carbon.identity.api.server.common.error.APIError;
28-
import org.wso2.carbon.identity.api.server.common.error.ErrorDTO;
2928
import org.wso2.carbon.identity.api.server.flow.execution.common.FlowExecutionServiceHolder;
3029
import org.wso2.carbon.identity.api.server.flow.execution.v1.Component;
3130
import org.wso2.carbon.identity.api.server.flow.execution.v1.Data;
3231
import org.wso2.carbon.identity.api.server.flow.execution.v1.FlowExecutionRequest;
3332
import org.wso2.carbon.identity.api.server.flow.execution.v1.constants.FlowExecutionEndpointConstants;
33+
import org.wso2.carbon.identity.api.server.flow.execution.v1.model.FlowExecutionErrorDTO;
3434
import org.wso2.carbon.identity.application.common.model.Property;
3535
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
3636
import org.wso2.carbon.identity.flow.execution.engine.exception.FlowEngineClientException;
@@ -88,9 +88,9 @@ private Utils() {
8888
* @return APIError object.
8989
*/
9090
public static APIError handleException(Response.Status status, String errorCode,
91-
String message, String description) {
91+
String message, String description, String flowType) {
9292

93-
return new APIError(status, getError(errorCode, message, description));
93+
return new APIError(status, getError(errorCode, message, description, flowType));
9494
}
9595

9696
/**
@@ -111,7 +111,7 @@ public static APIError handleFlowException(FlowEngineException e) {
111111
String errorCode = e.getErrorCode();
112112
errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode :
113113
FlowExecutionEndpointConstants.REGISTRATION_FLOW_PREFIX + errorCode;
114-
return handleException(status, errorCode, e.getMessage(), e.getDescription());
114+
return handleException(status, errorCode, e.getMessage(), e.getDescription(), e.getFlowType());
115115
}
116116

117117
/**
@@ -132,15 +132,15 @@ public static APIError handleFlowException(FlowEngineException e, String tenantD
132132
!isShowUsernameUnavailabilityEnabled(tenantDomain)) {
133133
return handleException(status, ERROR_CODE_INVALID_USER_INPUT.getCode(),
134134
ERROR_CODE_INVALID_USER_INPUT.getMessage(),
135-
ERROR_CODE_INVALID_USER_INPUT.getDescription());
135+
ERROR_CODE_INVALID_USER_INPUT.getDescription(), e.getFlowType());
136136
}
137137
} else {
138138
LOG.error(e.getMessage(), e);
139139
}
140140
// handle NPE when confirmation code expired
141141
errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode :
142142
FlowExecutionEndpointConstants.REGISTRATION_FLOW_PREFIX + errorCode;
143-
return handleException(status, errorCode, e.getMessage(), e.getDescription());
143+
return handleException(status, errorCode, e.getMessage(), e.getDescription(), e.getFlowType());
144144
}
145145

146146
/**
@@ -151,12 +151,14 @@ public static APIError handleFlowException(FlowEngineException e, String tenantD
151151
* @param errorDescription Error description.
152152
* @return A generic error with the specified details.
153153
*/
154-
public static ErrorDTO getError(String errorCode, String errorMessage, String errorDescription) {
154+
public static FlowExecutionErrorDTO getError(String errorCode, String errorMessage, String errorDescription,
155+
String flowType) {
155156

156-
ErrorDTO error = new ErrorDTO();
157+
FlowExecutionErrorDTO error = new FlowExecutionErrorDTO();
157158
error.setCode(errorCode);
158159
error.setMessage(errorMessage);
159160
error.setDescription(errorDescription);
161+
error.setFlowType(flowType);
160162
return error;
161163
}
162164

components/org.wso2.carbon.identity.api.server.flow.execution/org.wso2.carbon.identity.api.server.flow.execution.v1/src/main/resources/flow-execution.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,18 @@ components:
8989
type: object
9090
required:
9191
- flowId
92+
- flowType
9293
- flowStatus
9394
- type
9495
properties:
9596
flowId:
9697
type: string
9798
description: Unique identifier for the flow execution
9899
example: 3fa85f64-5717-4562-b3fc-2c963f66afa6
100+
flowType:
101+
type: string
102+
description: Unique identifier to identify the flow type
103+
example: REGISTRATION
99104
flowStatus:
100105
type: string
101106
example: INCOMPLETE

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@
958958
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
959959
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
960960
<identity.governance.version>1.11.103</identity.governance.version>
961-
<carbon.identity.framework.version>7.8.466</carbon.identity.framework.version>
961+
<carbon.identity.framework.version>7.8.476</carbon.identity.framework.version>
962962
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>
963963
<findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version>
964964
<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>

0 commit comments

Comments
 (0)