@Test(expected = WebApplicationException.class) public void testGetReferencesForNonExistingPlaylist() throws Exception { playlistService.getReferences(-1); }
@GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) public PlaylistReferences getReferences(@PathParam("playlistId") long playlistId) { Playlist existingPlaylist = getExistingPlaylist(playlistId, false); if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) { throwUnauthorized(); } PlaylistReferences refs = new PlaylistReferences(); List<Screen> screens = ScreenDAO.getScreensByPlaylist(existingPlaylist); for (Screen screen : screens) { if (this.isAdmin() || inAdminOwners(screen.getOwners())) { refs.addUserScreen(screen); } else { refs.setForeignScreens(refs.getForeignScreens() + 1); } } List<Playlist> playlists = PlaylistDAO.getPlaylistsByPlaylist(existingPlaylist); for (Playlist playlist : playlists) { if (this.isAdmin() || inAdminOwners(playlist.getOwners())) { refs.addUserPlaylist(playlist); } else { refs.setForeignPlaylists(refs.getForeignPlaylists() + 1); } } return refs; }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) public PlaylistReferences getReferences(@PathParam("playlistId") long playlistId) { Playlist existingPlaylist = getExistingPlaylist(playlistId, false); if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) { throwUnauthorized(); } PlaylistReferences refs = new PlaylistReferences(); List<Screen> screens = ScreenDAO.getScreensByPlaylist(existingPlaylist); for (Screen screen : screens) { if (this.isAdmin() || inAdminOwners(screen.getOwners())) { refs.addUserScreen(screen); } else { refs.setForeignScreens(refs.getForeignScreens() + 1); } } List<Playlist> playlists = PlaylistDAO.getPlaylistsByPlaylist(existingPlaylist); for (Playlist playlist : playlists) { if (this.isAdmin() || inAdminOwners(playlist.getOwners())) { refs.addUserPlaylist(playlist); } else { refs.setForeignPlaylists(refs.getForeignPlaylists() + 1); } } return refs; } }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) public PlaylistReferences getReferences(@PathParam("playlistId") long playlistId) { Playlist existingPlaylist = getExistingPlaylist(playlistId, false); if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) { throwUnauthorized(); } PlaylistReferences refs = new PlaylistReferences(); List<Screen> screens = ScreenDAO.getScreensByPlaylist(existingPlaylist); for (Screen screen : screens) { if (this.isAdmin() || inAdminOwners(screen.getOwners())) { refs.addUserScreen(screen); } else { refs.setForeignScreens(refs.getForeignScreens() + 1); } } List<Playlist> playlists = PlaylistDAO.getPlaylistsByPlaylist(existingPlaylist); for (Playlist playlist : playlists) { if (this.isAdmin() || inAdminOwners(playlist.getOwners())) { refs.addUserPlaylist(playlist); } else { refs.setForeignPlaylists(refs.getForeignPlaylists() + 1); } } return refs; }  }
PlaylistService extends BasicService implements OwnerAPISupport<Playlist> { @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) public PlaylistReferences getReferences(@PathParam("playlistId") long playlistId) { Playlist existingPlaylist = getExistingPlaylist(playlistId, false); if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) { throwUnauthorized(); } PlaylistReferences refs = new PlaylistReferences(); List<Screen> screens = ScreenDAO.getScreensByPlaylist(existingPlaylist); for (Screen screen : screens) { if (this.isAdmin() || inAdminOwners(screen.getOwners())) { refs.addUserScreen(screen); } else { refs.setForeignScreens(refs.getForeignScreens() + 1); } } List<Playlist> playlists = PlaylistDAO.getPlaylistsByPlaylist(existingPlaylist); for (Playlist playlist : playlists) { if (this.isAdmin() || inAdminOwners(playlist.getOwners())) { refs.addUserPlaylist(playlist); } else { refs.setForeignPlaylists(refs.getForeignPlaylists() + 1); } } return refs; }  @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> { @GET @Path("/playlists/{playlistId}/references") @Produces(MediaType.APPLICATION_JSON) public PlaylistReferences getReferences(@PathParam("playlistId") long playlistId) { Playlist existingPlaylist = getExistingPlaylist(playlistId, false); if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) { throwUnauthorized(); } PlaylistReferences refs = new PlaylistReferences(); List<Screen> screens = ScreenDAO.getScreensByPlaylist(existingPlaylist); for (Screen screen : screens) { if (this.isAdmin() || inAdminOwners(screen.getOwners())) { refs.addUserScreen(screen); } else { refs.setForeignScreens(refs.getForeignScreens() + 1); } } List<Playlist> playlists = PlaylistDAO.getPlaylistsByPlaylist(existingPlaylist); for (Playlist playlist : playlists) { if (this.isAdmin() || inAdminOwners(playlist.getOwners())) { refs.addUserPlaylist(playlist); } else { refs.setForeignPlaylists(refs.getForeignPlaylists() + 1); } } return refs; }  @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);  }