use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MusicFolderDaoTestCase method testCreateMusicFolder.
@Test
public void testCreateMusicFolder() {
MusicFolder musicFolder = new MusicFolder(new File("path"), "name", true, new Date());
musicFolderDao.createMusicFolder(musicFolder);
MusicFolder newMusicFolder = musicFolderDao.getAllMusicFolders().get(0);
assertMusicFolderEquals(musicFolder, newMusicFolder);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MusicFolderDaoTestCase method testDeleteMusicFolder.
@Test
public void testDeleteMusicFolder() {
assertEquals("Wrong number of music folders.", 0, musicFolderDao.getAllMusicFolders().size());
musicFolderDao.createMusicFolder(new MusicFolder(new File("path"), "name", true, new Date()));
assertEquals("Wrong number of music folders.", 1, musicFolderDao.getAllMusicFolders().size());
musicFolderDao.createMusicFolder(new MusicFolder(new File("path"), "name", true, new Date()));
assertEquals("Wrong number of music folders.", 2, musicFolderDao.getAllMusicFolders().size());
musicFolderDao.deleteMusicFolder(musicFolderDao.getAllMusicFolders().get(0).getId());
assertEquals("Wrong number of music folders.", 1, musicFolderDao.getAllMusicFolders().size());
musicFolderDao.deleteMusicFolder(musicFolderDao.getAllMusicFolders().get(0).getId());
assertEquals("Wrong number of music folders.", 0, musicFolderDao.getAllMusicFolders().size());
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getSimilarSongs2.
@RequestMapping(value = "/rest/getSimilarSongs2", method = { RequestMethod.GET, RequestMethod.POST })
public void getSimilarSongs2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
int id = getRequiredIntParameter(request, "id");
int count = getIntParameter(request, "count", 50);
SimilarSongs2 result = new SimilarSongs2();
Artist artist = artistDao.getArtist(id);
if (artist == null) {
error(request, response, ErrorCode.NOT_FOUND, "Artist not found.");
return;
}
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<MediaFile> similarSongs = lastFmService.getSimilarSongs(artist, count, musicFolders);
Player player = playerService.getPlayer(request, response);
for (MediaFile similarSong : similarSongs) {
result.getSong().add(createJaxbChild(player, similarSong, username));
}
Response res = createResponse();
res.setSimilarSongs2(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getShares.
@RequestMapping(value = "/rest/getShares", method = { RequestMethod.GET, RequestMethod.POST })
public void getShares(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
User user = securityService.getCurrentUser(request);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
Shares result = new Shares();
for (Share share : shareService.getSharesForUser(user)) {
org.libresonic.restapi.Share s = createJaxbShare(request, share);
result.getShare().add(s);
for (MediaFile mediaFile : shareService.getSharedFiles(share.getId(), musicFolders)) {
s.getEntry().add(createJaxbChild(player, mediaFile, username));
}
}
Response res = createResponse();
res.setShares(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getAlbumList2.
@RequestMapping(value = "/rest/getAlbumList2", method = { RequestMethod.GET, RequestMethod.POST })
public void getAlbumList2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
int size = getIntParameter(request, "size", 10);
int offset = getIntParameter(request, "offset", 0);
size = Math.max(0, Math.min(size, 500));
String type = getRequiredStringParameter(request, "type");
String username = securityService.getCurrentUsername(request);
Integer musicFolderId = getIntParameter(request, "musicFolderId");
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username, musicFolderId);
List<Album> albums;
if ("frequent".equals(type)) {
albums = albumDao.getMostFrequentlyPlayedAlbums(offset, size, musicFolders);
} else if ("recent".equals(type)) {
albums = albumDao.getMostRecentlyPlayedAlbums(offset, size, musicFolders);
} else if ("newest".equals(type)) {
albums = albumDao.getNewestAlbums(offset, size, musicFolders);
} else if ("alphabeticalByArtist".equals(type)) {
albums = albumDao.getAlphabetialAlbums(offset, size, true, musicFolders);
} else if ("alphabeticalByName".equals(type)) {
albums = albumDao.getAlphabetialAlbums(offset, size, false, musicFolders);
} else if ("byGenre".equals(type)) {
albums = albumDao.getAlbumsByGenre(offset, size, getRequiredStringParameter(request, "genre"), musicFolders);
} else if ("byYear".equals(type)) {
albums = albumDao.getAlbumsByYear(offset, size, getRequiredIntParameter(request, "fromYear"), getRequiredIntParameter(request, "toYear"), musicFolders);
} else if ("starred".equals(type)) {
albums = albumDao.getStarredAlbums(offset, size, securityService.getCurrentUser(request).getUsername(), musicFolders);
} else if ("random".equals(type)) {
albums = searchService.getRandomAlbumsId3(size, musicFolders);
} else {
throw new Exception("Invalid list type: " + type);
}
AlbumList2 result = new AlbumList2();
for (Album album : albums) {
result.getAlbum().add(createJaxbAlbum(new AlbumID3(), album, username));
}
Response res = createResponse();
res.setAlbumList2(result);
jaxbWriter.writeResponse(request, response, res);
}
Aggregations