72 return (Project) session.getAttribute(SESSION_ATTR_SELECTED_PROJECT); |
72 return (Project) session.getAttribute(SESSION_ATTR_SELECTED_PROJECT); |
73 } |
73 } |
74 } |
74 } |
75 |
75 |
76 @RequestMapping(method = HttpMethod.GET) |
76 @RequestMapping(method = HttpMethod.GET) |
77 public ResponseType indexRedirect(HttpServletResponse resp) throws IOException { |
|
78 resp.sendRedirect("index/"); |
|
79 return ResponseType.NONE; |
|
80 } |
|
81 |
|
82 @RequestMapping(requestPath = "index", method = HttpMethod.GET, menuKey = "menu.index") |
|
83 public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { |
77 public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { |
84 |
78 |
85 final var projectList = dao.getProjectDao().list(); |
79 final var projectList = dao.getProjectDao().list(); |
86 req.setAttribute("projects", projectList); |
80 req.setAttribute("projects", projectList); |
87 setDynamicFragment(req, "projects"); |
81 setDynamicFragment(req, "projects"); |
118 ownerId -> ownerId >= 0 ? new User(ownerId) : null |
112 ownerId -> ownerId >= 0 ? new User(ownerId) : null |
119 ).ifPresent(project::setOwner); |
113 ).ifPresent(project::setOwner); |
120 |
114 |
121 dao.getProjectDao().saveOrUpdate(project); |
115 dao.getProjectDao().saveOrUpdate(project); |
122 |
116 |
123 setRedirectLocation(req, "./projects/index/"); |
117 setRedirectLocation(req, "./projects/"); |
124 setDynamicFragment(req, Constants.DYN_FRAGMENT_COMMIT_SUCCESSFUL); |
118 setDynamicFragment(req, Constants.DYN_FRAGMENT_COMMIT_SUCCESSFUL); |
125 LOG.debug("Successfully updated project {}", project.getName()); |
119 LOG.debug("Successfully updated project {}", project.getName()); |
126 } catch (NoSuchElementException | NumberFormatException | SQLException ex) { |
120 } catch (NoSuchElementException | NumberFormatException | SQLException ex) { |
127 // TODO: set request attribute with error text |
121 // TODO: set request attribute with error text |
128 req.setAttribute("project", project); |
122 req.setAttribute("project", project); |
133 } |
127 } |
134 |
128 |
135 return ResponseType.HTML; |
129 return ResponseType.HTML; |
136 } |
130 } |
137 |
131 |
138 @RequestMapping(requestPath = "versions", method = HttpMethod.GET, menuKey = "menu.versions") |
132 @RequestMapping(requestPath = "view", method = HttpMethod.GET) |
139 public ResponseType versions(HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException, SQLException { |
133 public ResponseType view(HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException, SQLException { |
140 final var selectedProject = getSelectedProject(req, dao); |
134 final var selectedProject = getSelectedProject(req, dao); |
141 if (selectedProject == null) { |
135 if (selectedProject == null) { |
142 resp.sendError(HttpServletResponse.SC_FORBIDDEN); |
136 resp.sendError(HttpServletResponse.SC_FORBIDDEN); |
143 return ResponseType.NONE; |
137 return ResponseType.NONE; |
144 } |
138 } |
145 |
139 |
146 req.setAttribute("versions", dao.getVersionDao().list(selectedProject)); |
140 req.setAttribute("versions", dao.getVersionDao().list(selectedProject)); |
147 setDynamicFragment(req, "versions"); |
141 req.setAttribute("issues", dao.getIssueDao().list(selectedProject)); |
|
142 |
|
143 setDynamicFragment(req, "project-details"); |
148 |
144 |
149 return ResponseType.HTML; |
145 return ResponseType.HTML; |
150 } |
146 } |
151 |
147 |
152 @RequestMapping(requestPath = "versions/edit", method = HttpMethod.GET) |
148 @RequestMapping(requestPath = "versions/edit", method = HttpMethod.GET) |
191 req.setAttribute("versionStatusEnum", VersionStatus.values()); |
187 req.setAttribute("versionStatusEnum", VersionStatus.values()); |
192 setDynamicFragment(req, "version-form"); |
188 setDynamicFragment(req, "version-form"); |
193 LOG.warn("Form validation failure: {}", ex.getMessage()); |
189 LOG.warn("Form validation failure: {}", ex.getMessage()); |
194 LOG.debug("Details:", ex); |
190 LOG.debug("Details:", ex); |
195 } |
191 } |
196 |
|
197 return ResponseType.HTML; |
|
198 } |
|
199 |
|
200 |
|
201 @RequestMapping(requestPath = "issues", method = HttpMethod.GET, menuKey = "menu.issues") |
|
202 public ResponseType issues(HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException, SQLException { |
|
203 final var selectedProject = getSelectedProject(req, dao); |
|
204 if (selectedProject == null) { |
|
205 resp.sendError(HttpServletResponse.SC_FORBIDDEN); |
|
206 return ResponseType.NONE; |
|
207 } |
|
208 |
|
209 req.setAttribute("issues", dao.getVersionDao().list(selectedProject)); |
|
210 setDynamicFragment(req, "issues"); |
|
211 |
192 |
212 return ResponseType.HTML; |
193 return ResponseType.HTML; |
213 } |
194 } |
214 |
195 |
215 @RequestMapping(requestPath = "issues/edit", method = HttpMethod.GET) |
196 @RequestMapping(requestPath = "issues/edit", method = HttpMethod.GET) |