@@ -119,7 +119,7 @@ class TransportDeleteWorkflowAction @Inject constructor(
119
119
) {
120
120
suspend fun resolveUserAndStart () {
121
121
try {
122
- val workflow = getWorkflow()
122
+ val workflow: Workflow = getWorkflow() ? : return
123
123
124
124
val canDelete = user == null ||
125
125
! doFilterForUser(user) ||
@@ -296,17 +296,27 @@ class TransportDeleteWorkflowAction @Inject constructor(
296
296
return deletableMonitors
297
297
}
298
298
299
- private suspend fun getWorkflow (): Workflow {
299
+ private suspend fun getWorkflow (): Workflow ? {
300
300
val getRequest = GetRequest (ScheduledJob .SCHEDULED_JOBS_INDEX , workflowId)
301
301
302
302
val getResponse: GetResponse = client.suspendUntil { get(getRequest, it) }
303
- if (getResponse.isExists == false ) {
304
- actionListener.onFailure(
305
- AlertingException .wrap(
306
- OpenSearchStatusException (" Workflow not found." , RestStatus .NOT_FOUND )
307
- )
308
- )
303
+ if (! getResponse.isExists) {
304
+ handleWorkflowMissing()
305
+ return null
309
306
}
307
+
308
+ return parseWorkflow(getResponse)
309
+ }
310
+
311
+ private fun handleWorkflowMissing () {
312
+ actionListener.onFailure(
313
+ AlertingException .wrap(
314
+ OpenSearchStatusException (" Workflow not found." , RestStatus .NOT_FOUND )
315
+ )
316
+ )
317
+ }
318
+
319
+ private fun parseWorkflow (getResponse : GetResponse ): Workflow {
310
320
val xcp = XContentHelper .createParser(
311
321
xContentRegistry, LoggingDeprecationHandler .INSTANCE ,
312
322
getResponse.sourceAsBytesRef, XContentType .JSON
0 commit comments