@Deprecated
 public List<?> getEntities(EntityReference ref, Search search) {
   // get the pollId
   Restriction pollRes = search.getRestrictionByProperty("pollId");
   if (pollRes == null || pollRes.getSingleValue() == null) {
     throw new IllegalArgumentException(
         "Must include a non-null pollId in order to retreive a list of votes");
   }
   Long pollId = null;
   try {
     pollId = developerHelperService.convert(pollRes.getSingleValue(), Long.class);
   } catch (UnsupportedOperationException e) {
     throw new IllegalArgumentException(
         "Invalid: pollId must be a long number: " + e.getMessage(), e);
   }
   // get the poll
   Poll poll = pollListManager.getPollById(pollId);
   if (poll == null) {
     throw new IllegalArgumentException(
         "pollId (" + pollId + ") is invalid and does not match any known polls");
   } else {
     boolean allowedPublic = pollListManager.isPollPublic(poll);
     if (!allowedPublic) {
       String userReference = developerHelperService.getCurrentUserReference();
       if (userReference == null) {
         throw new EntityException(
             "User must be logged in in order to access poll data",
             ref.getId(),
             HttpServletResponse.SC_UNAUTHORIZED);
       } else {
         boolean allowedManage = false;
         boolean allowedVote = false;
         allowedManage =
             developerHelperService.isUserAllowedInEntityReference(
                 userReference, PollListManager.PERMISSION_ADD, "/site/" + poll.getSiteId());
         allowedVote =
             developerHelperService.isUserAllowedInEntityReference(
                 userReference, PollListManager.PERMISSION_VOTE, "/site/" + poll.getSiteId());
         if (!(allowedManage || allowedVote)) {
           throw new SecurityException(
               "User (" + userReference + ") not allowed to access poll data: " + ref);
         }
       }
     }
   }
   // get the options
   List<Option> options = pollListManager.getOptionsForPoll(pollId);
   return options;
 }
  public Object getEntity(EntityReference ref) {
    String id = ref.getId();
    if (id == null) {
      return new Poll();
    }
    Poll poll = getPollById(id);
    if (poll == null) {
      throw new IllegalArgumentException("No poll found for the given reference: " + ref);
    }
    Long pollId = poll.getPollId();
    String currentUserId = developerHelperService.getCurrentUserId();

    boolean allowedManage = false;
    if (!developerHelperService.isEntityRequestInternal(ref + "")) {
      if (!pollListManager.isPollPublic(poll)) {
        // this is not a public poll? (ie .anon role has poll.vote)
        String userReference = developerHelperService.getCurrentUserReference();
        if (userReference == null) {
          throw new EntityException(
              "User must be logged in in order to access poll data",
              ref.getId(),
              HttpServletResponse.SC_UNAUTHORIZED);
        }
        allowedManage =
            developerHelperService.isUserAllowedInEntityReference(
                userReference, PollListManager.PERMISSION_ADD, "/site/" + poll.getSiteId());
        boolean allowedVote =
            developerHelperService.isUserAllowedInEntityReference(
                userReference, PollListManager.PERMISSION_VOTE, "/site/" + poll.getSiteId());
        if (!allowedManage && !allowedVote) {
          throw new SecurityException(
              "User (" + userReference + ") not allowed to access poll data: " + ref);
        }
      }
    }

    Boolean includeVotes = requestStorage.getStoredValueAsType(Boolean.class, "includeVotes");
    if (includeVotes == null) {
      includeVotes = false;
    }
    if (includeVotes) {
      List<Vote> votes = pollVoteManager.getAllVotesForPoll(poll);
      poll.setVotes(votes);
    }
    Boolean includeOptions = requestStorage.getStoredValueAsType(Boolean.class, "includeOptions");
    if (includeOptions == null) {
      includeOptions = false;
    }
    if (includeOptions) {
      List<Option> options = pollListManager.getOptionsForPoll(poll);
      poll.setOptions(options);
    }
    // add in the indicator that this user has replied
    if (currentUserId != null) {
      Map<Long, List<Vote>> voteMap =
          pollVoteManager.getVotesForUser(currentUserId, new Long[] {pollId});
      List<Vote> l = voteMap.get(pollId);
      if (l != null) {
        poll.setCurrentUserVoted(true);
        poll.setCurrentUserVotes(l);
      } else {
        poll.setCurrentUserVoted(false);
      }
    }
    return poll;
  }