Skip to content

Commit 7e26b26

Browse files
authored
Merge pull request #27 from codingapi/dev
Dev
2 parents 6817b96 + a61e2db commit 7e26b26

31 files changed

Lines changed: 511 additions & 551 deletions

flow-engine-framework/src/main/java/com/codingapi/flow/action/actions/RejectAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import com.codingapi.flow.context.RepositoryHolderContext;
88
import com.codingapi.flow.event.FlowRecordTodoEvent;
99
import com.codingapi.flow.event.IFlowEvent;
10-
import com.codingapi.flow.exception.FlowConfigException;
10+
import com.codingapi.flow.exception.FlowStateException;
11+
import com.codingapi.flow.exception.FlowValidationException;
1112
import com.codingapi.flow.node.IFlowNode;
1213
import com.codingapi.flow.record.FlowRecord;
1314
import com.codingapi.flow.script.action.RejectActionScript;
@@ -76,7 +77,7 @@ public List<FlowRecord> generateRecords(FlowSession flowSession) {
7677
currentNode = flowSession.getWorkflow().getEndNode();
7778
}
7879
if (currentNode == null) {
79-
throw FlowConfigException.currentNodeNotNull();
80+
throw FlowStateException.currentNodeNotNull();
8081
}
8182
flowSession = flowSession.updateSession(currentNode);
8283
return currentNode.generateCurrentRecords(flowSession);

flow-engine-framework/src/main/java/com/codingapi/flow/context/RepositoryHolderContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codingapi.flow.context;
22

