Skip to content

Sort constants in alphabetical order #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions src/main/java/ru/mystamps/web/Url.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,56 +128,59 @@ public static Map<String, String> asMap(boolean production) {
boolean serveContentFromSingleHost = !production;

// Not all URLs are listed here but only those that are being used on views
// Constants sorted in an ascending order.
Map<String, String> map = new HashMap<>();
map.put("PUBLIC_URL", production ? PUBLIC_URL : SITE);
map.put("AUTHENTICATION_PAGE", AUTHENTICATION_PAGE);
map.put("LOGIN_PAGE", LOGIN_PAGE);
map.put("LOGOUT_PAGE", LOGOUT_PAGE);
map.put("ACTIVATE_ACCOUNT_PAGE", ACTIVATE_ACCOUNT_PAGE);
map.put("REGISTRATION_PAGE", REGISTRATION_PAGE);
map.put("ADD_CATEGORY_PAGE", ADD_CATEGORY_PAGE);
map.put("ADD_COUNTRY_PAGE", ADD_COUNTRY_PAGE);
map.put("ADD_IMAGE_SERIES_PAGE", ADD_IMAGE_SERIES_PAGE);
map.put("ADD_PARTICIPANT_PAGE", ADD_PARTICIPANT_PAGE);
map.put("ADD_SERIES_PAGE", ADD_SERIES_PAGE);
map.put("ADD_SERIES_ASK_PAGE", ADD_SERIES_ASK_PAGE);
map.put("INFO_SERIES_PAGE", INFO_SERIES_PAGE);
map.put("ADD_IMAGE_SERIES_PAGE", ADD_IMAGE_SERIES_PAGE);
map.put("SEARCH_SERIES_BY_CATALOG", SEARCH_SERIES_BY_CATALOG);
map.put("REQUEST_IMPORT_SERIES_PAGE", REQUEST_IMPORT_SERIES_PAGE);
map.put("REQUEST_IMPORT_PAGE", REQUEST_IMPORT_PAGE);
map.put("LIST_IMPORT_REQUESTS_PAGE", LIST_IMPORT_REQUESTS_PAGE);
map.put("SUGGEST_SERIES_COUNTRY", SUGGEST_SERIES_COUNTRY);
map.put("ADD_CATEGORY_PAGE", ADD_CATEGORY_PAGE);
map.put("ADD_SERIES_PAGE", ADD_SERIES_PAGE);
map.put("AUTHENTICATION_PAGE", AUTHENTICATION_PAGE);
map.put("BOOTSTRAP_LANGUAGE", BOOTSTRAP_LANGUAGE);
map.put("DAILY_STATISTICS", DAILY_STATISTICS);
map.put("INFO_CATEGORY_PAGE", INFO_CATEGORY_PAGE);
map.put("LIST_CATEGORIES_PAGE", LIST_CATEGORIES_PAGE);
map.put("ADD_COUNTRY_PAGE", ADD_COUNTRY_PAGE);
map.put("INFO_COLLECTION_PAGE", INFO_COLLECTION_PAGE);
map.put("INFO_COUNTRY_PAGE", INFO_COUNTRY_PAGE);
map.put("INFO_SERIES_PAGE", INFO_SERIES_PAGE);
map.put("LIST_CATEGORIES_PAGE", LIST_CATEGORIES_PAGE);
map.put("LIST_COUNTRIES_PAGE", LIST_COUNTRIES_PAGE);
map.put("INFO_COLLECTION_PAGE", INFO_COLLECTION_PAGE);
map.put("LIST_IMPORT_REQUESTS_PAGE", LIST_IMPORT_REQUESTS_PAGE);
map.put("LOGIN_PAGE", LOGIN_PAGE);
map.put("LOGOUT_PAGE", LOGOUT_PAGE);
map.put("PUBLIC_URL", production ? PUBLIC_URL : SITE);
map.put("REGISTRATION_PAGE", REGISTRATION_PAGE);
map.put("REQUEST_IMPORT_PAGE", REQUEST_IMPORT_PAGE);
map.put("REQUEST_IMPORT_SERIES_PAGE", REQUEST_IMPORT_SERIES_PAGE);
map.put("SEARCH_SERIES_BY_CATALOG", SEARCH_SERIES_BY_CATALOG);
map.put("SITE_EVENTS_PAGE", SITE_EVENTS_PAGE);
map.put("BOOTSTRAP_LANGUAGE", BOOTSTRAP_LANGUAGE);
map.put("DAILY_STATISTICS", DAILY_STATISTICS);
map.put("SUGGEST_SERIES_COUNTRY", SUGGEST_SERIES_COUNTRY);

