Skip to content

Commit 014ff4f

Browse files
committed
refactor(SeriesSalesImportUrl): move series sales import URL to the corresponding class.
Addressed to #927 No functional changes.
1 parent 83ee726 commit 014ff4f

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-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
@@ -23,6 +23,7 @@
2323
import ru.mystamps.web.feature.country.CountryUrl;
2424
import ru.mystamps.web.feature.image.ImageUrl;
2525
import ru.mystamps.web.feature.participant.ParticipantUrl;
26+
import ru.mystamps.web.feature.series.importing.sale.SeriesSalesImportUrl;
2627

2728
import java.util.HashMap;
2829
import java.util.Map;
@@ -59,8 +60,6 @@ public final class Url {
5960
public static final String REQUEST_IMPORT_PAGE = "/series/import/request/{id}";
6061
public static final String LIST_IMPORT_REQUESTS_PAGE = "/series/import/requests";
6162

62-
public static final String IMPORT_SERIES_SALES = "/series/sales/import";
63-
6463
public static final String FORBIDDEN_PAGE = "/error/403";
6564
public static final String NOT_FOUND_PAGE = "/error/404";
6665
public static final String INTERNAL_ERROR_PAGE = "/error/500";
@@ -120,6 +119,7 @@ public static Map<String, String> asMap(boolean production) {
120119
CountryUrl.exposeUrlsToView(map);
121120
CollectionUrl.exposeUrlsToView(map);
122121
ParticipantUrl.exposeUrlsToView(map);
122+
SeriesSalesImportUrl.exposeUrlsToView(map);
123123

124124
map.put("ADD_IMAGE_SERIES_PAGE", ADD_IMAGE_SERIES_PAGE);
125125
map.put("ADD_SERIES_ASK_PAGE", ADD_SERIES_ASK_PAGE);
@@ -128,7 +128,6 @@ public static Map<String, String> asMap(boolean production) {
128128
map.put("DAILY_STATISTICS", DAILY_STATISTICS);
129129
map.put("INFO_SERIES_PAGE", INFO_SERIES_PAGE);
130130
map.put("LIST_IMPORT_REQUESTS_PAGE", LIST_IMPORT_REQUESTS_PAGE);
131-
map.put("IMPORT_SERIES_SALES", IMPORT_SERIES_SALES);
132131
map.put("PUBLIC_URL", production ? PUBLIC_URL : SITE);
133132
map.put("REQUEST_IMPORT_PAGE", REQUEST_IMPORT_PAGE);
134133
map.put("REQUEST_IMPORT_SERIES_PAGE", REQUEST_IMPORT_SERIES_PAGE);

src/main/java/ru/mystamps/web/feature/series/importing/sale/SeriesSaleImportController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.web.bind.annotation.PostMapping;
2626
import org.springframework.web.bind.annotation.RequestBody;
2727
import org.springframework.web.bind.annotation.RestController;
28-
import ru.mystamps.web.Url;
2928
import ru.mystamps.web.feature.series.importing.RequestImportForm;
3029

3130
import javax.validation.Valid;
@@ -38,7 +37,7 @@ public class SeriesSaleImportController {
3837

3938
private final SeriesSalesImportService seriesSalesImportService;
4039

41-
@PostMapping(Url.IMPORT_SERIES_SALES)
40+
@PostMapping(SeriesSalesImportUrl.IMPORT_SERIES_SALES)
4241
public ResponseEntity<SeriesSaleExtractedInfo> downloadAndParse(
4342
@RequestBody @Valid RequestImportForm form) {
4443

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2009-2019 Slava Semushin <[email protected]>
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.series.importing.sale;
19+
20+
import java.util.Map;
21+
22+
/**
23+
* URLs related to the import of the sales of the series.
24+
*
25+
* Should be used everywhere instead of hard-coded paths.
26+
*
27+
* @author Slava Semushin
28+
*/
29+
public final class SeriesSalesImportUrl {
30+
31+
public static final String IMPORT_SERIES_SALES = "/series/sales/import";
32+
33+
private SeriesSalesImportUrl() {
34+
}
35+
36+
public static void exposeUrlsToView(Map<String, String> urls) {
37+
urls.put("IMPORT_SERIES_SALES", IMPORT_SERIES_SALES);
38+
}
39+
40+
}

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
@@ -48,6 +48,7 @@
4848
import ru.mystamps.web.feature.collection.CollectionUrl;
4949
import ru.mystamps.web.feature.country.CountryUrl;
5050
import ru.mystamps.web.feature.participant.ParticipantUrl;
51+
import ru.mystamps.web.feature.series.importing.sale.SeriesSalesImportUrl;
5152
import ru.mystamps.web.feature.site.SiteService;
5253

5354
import javax.servlet.Filter;
@@ -101,7 +102,7 @@ protected void configure(HttpSecurity http) throws Exception {
101102
)
102103
.regexMatchers(HttpMethod.POST, Url.ADD_SERIES_ASK_PAGE.replace("{id}", "[0-9]+"))
103104
.hasAuthority(StringAuthority.ADD_SERIES_SALES)
104-
.mvcMatchers(HttpMethod.POST, Url.IMPORT_SERIES_SALES)
105+
.mvcMatchers(HttpMethod.POST, SeriesSalesImportUrl.IMPORT_SERIES_SALES)
105106
.hasAuthority(StringAuthority.IMPORT_SERIES_SALES)
106107
.anyRequest().permitAll()
107108
.and()

0 commit comments

Comments
 (0)