diff --git a/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminController.java b/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminController.java index 574e9777ad..3bce339f7f 100644 --- a/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminController.java +++ b/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminController.java @@ -113,26 +113,32 @@ public interface AdminController { /** * Get supported ops. * + * @param model + * Overall model * @return the view */ @GetMapping("/") - ModelAndView mainUI(); + ModelAndView mainUI(ModelMap model); /** * List all users. * + * @param model + * Overall model * @return the model and view */ @GetMapping(USERS_PATH) - ModelAndView listUsers(); + ModelAndView listUsers(ModelMap model); /** * Get the form for creating a user. * + * @param model + * Overall model * @return the model and view */ @GetMapping(CREATE_USER_PATH) - ModelAndView getUserCreationForm(); + ModelAndView getUserCreationForm(ModelMap model); /** * Create a user. @@ -197,10 +203,12 @@ ModelAndView deleteUser(@PathVariable("id") int id, Principal principal, /** * List all groups. * + * @param model + * Overall model * @return the model and view */ @GetMapping(GROUPS_PATH) - ModelAndView listGroups(); + ModelAndView listGroups(ModelMap model); /** * Get info about a particular group. @@ -215,10 +223,12 @@ ModelAndView deleteUser(@PathVariable("id") int id, Principal principal, /** * Get the form for creating a group. * + * @param model + * Overall model * @return the model (a {@link CreateGroupModel}) and view */ @GetMapping(CREATE_GROUP_PATH) - ModelAndView getGroupCreationForm(); + ModelAndView getGroupCreationForm(ModelMap model); /** * Create a group. @@ -372,10 +382,12 @@ ModelAndView deleteGroup(@PathVariable("id") int id, /** * UI for boards. * + * @param model + * Overall model * @return the model and view */ @GetMapping(BOARDS_PATH) - ModelAndView boards(); + ModelAndView boards(ModelMap model); /** * Manipulate a board. @@ -437,10 +449,12 @@ CompletableFuture blacklistPush( /** * Provide the form for uploading a machine definition. * + * @param model + * Overall model * @return the model and view */ @GetMapping(MACHINE_PATH) - ModelAndView machineManagement(); + ModelAndView machineManagement(ModelMap model); /** * Handle the change of the tags of a machine. diff --git a/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminControllerImpl.java b/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminControllerImpl.java index 2a24223bb5..b72a385a0c 100644 --- a/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminControllerImpl.java +++ b/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/admin/AdminControllerImpl.java @@ -126,6 +126,15 @@ public class AdminControllerImpl extends DatabaseAwareBean /** One board-hour in board-seconds. */ private static final int BOARD_HOUR = 3600; + /** Dummy map. */ + private static final ModelMap NULL_MAP = null; + + /** Dummy user. */ + private static final Principal NULL_USER = null; + + /** Dummy attributes. */ + private static final RedirectAttributes NULL_ATTR = null; + @Autowired private UserControl userManager; @@ -192,12 +201,13 @@ private static void addStandardContextAttrs(Map model) { model.put(BASE_URI, fromCurrentRequestUri().toUriString()); model.put(TRUST_LEVELS, TrustLevel.values()); - model.put(USERS_URI, uri(admin().listUsers())); - model.put(CREATE_USER_URI, uri(admin().getUserCreationForm())); - model.put(CREATE_GROUP_URI, uri(admin().getGroupCreationForm())); - model.put(GROUPS_URI, uri(admin().listGroups())); - model.put(BOARDS_URI, uri(admin().boards())); - model.put(MACHINE_URI, uri(admin().machineManagement())); + model.put(USERS_URI, uri(admin().listUsers(NULL_MAP))); + model.put(CREATE_USER_URI, uri(admin().getUserCreationForm(NULL_MAP))); + model.put(CREATE_GROUP_URI, + uri(admin().getGroupCreationForm(NULL_MAP))); + model.put(GROUPS_URI, uri(admin().listGroups(NULL_MAP))); + model.put(BOARDS_URI, uri(admin().boards(NULL_MAP))); + model.put(MACHINE_URI, uri(admin().machineManagement(NULL_MAP))); model.put(USER_MAY_CHANGE_PASSWORD, mayChangePassword); } @@ -355,13 +365,13 @@ ModelAndView adminException(AdminException e, HandlerMethod hm) { @Override @Action("getting the main admin UI") - public ModelAndView mainUI() { + public ModelAndView mainUI(ModelMap ignored) { return addStandardContext(MAIN_VIEW.view()); } @Override @Action("listing the users") - public ModelAndView listUsers() { + public ModelAndView listUsers(ModelMap ignored) { var mav = USER_LIST_VIEW.view(); addLocalUserList(mav, userManager.listUsers(true, this::showUserFormUrl)); @@ -372,7 +382,7 @@ public ModelAndView listUsers() { @Override @Action("getting the user-creation UI") - public ModelAndView getUserCreationForm() { + public ModelAndView getUserCreationForm(ModelMap ignored) { var userForm = new UserRecord(); userForm.setInternal(true); return addStandardContext( @@ -461,7 +471,7 @@ public ModelAndView deleteUser(int id, Principal principal, () -> new AdminException("could not delete that user")); log.info("deleted user ID={} username={}", id, deletedUsername); // Not sure that these are the correct place - var mav = redirectTo(uri(admin().listUsers()), attrs); + var mav = redirectTo(uri(admin().listUsers(NULL_MAP)), attrs); addNotice(attrs, "deleted " + deletedUsername); addUser(attrs, new UserRecord()); return mav; @@ -477,12 +487,12 @@ public ModelAndView deleteUser(int id, Principal principal, * @return URL */ private URI deleteUserUrl(int id) { - return uri(admin().deleteUser(id, null, null)); + return uri(admin().deleteUser(id, NULL_USER, NULL_ATTR)); } @Override @Action("listing the groups") - public ModelAndView listGroups() { + public ModelAndView listGroups(ModelMap ignored) { var mav = GROUP_LIST_VIEW.view(); addLocalGroupList(mav, userManager.listGroups(INTERNAL, this::showGroupInfoUrl)); @@ -500,12 +510,15 @@ public ModelAndView showGroupInfo(int id) { var userLocations = new HashMap(); addGroup(mav, userManager.getGroup(id, m -> { userLocations.put(m.getUserName(), showUserFormUrl(m)); - return uri(admin().removeUserFromGroup(id, m.getUserId(), null)); + return uri( + admin().removeUserFromGroup(id, m.getUserId(), NULL_ATTR)); }).orElseThrow(NoGroup::new)); addUserList(mav, userLocations); - addUrl(mav, "deleteUri", uri(admin().deleteGroup(id, null))); - addUrl(mav, "addUserUri", uri(admin().addUserToGroup(id, null, null))); - addUrl(mav, "addQuotaUri", uri(admin().adjustGroupQuota(id, 0, null))); + addUrl(mav, "deleteUri", uri(admin().deleteGroup(id, NULL_ATTR))); + addUrl(mav, "addUserUri", + uri(admin().addUserToGroup(id, null, NULL_ATTR))); + addUrl(mav, "addQuotaUri", + uri(admin().adjustGroupQuota(id, 0, NULL_ATTR))); return addStandardContext(mav); } @@ -544,7 +557,7 @@ private URI showGroupInfoUrl(GroupRecord group) { @Override @Action("getting the group-creation UI") - public ModelAndView getGroupCreationForm() { + public ModelAndView getGroupCreationForm(ModelMap ignored) { return addStandardContext( CREATE_GROUP_VIEW.view(GROUP_OBJ, new CreateGroupModel())); } @@ -619,12 +632,12 @@ public ModelAndView deleteGroup(int id, RedirectAttributes attrs) { userManager.deleteGroup(id).orElseThrow(NoGroup::new); log.info("deleted group ID={} groupname={}", id, deletedGroupName); addNotice(attrs, "deleted " + deletedGroupName); - return redirectTo(uri(admin().listGroups()), attrs); + return redirectTo(uri(admin().listGroups(NULL_MAP)), attrs); } @Override @Action("getting the UI for finding boards") - public ModelAndView boards() { + public ModelAndView boards(ModelMap ignored) { var mav = BOARD_VIEW.view(); addBoard(mav, new BoardRecord()); addMachineList(mav, getMachineNames(true)); @@ -795,7 +808,7 @@ private void inflateBoardRecord(BoardRecord br, BoardState bs) { */ @Override @Action("getting a machine's configuration") - public ModelAndView machineManagement() { + public ModelAndView machineManagement(ModelMap ignored) { var mav = MACHINE_VIEW.view(); addMachineList(mav, getMachineNames(true)); var tagging = machineController.getMachineTagging(); @@ -813,7 +826,7 @@ public ModelAndView retagMachine(String machineName, String newTags) { stream(newTags.split(",")).map(String::strip).collect(toSet()); machineController.updateTags(machineName, tags); log.info("retagged {} to have tags {}", machineName, tags); - return machineManagement(); + return machineManagement(NULL_MAP); } @Override @@ -821,7 +834,7 @@ public ModelAndView retagMachine(String machineName, String newTags) { public ModelAndView disableMachine(String machineName) { machineController.setMachineState(machineName, false); log.info("marked {} as out of service", machineName); - return machineManagement(); + return machineManagement(NULL_MAP); } @Override @@ -829,7 +842,7 @@ public ModelAndView disableMachine(String machineName) { public ModelAndView enableMachine(String machineName) { machineController.setMachineState(machineName, true); log.info("marked {} as in service", machineName); - return machineManagement(); + return machineManagement(NULL_MAP); } @Override @@ -840,7 +853,7 @@ public ModelAndView defineMachine(MultipartFile file) { machineDefiner.loadMachineDefinition(m); log.info("defined machine {}", m.getName()); } - var mav = machineManagement(); + var mav = machineManagement(NULL_MAP); // Tailor with extra objects here mav.addObject(DEFINED_MACHINES_OBJ, machines); return mav; diff --git a/pom.xml b/pom.xml index 2c17ead944..ee3ca91109 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ limitations under the License. 2.20.0 5.3.28 - 2.7.12 + 2.7.13