33
import com.codingapi.flow.domain.DelayTask;
4-
import com.codingapi.flow.exception.FlowConfigException;
4+
import com.codingapi.flow.exception.FlowStateException;
55
import com.codingapi.flow.gateway.FlowOperatorGateway;
66
import com.codingapi.flow.operator.IFlowOperator;
77
import com.codingapi.flow.record.FlowRecord;
@@ -53,7 +53,7 @@ public boolean isRegistered() {
5353

5454
public void verify() {
5555
if (!isRegistered()) {
56-
throw FlowConfigException.repositoryNotRegistered();
56+
throw FlowStateException.repositoryNotRegistered();
5757
}
5858
}
5959

flow-engine-framework/src/main/java/com/codingapi/flow/exception/FlowConfigException.java

Lines changed: 0 additions & 141 deletions
This file was deleted.
Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
package com.codingapi.flow.exception;
22

3+
import com.codingapi.springboot.framework.exception.LocaleMessageException;
4+
35
/**
46
* 流程引擎框架异常基类
57
* <p>
68
* 所有流程引擎相关的异常都应该继承此类
79
*
810
* @since 1.0.0
911
*/
10-
public abstract class FlowException extends RuntimeException {
11-
12-
private static final long serialVersionUID = 1L;
13-
14-
/**
15-
* 错误码
16-
*/
17-
private final String errorCode;
12+
public abstract class FlowException extends LocaleMessageException {
1813

1914
/**
2015
* 构造函数
@@ -23,8 +18,7 @@ public abstract class FlowException extends RuntimeException {
2318
* @param message 错误信息
2419
*/
2520
public FlowException(String errorCode, String message) {
26-
super(message);
27-
this.errorCode = errorCode;
21+
super(errorCode,message);
2822
}
2923

3024
/**
@@ -35,21 +29,7 @@ public FlowException(String errorCode, String message) {
3529
* @param cause 原因
3630
*/
3731
public FlowException(String errorCode, String message, Throwable cause) {
38-
super(message, cause);
39-
this.errorCode = errorCode;
32+
super(errorCode,message, cause);
4033
}
4134

42-
/**
43-
* 获取错误码
44-
*
45-
* @return 错误码
46-
*/
47-
public String getErrorCode() {
48-
return errorCode;
49-
}
50-
51-
@Override
52-
public String toString() {
53-
return String.format("[%s] %s", errorCode, getMessage());
54-
}
5535
}

flow-engine-framework/src/main/java/com/codingapi/flow/exception/FlowExecutionException.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
*/
1111
public class FlowExecutionException extends FlowException {
1212

13-
private static final long serialVersionUID = 1L;
14-
1513
/**
1614
* Constructor
1715
*
@@ -45,54 +43,6 @@ public static FlowExecutionException scriptExecutionError(String scriptType, Thr
4543
String.format("Script execution error: %s", scriptType), cause);
4644
}
4745

48-
/**
49-
* Node execution error
50-
*
51-
* @param nodeId node ID
52-
* @param cause cause
53-
* @return exception
54-
*/
55-
public static FlowExecutionException nodeExecutionError(String nodeId, Throwable cause) {
56-
return new FlowExecutionException("execution.node.error",
57-
String.format("Node execution error: %s", nodeId), cause);
58-
}
59-
60-
/**
61-
* Action execution error
62-
*
63-
* @param actionId action ID
64-
* @param cause cause
65-
* @return exception
66-
*/
67-
public static FlowExecutionException actionExecutionError(String actionId, Throwable cause) {
68-
return new FlowExecutionException("execution.action.error",
69-
String.format("Action execution error: %s", actionId), cause);
70-
}
71-
72-
/**
73-
* Workflow execution error
74-
*
75-
* @param processId process instance ID
76-
* @param cause cause
77-
* @return exception
78-
*/
79-
public static FlowExecutionException workflowExecutionError(String processId, Throwable cause) {
80-
return new FlowExecutionException("execution.workflow.error",
81-
String.format("Workflow execution error: %s", processId), cause);
82-
}
83-
84-
/**
85-
* Database operation error
86-
*
87-
* @param operation operation type
88-
* @param cause cause
89-
* @return exception
90-
*/
91-
public static FlowExecutionException databaseError(String operation, Throwable cause) {
92-
return new FlowExecutionException("execution.database.error",
93-
String.format("Database operation error: %s", operation), cause);
94-
}
95-
9646
/**
9747
* Router node not found
9848
*

flow-engine-framework/src/main/java/com/codingapi/flow/exception/FlowNotFoundException.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
public class FlowNotFoundException extends FlowException {
1212

13-
private static final long serialVersionUID = 1L;
1413

1514
/**
1615
* Constructor
@@ -23,14 +22,12 @@ public FlowNotFoundException(String code, String message) {
2322
}
2423

2524
/**
26-
* Constructor
25+
* Parallel end node cannot be null
2726
*
28-
* @param code error code
29-
* @param message error message
30-
* @param cause cause
27+
* @return exception
3128
*/
32-
public FlowNotFoundException(String code, String message, Throwable cause) {
33-
super(code, message, cause);
29+
public static FlowNotFoundException parallelEndNodeNotNull() {
30+
return new FlowNotFoundException("notFound.parallel.endNode.required", "Parallel end node cannot be null");
3431
}
3532

3633
/**

flow-engine-framework/src/main/java/com/codingapi/flow/exception/FlowPermissionException.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
*/
1111
public class FlowPermissionException extends FlowException {
1212

13-
private static final long serialVersionUID = 1L;
14-
1513
/**
1614
* Constructor
1715
*
@@ -22,38 +20,7 @@ public FlowPermissionException(String code, String message) {
2220
super(code, message);
2321
}
2422

25-
/**
26-
* Constructor
27-
*
28-
* @param code error code
29-
* @param message error message
30-
* @param cause cause
31-
*/
32-
public FlowPermissionException(String code, String message, Throwable cause) {
33-
super(code, message, cause);
34-
}
35-
36-
/**
37-
* Field is read-only
38-
*
39-
* @param fieldName field name
40-
* @return exception
41-
*/
42-
public static FlowPermissionException fieldReadOnly(String fieldName) {
43-
return new FlowPermissionException("permission.field.readOnly",
44-
String.format("Field '%s' is read-only and cannot be modified", fieldName));
45-
}
4623

47-
/**
48-
* Field not found
49-
*
50-
* @param fieldName field name
51-
* @return exception
52-
*/
53-
public static FlowPermissionException fieldNotFound(String fieldName) {
54-
return new FlowPermissionException("permission.field.notFound",
55-
String.format("Field '%s' does not exist", fieldName));
56-
}
5724

5825
/**
5926
* Access denied
@@ -66,14 +33,4 @@ public static FlowPermissionException accessDenied(String operation) {
6633
String.format("Access denied to operation: %s", operation));
6734
}
6835

69-
/**
70-
* No permission to operate the flow
71-
*
72-
* @param operatorId operator ID
73-
* @return exception
74-
*/
75-
public static FlowPermissionException noPermission(long operatorId) {
76-
return new FlowPermissionException("permission.access.noPermission",
77-
String.format("Operator %d has no permission to access this resource", operatorId));
78-
}
7936
}

0 commit comments

Comments
 (0)