-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TaskTemplate.launch to provide backwards compatible behaviour …
…for old client. #5492
- Loading branch information
Corneil du Plessis
committed
Oct 5, 2023
1 parent
69444d7
commit ea0157a
Showing
1 changed file
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
package org.springframework.cloud.dataflow.rest.client; | ||
|
||
import javax.naming.OperationNotSupportedException; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
@@ -175,15 +177,22 @@ public TaskDefinitionResource create(String name, String definition, String desc | |
return restTemplate.postForObject(definitionsLink.expand().getHref(), values, | ||
TaskDefinitionResource.class); | ||
} | ||
|
||
private boolean isOldServer() { | ||
for(String version : Arrays.asList("2.10.", "1.5.", "2.9.", "1.4.")) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ilayaperumalg
Contributor
|
||
if(this.dataFlowServerVersion.contains(version)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
@Override | ||
public LaunchResponseResource launch(String name, Map<String, String> properties, List<String> arguments) { | ||
MultiValueMap<String, Object> values = new LinkedMultiValueMap<>(); | ||
String formattedProperties = DeploymentPropertiesUtils.format(properties); | ||
String commandLineArguments = StringUtils.collectionToDelimitedString(arguments, " "); | ||
values.add("properties", formattedProperties); | ||
values.add("arguments", commandLineArguments); | ||
if(this.dataFlowServerVersion.contains("2.10") || this.dataFlowServerVersion.contains("1.5")) { | ||
if(isOldServer()) { | ||
Long id = restTemplate.postForObject(executionByNameLink.expand(name).getHref(), values, Long.class, name); | ||
if(id != null) { | ||
LaunchResponseResource response = new LaunchResponseResource(); | ||
|
Can we use a better logic to check if we can go below the SCDF
2.11
or1.6
instead of hard coded values?