@Test public void testAddPlaylist() throws Exception { Page page1 = pageService.createPage(new Page("p1")); Page page2 = pageService.createPage(new Page("p2")); Page page3 = pageService.createPage(new Page("p3")); Playlist playlist1 = new Playlist("d1"); playlist1.addPageReference(new PageReference(page1)); playlist1 = playlistService.createPlaylist(playlist1); assertEquals(1, playlistService.getPlaylist(playlist1.getId(), false, false, true).getPageReferences().size()); Playlist playlist2 = new Playlist("d2"); playlist2.addPageReference(new PageReference(page2)); playlist2.addPageReference(new PageReference(page3)); playlist2 = playlistService.createPlaylist(playlist2); assertEquals(2, playlistService.getPlaylist(playlist2.getId(), false, false, true).getPageReferences().size()); playlist1 = playlistService.addPlaylist(playlist1.getId(), playlist2); List<PageReference> pageReferences = getPlaylist(playlist1.getId()).getPageReferences(); assertEquals(2, pageReferences.size()); assertEquals(PageRefType.PAGE, pageReferences.get(0).getRefType()); assertEquals(PageRefType.PLAYLIST, pageReferences.get(1).getRefType()); pageReferences = playlistService.getPlaylist(playlist1.getId(), false, true, true).getPageReferences(); assertEquals(3, pageReferences.size()); playlist1 = playlistService.addPlaylist(playlist1.getId(), playlist2); pageReferences = playlistService.getPlaylist(playlist1.getId(), false, true, true).getPageReferences(); assertEquals(5, pageReferences.size()); Playlist playlist3 = new Playlist("d3"); playlist3.addPageReference(new PageReference(playlist1)); playlist3 = playlistService.createPlaylist(playlist3); playlist1 = playlistService.addPlaylist(playlist1.getId(), playlist3); pageReferences = playlistService.getPlaylist(playlist1.getId(), false, true, true).getPageReferences(); assertEquals(5, pageReferences.size()); assertEquals("p1", pageReferences.get(0).getPage().getName()); assertEquals("p2", pageReferences.get(1).getPage().getName()); assertEquals("p3", pageReferences.get(2).getPage().getName()); assertEquals("p2", pageReferences.get(3).getPage().getName()); assertEquals("p3", pageReferences.get(4).getPage().getName()); List<Playlist> playlists = getPlaylists(false); assertEquals(4, playlists.get(0).getPageReferences().size()); assertEquals(2, playlists.get(1).getPageReferences().size()); assertEquals(1, playlists.get(2).getPageReferences().size()); playlists = getPlaylists(true); assertEquals(5, playlists.get(0).getPageReferences().size()); assertEquals(2, playlists.get(1).getPageReferences().size()); assertEquals(5, playlists.get(2).getPageReferences().size()); Screen screen = new Screen("s1", playlist1); screen.setKey("sk1"); screen = screenService.createScreen(screen); assertEquals(5, screen.getPlaylist().getPageReferences().size()); assertEquals(5, screenService.getScreen(screen.getId(), false, false).getPlaylist().getPageReferences().size()); assertEquals(5, screenService.getScreenByKey("sk1", false, false, false, null).getPlaylist().getPageReferences() .size()); assertEquals(5, screenService.getScreens(null).get(0).getPlaylist().getPageReferences().size()); screen = screenService.addOwners(screen.getId(), new Owner[] { new Owner(new User("i1")) }); assertEquals(5, screenService.getScreen(screen.getId(), false, false).getPlaylist().getPageReferences().size()); }
@POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) public Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist) { Playlist existingPlaylist = getExistingPlaylist(playlistId, true); Playlist existingPlaylist2 = getExistingPlaylist(playlist.getId(), false); existingPlaylist.addPageReference(new PageReference(existingPlaylist2)); return PlaylistDAO.save(existingPlaylist); }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) public Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist) { Playlist existingPlaylist = getExistingPlaylist(playlistId, true); Playlist existingPlaylist2 = getExistingPlaylist(playlist.getId(), false); existingPlaylist.addPageReference(new PageReference(existingPlaylist2)); return PlaylistDAO.save(existingPlaylist); } }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) public Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist) { Playlist existingPlaylist = getExistingPlaylist(playlistId, true); Playlist existingPlaylist2 = getExistingPlaylist(playlist.getId(), false); existingPlaylist.addPageReference(new PageReference(existingPlaylist2)); return PlaylistDAO.save(existingPlaylist); }  }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) public Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist) { Playlist existingPlaylist = getExistingPlaylist(playlistId, true); Playlist existingPlaylist2 = getExistingPlaylist(playlist.getId(), false); existingPlaylist.addPageReference(new PageReference(existingPlaylist2)); return PlaylistDAO.save(existingPlaylist); }  @GET @Path("/playlists") @Produces(MediaType.APPLICATION_JSON) List<Playlist> getPlaylists(@DefaultValue("false") @QueryParam("expand") boolean expand,
			@QueryParam("userId") String userId); @GET @Path("/catalog") @Produces(MediaType.APPLICATION_JSON) List<Playlist> getPlaylistCatalog(@DefaultValue("0") @QueryParam("exclude") long excludeId); @GET @Path("/playlists/{playlistId}") @Produces(MediaType.APPLICATION_JSON) Playlist getPlaylist(@PathParam("playlistId") long playlistId,
			@DefaultValue("false") @QueryParam("visibleOnly") boolean visibleOnly,
			@DefaultValue("false") @QueryParam("expand") boolean expand,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics); @PUT @Path("/playlists/{playlistId}") @Produces(MediaType.APPLICATION_JSON) Playlist updatePlaylist(@PathParam("playlistId") long playlistId, Playlist playlistData); @POST @Path("/playlists") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Playlist createPlaylist(Playlist playlist); @POST @Path("/playlists/{playlistId}/pages") @Consumes(MediaType.APPLICATION_JSON) Playlist addPage(@PathParam("playlistId") long playlistId, Page page); @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist); @POST @Path("/playlists/{playlistId}/files") @Consumes(MediaType.APPLICATION_JSON) Playlist addFile(@PathParam("playlistId") long playlistId, File file); @PUT @Path("/playlists/{playlistId}/pagereferences/{pageRefId}") @Produces(MediaType.APPLICATION_JSON) PageReference updatePageReference(@PathParam("pageRefId") long pageRefId, PageReference pageRef); @POST @Path("/playlists/{playlistId}/copy") @Consumes(MediaType.APPLICATION_JSON) Playlist copyPlaylist(@PathParam("playlistId") long playlistId, Playlist newPlaylist); @DELETE @Path("/playlists/{playlistId}") Response deletePlaylist(@PathParam("playlistId") long playlistId); @DELETE @Path("/playlists/{playlistId}/pagereferences/{pageReferenceId}") @Produces(MediaType.APPLICATION_JSON) Playlist deletePage(@PathParam("playlistId") long playlistId,
			@PathParam("pageReferenceId") long pageReferenceId); @POST @Path("/playlists/{playlistId}/pagereferences/{pageReferenceId}/moveto/{idx}") @Produces(MediaType.APPLICATION_JSON) Playlist movePage(@PathParam("playlistId") long playlistId,
			@PathParam("pageReferenceId") long pageReferenceId, @PathParam("idx") int newPosition); @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) PlaylistReferences getReferences(@PathParam("playlistId") long playlistId); @Override @POST @Path("/playlists/{playlistId}/owners") @Consumes(MediaType.APPLICATION_JSON) Playlist addOwners(@PathParam("playlistId") long playlistId, Owner[] ownerData); @Override @DELETE @Path("/playlists/{playlistId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) Playlist deleteOwner(@PathParam("playlistId") long playlistId, @PathParam("ownerId") long ownerId); }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) public Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist) { Playlist existingPlaylist = getExistingPlaylist(playlistId, true); Playlist existingPlaylist2 = getExistingPlaylist(playlist.getId(), false); existingPlaylist.addPageReference(new PageReference(existingPlaylist2)); return PlaylistDAO.save(existingPlaylist); }  @GET @Path("/playlists") @Produces(MediaType.APPLICATION_JSON) List<Playlist> getPlaylists(@DefaultValue("false") @QueryParam("expand") boolean expand,
			@QueryParam("userId") String userId); @GET @Path("/catalog") @Produces(MediaType.APPLICATION_JSON) List<Playlist> getPlaylistCatalog(@DefaultValue("0") @QueryParam("exclude") long excludeId); @GET @Path("/playlists/{playlistId}") @Produces(MediaType.APPLICATION_JSON) Playlist getPlaylist(@PathParam("playlistId") long playlistId,
			@DefaultValue("false") @QueryParam("visibleOnly") boolean visibleOnly,
			@DefaultValue("false") @QueryParam("expand") boolean expand,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics); @PUT @Path("/playlists/{playlistId}") @Produces(MediaType.APPLICATION_JSON) Playlist updatePlaylist(@PathParam("playlistId") long playlistId, Playlist playlistData); @POST @Path("/playlists") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Playlist createPlaylist(Playlist playlist); @POST @Path("/playlists/{playlistId}/pages") @Consumes(MediaType.APPLICATION_JSON) Playlist addPage(@PathParam("playlistId") long playlistId, Page page); @POST @Path("/playlists/{playlistId}/playlists") @Consumes(MediaType.APPLICATION_JSON) Playlist addPlaylist(@PathParam("playlistId") long playlistId, Playlist playlist); @POST @Path("/playlists/{playlistId}/files") @Consumes(MediaType.APPLICATION_JSON) Playlist addFile(@PathParam("playlistId") long playlistId, File file); @PUT @Path("/playlists/{playlistId}/pagereferences/{pageRefId}") @Produces(MediaType.APPLICATION_JSON) PageReference updatePageReference(@PathParam("pageRefId") long pageRefId, PageReference pageRef); @POST @Path("/playlists/{playlistId}/copy") @Consumes(MediaType.APPLICATION_JSON) Playlist copyPlaylist(@PathParam("playlistId") long playlistId, Playlist newPlaylist); @DELETE @Path("/playlists/{playlistId}") Response deletePlaylist(@PathParam("playlistId") long playlistId); @DELETE @Path("/playlists/{playlistId}/pagereferences/{pageReferenceId}") @Produces(MediaType.APPLICATION_JSON) Playlist deletePage(@PathParam("playlistId") long playlistId,
			@PathParam("pageReferenceId") long pageReferenceId); @POST @Path("/playlists/{playlistId}/pagereferences/{pageReferenceId}/moveto/{idx}") @Produces(MediaType.APPLICATION_JSON) Playlist movePage(@PathParam("playlistId") long playlistId,
			@PathParam("pageReferenceId") long pageReferenceId, @PathParam("idx") int newPosition); @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) PlaylistReferences getReferences(@PathParam("playlistId") long playlistId); @Override @POST @Path("/playlists/{playlistId}/owners") @Consumes(MediaType.APPLICATION_JSON) Playlist addOwners(@PathParam("playlistId") long playlistId, Owner[] ownerData); @Override @DELETE @Path("/playlists/{playlistId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) Playlist deleteOwner(@PathParam("playlistId") long playlistId, @PathParam("ownerId") long ownerId);  }