if (serveContentFromSingleHost) {
// Constants sorted in an ascending order.
map.put("BOOTSTRAP_CSS", BOOTSTRAP_CSS);
map.put("BOOTSTRAP_JS", BOOTSTRAP_JS);
map.put("JQUERY_JS", JQUERY_JS);
map.put("SELECTIZE_CSS", SELECTIZE_CSS);
map.put("SELECTIZE_JS", SELECTIZE_JS);
map.put("CATALOG_UTILS_JS", CATALOG_UTILS_JS);
map.put("COLLECTION_INFO_JS", COLLECTION_INFO_JS);
map.put("FAVICON_ICO", FAVICON_ICO);
map.put("GET_IMAGE_PAGE", GET_IMAGE_PAGE);
map.put("GET_IMAGE_PREVIEW_PAGE", GET_IMAGE_PREVIEW_PAGE);
map.put("FAVICON_ICO", FAVICON_ICO);
map.put("JQUERY_JS", JQUERY_JS);
map.put("MAIN_CSS", MAIN_CSS);
map.put("CATALOG_UTILS_JS", CATALOG_UTILS_JS);
map.put("SELECTIZE_CSS", SELECTIZE_CSS);
map.put("SELECTIZE_JS", SELECTIZE_JS);
map.put("SERIES_ADD_JS", SERIES_ADD_JS);
map.put("COLLECTION_INFO_JS", COLLECTION_INFO_JS);
} else {
// Use a separate domain for our own resources
// Constants sorted in an ascending order.
map.put("FAVICON_ICO", STATIC_RESOURCES_URL + FAVICON_ICO);
map.put("CATALOG_UTILS_JS", STATIC_RESOURCES_URL + CATALOG_UTILS_JS);
map.put("COLLECTION_INFO_JS", STATIC_RESOURCES_URL + COLLECTION_INFO_JS);
map.put("GET_IMAGE_PAGE", STATIC_RESOURCES_URL + GET_IMAGE_PAGE);
map.put("GET_IMAGE_PREVIEW_PAGE", STATIC_RESOURCES_URL + GET_IMAGE_PREVIEW_PAGE);
map.put("FAVICON_ICO", STATIC_RESOURCES_URL + FAVICON_ICO);
map.put("MAIN_CSS", STATIC_RESOURCES_URL + MAIN_CSS);
map.put("CATALOG_UTILS_JS", STATIC_RESOURCES_URL + CATALOG_UTILS_JS);
map.put("SERIES_ADD_JS", STATIC_RESOURCES_URL + SERIES_ADD_JS);
map.put("COLLECTION_INFO_JS", STATIC_RESOURCES_URL + COLLECTION_INFO_JS);

// Use CDN for the external resources like libraries
map.put("BOOTSTRAP_CSS", BOOTSTRAP_CSS_CDN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@

@SuppressWarnings("checkstyle:linelength")
public final class Authority {
// Constants sorted in an ascending order.
public static final GrantedAuthority ADD_COMMENTS_TO_SERIES = new SimpleGrantedAuthority(StringAuthority.ADD_COMMENTS_TO_SERIES);
public static final GrantedAuthority ADD_IMAGES_TO_SERIES = new SimpleGrantedAuthority(StringAuthority.ADD_IMAGES_TO_SERIES);
public static final GrantedAuthority ADD_PARTICIPANT = new SimpleGrantedAuthority(StringAuthority.ADD_PARTICIPANT);
public static final GrantedAuthority ADD_SERIES_SALES = new SimpleGrantedAuthority(StringAuthority.ADD_SERIES_SALES);
public static final GrantedAuthority MANAGE_TOGGLZ = new SimpleGrantedAuthority(StringAuthority.MANAGE_TOGGLZ);
public static final GrantedAuthority CREATE_CATEGORY = new SimpleGrantedAuthority(StringAuthority.CREATE_CATEGORY);
public static final GrantedAuthority CREATE_COUNTRY = new SimpleGrantedAuthority(StringAuthority.CREATE_COUNTRY);
public static final GrantedAuthority CREATE_SERIES = new SimpleGrantedAuthority(StringAuthority.CREATE_SERIES);
public static final GrantedAuthority DOWNLOAD_IMAGE = new SimpleGrantedAuthority(StringAuthority.DOWNLOAD_IMAGE);
public static final GrantedAuthority IMPORT_SERIES = new SimpleGrantedAuthority(StringAuthority.IMPORT_SERIES);
public static final GrantedAuthority MANAGE_TOGGLZ = new SimpleGrantedAuthority(StringAuthority.MANAGE_TOGGLZ);
public static final GrantedAuthority UPDATE_COLLECTION = new SimpleGrantedAuthority(StringAuthority.UPDATE_COLLECTION);
public static final GrantedAuthority VIEW_SITE_EVENTS = new SimpleGrantedAuthority(StringAuthority.VIEW_SITE_EVENTS);
public static final GrantedAuthority VIEW_SERIES_SALES = new SimpleGrantedAuthority(StringAuthority.VIEW_SERIES_SALES);
public static final GrantedAuthority VIEW_DAILY_STATS = new SimpleGrantedAuthority(StringAuthority.VIEW_DAILY_STATS);
public static final GrantedAuthority VIEW_SERIES_SALES = new SimpleGrantedAuthority(StringAuthority.VIEW_SERIES_SALES);
public static final GrantedAuthority VIEW_SITE_EVENTS = new SimpleGrantedAuthority(StringAuthority.VIEW_SITE_EVENTS);

private Authority() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,25 @@ public org.springframework.security.core.userdetails.UserDetails loadUserByUsern
}

private static Collection<? extends GrantedAuthority> getAuthorities(UserDetails userDetails) {
// Constants sorted in an ascending order.
List<GrantedAuthority> authorities = new LinkedList<>();
authorities.add(Authority.CREATE_CATEGORY);
authorities.add(Authority.CREATE_COUNTRY);
authorities.add(Authority.CREATE_SERIES);
authorities.add(Authority.UPDATE_COLLECTION);

if (userDetails.isAdmin()) {
// Constants sorted in an ascending order.
authorities.add(Authority.ADD_COMMENTS_TO_SERIES);
authorities.add(Authority.ADD_IMAGES_TO_SERIES);
authorities.add(Authority.VIEW_SITE_EVENTS);
authorities.add(Authority.ADD_PARTICIPANT);
authorities.add(Authority.ADD_SERIES_SALES);
authorities.add(Authority.DOWNLOAD_IMAGE);
authorities.add(Authority.VIEW_SERIES_SALES);
authorities.add(Authority.IMPORT_SERIES);
authorities.add(Authority.MANAGE_TOGGLZ);
authorities.add(Authority.VIEW_DAILY_STATS);
authorities.add(Authority.VIEW_SERIES_SALES);
authorities.add(Authority.VIEW_SITE_EVENTS);
}

return authorities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@

@SuppressWarnings({ "checkstyle:linelength", "PMD.AvoidDuplicateLiterals" })
public final class HasAuthority {
// Constants sorted in an ascending order.
public static final String ADD_PARTICIPANT = "hasAuthority('" + StringAuthority.ADD_PARTICIPANT + "')";
public static final String ADD_SERIES_SALES = "hasAuthority('" + StringAuthority.ADD_SERIES_SALES + "')";
public static final String CREATE_SERIES = "hasAuthority('" + StringAuthority.CREATE_SERIES + "')";
public static final String CREATE_CATEGORY = "hasAuthority('" + StringAuthority.CREATE_CATEGORY + "')";
public static final String CREATE_COUNTRY = "hasAuthority('" + StringAuthority.CREATE_COUNTRY + "')";
public static final String CREATE_SERIES = "hasAuthority('" + StringAuthority.CREATE_SERIES + "')";
public static final String DOWNLOAD_IMAGE = "hasAuthority('" + StringAuthority.DOWNLOAD_IMAGE + "')";
public static final String IMPORT_SERIES = "hasAuthority('" + StringAuthority.IMPORT_SERIES + "')";
public static final String VIEW_DAILY_STATS = "hasAuthority('" + StringAuthority.VIEW_DAILY_STATS + "')";
public static final String UPDATE_COLLECTION = "hasAuthority('" + StringAuthority.UPDATE_COLLECTION + "')";
public static final String VIEW_SITE_EVENTS = "hasAuthority('" + StringAuthority.VIEW_SITE_EVENTS + "')";
public static final String VIEW_DAILY_STATS = "hasAuthority('" + StringAuthority.VIEW_DAILY_STATS + "')";
public static final String VIEW_SERIES_SALES = "hasAuthority('" + StringAuthority.VIEW_SERIES_SALES + "')";
public static final String VIEW_SITE_EVENTS = "hasAuthority('" + StringAuthority.VIEW_SITE_EVENTS + "')";

private HasAuthority() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
package ru.mystamps.web.support.spring.security;

public final class StringAuthority {
// Constants sorted in an ascending order.
public static final String ADD_COMMENTS_TO_SERIES = "ADD_COMMENTS_TO_SERIES";
public static final String ADD_IMAGES_TO_SERIES = "ADD_IMAGES_TO_SERIES";
public static final String ADD_PARTICIPANT = "ADD_PARTICIPANT";
public static final String ADD_SERIES_SALES = "ADD_SERIES_SALES";
public static final String MANAGE_TOGGLZ = "MANAGE_TOGGLZ";
public static final String CREATE_CATEGORY = "CREATE_CATEGORY";
public static final String CREATE_COUNTRY = "CREATE_COUNTRY";
public static final String CREATE_SERIES = "CREATE_SERIES";
public static final String DOWNLOAD_IMAGE = "DOWNLOAD_IMAGE";
public static final String IMPORT_SERIES = "IMPORT_SERIES";
public static final String MANAGE_TOGGLZ = "MANAGE_TOGGLZ";
public static final String UPDATE_COLLECTION = "UPDATE_COLLECTION";
public static final String VIEW_SITE_EVENTS = "VIEW_SITE_EVENTS";
public static final String VIEW_SERIES_SALES = "VIEW_SERIES_SALES";
public static final String VIEW_DAILY_STATS = "VIEW_DAILY_STATS";
public static final String VIEW_SERIES_SALES = "VIEW_SERIES_SALES";
public static final String VIEW_SITE_EVENTS = "VIEW_SITE_EVENTS";

private StringAuthority() {
}
Expand Down