class PlaylistService extends BasicService implements OwnerAPISupport<Playlist> {

	@DELETE
	@Path("/playlists/{playlistId}/pagereferences/{pageReferenceId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Playlist deletePage(@PathParam("playlistId") long playlistId,
			@PathParam("pageReferenceId") long pageReferenceId) {
		Playlist existingPlaylist = getExistingPlaylist(playlistId, true);

		for (int i = 0; i < existingPlaylist.getPageReferences().size(); i++) {
			if (existingPlaylist.getPageReferences().get(i).getId() == pageReferenceId) {
				existingPlaylist.getPageReferences().remove(i);
				break;
			}
		}
		// re-index list
		for (int i = 0; i < existingPlaylist.getPageReferences().size(); i++) {
			existingPlaylist.getPageReferences().get(i).setPosition(i);
		}

		return PlaylistDAO.save(existingPlaylist);
	}

}