This repository was archived by the owner on Apr 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/org/springframework/xd/dirt/job/dsl
test/java/org/springframework/xd/dirt/rest Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,16 @@ public class ComposedJobUtil {
2929
3030 public static final String MODULE_SUFFIX = "_COMPOSED" ;
3131
32+ private static String orchestrationPatternString = "(\\ |\\ |" +//search for || in the definition
33+ "(?=([^\\ \" ']*[\\ \" '][^\\ \" ']*[\\ \" '])*[^\\ \" ']*$))" + //make sure its not in quotes
34+ "|(\\ &" + //or find a & in the definition
35+ "(?=([^\\ \" ']*[\\ \" '][^\\ \" ']*[\\ \" '])*[^\\ \" ']*$))" ;// make sure its not in quotes
36+
3237 private static String parameterPatternString = "(--" +//search for -- in the definition
3338 "(?=([^\\ \" ']*[\\ \" '][^\\ \" ']*[\\ \" '])*[^\\ \" ']*$))" ; //make sure its not in quotes
3439
40+ private static Pattern orchestrationPattern = Pattern .compile (orchestrationPatternString );
41+
3542 private static Pattern parameterPattern = Pattern .compile (parameterPatternString );
3643
3744 /**
@@ -64,7 +71,10 @@ public static boolean isComposedJobDefinition(String definition){
6471 }
6572 }
6673 } catch (JobSpecificationException e ) {
67- result = false ; //failed to parse, could be a stream.
74+ //failed to parse, could still be a composed job. Look for basic components
75+ // such as || or & if found return true.
76+ Matcher matcher = orchestrationPattern .matcher (definition );
77+ result = matcher .find ();
6878 }
6979 return result ;
7080 }
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ public void testComposedJobCreation() throws Exception {
122122 public void testComposedJobCreationBadDSL () throws Exception {
123123 mockMvc .perform (
124124 post ("/jobs/definitions" ).param ("name" , "job1" ).param ("definition" , "A || B >" ).accept (
125- MediaType .APPLICATION_JSON )).andExpect (status ().is4xxClientError ());
125+ MediaType .APPLICATION_JSON )).andExpect (status ().isInternalServerError ());
126126 }
127127
128128 @ Test
You can’t perform that action at this time.
0 commit comments