diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowControllerAutoConfiguration.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowControllerAutoConfiguration.java index 122f69ca91..57284eadca 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowControllerAutoConfiguration.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowControllerAutoConfiguration.java @@ -300,8 +300,8 @@ public TaskExecutionController taskExecutionController( } @Bean - public TaskExecutionThinController taskExecutionThinController(AggregateTaskExplorer aggregateTaskExplorer, TaskJobService taskJobService) { - return new TaskExecutionThinController(aggregateTaskExplorer, taskJobService); + public TaskExecutionThinController taskExecutionThinController(AggregateTaskExplorer aggregateTaskExplorer, TaskDefinitionRepository taskDefinitionRepository, TaskJobService taskJobService) { + return new TaskExecutionThinController(aggregateTaskExplorer, taskDefinitionRepository, taskJobService); } @Bean diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskExecutionThinController.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskExecutionThinController.java index 210911b3c3..da44e34c76 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskExecutionThinController.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskExecutionThinController.java @@ -18,6 +18,8 @@ import org.springframework.cloud.dataflow.aggregate.task.AggregateTaskExplorer; import org.springframework.cloud.dataflow.rest.resource.TaskExecutionThinResource; import org.springframework.cloud.dataflow.schema.AggregateTaskExecution; +import org.springframework.cloud.dataflow.server.repository.NoSuchTaskDefinitionException; +import org.springframework.cloud.dataflow.server.repository.TaskDefinitionRepository; import org.springframework.cloud.dataflow.server.service.TaskJobService; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -46,13 +48,15 @@ public class TaskExecutionThinController { private final AggregateTaskExplorer explorer; + private final TaskDefinitionRepository taskDefinitionRepository; private final TaskExecutionThinResourceAssembler resourceAssembler; private final TaskJobService taskJobService; - public TaskExecutionThinController(AggregateTaskExplorer explorer, TaskJobService taskJobService) { + public TaskExecutionThinController(AggregateTaskExplorer explorer, TaskDefinitionRepository taskDefinitionRepository, TaskJobService taskJobService) { this.explorer = explorer; - this.taskJobService = taskJobService; + this.taskDefinitionRepository = taskDefinitionRepository; + this.taskJobService = taskJobService; this.resourceAssembler = new TaskExecutionThinResourceAssembler(); } @@ -68,6 +72,10 @@ public PagedModel listTasks(Pageable pageable, PagedR @ResponseStatus(HttpStatus.OK) public PagedModel retrieveTasksByName(@RequestParam("name") String taskName, Pageable pageable, PagedResourcesAssembler pagedAssembler) { + long tasks = this.taskDefinitionRepository.countByTaskName(taskName); + if(tasks == 0) { + throw new NoSuchTaskDefinitionException(taskName); + } Page page = this.explorer.findTaskExecutionsByName(taskName, pageable); taskJobService.populateComposeTaskRunnerStatus(page.getContent()); return pagedAssembler.toModel(page, resourceAssembler); diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/TaskDefinitionRepository.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/TaskDefinitionRepository.java index eb7464fae6..d67268bef5 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/TaskDefinitionRepository.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/TaskDefinitionRepository.java @@ -46,4 +46,5 @@ public interface TaskDefinitionRepository extends KeyValueRepository /dev/null || exit +SCDIR=$(realpath "$SCDIR/../..") +pushd "$SCDIR" || exit ./mvnw install -DskipTests -am -pl :spring-cloud-dataflow-classic-docs,:spring-cloud-dataflow-docs,:spring-cloud-skipper-server-core,:spring-cloud-skipper-docs -Pfull,docs popd > /dev/null || exit