Skip to content

Commit

Permalink
Handles FS access errors in UI 馃
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobvogel committed Sep 18, 2023
1 parent bcf7dd5 commit 0c1b575
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/main/java/ninja/NinjaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ public void bucket(WebContext webContext, String bucketName) {
return;
}

bucket.create();
if (!bucket.create()) {
throw Exceptions.createHandled()
.to(Storage.LOG)
.withDirectMessage("Failed creating bucket. Missing file system permission?")
.handle();
}

UserContext.message(Message.info().withTextMessage("Bucket successfully created."));
webContext.respondWith().redirectTemporarily("/ui/" + bucket.getEncodedName());
Expand All @@ -181,7 +186,12 @@ public void bucket(WebContext webContext, String bucketName) {

// handle /ui/[bucket]?make-public
if (webContext.hasParameter("make-public")) {
bucket.makePublic();
if (!bucket.makePublic()) {
throw Exceptions.createHandled()
.to(Storage.LOG)
.withDirectMessage("Failed making bucket public. Missing file system permission?")
.handle();
}

UserContext.message(Message.info().withTextMessage("ACLs successfully changed"));
webContext.respondWith().redirectTemporarily(address);
Expand All @@ -190,7 +200,12 @@ public void bucket(WebContext webContext, String bucketName) {

// handle /ui/[bucket]?make-private
if (webContext.hasParameter("make-private")) {
bucket.makePrivate();
if (!bucket.makePrivate()) {
throw Exceptions.createHandled()
.to(Storage.LOG)
.withDirectMessage("Failed making bucket private. Missing file system permission?")
.handle();
}

UserContext.message(Message.info().withTextMessage("ACLs successfully changed"));
webContext.respondWith().redirectTemporarily(address);
Expand All @@ -199,7 +214,12 @@ public void bucket(WebContext webContext, String bucketName) {

// handle /ui/[bucket]?delete
if (webContext.hasParameter("delete")) {
bucket.delete();
if (!bucket.delete()) {
throw Exceptions.createHandled()
.to(Storage.LOG)
.withDirectMessage("Failed deleting bucket. Missing file system permission?")
.handle();
}

UserContext.message(Message.info().withTextMessage("Bucket successfully deleted."));
webContext.respondWith().redirectTemporarily("/ui");
Expand Down

0 comments on commit 0c1b575

Please sign in to comment.