class 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();

		// screens
		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);
			}
		}

		// other playlists
		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;
	}

}