Merge remote-tracking branch 'origin/pr/1434'

master
Andrew DeMaria 5 years ago
commit ec426fc1ed
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 4
      airsonic-main/src/main/java/org/airsonic/player/ajax/LyricsService.java
  2. 4
      airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java
  3. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/AvatarUploadController.java
  4. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/ChangeCoverArtController.java
  5. 8
      airsonic-main/src/main/java/org/airsonic/player/controller/CoverArtController.java
  6. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/EditTagsController.java
  7. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/GeneralSettingsController.java
  8. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/HomeController.java
  9. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/LeftController.java
  10. 4
      airsonic-main/src/main/java/org/airsonic/player/controller/M3UController.java
  11. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/MainController.java
  12. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/MoreController.java
  13. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/PersonalSettingsController.java
  14. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/PlayerSettingsController.java
  15. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/PodcastController.java
  16. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/ProxyController.java
  17. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/RightController.java
  18. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/SettingsController.java
  19. 10
      airsonic-main/src/main/java/org/airsonic/player/controller/ShareManagementController.java
  20. 3
      airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java
  21. 6
      airsonic-main/src/main/java/org/airsonic/player/dao/AbstractDao.java
  22. 4
      airsonic-main/src/main/java/org/airsonic/player/domain/InternetRadioSource.java
  23. 2
      airsonic-main/src/main/java/org/airsonic/player/domain/MediaFileComparator.java
  24. 24
      airsonic-main/src/main/java/org/airsonic/player/domain/PlayQueue.java
  25. 4
      airsonic-main/src/main/java/org/airsonic/player/monitor/MetricsManager.java
  26. 10
      airsonic-main/src/main/java/org/airsonic/player/security/JWTRequestParameterProcessingFilter.java
  27. 15
      airsonic-main/src/main/java/org/airsonic/player/service/InternetRadioService.java
  28. 3
      airsonic-main/src/main/java/org/airsonic/player/service/MediaScannerService.java
  29. 2
      airsonic-main/src/main/java/org/airsonic/player/service/NetworkService.java
  30. 2
      airsonic-main/src/main/java/org/airsonic/player/service/search/DocumentFactory.java
  31. 4
      airsonic-main/src/main/java/org/airsonic/player/service/search/SearchServiceImpl.java
  32. 2
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java
  33. 2
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/ArtistUpnpProcessor.java
  34. 2
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/GenreUpnpProcessor.java
  35. 2
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/UpnpContentProcessor.java
  36. 2
      airsonic-main/src/main/java/org/airsonic/player/spring/RegisterPrecompiledJSPInitializer.java
  37. 2
      airsonic-main/src/test/java/org/airsonic/player/MissingTranslations.java
  38. 2
      airsonic-main/src/test/java/org/airsonic/player/domain/VersionTestCase.java
  39. 2
      airsonic-main/src/test/java/org/airsonic/player/service/search/QueryFactoryTestCase.java
  40. 2
      airsonic-main/src/test/java/org/airsonic/player/validator/PasswordSettingsValidatorTestCase.java
  41. 8
      checkstyle.xml

@ -97,8 +97,8 @@ public class LyricsService {
Namespace ns = root.getNamespace();
String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
String song = root.getChildText("LyricSong", ns);
String artist = root.getChildText("LyricArtist", ns);
String song = root.getChildText("LyricSong", ns);
String artist = root.getChildText("LyricArtist", ns);
return new LyricsInfo(lyric, artist, song);
}

