@GET @Path("/jail") @Permission({ "jail", "list" }) @ApiOperation(value = "List jails", notes = "Get a list of all the jails on the server.") public Collection<CachedNamedLocation> listJails() { Optional<NucleusJailService> optSrv = NucleusAPI.getJailService(); if (!optSrv.isPresent()) { throw new InternalServerErrorException("Nuclues jail service not available"); } NucleusJailService srv = optSrv.get(); return WebAPI.runOnMain( () -> srv.getJails().values().stream() .map(CachedNamedLocation::new) .collect(Collectors.toList()) ); }
@GET @Path("/jail/{name}") @Permission({ "jail", "one" }) @ApiOperation(value = "Get a jail", notes = "Get detailed information about a jail.") public CachedNamedLocation getJail(@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"); } return new CachedNamedLocation(optJail.get()); }); }
@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()); }); }
Optional<NucleusJailService> optSrv = NucleusAPI.getJailService(); if (!optSrv.isPresent()) { throw new InternalServerErrorException("Nuclues jail service not available");