Enable additional checkstyles for whitespace
* Enable checkstyle WhitespaceAround * Enable checkstyle NoWhitespaceBefore * Enable checkstyle MethodParamPad
This commit is contained in:
@@ -197,7 +197,7 @@ public class Application extends SpringBootServletInitializer implements Embedde
|
|||||||
// specific classes.
|
// specific classes.
|
||||||
try {
|
try {
|
||||||
Class<?> tomcatESCF = Class.forName("org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory");
|
Class<?> tomcatESCF = Class.forName("org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory");
|
||||||
if(tomcatESCF.isInstance(container)) {
|
if (tomcatESCF.isInstance(container)) {
|
||||||
LOG.info("Detected Tomcat web server");
|
LOG.info("Detected Tomcat web server");
|
||||||
LOG.debug("Attempting to optimize tomcat");
|
LOG.debug("Attempting to optimize tomcat");
|
||||||
Object tomcatESCFInstance = tomcatESCF.cast(container);
|
Object tomcatESCFInstance = tomcatESCF.cast(container);
|
||||||
@@ -216,7 +216,7 @@ public class Application extends SpringBootServletInitializer implements Embedde
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> jettyESCF = Class.forName("org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory");
|
Class<?> jettyESCF = Class.forName("org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory");
|
||||||
if(jettyESCF.isInstance(container)) {
|
if (jettyESCF.isInstance(container)) {
|
||||||
LOG.warn("Detected Jetty web server. Here there be dragons.");
|
LOG.warn("Detected Jetty web server. Here there be dragons.");
|
||||||
}
|
}
|
||||||
} catch (NoClassDefFoundError | ClassNotFoundException e) {
|
} catch (NoClassDefFoundError | ClassNotFoundException e) {
|
||||||
|
|||||||
@@ -745,7 +745,7 @@ public class PlayQueueService {
|
|||||||
List<PlayQueueInfo.Entry> entries = new ArrayList<>();
|
List<PlayQueueInfo.Entry> entries = new ArrayList<>();
|
||||||
for (InternetRadioSource streamSource: internetRadioService.getInternetRadioSources(radio)) {
|
for (InternetRadioSource streamSource: internetRadioService.getInternetRadioSources(radio)) {
|
||||||
// Fake entry id so that the source can be selected in the UI
|
// Fake entry id so that the source can be selected in the UI
|
||||||
Integer streamId = -(1+entries.size());
|
Integer streamId = -(1 + entries.size());
|
||||||
Integer streamTrackNumber = entries.size();
|
Integer streamTrackNumber = entries.size();
|
||||||
String streamUrl = streamSource.getStreamUrl();
|
String streamUrl = streamSource.getStreamUrl();
|
||||||
entries.add(new PlayQueueInfo.Entry(
|
entries.add(new PlayQueueInfo.Entry(
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class AvatarController implements LastModified {
|
|||||||
if (userSettings.getAvatarScheme() == AvatarScheme.CUSTOM || forceCustom) {
|
if (userSettings.getAvatarScheme() == AvatarScheme.CUSTOM || forceCustom) {
|
||||||
return settingsService.getCustomAvatar(username);
|
return settingsService.getCustomAvatar(username);
|
||||||
}
|
}
|
||||||
if(userSettings.getAvatarScheme() == AvatarScheme.NONE) {
|
if (userSettings.getAvatarScheme() == AvatarScheme.NONE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
|
return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*/
|
*/
|
||||||
public class ControllerUtils {
|
public class ControllerUtils {
|
||||||
|
|
||||||
public static String extractMatched(final HttpServletRequest request){
|
public static String extractMatched(final HttpServletRequest request) {
|
||||||
|
|
||||||
String path = (String) request.getAttribute(
|
String path = (String) request.getAttribute(
|
||||||
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
||||||
|
|||||||
+2
-2
@@ -66,7 +66,7 @@ public class DatabaseSettingsController {
|
|||||||
if (!bindingResult.hasErrors()) {
|
if (!bindingResult.hasErrors()) {
|
||||||
settingsService.resetDatabaseToDefault();
|
settingsService.resetDatabaseToDefault();
|
||||||
settingsService.setDatabaseConfigType(command.getConfigType());
|
settingsService.setDatabaseConfigType(command.getConfigType());
|
||||||
switch(command.getConfigType()) {
|
switch (command.getConfigType()) {
|
||||||
case EMBED:
|
case EMBED:
|
||||||
settingsService.setDatabaseConfigEmbedDriver(command.getEmbedDriver());
|
settingsService.setDatabaseConfigEmbedDriver(command.getEmbedDriver());
|
||||||
settingsService.setDatabaseConfigEmbedPassword(command.getEmbedPassword());
|
settingsService.setDatabaseConfigEmbedPassword(command.getEmbedPassword());
|
||||||
@@ -80,7 +80,7 @@ public class DatabaseSettingsController {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(command.getConfigType() != DataSourceConfigType.LEGACY) {
|
if (command.getConfigType() != DataSourceConfigType.LEGACY) {
|
||||||
settingsService.setDatabaseMysqlVarcharMaxlength(command.getMysqlVarcharMaxlength());
|
settingsService.setDatabaseMysqlVarcharMaxlength(command.getMysqlVarcharMaxlength());
|
||||||
settingsService.setDatabaseUsertableQuote(command.getUsertableQuote());
|
settingsService.setDatabaseUsertableQuote(command.getUsertableQuote());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -72,7 +72,7 @@ public class ExternalPlayerController {
|
|||||||
String shareName = ControllerUtils.extractMatched(request);
|
String shareName = ControllerUtils.extractMatched(request);
|
||||||
LOG.debug("Share name is {}", shareName);
|
LOG.debug("Share name is {}", shareName);
|
||||||
|
|
||||||
if(StringUtils.isBlank(shareName)) {
|
if (StringUtils.isBlank(shareName)) {
|
||||||
LOG.warn("Could not find share with shareName " + shareName);
|
LOG.warn("Could not find share with shareName " + shareName);
|
||||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return null;
|
return null;
|
||||||
@@ -102,7 +102,7 @@ public class ExternalPlayerController {
|
|||||||
private List<MediaFileWithUrlInfo> getSongs(HttpServletRequest request, Share share, Player player) throws IOException {
|
private List<MediaFileWithUrlInfo> getSongs(HttpServletRequest request, Share share, Player player) throws IOException {
|
||||||
Date expires = null;
|
Date expires = null;
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if(authentication instanceof JWTAuthenticationToken) {
|
if (authentication instanceof JWTAuthenticationToken) {
|
||||||
DecodedJWT token = jwtSecurityService.verify((String) authentication.getCredentials());
|
DecodedJWT token = jwtSecurityService.verify((String) authentication.getCredentials());
|
||||||
expires = token.getExpiresAt();
|
expires = token.getExpiresAt();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class HelpController {
|
|||||||
List<String> lines = new ArrayList<>(LOG_LINES_TO_SHOW);
|
List<String> lines = new ArrayList<>(LOG_LINES_TO_SHOW);
|
||||||
ReversedLinesFileReader reader = new ReversedLinesFileReader(logFile, Charset.defaultCharset());
|
ReversedLinesFileReader reader = new ReversedLinesFileReader(logFile, Charset.defaultCharset());
|
||||||
String current;
|
String current;
|
||||||
while((current = reader.readLine()) != null) {
|
while ((current = reader.readLine()) != null) {
|
||||||
if (lines.size() >= LOG_LINES_TO_SHOW) {
|
if (lines.size() >= LOG_LINES_TO_SHOW) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class InternetRadioSettingsController {
|
|||||||
|
|
||||||
String error = handleParameters(request);
|
String error = handleParameters(request);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
if(error == null) {
|
if (error == null) {
|
||||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ public class LoginController {
|
|||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
username = StringUtil.urlEncode(username);
|
username = StringUtil.urlEncode(username);
|
||||||
password = StringUtil.urlEncode(password);
|
password = StringUtil.urlEncode(password);
|
||||||
return new ModelAndView(new RedirectView("/login?"+
|
return new ModelAndView(new RedirectView("/login?" +
|
||||||
UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY+"=" + username +
|
UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY + "=" + username +
|
||||||
"&"+UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY+"=" + password
|
"&" + UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY + "=" + password
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class MainController {
|
|||||||
|
|
||||||
int userPaginationPreference = userSettings.getPaginationSize();
|
int userPaginationPreference = userSettings.getPaginationSize();
|
||||||
|
|
||||||
if(userPaginationPreference <= 0) {
|
if (userPaginationPreference <= 0) {
|
||||||
showAll = true;
|
showAll = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +175,8 @@ public class MainController {
|
|||||||
|
|
||||||
private <T> boolean trimToSize(Boolean showAll, List<T> list, int userPaginationPreference) {
|
private <T> boolean trimToSize(Boolean showAll, List<T> list, int userPaginationPreference) {
|
||||||
boolean trimmed = false;
|
boolean trimmed = false;
|
||||||
if(!BooleanUtils.isTrue(showAll)) {
|
if (!BooleanUtils.isTrue(showAll)) {
|
||||||
if(list.size() > userPaginationPreference) {
|
if (list.size() > userPaginationPreference) {
|
||||||
trimmed = true;
|
trimmed = true;
|
||||||
list.subList(userPaginationPreference, list.size()).clear();
|
list.subList(userPaginationPreference, list.size()).clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class RecoverController {
|
|||||||
map.put("error", "recover.error.noemail");
|
map.put("error", "recover.error.noemail");
|
||||||
} else {
|
} else {
|
||||||
StringBuilder sb = new StringBuilder(PASSWORD_LENGTH);
|
StringBuilder sb = new StringBuilder(PASSWORD_LENGTH);
|
||||||
for(int i=0; i<PASSWORD_LENGTH; i++) {
|
for (int i = 0; i < PASSWORD_LENGTH; i++) {
|
||||||
int index = random.nextInt(SYMBOLS.length());
|
int index = random.nextInt(SYMBOLS.length());
|
||||||
sb.append(SYMBOLS.charAt(index));
|
sb.append(SYMBOLS.charAt(index));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -149,7 +149,7 @@ public class SubsonicRESTController {
|
|||||||
public void handleMissingRequestParam(HttpServletRequest request,
|
public void handleMissingRequestParam(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
MissingServletRequestParameterException exception) throws Exception {
|
MissingServletRequestParameterException exception) throws Exception {
|
||||||
error(request, response, ErrorCode.MISSING_PARAMETER, "Required param ("+exception.getParameterName()+") is missing");
|
error(request, response, ErrorCode.MISSING_PARAMETER, "Required param (" + exception.getParameterName() + ") is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/ping")
|
@RequestMapping(value = "/ping")
|
||||||
|
|||||||
+2
-2
@@ -68,7 +68,7 @@ public class TranscodingSettingsController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||||
String error = handleParameters(request, redirectAttributes);
|
String error = handleParameters(request, redirectAttributes);
|
||||||
if(error != null) {
|
if (error != null) {
|
||||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||||
}
|
}
|
||||||
redirectAttributes.addFlashAttribute("error", error);
|
redirectAttributes.addFlashAttribute("error", error);
|
||||||
@@ -127,7 +127,7 @@ public class TranscodingSettingsController {
|
|||||||
} else {
|
} else {
|
||||||
transcodingService.createTranscoding(transcoding);
|
transcodingService.createTranscoding(transcoding);
|
||||||
}
|
}
|
||||||
if(error != null) {
|
if (error != null) {
|
||||||
redirectAttributes.addAttribute("newTranscoding", transcoding);
|
redirectAttributes.addAttribute("newTranscoding", transcoding);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -75,7 +75,7 @@ public class UserSettingsController {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
protected String displayForm(HttpServletRequest request, Model model) throws Exception {
|
protected String displayForm(HttpServletRequest request, Model model) throws Exception {
|
||||||
UserSettingsCommand command;
|
UserSettingsCommand command;
|
||||||
if(!model.containsAttribute("command")) {
|
if (!model.containsAttribute("command")) {
|
||||||
command = new UserSettingsCommand();
|
command = new UserSettingsCommand();
|
||||||
|
|
||||||
User user = getUser(request);
|
User user = getUser(request);
|
||||||
@@ -132,7 +132,7 @@ public class UserSettingsController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command, BindingResult bindingResult, RedirectAttributes redirectAttributes) throws Exception {
|
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command, BindingResult bindingResult, RedirectAttributes redirectAttributes) throws Exception {
|
||||||
|
|
||||||
if(!bindingResult.hasErrors()) {
|
if (!bindingResult.hasErrors()) {
|
||||||
if (command.isDeleteUser()) {
|
if (command.isDeleteUser()) {
|
||||||
deleteUser(command);
|
deleteUser(command);
|
||||||
} else if (command.isNewUser()) {
|
} else if (command.isNewUser()) {
|
||||||
@@ -154,7 +154,7 @@ public class UserSettingsController {
|
|||||||
private Integer getUserIndex(UserSettingsCommand command) {
|
private Integer getUserIndex(UserSettingsCommand command) {
|
||||||
List<User> allUsers = securityService.getAllUsers();
|
List<User> allUsers = securityService.getAllUsers();
|
||||||
for (int i = 0; i < allUsers.size(); i++) {
|
for (int i = 0; i < allUsers.size(); i++) {
|
||||||
if(StringUtils.equalsIgnoreCase(allUsers.get(i).getUsername(), command.getUsername())) {
|
if (StringUtils.equalsIgnoreCase(allUsers.get(i).getUsername(), command.getUsername())) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ public class LegacyHsqlDaoHelper extends GenericDaoHelper {
|
|||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if(conn != null)
|
if (conn != null)
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch(Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ public class MediaFileDao extends AbstractDao {
|
|||||||
args.put("type", MediaFile.MediaType.MUSIC.name());
|
args.put("type", MediaFile.MediaType.MUSIC.name());
|
||||||
args.put("folders", MusicFolder.toPathList(musicFolders));
|
args.put("folders", MusicFolder.toPathList(musicFolders));
|
||||||
return namedQueryOne("select " + QUERY_COLUMNS + " from media_file where artist = :artist " +
|
return namedQueryOne("select " + QUERY_COLUMNS + " from media_file where artist = :artist " +
|
||||||
"and title = :title and type = :type and present and folder in (:folders)" ,
|
"and title = :title and type = :type and present and folder in (:folders)",
|
||||||
rowMapper, args);
|
rowMapper, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class PlayerDao extends AbstractDao {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void createPlayer(Player player) {
|
public void createPlayer(Player player) {
|
||||||
Integer existingMax = getJdbcTemplate().queryForObject("select max(id) from player", Integer.class);
|
Integer existingMax = getJdbcTemplate().queryForObject("select max(id) from player", Integer.class);
|
||||||
if(existingMax == null) {
|
if (existingMax == null) {
|
||||||
existingMax = 0;
|
existingMax = 0;
|
||||||
}
|
}
|
||||||
int id = existingMax + 1;
|
int id = existingMax + 1;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class TranscodingDao extends AbstractDao {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void createTranscoding(Transcoding transcoding) {
|
public void createTranscoding(Transcoding transcoding) {
|
||||||
Integer existingMax = getJdbcTemplate().queryForObject("select max(id) from transcoding2", Integer.class);
|
Integer existingMax = getJdbcTemplate().queryForObject("select max(id) from transcoding2", Integer.class);
|
||||||
if(existingMax == null) {
|
if (existingMax == null) {
|
||||||
existingMax = 0;
|
existingMax = 0;
|
||||||
}
|
}
|
||||||
transcoding.setId(existingMax + 1);
|
transcoding.setId(existingMax + 1);
|
||||||
|
|||||||
@@ -84,19 +84,19 @@ public class UserDao extends AbstractDao {
|
|||||||
*/
|
*/
|
||||||
public User getUserByName(String username, boolean caseSensitive) {
|
public User getUserByName(String username, boolean caseSensitive) {
|
||||||
String sql;
|
String sql;
|
||||||
if(caseSensitive) {
|
if (caseSensitive) {
|
||||||
sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where username=?";
|
sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where username=?";
|
||||||
} else {
|
} else {
|
||||||
sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where UPPER(username)=UPPER(?)";
|
sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where UPPER(username)=UPPER(?)";
|
||||||
}
|
}
|
||||||
List<User> users = query(sql, userRowMapper, username);
|
List<User> users = query(sql, userRowMapper, username);
|
||||||
User user = null;
|
User user = null;
|
||||||
if(users.size() == 1) {
|
if (users.size() == 1) {
|
||||||
user = users.iterator().next();
|
user = users.iterator().next();
|
||||||
} else if (users.size() > 1) {
|
} else if (users.size() > 1) {
|
||||||
throw new RuntimeException("Too many matching users");
|
throw new RuntimeException("Too many matching users");
|
||||||
}
|
}
|
||||||
if(user != null) {
|
if (user != null) {
|
||||||
readRoles(user);
|
readRoles(user);
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
@@ -111,7 +111,7 @@ public class UserDao extends AbstractDao {
|
|||||||
public User getUserByEmail(String email) {
|
public User getUserByEmail(String email) {
|
||||||
String sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where email=?";
|
String sql = "select " + USER_COLUMNS + " from " + getUserTable() + " where email=?";
|
||||||
User user = queryOne(sql, userRowMapper, email);
|
User user = queryOne(sql, userRowMapper, email);
|
||||||
if(user != null) {
|
if (user != null) {
|
||||||
readRoles(user);
|
readRoles(user);
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class Version implements Comparable<Version> {
|
|||||||
* @return Whether this object is equals to another.
|
* @return Whether this object is equals to another.
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if(o instanceof Version) {
|
if (o instanceof Version) {
|
||||||
return internalVersion.equals(((Version)o).internalVersion);
|
return internalVersion.equals(((Version)o).internalVersion);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class GlobalSecurityConfig extends GlobalAuthenticationConfigurerAdapter
|
|||||||
}
|
}
|
||||||
auth.userDetailsService(securityService);
|
auth.userDetailsService(securityService);
|
||||||
String jwtKey = settingsService.getJWTKey();
|
String jwtKey = settingsService.getJWTKey();
|
||||||
if(StringUtils.isBlank(jwtKey)) {
|
if (StringUtils.isBlank(jwtKey)) {
|
||||||
logger.warn("Generating new jwt key");
|
logger.warn("Generating new jwt key");
|
||||||
jwtKey = JWTSecurityService.generateKey();
|
jwtKey = JWTSecurityService.generateKey();
|
||||||
settingsService.setJWTKey(jwtKey);
|
settingsService.setJWTKey(jwtKey);
|
||||||
|
|||||||
+7
-7
@@ -34,7 +34,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
@Override
|
@Override
|
||||||
public Authentication authenticate(Authentication auth) throws AuthenticationException {
|
public Authentication authenticate(Authentication auth) throws AuthenticationException {
|
||||||
JWTAuthenticationToken authentication = (JWTAuthenticationToken) auth;
|
JWTAuthenticationToken authentication = (JWTAuthenticationToken) auth;
|
||||||
if(authentication.getCredentials() == null || !(authentication.getCredentials() instanceof String)) {
|
if (authentication.getCredentials() == null || !(authentication.getCredentials() instanceof String)) {
|
||||||
logger.error("Credentials not present");
|
logger.error("Credentials not present");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -44,9 +44,9 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
authentication.setAuthenticated(true);
|
authentication.setAuthenticated(true);
|
||||||
|
|
||||||
// TODO:AD This is super unfortunate, but not sure there is a better way when using JSP
|
// TODO:AD This is super unfortunate, but not sure there is a better way when using JSP
|
||||||
if(StringUtils.contains(authentication.getRequestedPath(), "/WEB-INF/jsp/")) {
|
if (StringUtils.contains(authentication.getRequestedPath(), "/WEB-INF/jsp/")) {
|
||||||
logger.warn("BYPASSING AUTH FOR WEB-INF page");
|
logger.warn("BYPASSING AUTH FOR WEB-INF page");
|
||||||
} else if(!roughlyEqual(path.asString(), authentication.getRequestedPath())) {
|
} else if (!roughlyEqual(path.asString(), authentication.getRequestedPath())) {
|
||||||
throw new InsufficientAuthenticationException("Credentials not valid for path " + authentication
|
throw new InsufficientAuthenticationException("Credentials not valid for path " + authentication
|
||||||
.getRequestedPath() + ". They are valid for " + path.asString());
|
.getRequestedPath() + ". They are valid for " + path.asString());
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
|
|
||||||
private static boolean roughlyEqual(String expectedRaw, String requestedPathRaw) {
|
private static boolean roughlyEqual(String expectedRaw, String requestedPathRaw) {
|
||||||
logger.debug("Comparing expected [{}] vs requested [{}]", expectedRaw, requestedPathRaw);
|
logger.debug("Comparing expected [{}] vs requested [{}]", expectedRaw, requestedPathRaw);
|
||||||
if(StringUtils.isEmpty(expectedRaw)) {
|
if (StringUtils.isEmpty(expectedRaw)) {
|
||||||
logger.debug("False: empty expected");
|
logger.debug("False: empty expected");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
UriComponents expected = UriComponentsBuilder.fromUriString(expectedRaw).build();
|
UriComponents expected = UriComponentsBuilder.fromUriString(expectedRaw).build();
|
||||||
UriComponents requested = UriComponentsBuilder.fromUriString(requestedPathRaw).build();
|
UriComponents requested = UriComponentsBuilder.fromUriString(requestedPathRaw).build();
|
||||||
|
|
||||||
if(!Objects.equals(expected.getPath(), requested.getPath())) {
|
if (!Objects.equals(expected.getPath(), requested.getPath())) {
|
||||||
logger.debug("False: expected path [{}] does not match requested path [{}]",
|
logger.debug("False: expected path [{}] does not match requested path [{}]",
|
||||||
expected.getPath(), requested.getPath());
|
expected.getPath(), requested.getPath());
|
||||||
return false;
|
return false;
|
||||||
@@ -76,7 +76,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
MapDifference<String, List<String>> difference = Maps.difference(expected.getQueryParams(),
|
MapDifference<String, List<String>> difference = Maps.difference(expected.getQueryParams(),
|
||||||
requested.getQueryParams());
|
requested.getQueryParams());
|
||||||
|
|
||||||
if(!difference.entriesDiffering().isEmpty() ||
|
if (!difference.entriesDiffering().isEmpty() ||
|
||||||
!difference.entriesOnlyOnLeft().isEmpty() ||
|
!difference.entriesOnlyOnLeft().isEmpty() ||
|
||||||
difference.entriesOnlyOnRight().size() != 1 ||
|
difference.entriesOnlyOnRight().size() != 1 ||
|
||||||
difference.entriesOnlyOnRight().get(JWTSecurityService.JWT_PARAM_NAME) == null) {
|
difference.entriesOnlyOnRight().get(JWTSecurityService.JWT_PARAM_NAME) == null) {
|
||||||
@@ -84,7 +84,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Exception encountered while comparing paths", e);
|
logger.warn("Exception encountered while comparing paths", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -33,7 +33,7 @@ public class JWTRequestParameterProcessingFilter implements Filter {
|
|||||||
|
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
|
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
|
||||||
Optional<JWTAuthenticationToken> token = findToken(request);
|
Optional<JWTAuthenticationToken> token = findToken(request);
|
||||||
if(token.isPresent()) {
|
if (token.isPresent()) {
|
||||||
return authenticationManager.authenticate(token.get());
|
return authenticationManager.authenticate(token.get());
|
||||||
}
|
}
|
||||||
throw new AuthenticationServiceException("Invalid auth method");
|
throw new AuthenticationServiceException("Invalid auth method");
|
||||||
@@ -41,7 +41,7 @@ public class JWTRequestParameterProcessingFilter implements Filter {
|
|||||||
|
|
||||||
private static Optional<JWTAuthenticationToken> findToken(HttpServletRequest request) {
|
private static Optional<JWTAuthenticationToken> findToken(HttpServletRequest request) {
|
||||||
String token = request.getParameter(JWTSecurityService.JWT_PARAM_NAME);
|
String token = request.getParameter(JWTSecurityService.JWT_PARAM_NAME);
|
||||||
if(!StringUtils.isEmpty(token)) {
|
if (!StringUtils.isEmpty(token)) {
|
||||||
return Optional.of(new JWTAuthenticationToken(AuthorityUtils.NO_AUTHORITIES, token, request.getRequestURI() + "?" + request.getQueryString()));
|
return Optional.of(new JWTAuthenticationToken(AuthorityUtils.NO_AUTHORITIES, token, request.getRequestURI() + "?" + request.getQueryString()));
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -58,7 +58,7 @@ public class JWTRequestParameterProcessingFilter implements Filter {
|
|||||||
HttpServletRequest request = (HttpServletRequest) req;
|
HttpServletRequest request = (HttpServletRequest) req;
|
||||||
HttpServletResponse response = (HttpServletResponse) resp;
|
HttpServletResponse response = (HttpServletResponse) resp;
|
||||||
|
|
||||||
if(!findToken(request).isPresent()) {
|
if (!findToken(request).isPresent()) {
|
||||||
chain.doFilter(req, resp);
|
chain.doFilter(req, resp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public class ApacheCommonsConfigurationService {
|
|||||||
|
|
||||||
public ApacheCommonsConfigurationService() {
|
public ApacheCommonsConfigurationService() {
|
||||||
File propertyFile = SettingsService.getPropertyFile();
|
File propertyFile = SettingsService.getPropertyFile();
|
||||||
if(!propertyFile.exists()) {
|
if (!propertyFile.exists()) {
|
||||||
try {
|
try {
|
||||||
FileUtils.touch(propertyFile);
|
FileUtils.touch(propertyFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class NetworkService {
|
|||||||
xForardedHost = xForardedHost.split(",")[0];
|
xForardedHost = xForardedHost.split(",")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValidXForwardedHost(xForardedHost)) {
|
if (!isValidXForwardedHost(xForardedHost)) {
|
||||||
xForardedHost = request.getHeader(X_FORWARDED_SERVER);
|
xForardedHost = request.getHeader(X_FORWARDED_SERVER);
|
||||||
|
|
||||||
// If the request has been through multiple reverse proxies,
|
// If the request has been through multiple reverse proxies,
|
||||||
@@ -77,7 +77,7 @@ public class NetworkService {
|
|||||||
xForardedHost = xForardedHost.split(",")[0];
|
xForardedHost = xForardedHost.split(",")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValidXForwardedHost(xForardedHost)) {
|
if (!isValidXForwardedHost(xForardedHost)) {
|
||||||
throw new RuntimeException("Cannot calculate proxy uri without HTTP header " + X_FORWARDED_HOST);
|
throw new RuntimeException("Cannot calculate proxy uri without HTTP header " + X_FORWARDED_HOST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class NetworkService {
|
|||||||
String host = proxyHost.getHost();
|
String host = proxyHost.getHost();
|
||||||
int port = proxyHost.getPort();
|
int port = proxyHost.getPort();
|
||||||
String scheme = request.getHeader(X_FORWARDED_PROTO);
|
String scheme = request.getHeader(X_FORWARDED_PROTO);
|
||||||
if(StringUtils.isBlank(scheme)) {
|
if (StringUtils.isBlank(scheme)) {
|
||||||
throw new RuntimeException("Scheme not provided");
|
throw new RuntimeException("Scheme not provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class PlaylistService {
|
|||||||
throw new Exception("Unsupported playlist " + fileName);
|
throw new Exception("Unsupported playlist " + fileName);
|
||||||
}
|
}
|
||||||
PlaylistImportHandler importHandler = getImportHandler(inputSpecificPlaylist);
|
PlaylistImportHandler importHandler = getImportHandler(inputSpecificPlaylist);
|
||||||
LOG.debug("Using "+importHandler.getClass().getSimpleName()+" playlist import handler");
|
LOG.debug("Using " + importHandler.getClass().getSimpleName() + " playlist import handler");
|
||||||
|
|
||||||
Pair<List<MediaFile>, List<String>> result = importHandler.handle(inputSpecificPlaylist);
|
Pair<List<MediaFile>, List<String>> result = importHandler.handle(inputSpecificPlaylist);
|
||||||
|
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ public class PodcastService {
|
|||||||
private void downloadImage(PodcastChannel channel) {
|
private void downloadImage(PodcastChannel channel) {
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
try(CloseableHttpClient client = HttpClients.createDefault()) {
|
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||||
String imageUrl = channel.getImageUrl();
|
String imageUrl = channel.getImageUrl();
|
||||||
if (imageUrl == null) {
|
if (imageUrl == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class SettingsService {
|
|||||||
private void removeObsoleteProperties() {
|
private void removeObsoleteProperties() {
|
||||||
|
|
||||||
OBSOLETE_KEYS.forEach(oKey -> {
|
OBSOLETE_KEYS.forEach(oKey -> {
|
||||||
if(configurationService.containsKey(oKey)) {
|
if (configurationService.containsKey(oKey)) {
|
||||||
LOG.info("Removing obsolete property [" + oKey + ']');
|
LOG.info("Removing obsolete property [" + oKey + ']');
|
||||||
configurationService.clearProperty(oKey);
|
configurationService.clearProperty(oKey);
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ public class SettingsService {
|
|||||||
String oldHome = System.getProperty("libresonic.home");
|
String oldHome = System.getProperty("libresonic.home");
|
||||||
if (overrideHome != null) {
|
if (overrideHome != null) {
|
||||||
home = new File(overrideHome);
|
home = new File(overrideHome);
|
||||||
} else if(oldHome != null) {
|
} else if (oldHome != null) {
|
||||||
home = new File(oldHome);
|
home = new File(oldHome);
|
||||||
} else {
|
} else {
|
||||||
boolean isWindows = System.getProperty("os.name", "Windows").toLowerCase().startsWith("windows");
|
boolean isWindows = System.getProperty("os.name", "Windows").toLowerCase().startsWith("windows");
|
||||||
@@ -314,7 +314,7 @@ public class SettingsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(boolean updateSettingsChanged) {
|
public void save(boolean updateSettingsChanged) {
|
||||||
if(updateSettingsChanged) {
|
if (updateSettingsChanged) {
|
||||||
removeObsoleteProperties();
|
removeObsoleteProperties();
|
||||||
this.setLong(KEY_SETTINGS_CHANGED, System.currentTimeMillis());
|
this.setLong(KEY_SETTINGS_CHANGED, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ public class TranscodingService {
|
|||||||
List<Transcoding> transcodingsForPlayer = getTranscodingsForPlayer(player);
|
List<Transcoding> transcodingsForPlayer = getTranscodingsForPlayer(player);
|
||||||
for (Transcoding transcoding : transcodingsForPlayer) {
|
for (Transcoding transcoding : transcodingsForPlayer) {
|
||||||
// special case for now as video must have a transcoding
|
// special case for now as video must have a transcoding
|
||||||
if(mediaFile.isVideo() && StringUtils.equalsIgnoreCase(preferredTargetFormat, transcoding.getTargetFormat())) {
|
if (mediaFile.isVideo() && StringUtils.equalsIgnoreCase(preferredTargetFormat, transcoding.getTargetFormat())) {
|
||||||
LOG.debug("Detected source to target format match for video");
|
LOG.debug("Detected source to target format match for video");
|
||||||
return transcoding;
|
return transcoding;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ public class UPnPService {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
if(settingsService.isDlnaEnabled() || settingsService.isSonosEnabled()) {
|
if (settingsService.isDlnaEnabled() || settingsService.isSonosEnabled()) {
|
||||||
ensureServiceStarted();
|
ensureServiceStarted();
|
||||||
if(settingsService.isDlnaEnabled()) {
|
if (settingsService.isDlnaEnabled()) {
|
||||||
// Start DLNA media server?
|
// Start DLNA media server?
|
||||||
setMediaServerEnabled(true);
|
setMediaServerEnabled(true);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class UPnPService {
|
|||||||
|
|
||||||
public void ensureServiceStarted() {
|
public void ensureServiceStarted() {
|
||||||
running.getAndUpdate(bo -> {
|
running.getAndUpdate(bo -> {
|
||||||
if(!bo) {
|
if (!bo) {
|
||||||
startService();
|
startService();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ public class VersionService {
|
|||||||
|
|
||||||
Function<String, Version> convertToVersion = s -> {
|
Function<String, Version> convertToVersion = s -> {
|
||||||
Matcher match = VERSION_REGEX.matcher(s);
|
Matcher match = VERSION_REGEX.matcher(s);
|
||||||
if(!match.matches()) {
|
if (!match.matches()) {
|
||||||
throw new RuntimeException("Unexpected tag format " + s);
|
throw new RuntimeException("Unexpected tag format " + s);
|
||||||
}
|
}
|
||||||
return new Version(match.group(1));
|
return new Version(match.group(1));
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ public class DefaultPlaylistImportHandler implements PlaylistImportHandler {
|
|||||||
URI uri = media.getSource().getURI();
|
URI uri = media.getSource().getURI();
|
||||||
File file = new File(uri);
|
File file = new File(uri);
|
||||||
MediaFile mediaFile = mediaFileService.getMediaFile(file);
|
MediaFile mediaFile = mediaFileService.getMediaFile(file);
|
||||||
if(mediaFile != null) {
|
if (mediaFile != null) {
|
||||||
mediaFiles.add(mediaFile);
|
mediaFiles.add(mediaFile);
|
||||||
} else {
|
} else {
|
||||||
errors.add("Cannot find media file " + file);
|
errors.add("Cannot find media file " + file);
|
||||||
|
|||||||
+4
-4
@@ -34,15 +34,15 @@ public class XspfPlaylistImportHandler implements PlaylistImportHandler {
|
|||||||
Playlist xspfPlaylist = (Playlist) inputSpecificPlaylist;
|
Playlist xspfPlaylist = (Playlist) inputSpecificPlaylist;
|
||||||
xspfPlaylist.getTracks().forEach(track -> {
|
xspfPlaylist.getTracks().forEach(track -> {
|
||||||
MediaFile mediaFile = null;
|
MediaFile mediaFile = null;
|
||||||
for(StringContainer sc : track.getStringContainers()) {
|
for (StringContainer sc : track.getStringContainers()) {
|
||||||
if(sc instanceof Location) {
|
if (sc instanceof Location) {
|
||||||
Location location = (Location) sc;
|
Location location = (Location) sc;
|
||||||
try {
|
try {
|
||||||
File file = new File(new URI(location.getText()));
|
File file = new File(new URI(location.getText()));
|
||||||
mediaFile = mediaFileService.getMediaFile(file);
|
mediaFile = mediaFileService.getMediaFile(file);
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
if(mediaFile == null) {
|
if (mediaFile == null) {
|
||||||
try {
|
try {
|
||||||
File file = new File(sc.getText());
|
File file = new File(sc.getText());
|
||||||
mediaFile = mediaFileService.getMediaFile(file);
|
mediaFile = mediaFileService.getMediaFile(file);
|
||||||
@@ -50,7 +50,7 @@ public class XspfPlaylistImportHandler implements PlaylistImportHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mediaFile != null) {
|
if (mediaFile != null) {
|
||||||
mediaFiles.add(mediaFile);
|
mediaFiles.add(mediaFile);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = "Could not find media file matching ";
|
String errorMsg = "Could not find media file matching ";
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public enum IndexType {
|
|||||||
FieldNames.ARTIST),
|
FieldNames.ARTIST),
|
||||||
boosts(
|
boosts(
|
||||||
entry(FieldNames.ARTIST, 2F))),
|
entry(FieldNames.ARTIST, 2F))),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ public class ArtistUpnpProcessor extends UpnpContentProcessor <Artist, Album> {
|
|||||||
List<MusicFolder> allFolders = getDispatcher().getSettingsService().getAllMusicFolders();
|
List<MusicFolder> allFolders = getDispatcher().getSettingsService().getAllMusicFolders();
|
||||||
List<Artist> allArtists = getArtistDao().getAlphabetialArtists(0, Integer.MAX_VALUE, allFolders);
|
List<Artist> allArtists = getArtistDao().getAlphabetialArtists(0, Integer.MAX_VALUE, allFolders);
|
||||||
// alpha artists doesn't quite work :P
|
// alpha artists doesn't quite work :P
|
||||||
allArtists.sort((Artist o1, Artist o2)->o1.getName().replaceAll("\\W", "").compareToIgnoreCase(o2.getName().replaceAll("\\W", "")));
|
allArtists.sort((Artist o1, Artist o2) -> o1.getName().replaceAll("\\W", "").compareToIgnoreCase(o2.getName().replaceAll("\\W", "")));
|
||||||
|
|
||||||
return allArtists;
|
return allArtists;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ public abstract class CustomContentDirectory extends AbstractContentDirectorySer
|
|||||||
|
|
||||||
protected String getBaseUrl() {
|
protected String getBaseUrl() {
|
||||||
String dlnaBaseLANURL = settingsService.getDlnaBaseLANURL();
|
String dlnaBaseLANURL = settingsService.getDlnaBaseLANURL();
|
||||||
if(StringUtils.isBlank(dlnaBaseLANURL)) {
|
if (StringUtils.isBlank(dlnaBaseLANURL)) {
|
||||||
throw new RuntimeException("DLNA Base LAN URL is not set correctly");
|
throw new RuntimeException("DLNA Base LAN URL is not set correctly");
|
||||||
}
|
}
|
||||||
return dlnaBaseLANURL;
|
return dlnaBaseLANURL;
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ public class DispatchingContentDirectory extends CustomContentDirectory {
|
|||||||
|
|
||||||
|
|
||||||
private UpnpContentProcessor findProcessor(String type) {
|
private UpnpContentProcessor findProcessor(String type) {
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case CONTAINER_ID_ROOT:
|
case CONTAINER_ID_ROOT:
|
||||||
return getRootProcessor();
|
return getRootProcessor();
|
||||||
case CONTAINER_ID_PLAYLIST_PREFIX:
|
case CONTAINER_ID_PLAYLIST_PREFIX:
|
||||||
|
|||||||
+2
-2
@@ -58,9 +58,9 @@ public class GenreUpnpProcessor extends UpnpContentProcessor <Genre, MediaFile>
|
|||||||
// sort items
|
// sort items
|
||||||
}
|
}
|
||||||
List<Genre> selectedItems = Util.subList(allItems, firstResult, maxResults);
|
List<Genre> selectedItems = Util.subList(allItems, firstResult, maxResults);
|
||||||
for (int i=0; i < selectedItems.size(); i++) {
|
for (int i = 0; i < selectedItems.size(); i++) {
|
||||||
Genre item = selectedItems.get(i);
|
Genre item = selectedItems.get(i);
|
||||||
didl.addContainer(createContainer(item, (int) (i+firstResult)));
|
didl.addContainer(createContainer(item, (int) (i + firstResult)));
|
||||||
}
|
}
|
||||||
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
|
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ public class MediaFileUpnpProcessor extends UpnpContentProcessor <MediaFile, Med
|
|||||||
|
|
||||||
public List<MediaFile> getChildren(MediaFile item) {
|
public List<MediaFile> getChildren(MediaFile item) {
|
||||||
List<MediaFile> children = getMediaFileService().getChildrenOf(item, true, true, true);
|
List<MediaFile> children = getMediaFileService().getChildrenOf(item, true, true, true);
|
||||||
children.sort((MediaFile o1, MediaFile o2)->o1.getPath().replaceAll("\\W", "").compareToIgnoreCase(o2.getPath().replaceAll("\\W", "")));
|
children.sort((MediaFile o1, MediaFile o2) -> o1.getPath().replaceAll("\\W", "").compareToIgnoreCase(o2.getPath().replaceAll("\\W", "")));
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ public class CustomPropertySourceConfigurer implements
|
|||||||
private void addDataSourceProfile(ConfigurableWebApplicationContext ctx) {
|
private void addDataSourceProfile(ConfigurableWebApplicationContext ctx) {
|
||||||
DataSourceConfigType dataSourceConfigType;
|
DataSourceConfigType dataSourceConfigType;
|
||||||
String rawType = ctx.getEnvironment().getProperty(DATASOURCE_CONFIG_TYPE);
|
String rawType = ctx.getEnvironment().getProperty(DATASOURCE_CONFIG_TYPE);
|
||||||
if(StringUtils.isNotBlank(rawType)) {
|
if (StringUtils.isNotBlank(rawType)) {
|
||||||
dataSourceConfigType = DataSourceConfigType.valueOf(StringUtils.upperCase(rawType));
|
dataSourceConfigType = DataSourceConfigType.valueOf(StringUtils.upperCase(rawType));
|
||||||
} else {
|
} else {
|
||||||
dataSourceConfigType = DataSourceConfigType.LEGACY;
|
dataSourceConfigType = DataSourceConfigType.LEGACY;
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ public class DbmsVersionPrecondition implements CustomPrecondition {
|
|||||||
try {
|
try {
|
||||||
int dbMajor = database.getDatabaseMajorVersion();
|
int dbMajor = database.getDatabaseMajorVersion();
|
||||||
int dbMinor = database.getDatabaseMinorVersion();
|
int dbMinor = database.getDatabaseMinorVersion();
|
||||||
if(major != null && !major.equals(dbMajor)) {
|
if (major != null && !major.equals(dbMajor)) {
|
||||||
throw new CustomPreconditionFailedException("DBMS Major Version Precondition failed: expected " + major + ", got " + dbMajor);
|
throw new CustomPreconditionFailedException("DBMS Major Version Precondition failed: expected " + major + ", got " + dbMajor);
|
||||||
}
|
}
|
||||||
if(minor != null && !minor.equals(dbMinor)) {
|
if (minor != null && !minor.equals(dbMinor)) {
|
||||||
throw new CustomPreconditionFailedException("DBMS Minor Version Precondition failed: expected " + minor + ", got " + dbMinor);
|
throw new CustomPreconditionFailedException("DBMS Minor Version Precondition failed: expected " + minor + ", got " + dbMinor);
|
||||||
}
|
}
|
||||||
} catch (DatabaseException e) {
|
} catch (DatabaseException e) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class HsqlDatabase extends liquibase.database.core.HsqlDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsSchemas() {
|
public boolean supportsSchemas() {
|
||||||
try {
|
try {
|
||||||
if(getDatabaseMajorVersion() < 2) {
|
if (getDatabaseMajorVersion() < 2) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return super.supportsSchemas();
|
return super.supportsSchemas();
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public class RegisterPrecompiledJSPInitializer implements ServletContextInitiali
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartup(ServletContext servletContext) {
|
public void onStartup(ServletContext servletContext) {
|
||||||
if(SettingsService.isDevelopmentMode()) {
|
if (SettingsService.isDevelopmentMode()) {
|
||||||
logger.debug("Not registering precompiled jsps");
|
logger.debug("Not registering precompiled jsps");
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Registering precompiled jsps");
|
logger.debug("Registering precompiled jsps");
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class SpringLiquibase extends liquibase.integration.spring.SpringLiquibas
|
|||||||
logger.trace("Starting Liquibase Update");
|
logger.trace("Starting Liquibase Update");
|
||||||
try {
|
try {
|
||||||
super.afterPropertiesSet();
|
super.afterPropertiesSet();
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("===============================================");
|
logger.error("===============================================");
|
||||||
logger.error("An exception occurred during database migration");
|
logger.error("An exception occurred during database migration");
|
||||||
logger.error("A rollback file has been generated at " + rollbackFile);
|
logger.error("A rollback file has been generated at " + rollbackFile);
|
||||||
@@ -66,9 +66,9 @@ public class SpringLiquibase extends liquibase.integration.spring.SpringLiquibas
|
|||||||
|
|
||||||
private void removeCurrentHsqlDb(List<Database> implementedDatabases) {
|
private void removeCurrentHsqlDb(List<Database> implementedDatabases) {
|
||||||
Iterator<Database> iterator = implementedDatabases.iterator();
|
Iterator<Database> iterator = implementedDatabases.iterator();
|
||||||
while(iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Database db = iterator.next();
|
Database db = iterator.next();
|
||||||
if(db instanceof liquibase.database.core.HsqlDatabase) {
|
if (db instanceof liquibase.database.core.HsqlDatabase) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ServletDef {
|
public class ServletDef {
|
||||||
@XmlElement(name="servlet-name")
|
@XmlElement(name = "servlet-name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@XmlElement(name="servlet-class")
|
@XmlElement(name = "servlet-class")
|
||||||
private String sclass;
|
private String sclass;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
+2
-2
@@ -8,10 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ServletMappingDef {
|
public class ServletMappingDef {
|
||||||
@XmlElement(name="servlet-name")
|
@XmlElement(name = "servlet-name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@XmlElement(name="url-pattern")
|
@XmlElement(name = "url-pattern")
|
||||||
private String urlPattern;
|
private String urlPattern;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name="web-app")
|
@XmlRootElement(name = "web-app")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class WebApp {
|
public class WebApp {
|
||||||
@XmlElement(name="servlet")
|
@XmlElement(name = "servlet")
|
||||||
private List<ServletDef> servletDefs;
|
private List<ServletDef> servletDefs;
|
||||||
|
|
||||||
@XmlElement(name="servlet-mapping")
|
@XmlElement(name = "servlet-mapping")
|
||||||
private List<ServletMappingDef> servletMappingDefs;
|
private List<ServletMappingDef> servletMappingDefs;
|
||||||
|
|
||||||
public List<ServletDef> getServletDefs() {
|
public List<ServletDef> getServletDefs() {
|
||||||
|
|||||||
@@ -31,11 +31,22 @@
|
|||||||
<module name="EqualsHashCode"/>
|
<module name="EqualsHashCode"/>
|
||||||
<module name="Indentation"/>
|
<module name="Indentation"/>
|
||||||
<module name="InnerAssignment"/>
|
<module name="InnerAssignment"/>
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
<module name="NoWhitespaceBefore">
|
||||||
|
<property name="allowLineBreaks" value="true"/>
|
||||||
|
</module>
|
||||||
<module name="OneStatementPerLine"/>
|
<module name="OneStatementPerLine"/>
|
||||||
<module name="ParenPadCheck"/>
|
<module name="ParenPadCheck"/>
|
||||||
<module name="RedundantImport"/>
|
<module name="RedundantImport"/>
|
||||||
<module name="StringLiteralEquality"/>
|
<module name="StringLiteralEquality"/>
|
||||||
<module name="TypecastParenPad"/>
|
<module name="TypecastParenPad"/>
|
||||||
<module name="UnusedImports"/>
|
<module name="UnusedImports"/>
|
||||||
|
<module name="WhitespaceAround">
|
||||||
|
<property name="allowEmptyCatches" value="true"/>
|
||||||
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
|
<property name="allowEmptyLambdas" value="true"/>
|
||||||
|
<property name="allowEmptyMethods" value="true"/>
|
||||||
|
<property name="allowEmptyTypes" value="true"/>
|
||||||
|
</module>
|
||||||
</module>
|
</module>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user