diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-08-03 11:11:58 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-08-03 11:33:44 +0200 |
| commit | a424aa5e81c31f8cc6ba8846f0a6af29623588d4 (patch) | |
| tree | 18006e7c5b3c9c2ff4faa9a988a29a8a6c0499c3 /opendc-web/opendc-web-api | |
| parent | f6932d264db5b2e185ec7ea7aaec84dfb83f8fe9 (diff) | |
refactor(web/runner): Support pluggable job manager
This change introduces a new interface `JobManager` that is responsible
for communicating with the backend about the available jobs and updating
their status when the runner is simulating a job. This manager can be
injected into the `OpenDCRunner` class and allows users to provide
different sources for the jobs, not only the current REST API.
Diffstat (limited to 'opendc-web/opendc-web-api')
| -rw-r--r-- | opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt b/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt index 7e31e2c5..d9923505 100644 --- a/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt +++ b/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt @@ -60,6 +60,13 @@ class JobResource @Inject constructor(private val jobService: JobService) { @Path("{job}") @Transactional fun update(@PathParam("job") id: Long, @Valid update: Job.Update): Job { - return jobService.updateState(id, update.state, update.results) ?: throw WebApplicationException("Job not found", 404) + return try { + jobService.updateState(id, update.state, update.results) + ?: throw WebApplicationException("Job not found", 404) + } catch (e: IllegalArgumentException) { + throw WebApplicationException(e, 400) + } catch (e: IllegalStateException) { + throw WebApplicationException(e, 409) + } } } |
