Skip to content

Commit 336e55c

Browse files
committed
Fixed #103, Fixed #102
1 parent 58089e0 commit 336e55c

File tree

4 files changed

+102
-46
lines changed

4 files changed

+102
-46
lines changed

src/main/java/org/woehlke/simpleworklist/config/di/WebSecurityConfig.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ protected void configure(HttpSecurity http) throws Exception {
7979
.logoutUrl(applicationProperties.getWebSecurity().getLogoutUrl())
8080
.deleteCookies(applicationProperties.getWebSecurity().getCookieNamesToClear())
8181
.invalidateHttpSession(applicationProperties.getWebSecurity().getInvalidateHttpSession())
82-
.permitAll()
83-
.and()
84-
.csrf()
85-
.and()
86-
.exceptionHandling()
87-
.accessDeniedPage("/error/error-403");
82+
.permitAll();
8883
}
8984

9085
@Bean

src/main/java/org/woehlke/simpleworklist/error/MyErrorController.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.stereotype.Controller;
88
import org.springframework.ui.Model;
99
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RequestMethod;
1011

1112
import javax.servlet.RequestDispatcher;
1213
import javax.servlet.http.HttpServletRequest;
@@ -16,7 +17,7 @@
1617
@Controller
1718
public class MyErrorController implements ErrorController {
1819

19-
@RequestMapping("/fehler")
20+
@RequestMapping(path="/fehler", method={RequestMethod.GET,RequestMethod.POST, RequestMethod.PUT})
2021
public String handleError(HttpServletRequest request, Model model) {
2122
String errorMessage = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE);
2223
if(errorMessage!=null){
@@ -28,12 +29,53 @@ public String handleError(HttpServletRequest request, Model model) {
2829
log.warn(httpStatus.value()+""+httpStatus.getReasonPhrase());
2930
switch (httpStatus){
3031
case NOT_FOUND:
32+
log.warn("##################################################");
33+
log.warn(" 404 NOT_FOUND");
34+
log.warn("##################################################");
3135
return "error/error-404";
3236
case INTERNAL_SERVER_ERROR:
37+
log.warn("##################################################");
38+
log.warn(" 500 INTERNAL_SERVER_ERROR");
39+
log.warn("##################################################");
3340
return "error/error-500";
3441
case UNAUTHORIZED:
3542
log.warn("##################################################");
36-
log.warn(" UNAUTHORIZED");
43+
log.warn(" 401 UNAUTHORIZED");
44+
log.warn("##################################################");
45+
return "redirect:/login?login_error=1";
46+
case METHOD_NOT_ALLOWED:
47+
log.warn("##################################################");
48+
log.warn(" 405 METHOD_NOT_ALLOWED");
49+
log.warn("##################################################");
50+
return "redirect:/login?login_error=1";
51+
case FORBIDDEN:
52+
log.warn("##################################################");
53+
log.warn(" 403 FORBIDDEN");
54+
log.warn("##################################################");
55+
return "redirect:/login?login_error=1";
56+
case REQUEST_TIMEOUT:
57+
log.warn("##################################################");
58+
log.warn(" 408 REQUEST_TIMEOUT");
59+
log.warn("##################################################");
60+
return "redirect:/login?login_error=1";
61+
case CONFLICT:
62+
log.warn("##################################################");
63+
log.warn(" 409 CONFLICT");
64+
log.warn("##################################################");
65+
return "redirect:/login?login_error=1";
66+
case PRECONDITION_FAILED:
67+
log.warn("##################################################");
68+
log.warn(" 412 PRECONDITION_FAILED");
69+
log.warn("##################################################");
70+
return "redirect:/login?login_error=1";
71+
case URI_TOO_LONG:
72+
log.warn("##################################################");
73+
log.warn(" 414 URI_TOO_LONG");
74+
log.warn("##################################################");
75+
return "redirect:/login?login_error=1";
76+
case UNSUPPORTED_MEDIA_TYPE:
77+
log.warn("##################################################");
78+
log.warn(" 415 UNSUPPORTED_MEDIA_TYPE");
3779
log.warn("##################################################");
3880
return "redirect:/login?login_error=1";
3981
}

src/main/java/org/woehlke/simpleworklist/project/ProjectController.java

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
@Slf4j
3030
@Controller
31-
@RequestMapping(value = "/project")
31+
@RequestMapping(path = "/project")
3232
public class ProjectController extends AbstractController {
3333

3434
private final TaskService taskService;
@@ -44,7 +44,7 @@ public ProjectController(TaskService taskService, TaskMoveService taskMoveServic
4444
this.projectService = projectService;
4545
}
4646

47-
@RequestMapping(value = "/root", method = RequestMethod.GET)
47+
@RequestMapping(path = "/root", method = RequestMethod.GET)
4848
public final String showRootProject(
4949
@PageableDefault(sort = "orderIdProject") Pageable pageable,
5050
@RequestParam(required = false) String message,
@@ -66,7 +66,7 @@ public final String showRootProject(
6666
return "project/root";
6767
}
6868

69-
@RequestMapping(value = "/{projectId}", method = RequestMethod.GET)
69+
@RequestMapping(path = "/{projectId}", method = RequestMethod.GET)
7070
public final String showProject(
7171
@PathVariable long projectId,
7272
@PageableDefault(sort = "orderIdProject") Pageable pageable,
@@ -100,26 +100,26 @@ public final String showProject(
100100
return "project/show";
101101
}
102102

103-
@RequestMapping(value = "/add/new/project", method = RequestMethod.GET)
103+
@RequestMapping(path = "/add/new/project", method = RequestMethod.GET)
104104
public final String addNewTopLevelProjectForm(
105105
@ModelAttribute("userSession") UserSessionBean userSession,
106106
Locale locale, Model model
107107
){
108-
return addNewProjectGet(rootProjectId, userSession,locale, model);
108+
return addNewProject(rootProjectId, userSession, locale, model);
109109
}
110110

111111

112-
@RequestMapping(value = "/add/new/project", method = RequestMethod.POST)
112+
@RequestMapping(path = "/add/new/project", method = RequestMethod.POST)
113113
public final String addNewTopLevelProjectSave(
114114
@Valid Project project,
115115
@ModelAttribute("userSession") UserSessionBean userSession,
116116
BindingResult result,
117117
Locale locale, Model model
118118
){
119-
return addNewProjectPost(rootProjectId, userSession, project, result, locale, model);
119+
return addNewProjectPersist( rootProjectId, userSession, project, result, locale, model );
120120
}
121121

122-
@RequestMapping(value = "/{thisProjectId}/move/to/{targetProjectId}", method = RequestMethod.GET)
122+
@RequestMapping(path = "/{thisProjectId}/move/to/{targetProjectId}", method = RequestMethod.GET)
123123
public final String moveProject(
124124
@PathVariable("thisProjectId") Project thisProject,
125125
@PathVariable long targetProjectId,
@@ -134,7 +134,7 @@ public final String moveProject(
134134
return "redirect:/project/" + thisProject.getId();
135135
}
136136

137-
@RequestMapping(value = "/{projectId}/edit", method = RequestMethod.GET)
137+
@RequestMapping(path = "/{projectId}/edit", method = RequestMethod.GET)
138138
public final String editProjectGet(
139139
@PathVariable("projectId") Project thisProject,
140140
@ModelAttribute("userSession") UserSessionBean userSession,
@@ -153,7 +153,7 @@ public final String editProjectGet(
153153
return "project/edit";
154154
}
155155

156-
@RequestMapping(value = "/{projectId}/edit", method = RequestMethod.POST)
156+
@RequestMapping(path = "/{projectId}/edit", method = RequestMethod.POST)
157157
public final String editProjectPost(
158158
@PathVariable long projectId,
159159
@Valid Project project,
@@ -190,7 +190,7 @@ public final String editProjectPost(
190190
}
191191
}
192192

193-
@RequestMapping(value = "/{projectId}/delete", method = RequestMethod.GET)
193+
@RequestMapping(path = "/{projectId}/delete", method = RequestMethod.GET)
194194
public final String deleteProject(
195195
@PathVariable("projectId") Project project,
196196
@PageableDefault(sort = "title") Pageable request,
@@ -239,11 +239,11 @@ public final String deleteProject(
239239
}
240240

241241

242-
@RequestMapping(value = "/{projectId}/add/new/project", method = RequestMethod.GET)
243-
public final String addNewProjectGet(
244-
@PathVariable long projectId,
245-
@ModelAttribute("userSession") UserSessionBean userSession,
246-
Locale locale, Model model
242+
private final String addNewProject(
243+
long projectId,
244+
UserSessionBean userSession,
245+
Locale locale,
246+
Model model
247247
) {
248248
Context context = super.getContext(userSession);
249249
UserAccount userAccount = context.getUserAccount();
@@ -272,14 +272,13 @@ public final String addNewProjectGet(
272272
return "project/add";
273273
}
274274

275-
@RequestMapping(value = "/{projectId}/add/new/project",
276-
method = RequestMethod.POST)
277-
public final String addNewProjectPost(
278-
@PathVariable long projectId,
279-
@ModelAttribute("userSession") UserSessionBean userSession,
280-
@Valid Project project,
281-
BindingResult result,
282-
Locale locale, Model model) {
275+
private String addNewProjectPersist(
276+
@PathVariable long projectId,
277+
@ModelAttribute("userSession") UserSessionBean userSession,
278+
@Valid Project project,
279+
BindingResult result,
280+
Locale locale, Model model
281+
){
283282
Context context = super.getContext(userSession);
284283
UserAccount userAccount = context.getUserAccount();
285284
userSession.setLastProjectId(projectId);
@@ -319,7 +318,27 @@ public final String addNewProjectPost(
319318
}
320319
}
321320

322-
@RequestMapping(value = "/task/{sourceTaskId}/changeorderto/{destinationTaskId}", method = RequestMethod.GET)
321+
@RequestMapping(path = "/{projectId}/add/new/project", method = RequestMethod.GET)
322+
public final String addNewProjectGet(
323+
@PathVariable long projectId,
324+
@ModelAttribute("userSession") UserSessionBean userSession,
325+
Locale locale, Model model
326+
) {
327+
return addNewProject(projectId, userSession, locale, model);
328+
}
329+
330+
@RequestMapping(path = "/{projectId}/add/new/project",
331+
method = RequestMethod.POST)
332+
public final String addNewProjectPost(
333+
@PathVariable long projectId,
334+
@ModelAttribute("userSession") UserSessionBean userSession,
335+
@Valid Project project,
336+
BindingResult result,
337+
Locale locale, Model model) {
338+
return addNewProjectPersist( projectId, userSession, project, result, locale, model );
339+
}
340+
341+
@RequestMapping(path = "/task/{sourceTaskId}/changeorderto/{destinationTaskId}", method = RequestMethod.GET)
323342
public String changeTaskOrderIdWithinAProject(
324343
@PathVariable("sourceTaskId") Task sourceTask,
325344
@PathVariable("destinationTaskId") Task destinationTask,

src/main/java/org/woehlke/simpleworklist/task/TaskController.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.woehlke.simpleworklist.user.UserSessionBean;
2323

2424
@Controller
25-
@RequestMapping(value = "/task")
25+
@RequestMapping(path = "/task")
2626
public class TaskController extends AbstractController {
2727

2828
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
@@ -36,7 +36,7 @@ public TaskController(TaskService taskService, TaskMoveService taskMoveService)
3636
this.taskMoveService = taskMoveService;
3737
}
3838

39-
@RequestMapping(value = "/{taskId}/edit", method = RequestMethod.GET)
39+
@RequestMapping(path = "/{taskId}/edit", method = RequestMethod.GET)
4040
public final String editTaskGet(
4141
@PathVariable("taskId") Task task,
4242
@ModelAttribute("userSession") UserSessionBean userSession,
@@ -63,7 +63,7 @@ public final String editTaskGet(
6363
}
6464
}
6565

66-
@RequestMapping(value = "/{taskId}/edit", method = RequestMethod.POST)
66+
@RequestMapping(path = "/{taskId}/edit", method = RequestMethod.POST)
6767
public final String editTaskPost(
6868
@PathVariable long taskId,
6969
@Valid Task task,
@@ -136,7 +136,7 @@ private Project getProject(long projectId, UserAccount userAccount, UserSessionB
136136
return thisProject;
137137
}
138138

139-
@RequestMapping(value = "/addtorootproject/", method = RequestMethod.GET)
139+
@RequestMapping(path = "/addtorootproject/", method = RequestMethod.GET)
140140
public final String addNewTaskToProjectGet(
141141
@ModelAttribute("userSession") UserSessionBean userSession,
142142
Locale locale, Model model
@@ -163,7 +163,7 @@ public final String addNewTaskToProjectGet(
163163
return "task/add";
164164
}
165165

166-
@RequestMapping(value = "/addtoproject/{projectId}", method = RequestMethod.GET)
166+
@RequestMapping(path = "/addtoproject/{projectId}", method = RequestMethod.GET)
167167
public final String addNewTaskToProjectGet(
168168
@PathVariable long projectId,
169169
@ModelAttribute("userSession") UserSessionBean userSession,
@@ -203,7 +203,7 @@ public final String addNewTaskToProjectGet(
203203
return "task/add";
204204
}
205205

206-
@RequestMapping(value = "/addtoproject/{projectId}", method = RequestMethod.POST)
206+
@RequestMapping(path = "/addtoproject/{projectId}", method = RequestMethod.POST)
207207
public final String addNewTaskToProjectPost(
208208
@PathVariable long projectId,
209209
@ModelAttribute("userSession") UserSessionBean userSession,
@@ -254,15 +254,15 @@ public final String addNewTaskToProjectPost(
254254
}
255255
}
256256

257-
@RequestMapping(value = "/delete/{taskId}", method = RequestMethod.GET)
257+
@RequestMapping(path = "/delete/{taskId}", method = RequestMethod.GET)
258258
public final String deleteTaskGet(@PathVariable("taskId") Task task) {
259259
if(task!= null){
260260
taskService.delete(task);
261261
}
262262
return "redirect:/taskstate/trash";
263263
}
264264

265-
@RequestMapping(value = "/task/undelete/{taskId}", method = RequestMethod.GET)
265+
@RequestMapping(path = "/task/undelete/{taskId}", method = RequestMethod.GET)
266266
public final String undeleteTaskGet(@PathVariable("taskId") Task task) {
267267
if(task!= null) {
268268
taskService.undelete(task);
@@ -272,7 +272,7 @@ public final String undeleteTaskGet(@PathVariable("taskId") Task task) {
272272
}
273273
}
274274

275-
@RequestMapping(value = "/transform/{taskId}", method = RequestMethod.GET)
275+
@RequestMapping(path = "/transform/{taskId}", method = RequestMethod.GET)
276276
public final String transformTaskIntoProjectGet(@PathVariable("taskId") Task task) {
277277
long projectId = 0;
278278
if(task != null) {
@@ -294,7 +294,7 @@ public final String transformTaskIntoProjectGet(@PathVariable("taskId") Task tas
294294
return "redirect:/project/" + projectId + "/";
295295
}
296296

297-
@RequestMapping(value = "/complete/{taskId}", method = RequestMethod.GET)
297+
@RequestMapping(path = "/complete/{taskId}", method = RequestMethod.GET)
298298
public final String completeTaskGet(@PathVariable("taskId") Task task) {
299299
if(task != null){
300300
long maxOrderIdTaskState = taskMoveService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
@@ -304,7 +304,7 @@ public final String completeTaskGet(@PathVariable("taskId") Task task) {
304304
return "redirect:/taskstate/completed";
305305
}
306306

307-
@RequestMapping(value = "/incomplete/{taskId}", method = RequestMethod.GET)
307+
@RequestMapping(path = "/incomplete/{taskId}", method = RequestMethod.GET)
308308
public final String undoneTaskGet(@PathVariable("taskId") Task task) {
309309
if(task !=null) {
310310
taskService.incomplete(task);
@@ -360,7 +360,7 @@ private String getView(Task task,String back){
360360
}
361361
}
362362

363-
@RequestMapping(value = "/setfocus/{taskId}", method = RequestMethod.GET)
363+
@RequestMapping(path = "/setfocus/{taskId}", method = RequestMethod.GET)
364364
public final String setFocusGet(@PathVariable("taskId") Task task,
365365
@RequestParam(required=false) String back){
366366
if(task !=null) {
@@ -371,7 +371,7 @@ public final String setFocusGet(@PathVariable("taskId") Task task,
371371
}
372372
}
373373

374-
@RequestMapping(value = "/unsetfocus/{taskId}", method = RequestMethod.GET)
374+
@RequestMapping(path = "/unsetfocus/{taskId}", method = RequestMethod.GET)
375375
public final String unsetFocusGet(@PathVariable("taskId") Task task,
376376
@RequestParam(required=false) String back){
377377
if(task !=null) {

0 commit comments

Comments
 (0)