@@ -66,6 +66,8 @@ public class TaskTemplate implements TaskOperations {
66
66
67
67
private static final String VALIDATION_RELATION_VERSION = "1.7.0" ;
68
68
69
+ private static final String VALIDATION_THIN_TASK_VERSION = "2.11.3" ;
70
+
69
71
private static final String EXECUTIONS_RELATION = "tasks/executions" ;
70
72
71
73
private static final String THIN_EXECUTIONS_RELATION = "tasks/thinexecutions" ;
@@ -120,7 +122,7 @@ public class TaskTemplate implements TaskOperations {
120
122
Assert .notNull (restTemplate , "RestTemplate must not be null" );
121
123
Assert .isTrue (resources .getLink ("about" ).isPresent (), "Expected about relation" );
122
124
Assert .isTrue (resources .getLink (EXECUTIONS_RELATION ).isPresent (), "Executions relation is required" );
123
- Assert . isTrue ( resources . getLink ( THIN_EXECUTIONS_RELATION ). isPresent (), "Executions relation is required" );
125
+
124
126
Assert .isTrue (resources .getLink (DEFINITIONS_RELATION ).isPresent (), "Definitions relation is required" );
125
127
Assert .isTrue (resources .getLink (DEFINITION_RELATION ).isPresent (), "Definition relation is required" );
126
128
Assert .isTrue (resources .getLink (EXECUTIONS_RELATION ).isPresent (), "Executions relation is required" );
@@ -129,41 +131,35 @@ public class TaskTemplate implements TaskOperations {
129
131
Assert .isTrue (resources .getLink (EXECUTION_RELATION_BY_NAME ).isPresent (), "Execution by name relation is required" );
130
132
Assert .notNull (dataFlowServerVersion , "dataFlowVersion must not be null" );
131
133
Assert .isTrue (resources .getLink (RETRIEVE_LOG ).isPresent (), "Log relation is required" );
134
+ this .restTemplate = restTemplate ;
132
135
this .dataFlowServerVersion = dataFlowServerVersion ;
133
136
134
- if ( VersionUtils .isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion (
135
- VersionUtils .getThreePartVersion ( dataFlowServerVersion ),
136
- VALIDATION_RELATION_VERSION )) {
137
- Assert . notNull ( resources . getLink ( VALIDATION_REL ), "Validiation relation for tasks is required" );
137
+ String version = VersionUtils .getThreePartVersion ( dataFlowServerVersion );
138
+ if ( VersionUtils .isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion ( version , VALIDATION_RELATION_VERSION )) {
139
+ Assert . isTrue ( resources . getLink ( VALIDATION_REL ). isPresent (), "Validiation relation for tasks is required" );
140
+
138
141
}
142
+ if (VersionUtils .isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion (version , VALIDATION_THIN_TASK_VERSION )) {
143
+ Assert .isTrue (resources .getLink (THIN_EXECUTIONS_RELATION ).isPresent (), "Executions relation is required" );
144
+ }
145
+
139
146
140
- if (VersionUtils .isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion (
141
- VersionUtils .getThreePartVersion (dataFlowServerVersion ),
142
- EXECUTIONS_CURRENT_RELATION_VERSION )) {
147
+ if (VersionUtils .isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion (version , EXECUTIONS_CURRENT_RELATION_VERSION )) {
143
148
Assert .isTrue (resources .getLink (EXECUTIONS_CURRENT_RELATION ).isPresent (), "Current Executions relation is required" );
144
- Assert .notNull (resources .getLink (EXECUTIONS_CURRENT_RELATION ), "Executions current relation is required" );
145
- this .executionsCurrentLink = resources .getLink (EXECUTIONS_CURRENT_RELATION ).get ();
146
- } else {
147
- this .executionsCurrentLink = null ;
148
149
}
150
+ this .thinExecutionsLink = resources .getLink (THIN_EXECUTIONS_RELATION ).get ();
151
+ this .validationLink = resources .getLink (VALIDATION_REL ).get ();
152
+ this .executionsCurrentLink = resources .getLink (EXECUTIONS_CURRENT_RELATION ).get ();
149
153
150
- this .restTemplate = restTemplate ;
151
154
this .aboutLink = resources .getLink ("about" ).get ();
152
155
this .definitionsLink = resources .getLink (DEFINITIONS_RELATION ).get ();
153
156
this .definitionLink = resources .getLink (DEFINITION_RELATION ).get ();
154
157
this .executionsLink = resources .getLink (EXECUTIONS_RELATION ).get ();
155
- this . thinExecutionsLink = resources . getLink ( THIN_EXECUTIONS_RELATION ). get ();
158
+
156
159
this .executionLink = resources .getLink (EXECUTION_RELATION ).get ();
157
- if (resources .getLink (EXECUTION_LAUNCH_RELATION ).isPresent ()) {
158
- this .executionLaunchLink = resources .getLink (EXECUTION_LAUNCH_RELATION ).get ();
159
- } else {
160
- this .executionLaunchLink = null ;
161
- }
160
+ this .executionLaunchLink = resources .getLink (EXECUTION_LAUNCH_RELATION ).get ();
162
161
this .executionByNameLink = resources .getLink (EXECUTION_RELATION_BY_NAME ).get ();
163
- if (resources .getLink (EXECUTIONS_INFO_RELATION ).isPresent ()) {
164
- this .executionsInfoLink = resources .getLink (EXECUTIONS_INFO_RELATION ).get ();
165
- }
166
- this .validationLink = resources .getLink (VALIDATION_REL ).get ();
162
+ this .executionsInfoLink = resources .getLink (EXECUTIONS_INFO_RELATION ).get ();
167
163
this .platformListLink = resources .getLink (PLATFORM_LIST_RELATION ).get ();
168
164
this .retrieveLogLink = resources .getLink (RETRIEVE_LOG ).get ();
169
165
}
@@ -189,7 +185,7 @@ public TaskDefinitionResource create(String name, String definition, String desc
189
185
values .add ("definition" , definition );
190
186
values .add ("description" , description );
191
187
return restTemplate .postForObject (definitionsLink .expand ().getHref (), values ,
192
- TaskDefinitionResource .class );
188
+ TaskDefinitionResource .class );
193
189
}
194
190
private boolean isNewServer () {
195
191
if (this .actualDataFlowServerCoreVersion == null ) {
@@ -275,7 +271,7 @@ public PagedModel<TaskExecutionThinResource> thinExecutionList() {
275
271
@ Override
276
272
public TaskExecutionResource .Page executionListByTaskName (String taskName ) {
277
273
return restTemplate .getForObject (executionByNameLink .expand (taskName ).getHref (),
278
- TaskExecutionResource .Page .class );
274
+ TaskExecutionResource .Page .class );
279
275
}
280
276
281
277
@ Override
@@ -305,10 +301,10 @@ public String taskExecutionLog(String externalExecutionId, String platform) {
305
301
@ Override
306
302
public Collection <CurrentTaskExecutionsResource > currentTaskExecutions () {
307
303
ParameterizedTypeReference <Collection <CurrentTaskExecutionsResource >> typeReference =
308
- new ParameterizedTypeReference <Collection <CurrentTaskExecutionsResource >>() {
309
- };
304
+ new ParameterizedTypeReference <Collection <CurrentTaskExecutionsResource >>() {
305
+ };
310
306
return restTemplate
311
- .exchange (executionsCurrentLink .getHref (), HttpMethod .GET , null , typeReference ).getBody ();
307
+ .exchange (executionsCurrentLink .getHref (), HttpMethod .GET , null , typeReference ).getBody ();
312
308
}
313
309
314
310
@ Override
@@ -352,7 +348,7 @@ public Integer getAllTaskExecutionsCount(boolean completed, String taskName) {
352
348
map .put ("name" , StringUtils .hasText (taskName ) ? taskName : "" );
353
349
if (this .executionsInfoLink != null ) {
354
350
return Objects .requireNonNull (
355
- restTemplate .getForObject (this .executionsInfoLink .expand (map ).getHref (), TaskExecutionsInfoResource .class )
351
+ restTemplate .getForObject (this .executionsInfoLink .expand (map ).getHref (), TaskExecutionsInfoResource .class )
356
352
).getTotalExecutions ();
357
353
}
358
354
// for backwards-compatibility return zero count
@@ -362,10 +358,10 @@ public Integer getAllTaskExecutionsCount(boolean completed, String taskName) {
362
358
363
359
@ Override
364
360
public TaskAppStatusResource validateTaskDefinition (String taskDefinitionName )
365
- throws OperationNotSupportedException {
361
+ throws OperationNotSupportedException {
366
362
if (validationLink == null ) {
367
363
throw new OperationNotSupportedException ("Task Validation not supported on Data Flow Server version "
368
- + dataFlowServerVersion );
364
+ + dataFlowServerVersion );
369
365
}
370
366
String uriTemplate = this .validationLink .expand (taskDefinitionName ).getHref ();
371
367
return restTemplate .getForObject (uriTemplate , TaskAppStatusResource .class );
0 commit comments