use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.
the class PodcastDaoTestCase method testCreateChannel.
@Test
public void testCreateChannel() {
PodcastChannel channel = new PodcastChannel("http://foo");
podcastDao.createChannel(channel);
PodcastChannel newChannel = podcastDao.getAllChannels().get(0);
assertNotNull("Wrong ID.", newChannel.getId());
assertChannelEquals(channel, newChannel);
}
use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.
the class PodcastDaoTestCase method testDeleteChannel.
@Test
public void testDeleteChannel() {
assertEquals("Wrong number of channels.", 0, podcastDao.getAllChannels().size());
PodcastChannel channel = new PodcastChannel("http://foo");
podcastDao.createChannel(channel);
assertEquals("Wrong number of channels.", 1, podcastDao.getAllChannels().size());
podcastDao.createChannel(channel);
assertEquals("Wrong number of channels.", 2, podcastDao.getAllChannels().size());
podcastDao.deleteChannel(podcastDao.getAllChannels().get(0).getId());
assertEquals("Wrong number of channels.", 1, podcastDao.getAllChannels().size());
podcastDao.deleteChannel(podcastDao.getAllChannels().get(0).getId());
assertEquals("Wrong number of channels.", 0, podcastDao.getAllChannels().size());
}
use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.
the class RESTController method getPodcasts.
@RequestMapping(value = "/rest/getPodcasts", method = { RequestMethod.GET, RequestMethod.POST })
public void getPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
boolean includeEpisodes = getBooleanParameter(request, "includeEpisodes", true);
Integer channelId = getIntParameter(request, "id");
Podcasts result = new Podcasts();
for (PodcastChannel channel : podcastService.getAllChannels()) {
if (channelId == null || channelId.equals(channel.getId())) {
org.libresonic.restapi.PodcastChannel c = new org.libresonic.restapi.PodcastChannel();
result.getChannel().add(c);
c.setId(String.valueOf(channel.getId()));
c.setUrl(channel.getUrl());
c.setStatus(PodcastStatus.valueOf(channel.getStatus().name()));
c.setTitle(channel.getTitle());
c.setDescription(channel.getDescription());
c.setCoverArt(CoverArtController.PODCAST_COVERART_PREFIX + channel.getId());
c.setOriginalImageUrl(channel.getImageUrl());
c.setErrorMessage(channel.getErrorMessage());
if (includeEpisodes) {
List<PodcastEpisode> episodes = podcastService.getEpisodes(channel.getId());
for (PodcastEpisode episode : episodes) {
c.getEpisode().add(createJaxbPodcastEpisode(player, username, episode));
}
}
}
}
Response res = createResponse();
res.setPodcasts(result);
jaxbWriter.writeResponse(request, response, res);
}
Aggregations