@@ -217,7 +217,7 @@ List<String> validateStep(Step step, String workflowId ) {
217217 }
218218
219219 List <String > validateParameter (Parameter parameter , String workflowId , String componentName ) {
220- List <String > SUPPORTED_VALUES = Arrays .asList ("path" , "query" , "header" , "cookie" , "body" );
220+ List <String > SUPPORTED_VALUES = Arrays .asList ("path" , "query" , "header" , "cookie" );
221221
222222 String source ;
223223
@@ -299,25 +299,17 @@ List<String> validateSuccessAction(String workflowId, String stepId, SuccessActi
299299 }
300300 }
301301
302- if (successAction .getWorkflowId () == null && successAction .getStepId () == null ) {
303- errors .add ("Step " + stepId + " SuccessAction must define either workflowId or stepId" );
304- }
305-
306- if (successAction .getWorkflowId () != null && successAction .getStepId () != null ) {
307- errors .add ("Step " + stepId + " SuccessAction cannot define both workflowId and stepId" );
308- }
309-
310- if (successAction .getStepId () != null && successAction .getType () != null && successAction .getType ().equals ("goto" )) {
311- // when type `goto` stepId must exist (if provided)
312- if (!stepExists (workflowId , successAction .getStepId ())) {
313- errors .add ("Step " + stepId + " SuccessAction stepId is invalid (no such a step exists)" );
302+ if ("goto" .equals (successAction .getType ())) {
303+ errors .addAll (validateGotoTarget (stepId , "SuccessAction" , successAction .getStepId (), successAction .getWorkflowId ()));
304+ if (successAction .getStepId () != null ) {
305+ if (!stepExists (workflowId , successAction .getStepId ())) {
306+ errors .add ("Step " + stepId + " SuccessAction stepId is invalid (no such a step exists)" );
307+ }
314308 }
315- }
316-
317- if (successAction .getWorkflowId () != null && successAction .getType () != null && successAction .getType ().equals ("goto" )) {
318- // when type `goto` workflowId must exist (if provided)
319- if (!workflowExists (workflowId )) {
320- errors .add ("Step " + stepId + " SuccessAction workflowId is invalid (no such a workflow exists)" );
309+ if (successAction .getWorkflowId () != null ) {
310+ if (!workflowExists (successAction .getWorkflowId ())) {
311+ errors .add ("Step " + stepId + " SuccessAction workflowId is invalid (no such a workflow exists)" );
312+ }
321313 }
322314 }
323315
@@ -339,12 +331,8 @@ List<String> validateFailureAction(String workflowId, String stepId, FailureActi
339331 }
340332 }
341333
342- if (failureAction .getWorkflowId () == null && failureAction .getStepId () == null ) {
343- errors .add ("Step " + stepId + " FailureAction must define either workflowId or stepId" );
344- }
345-
346- if (failureAction .getWorkflowId () != null && failureAction .getStepId () != null ) {
347- errors .add ("Step " + stepId + " FailureAction cannot define both workflowId and stepId" );
334+ if ("goto" .equals (failureAction .getType ())) {
335+ errors .addAll (validateGotoTarget (stepId , "FailureAction" , failureAction .getStepId (), failureAction .getWorkflowId ()));
348336 }
349337
350338 if (failureAction .getRetryAfter () != null && failureAction .getRetryAfter () < 0 ) {
@@ -434,7 +422,7 @@ String getStepIdRegularExpression() {
434422 }
435423
436424 String getWorkflowIdRegularExpression () {
437- return "[A-Za-z0-9_\\ \\ -]+ +" ;
425+ return "[A-Za-z0-9_\\ -] +" ;
438426 }
439427 String getComponentKeyRegularExpression () {
440428 return "^[a-zA-Z0-9\\ .\\ -_]+$" ;
@@ -595,4 +583,15 @@ boolean isRuntimeExpression(String name) {
595583 return name != null && name .startsWith ("$" );
596584 }
597585
586+ private List <String > validateGotoTarget (String stepId , String actionLabel , String targetStepId , String targetWorkflowId ) {
587+ List <String > errors = new ArrayList <>();
588+ if (targetWorkflowId == null && targetStepId == null ) {
589+ errors .add ("Step " + stepId + " " + actionLabel + " must define either workflowId or stepId" );
590+ }
591+ if (targetWorkflowId != null && targetStepId != null ) {
592+ errors .add ("Step " + stepId + " " + actionLabel + " cannot define both workflowId and stepId" );
593+ }
594+ return errors ;
595+ }
596+
598597}
0 commit comments