@DELETE @Path("/jail/{name}") @Permission({ "jail", "delete" }) @ApiOperation(value = "Delete a jail", notes = "Delete an existing jail.") public CachedNamedLocation deleteJail(@PathParam("name") String name) throws NotFoundException { Optional<NucleusJailService> optSrv = NucleusAPI.getJailService(); if (!optSrv.isPresent()) { throw new InternalServerErrorException("Nuclues jail service not available"); } NucleusJailService srv = optSrv.get(); return WebAPI.runOnMain(() -> { Optional<NamedLocation> optJail = srv.getJail(name); if (!optJail.isPresent()) { throw new NotFoundException("Jail with name " + name + " not found"); } srv.removeJail(name); return new CachedNamedLocation(optJail.get()); }); }