class PlaylistService extends BasicService implements OwnerAPISupport<Playlist> {

	@GET
	@Path("/playlists/{playlistId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Playlist getPlaylist(@PathParam("playlistId") long playlistId,
			@DefaultValue("false") @QueryParam("visibleOnly") boolean visibleOnly,
			@DefaultValue("false") @QueryParam("expand") boolean expand,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics) {
		Playlist existingPlaylist = getExistingPlaylist(playlistId, false);

		if (!existingPlaylist.isListPublicly() && !this.isAdmin() && !inAdminOwners(existingPlaylist.getOwners())) {
			throwUnauthorized();
		}

		if (visibleOnly) {
			for (PageReference pageReference : existingPlaylist.getPageReferences()) {
				if (!pageReference.isVisible()) {
					existingPlaylist.getPageReferences().remove(pageReference);
				}
			}
		}

		if (expand) {
			existingPlaylist.expand();
		} else {
			existingPlaylist.breakRecursion();
		}
		if (!includeMetrics) {
			removePlaylistMetrics(existingPlaylist);
		}
		return existingPlaylist;
	}

}