Skip to content

Commit 9847e80

Browse files
committed
refactor(ParticipantUrl): move participant-related values to the corresponding class.
Addressed to #927 No functional changes.
1 parent 232d41e commit 9847e80

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

src/main/java/ru/mystamps/web/Url.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import ru.mystamps.web.feature.category.CategoryUrl;
2222
import ru.mystamps.web.feature.collection.CollectionUrl;
2323
import ru.mystamps.web.feature.country.CountryUrl;
24+
import ru.mystamps.web.feature.participant.ParticipantUrl;
2425

2526
import java.util.HashMap;
2627
import java.util.Map;
@@ -65,8 +66,6 @@ public final class Url {
6566
public static final String GET_IMAGE_PAGE = "/image/{id}";
6667
public static final String GET_IMAGE_PREVIEW_PAGE = "/image/preview/{id}";
6768

68-
public static final String ADD_PARTICIPANT_PAGE = "/participant/add";
69-
7069
public static final String FORBIDDEN_PAGE = "/error/403";
7170
public static final String NOT_FOUND_PAGE = "/error/404";
7271
public static final String INTERNAL_ERROR_PAGE = "/error/500";
@@ -126,7 +125,7 @@ public static Map<String, String> asMap(boolean production) {
126125
map.put("ADD_CATEGORY_PAGE", CategoryUrl.ADD_CATEGORY_PAGE);
127126
map.put("ADD_COUNTRY_PAGE", CountryUrl.ADD_COUNTRY_PAGE);
128127
map.put("ADD_IMAGE_SERIES_PAGE", ADD_IMAGE_SERIES_PAGE);
129-
map.put("ADD_PARTICIPANT_PAGE", ADD_PARTICIPANT_PAGE);
128+
map.put("ADD_PARTICIPANT_PAGE", ParticipantUrl.ADD_PARTICIPANT_PAGE);
130129
map.put("ADD_SERIES_ASK_PAGE", ADD_SERIES_ASK_PAGE);
131130
map.put("ADD_SERIES_PAGE", ADD_SERIES_PAGE);
132131
map.put("AUTHENTICATION_PAGE", AccountUrl.AUTHENTICATION_PAGE);

src/main/java/ru/mystamps/web/feature/participant/ParticipantController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void initBinder(WebDataBinder binder) {
4747
binder.registerCustomEditor(String.class, "url", editor);
4848
}
4949

50-
@GetMapping(Url.ADD_PARTICIPANT_PAGE)
50+
@GetMapping(ParticipantUrl.ADD_PARTICIPANT_PAGE)
5151
public AddParticipantForm showForm(
5252
Model model,
5353
@RequestParam(name = "seller", required = false) Boolean seller,
@@ -63,7 +63,7 @@ public AddParticipantForm showForm(
6363
return form;
6464
}
6565

66-
@PostMapping(Url.ADD_PARTICIPANT_PAGE)
66+
@PostMapping(ParticipantUrl.ADD_PARTICIPANT_PAGE)
6767
public String processInput(Model model, @Valid AddParticipantForm form, BindingResult result) {
6868
if (result.hasErrors()) {
6969
List<EntityWithIdDto> groups = participantService.findAllGroups();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2009-2019 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.feature.participant;
19+
20+
/**
21+
* Participant-related URLs.
22+
*
23+
* Should be used everywhere instead of hard-coded paths.
24+
*
25+
* @author Slava Semushin
26+
*/
27+
public final class ParticipantUrl {
28+
29+
public static final String ADD_PARTICIPANT_PAGE = "/participant/add";
30+
31+
private ParticipantUrl() {
32+
}
33+
34+
}

src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import ru.mystamps.web.feature.category.CategoryUrl;
4848
import ru.mystamps.web.feature.collection.CollectionUrl;
4949
import ru.mystamps.web.feature.country.CountryUrl;
50+
import ru.mystamps.web.feature.participant.ParticipantUrl;
5051
import ru.mystamps.web.feature.site.SiteService;
5152

5253
import javax.servlet.Filter;
@@ -85,7 +86,7 @@ protected void configure(HttpSecurity http) throws Exception {
8586
.authorizeRequests()
8687
.mvcMatchers(CategoryUrl.ADD_CATEGORY_PAGE).hasAuthority(StringAuthority.CREATE_CATEGORY)
8788
.mvcMatchers(CountryUrl.ADD_COUNTRY_PAGE).hasAuthority(StringAuthority.CREATE_COUNTRY)
88-
.mvcMatchers(Url.ADD_PARTICIPANT_PAGE).hasAuthority(StringAuthority.ADD_PARTICIPANT)
89+
.mvcMatchers(ParticipantUrl.ADD_PARTICIPANT_PAGE).hasAuthority(StringAuthority.ADD_PARTICIPANT)
8990
.mvcMatchers(Url.ADD_SERIES_PAGE).hasAuthority(StringAuthority.CREATE_SERIES)
9091
.mvcMatchers(Url.REQUEST_IMPORT_SERIES_PAGE).hasAuthority(StringAuthority.IMPORT_SERIES)
9192
.mvcMatchers(Url.SITE_EVENTS_PAGE).hasAuthority(StringAuthority.VIEW_SITE_EVENTS)

0 commit comments

Comments
 (0)