Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up workflow-controller #6302

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private void broadCastWorkflowChange(Workflow workflow, UUID projectId) {
// }
} catch (final Exception e) {
log.error("Unable to notify users of update to workflow", e);
// No response status exception here because the workflow was updated successfully, and it's just the update that's failed.
}
}

Expand All @@ -113,7 +112,7 @@ private void broadCastWorkflowChange(Workflow workflow, UUID projectId) {
schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = Workflow.class)
)
),
@ApiResponse(responseCode = "204", description = "There was no workflow found", content = @Content),
@ApiResponse(responseCode = "404", description = "There was no workflow found", content = @Content),
@ApiResponse(
responseCode = "500",
description = "There was an issue retrieving the workflow from the data store",
Expand All @@ -131,7 +130,7 @@ public ResponseEntity<Workflow> getWorkflow(
);

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
return workflow.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.noContent().build());
return workflow.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@PostMapping
Expand Down Expand Up @@ -312,6 +311,9 @@ public ResponseEntity<Workflow> selectOutput(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.selectOutput(workflow.get(), nodeId, outputId);
Expand Down Expand Up @@ -357,6 +359,9 @@ public ResponseEntity<Workflow> updatePositions(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.updatePositions(workflow.get(), payload);
Expand Down Expand Up @@ -402,6 +407,9 @@ public ResponseEntity<Workflow> updateNodeState(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.updateNodeState(workflow.get(), payload);
Expand Down Expand Up @@ -447,6 +455,9 @@ public ResponseEntity<Workflow> updateNodeStatus(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.updateNodeStatus(workflow.get(), payload);
Expand Down Expand Up @@ -500,6 +511,9 @@ public ResponseEntity<Workflow> appendInput(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.appendInput(workflow.get(), nodeId, payload);
Expand Down Expand Up @@ -546,6 +560,9 @@ public ResponseEntity<Workflow> appendOutput(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.appendOutput(workflow.get(), nodeId, payload.getOutput(), payload.getNodeState());
Expand Down Expand Up @@ -591,6 +608,10 @@ public ResponseEntity<Workflow> addNode(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.addNode(workflow.get(), node);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down Expand Up @@ -635,6 +656,10 @@ public ResponseEntity<Workflow> removeNodes(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.removeNodes(workflow.get(), nodes);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down Expand Up @@ -679,6 +704,10 @@ public ResponseEntity<Workflow> addEdge(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.addEdge(workflow.get(), edge);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down Expand Up @@ -707,6 +736,7 @@ public ResponseEntity<Workflow> addEdge(
schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = Workflow.class)
)
),
@ApiResponse(responseCode = "404", description = "Workflow could not be found", content = @Content),
@ApiResponse(responseCode = "500", description = "There was an issue updating the workflow", content = @Content)
}
)
Expand All @@ -722,6 +752,10 @@ public ResponseEntity<Workflow> removeEdges(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.removeEdges(workflow.get(), edges);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down Expand Up @@ -750,6 +784,7 @@ public ResponseEntity<Workflow> removeEdges(
schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = Workflow.class)
)
),
@ApiResponse(responseCode = "404", description = "Workflow could not be found", content = @Content),
@ApiResponse(responseCode = "500", description = "There was an issue updating the workflow", content = @Content)
}
)
Expand All @@ -765,6 +800,10 @@ public ResponseEntity<Workflow> addOrUpdateAnnotation(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.addOrUpdateAnnotation(workflow.get(), annotation);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down Expand Up @@ -792,6 +831,7 @@ public ResponseEntity<Workflow> addOrUpdateAnnotation(
schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = Workflow.class)
)
),
@ApiResponse(responseCode = "404", description = "Workflow could not be found", content = @Content),
@ApiResponse(responseCode = "500", description = "There was an issue updating the workflow", content = @Content)
}
)
Expand All @@ -807,6 +847,10 @@ public ResponseEntity<Workflow> removeAnnotation(

final Optional<Workflow> workflow = workflowService.getAsset(id, permission);
final Optional<Workflow> updated;
if (workflow.isPresent() == false) {
return ResponseEntity.notFound().build();
}

try {
workflowService.removeAnnotation(workflow.get(), annotationId);
updated = workflowService.updateAsset(workflow.get(), projectId, permission);
Expand Down
Loading