summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2022-05-11 17:50:30 +0200
committerGeorg Pfuetzenreuter2022-05-11 17:50:30 +0200
commit812cf73cb76eeaed530a36c8e848354d7d9269dd (patch)
treef25d3deea36f395c3c5a065c0760bbb2ee616c19 /src
parent1a4e969557a31c97a66c3769fa242513dc66d1be (diff)
downloadpubsh-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')
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java1
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/WebApplication.java14
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");
}