public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { Owner owner = DatastoreManager.getCurrentOwner(); if (owner == null) { UserService userService = UserServiceFactory.getUserService(); resp.sendRedirect(userService.createLoginURL(req.getRequestURI())); return; } resp.sendRedirect("/driverselection.jsp"); }
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { String[] driverStrings = null; if (req.getParameterValues("driver") != null) { driverStrings = req.getParameterValues("driver"); } if (driverStrings != null && driverStrings.length > 5) { resp.setStatus(400); } else { NascarConfig config = NascarConfigSingleton.get(); List<Driver> drivers = DatastoreManager.getDriversByNamesAndRace(driverStrings, config.getRaceKey()); Owner owner = DatastoreManager.getCurrentOwner(); Lineup lineup = new Lineup(config.getRaceKey()); boolean driversAdded = lineup.setDrivers(drivers); if (driversAdded) { Team team = owner.getTeam(); team.setLineup(lineup); DatastoreManager.persistObject(team); } } resp.sendRedirect(req.getRequestURI()); }