diff options
author | Georg Pfuetzenreuter | 2022-05-11 17:50:30 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-11 17:50:30 +0200 |
commit | 812cf73cb76eeaed530a36c8e848354d7d9269dd (patch) | |
tree | f25d3deea36f395c3c5a065c0760bbb2ee616c19 /src/main | |
parent | 1a4e969557a31c97a66c3769fa242513dc66d1be (diff) | |
download | pubsh-web-812cf73cb76eeaed530a36c8e848354d7d9269dd.tar.gz pubsh-web-812cf73cb76eeaed530a36c8e848354d7d9269dd.tar.bz2 pubsh-web-812cf73cb76eeaed530a36c8e848354d7d9269dd.zip |
Shell deletion exception handling
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java | 1 | ||||
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/WebApplication.java | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java b/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java index b68a14a..26408df 100644 --- a/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java +++ b/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java @@ -26,7 +26,6 @@ public class SchedulerBean { @Bean public static Task<Void> shellRemovalTask() { - return Tasks.oneTime("shell-removal") .execute((instance, ctx) -> { System.out.printf("Running container removal task - Instance: %s, ctx: %s\n", instance, ctx); diff --git a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java index a22c390..55628fe 100644 --- a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java +++ b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java @@ -276,7 +276,19 @@ public class WebApplication { System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username); - Docker.deleteShell(username, id); + try { + Docker.deleteShell(username, id); + String returnmessage = "Ok, deleted the shell with container ID " + id; + redirectAttributes.addFlashAttribute("message", returnmessage); + } catch (com.github.dockerjava.api.exception.NotFoundException exception) { + String returnmessage = "Shell does not exist, maybe it already expired?"; + redirectAttributes.addFlashAttribute("message", returnmessage); + System.out.println(exception); + } catch (Exception exception) { + String returnmessage = "Error."; + redirectAttributes.addFlashAttribute("message", returnmessage); + System.out.println(exception); + } return("redirect:/portal"); } |