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