61 |
61 |
62 private static final Logger LOG = LoggerFactory.getLogger(ProjectsModule.class); |
62 private static final Logger LOG = LoggerFactory.getLogger(ProjectsModule.class); |
63 |
63 |
64 public static final String SESSION_ATTR_SELECTED_PROJECT = fqn(ProjectsModule.class, "selected-project"); |
64 public static final String SESSION_ATTR_SELECTED_PROJECT = fqn(ProjectsModule.class, "selected-project"); |
65 |
65 |
66 @RequestMapping(method = HttpMethod.GET, menuKey = "menu.index") |
66 @RequestMapping(method = HttpMethod.GET) |
|
67 public ResponseType indexRedirect(HttpServletResponse resp) throws IOException { |
|
68 resp.sendRedirect("index/"); |
|
69 return ResponseType.NONE; |
|
70 } |
|
71 |
|
72 @RequestMapping(requestPath = "index", method = HttpMethod.GET, menuKey = "menu.index") |
67 public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { |
73 public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { |
68 final var projectList = dao.getProjectDao().list(); |
74 final var projectList = dao.getProjectDao().list(); |
69 req.setAttribute("projects", projectList); |
75 req.setAttribute("projects", projectList); |
70 setDynamicFragment(req, "projects"); |
76 setDynamicFragment(req, "projects"); |
71 setStylesheet(req, "projects"); |
77 setStylesheet(req, "projects"); |
120 ownerId -> ownerId >= 0 ? new User(ownerId) : null |
126 ownerId -> ownerId >= 0 ? new User(ownerId) : null |
121 ).ifPresent(project::setOwner); |
127 ).ifPresent(project::setOwner); |
122 |
128 |
123 dao.getProjectDao().saveOrUpdate(project); |
129 dao.getProjectDao().saveOrUpdate(project); |
124 |
130 |
125 setRedirectLocation(req, "./projects/"); |
131 setRedirectLocation(req, "./projects/index/"); |
126 setDynamicFragment(req, Constants.DYN_FRAGMENT_COMMIT_SUCCESSFUL); |
132 setDynamicFragment(req, Constants.DYN_FRAGMENT_COMMIT_SUCCESSFUL); |
127 LOG.debug("Successfully updated project {}", project.getName()); |
133 LOG.debug("Successfully updated project {}", project.getName()); |
128 } catch (NoSuchElementException | NumberFormatException | SQLException ex) { |
134 } catch (NoSuchElementException | NumberFormatException | SQLException ex) { |
129 // TODO: set request attribute with error text |
135 // TODO: set request attribute with error text |
130 req.setAttribute("project", project); |
136 req.setAttribute("project", project); |