@@ -348,8 +348,8 @@ List<String> validateComponents(Components components) {
348
348
if (components .getParameters () != null ) {
349
349
350
350
for (String key : components .getParameters ().keySet ()) {
351
- if (isValidComponentKey (key )) {
352
- errors .add ("'Component parameter " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
351
+ if (! isValidComponentKey (key )) {
352
+ errors .add ("'Component parameter name " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
353
353
}
354
354
}
355
355
@@ -358,13 +358,11 @@ List<String> validateComponents(Components components) {
358
358
}
359
359
}
360
360
if (components .getInputs () != null ) {
361
-
362
361
for (String key : components .getInputs ().keySet ()) {
363
- if (isValidComponentKey (key )) {
362
+ if (! isValidComponentKey (key )) {
364
363
errors .add ("'Component input " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
365
364
}
366
365
}
367
-
368
366
}
369
367
}
370
368
@@ -402,18 +400,24 @@ String getOutputsKeyRegularExpression() {
402
400
return "^[a-zA-Z0-9\\ .\\ -_]+$" ;
403
401
}
404
402
405
- List <String > loadWorkflowIds (List < Workflow > workflows ) {
403
+ List <String > loadWorkflowIds (OpenAPIWorkflow openAPIWorkflow ) {
406
404
List <String > errors = new ArrayList <>();
407
405
408
- if (workflows != null ) {
409
- for (Workflow workflow : workflows ) {
410
- if (!this .workflowIds .add (workflow .getWorkflowId ())) {
411
- // id already exists
412
- errors .add ("WorkflowId is not unique: " + workflow .getWorkflowId ());
413
- }
406
+ boolean multipleWorkflowsSpec = getNumWorkflowsSpecSourceDescriptions (openAPIWorkflow .getSourceDescriptions ()) > 1 ? true : false ;
407
+
408
+
409
+ if (openAPIWorkflow .getWorkflows () != null ) {
410
+ validateWorkflowIdsUniqueness (openAPIWorkflow .getWorkflows ());
411
+
412
+ for (Workflow workflow : openAPIWorkflow .getWorkflows ()) {
413
+ errors .addAll (validateStepsWorkflowIds (workflow .getSteps (), multipleWorkflowsSpec ));
414
+ }
415
+
416
+ for (Workflow workflow : openAPIWorkflow .getWorkflows ()) {
417
+ this .workflowIds .add (workflow .getWorkflowId ());
414
418
}
415
- }
416
419
420
+ }
417
421
return errors ;
418
422
}
419
423
@@ -489,6 +493,35 @@ boolean stepExists(String workflowId, String stepId) {
489
493
return this .stepIds .get (workflowId ) != null && this .stepIds .get (workflowId ).contains (stepId );
490
494
}
491
495
496
+ List <String > validateWorkflowIdsUniqueness (List <Workflow > workflows ) {
497
+ List <String > errors = new ArrayList <>();
498
+
499
+ Set <String > ids = new HashSet <>();
500
+ for (Workflow workflow : workflows ) {
501
+ if (!ids .add (workflow .getWorkflowId ())) {
502
+ // id already exists
503
+ errors .add ("WorkflowId is not unique: " + workflow .getWorkflowId ());
504
+ }
505
+ }
506
+ return errors ;
507
+ }
508
+
509
+ List <String > validateStepsWorkflowIds (List <Step > steps , boolean multipleWorkflowsSpecFiles ) {
510
+ List <String > errors = new ArrayList <>();
511
+
512
+ for (Step step : steps ) {
513
+ if (multipleWorkflowsSpecFiles ) {
514
+ // must use runtime expression to map applicable SourceDescription
515
+ if (step .getWorkflowId () != null && !step .getWorkflowId ().startsWith ("$sourceDescriptions." )) {
516
+ errors .add ("Operation " + step .getWorkflowId () + " must be specified using a runtime expression (e.g., $sourceDescriptions.<name>.<workflowId>)" );
517
+ }
518
+ }
519
+ }
520
+
521
+ return errors ;
522
+ }
523
+
524
+
492
525
public boolean isValidJsonPointer (String jsonPointerString ) {
493
526
494
527
boolean ret ;
0 commit comments