@ -244,7 +244,9 @@ public class PlayQueueService {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
InternetRadio radio = internetRadioDao.getInternetRadioById(id);
if (!radio.isEnabled()) { throw new Exception("Radio is not enabled"); }
if (!radio.isEnabled()) {
throw new Exception("Radio is not enabled");
}
Player player = resolvePlayer();
return doPlayInternetRadio(request, player, radio).setStartPlayerAt(0);

@ -56,7 +56,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/avatarUpload")
public class AvatarUploadController {
public class AvatarUploadController {
private static final Logger LOG = LoggerFactory.getLogger(AvatarUploadController.class);
private static final int MAX_AVATAR_SIZE = 64;

@ -42,7 +42,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/changeCoverArt")
public class ChangeCoverArtController {
public class ChangeCoverArtController {
@Autowired
private MediaFileService mediaFileService;

@ -300,7 +300,7 @@ public class CoverArtController implements LastModified {
throw new RuntimeException(e);
}
} else {
is = new FileInputStream(file);
is = new FileInputStream(file);
mimeType = StringUtil.getMimeType(FilenameUtils.getExtension(file.getName()));
}
return Pair.of(is, mimeType);
@ -385,13 +385,11 @@ public class CoverArtController implements LastModified {
in = getImageInputStream(coverArt);
if (in == null) {
reason = "getImageInputStream";
}
else {
} else {
BufferedImage bimg = ImageIO.read(in);
if (bimg == null) {
reason = "ImageIO.read";
}
else {
} else {
return scale(bimg, size, size);
}
}

@ -47,7 +47,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/editTags")
public class EditTagsController {
public class EditTagsController {
@Autowired
private MetaDataParserFactory metaDataParserFactory;

@ -40,7 +40,7 @@ import java.util.Locale;
*/
@Controller
@RequestMapping("/generalSettings")
public class GeneralSettingsController {
public class GeneralSettingsController {
@Autowired
private SettingsService settingsService;

@ -42,7 +42,7 @@ import static org.springframework.web.bind.ServletRequestUtils.getStringParamete
*/
@Controller
@RequestMapping("/home")
public class HomeController {
public class HomeController {
private static final int LIST_SIZE = 40;

@ -45,7 +45,7 @@ import java.util.*;
*/
@Controller
@RequestMapping("/left")
public class LeftController {
public class LeftController {
// Update this time if you want to force a refresh in clients.
private static final Calendar LAST_COMPATIBILITY_TIME = Calendar.getInstance();

@ -46,7 +46,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/play.m3u")
public class M3UController {
public class M3UController {
@Autowired
private PlayerService playerService;
@ -89,7 +89,7 @@ public class M3UController {
}
out.println("#EXTINF:" + duration + "," + mediaFile.getArtist() + " - " + mediaFile.getTitle());
String urlNoAuth = url + "player=" + player.getId() + "&id=" + mediaFile.getId() + "&suffix=." +
String urlNoAuth = url + "player=" + player.getId() + "&id=" + mediaFile.getId() + "&suffix=." +
transcodingService.getSuffix(player, mediaFile, null);
String urlWithAuth = jwtSecurityService.addJWTToken(urlNoAuth);
out.println(urlWithAuth);

@ -44,7 +44,7 @@ import java.util.stream.Collectors;
*/
@Controller
@RequestMapping("/main")
public class MainController {
public class MainController {
@Autowired
private SecurityService securityService;

@ -48,7 +48,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/more")
public class MoreController {
public class MoreController {
@Autowired
private SettingsService settingsService;

@ -45,7 +45,7 @@ import java.util.Locale;
*/
@Controller
@RequestMapping("/personalSettings")
public class PersonalSettingsController {
public class PersonalSettingsController {
@Autowired
private SettingsService settingsService;

@ -49,7 +49,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/playerSettings")
public class PlayerSettingsController {
public class PlayerSettingsController {
@Autowired
private PlayerService playerService;

@ -45,7 +45,7 @@ import java.util.*;
*/
@Controller
@RequestMapping("/podcast")
public class PodcastController {
public class PodcastController {
private static final DateFormat RSS_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
@Autowired

@ -46,7 +46,7 @@ import static org.springframework.http.HttpStatus.OK;
*/
@Controller
@RequestMapping("/proxy")
public class ProxyController {
public class ProxyController {
@GetMapping
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

@ -41,7 +41,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/right")
public class RightController {
public class RightController {
@Autowired
private SettingsService settingsService;

@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletRequest;
*/
@Controller
@RequestMapping("/settings")
public class SettingsController {
public class SettingsController {
@Autowired
private SecurityService securityService;

@ -44,7 +44,7 @@ import java.util.*;
*/
@Controller
@RequestMapping("/createShare")
public class ShareManagementController {
public class ShareManagementController {
@Autowired
private MediaFileService mediaFileService;
@ -109,15 +109,11 @@ public class ShareManagementController {
for (int index : indexes) {
result.add(children.get(index));
}
}
else if (playerId != null) {
} else if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
PlayQueue playQueue = player.getPlayQueue();
result = playQueue.getFiles();
}
else if (playlistId != null) {
} else if (playlistId != null) {
result = playlistService.getFilesInPlaylist(playlistId);
}

@ -2244,8 +2244,7 @@ public class SubsonicRESTController {
private AlbumInfo getAlbumInfoInternal(AlbumNotes albumNotes) {
AlbumInfo result = new AlbumInfo();
if (albumNotes != null)
{
if (albumNotes != null) {
result.setNotes(albumNotes.getNotes());
result.setMusicBrainzId(albumNotes.getMusicBrainzId());
result.setLastFmUrl(albumNotes.getLastFmUrl());

@ -60,7 +60,7 @@ public class AbstractDao {
}
protected String questionMarks(String columns) {
int numberOfColumns = StringUtils.countMatches(columns, ",") + 1;
int numberOfColumns = StringUtils.countMatches(columns, ",") + 1;
return StringUtils.repeat("?", ", ", numberOfColumns);
}
@ -179,6 +179,8 @@ public class AbstractDao {
this.daoHelper = daoHelper;
}
public void checkpoint() { daoHelper.checkpoint(); }
public void checkpoint() {
daoHelper.checkpoint();
}
}

@ -7,5 +7,7 @@ public class InternetRadioSource {
this.streamUrl = streamUrl;
}
public String getStreamUrl() { return streamUrl; }
public String getStreamUrl() {
return streamUrl;
}
}

@ -74,7 +74,7 @@ public class MediaFileComparator implements Comparator<MediaFile> {
return a.getPath().compareToIgnoreCase(b.getPath());
}
private <T extends Comparable<T>> int nullSafeCompare(T a, T b, boolean nullIsSmaller) {
private <T extends Comparable<T>> int nullSafeCompare(T a, T b, boolean nullIsSmaller) {
if (a == null && b == null) {
return 0;
}

@ -356,14 +356,18 @@ public class PlayQueue {
*
* @return Whether the play queue is a shuffle radio mode.
*/
public synchronized boolean isShuffleRadioEnabled() { return this.randomSearchCriteria != null; }
public synchronized boolean isShuffleRadioEnabled() {
return this.randomSearchCriteria != null;
}
/**
* Returns whether the play queue is a internet radio mode.
*
* @return Whether the play queue is a internet radio mode.
*/
public synchronized boolean isInternetRadioEnabled() { return this.internetRadio != null; }
public synchronized boolean isInternetRadioEnabled() {
return this.internetRadio != null;
}
/**
* Revert the last operation.
@ -405,28 +409,36 @@ public class PlayQueue {
*
* @param internetRadio An internet radio, or <code>null</code> if this is not an internet radio playlist
*/
public void setInternetRadio(InternetRadio internetRadio) { this.internetRadio = internetRadio; }
public void setInternetRadio(InternetRadio internetRadio) {
this.internetRadio = internetRadio;
}
/**
* Gets the current internet radio
*
* @return The current internet radio, or <code>null</code> if this is not an internet radio playlist
*/
public InternetRadio getInternetRadio() { return internetRadio; }
public InternetRadio getInternetRadio() {
return internetRadio;
}
/**
* Returns the criteria used to generate this random playlist
*
* @return The search criteria, or <code>null</code> if this is not a random playlist.
*/
public synchronized RandomSearchCriteria getRandomSearchCriteria() { return randomSearchCriteria; }
public synchronized RandomSearchCriteria getRandomSearchCriteria() {
return randomSearchCriteria;
}
/**
* Sets the criteria used to generate this random playlist
*
* @param randomSearchCriteria The search criteria, or <code>null</code> if this is not a random playlist.
*/
public synchronized void setRandomSearchCriteria(RandomSearchCriteria randomSearchCriteria) { this.randomSearchCriteria = randomSearchCriteria; }
public synchronized void setRandomSearchCriteria(RandomSearchCriteria randomSearchCriteria) {
this.randomSearchCriteria = randomSearchCriteria;
}
/**
* Returns the total length in bytes.

@ -99,7 +99,7 @@ public class MetricsManager {
public Timer timer(Class clazz, String name) {
com.codahale.metrics.Timer t = metrics.timer(MetricRegistry.name(clazz,name));
com.codahale.metrics.Timer.Context tContext = t.time();
com.codahale.metrics.Timer.Context tContext = t.time();
return new Timer(tContext);
}
@ -143,7 +143,7 @@ public class MetricsManager {
}
@Override
public void close() {
public void close() {
// Does nothing
}
}

@ -76,19 +76,15 @@ public class JWTRequestParameterProcessingFilter implements Filter {
// authentication
return;
}
}
catch (InternalAuthenticationServiceException failed) {
} catch (InternalAuthenticationServiceException failed) {
LOG.error(
"An internal error occurred while trying to authenticate the user.",
failed);
unsuccessfulAuthentication(request, response, failed);
return;
}
catch (AuthenticationException failed) {
// Authentication failed
unsuccessfulAuthentication(request, response, failed);
} catch (AuthenticationException e) {
unsuccessfulAuthentication(request, response, e);
return;
}

@ -43,14 +43,18 @@ public class InternetRadioService {
* Generic exception class for playlists.
*/
private class PlaylistException extends Exception {
public PlaylistException(String message) { super(message); }
public PlaylistException(String message) {
super(message);
}
}
/**
* Exception thrown when the remote playlist is too large to be parsed completely.
*/
private class PlaylistTooLarge extends PlaylistException {
public PlaylistTooLarge(String message) { super(message); }
public PlaylistTooLarge(String message) {
super(message);
}
}
/**
@ -66,7 +70,9 @@ public class InternetRadioService {
* Exception thrown when too many redirects occurred when retrieving a remote playlist.
*/
private class PlaylistHasTooManyRedirects extends PlaylistException {
public PlaylistHasTooManyRedirects(String message) { super(message); }
public PlaylistHasTooManyRedirects(String message) {
super(message);
}
}
public InternetRadioService() {
@ -233,8 +239,7 @@ public class InternetRadioService {
} else {
playlist = SpecificPlaylistFactory.getInstance().readFrom(in, contentEncoding);
}
}
finally {
} finally {
urlConnection.disconnect();
}
if (playlist == null) {

@ -270,8 +270,7 @@ public class MediaScannerService {
}
if (file.isAlbum()) {
genres.incrementAlbumCount(genre);
}
else if (file.isAudio()) {
} else if (file.isAudio()) {
genres.incrementSongCount(genre);
}
}

@ -53,7 +53,7 @@ public class NetworkService {
}
String baseUrl = uri.toString() + "/";
LOG.debug("Calculated base url to " + baseUrl);
LOG.debug("Calculated base url to " + baseUrl);
return baseUrl;
} catch (MalformedURLException | URISyntaxException e) {
throw new RuntimeException("Could not calculate base url: " + e.getMessage());

@ -97,7 +97,7 @@ public class DocumentFactory {
doc.add(new StoredField(field, value, TYPE_KEY));
};
private BiConsumer<@NonNull Document, @NonNull String> fieldMediatype = (doc, value) ->
private BiConsumer<@NonNull Document, @NonNull String> fieldMediatype = (doc, value) ->
fieldKey.accept(doc, FieldNames.MEDIA_TYPE, value);
private BiConsumer<@NonNull Document, @NonNull String> fieldFolderPath = (doc, value) ->

@ -44,9 +44,9 @@ public class SearchServiceImpl implements SearchService {
private static final Logger LOG = LoggerFactory.getLogger(SearchServiceImpl.class);
@Autowired
private QueryFactory queryFactory;
private QueryFactory queryFactory;
@Autowired
private IndexManager indexManager;
private IndexManager indexManager;
@Autowired
private SearchServiceUtilities util;

@ -117,7 +117,7 @@ public class AlbumUpnpProcessor extends UpnpContentProcessor <Album, MediaFile>
List<Album> albumList = null;
if (album.getComment().startsWith(ALL_BY_ARTIST)) {
ArtistUpnpProcessor ap = getDispatcher().getArtistProcessor();
albumList = ap.getChildren(ap.getItemById(album.getComment().replaceAll(ALL_BY_ARTIST + "_", "")));
albumList = ap.getChildren(ap.getItemById(album.getComment().replaceAll(ALL_BY_ARTIST + "_", "")));
} else if (album.getComment().equalsIgnoreCase(ALL_RECENT)) {
albumList = getDispatcher().getRecentAlbumProcessor().getAllItems();
} else {

@ -73,7 +73,7 @@ public class ArtistUpnpProcessor extends UpnpContentProcessor <Artist, Album> {
return getArtistDao().getArtist(Integer.parseInt(id));
}
public List<Album> getChildren(Artist artist) {
public List<Album> getChildren(Artist artist) {
List<MusicFolder> allFolders = getDispatcher().getSettingsService().getAllMusicFolders();
List<Album> allAlbums = getAlbumProcessor().getAlbumDao().getAlbumsForArtist(artist.getName(), allFolders);
if (allAlbums.size() > 1) {

@ -93,7 +93,7 @@ public class GenreUpnpProcessor extends UpnpContentProcessor <Genre, MediaFile>
return null;
}
public List<MediaFile> getChildren(Genre item) {
public List<MediaFile> getChildren(Genre item) {
List<MusicFolder> allFolders = getDispatcher().getSettingsService().getAllMusicFolders();
return getDispatcher().getMediaFileProcessor().getMediaFileDao().getSongsByGenre(item.getName(), 0, Integer.MAX_VALUE, allFolders);
}

@ -125,7 +125,7 @@ public abstract class UpnpContentProcessor<T extends Object, U extends Object> {
SortCriterion[] orderBy) {
DIDLContent didl = new DIDLContent();
Class clazz = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
Class clazz = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
try {
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();

@ -38,7 +38,7 @@ public class RegisterPrecompiledJSPInitializer implements ServletContextInitiali
private static void registerPrecompiledJSPs(ServletContext servletContext) {
WebApp webApp = parseXmlFragment();
for (ServletDef def : webApp.getServletDefs()) {
for (ServletDef def : webApp.getServletDefs()) {
LOG.trace("Registering precompiled JSP: {} -> {}", def.getName(), def.getSclass());
ServletRegistration.Dynamic reg = servletContext.addServlet(def.getName(), def.getSclass());
// Need to set loadOnStartup somewhere between 0 and 128. 0 is highest priority. 99 should be fine

@ -6,7 +6,7 @@ import java.util.Properties;
import java.util.SortedMap;
import java.util.TreeMap;
public class MissingTranslations {
public class MissingTranslations {
public static void main(String[] args) throws IOException {
String[] locales = {"da", "de", "es", "pt", "fi", "fr", "is", "it", "ja_JP", "mk", "nl", "no", "pl", "ru", "sl", "sv", "zh_CN", "zh_TW"};

@ -31,7 +31,7 @@ public class VersionTestCase extends TestCase {
/**
* Tests that equals(), hashCode(), toString() and compareTo() works.
*/
public void testVersion() {
public void testVersion() {
doTestVersion("0.0", "0.1");
doTestVersion("1.5", "2.3");
doTestVersion("2.3", "2.34");

@ -69,7 +69,7 @@ public class QueryFactoryTestCase {
new MusicFolder(FID2, new File(PATH2), "music2", true, new java.util.Date());
private static final List<MusicFolder> SINGLE_FOLDERS = Arrays.asList(MUSIC_FOLDER1);
private static final List<MusicFolder> MULTI_FOLDERS = Arrays.asList(MUSIC_FOLDER1, MUSIC_FOLDER2);
private static final List<MusicFolder> MULTI_FOLDERS = Arrays.asList(MUSIC_FOLDER1, MUSIC_FOLDER2);
/*

@ -21,7 +21,7 @@ public class PasswordSettingsValidatorTestCase extends TestCase {
PasswordSettingsValidator psv = new PasswordSettingsValidator();
Errors errors = new BeanPropertyBindingResult(psc, "psv");
psv.validate(psc, errors);
return errors;
return errors;
}
public void testValidateEmptyPassword() {

@ -10,6 +10,11 @@
<property name="fileExtensions" value="java, properties, xml"/>
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Unnecessary trailing whitespace"/>
</module>
<module name="FileTabCharacter"/>
<!-- This is a temporary workaround until ^M line endings is added to upstream checkstyle -->
@ -39,6 +44,7 @@
<module name="EqualsHashCode"/>
<module name="Indentation"/>
<module name="InnerAssignment"/>
<module name="LeftCurly"/>
<module name="MethodParamPad"/>
<module name="MultipleVariableDeclarations"/>
<module name="NoWhitespaceBefore">
@ -50,8 +56,10 @@
<module name="ParenPadCheck"/>
<module name="RedundantImport"/>
<module name="RequireThis"/>
<module name="RightCurly"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="SingleSpaceSeparator"/>
<module name="StringLiteralEquality"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>

Loading…
Cancel
Save