}
@Override
public PagedSet<StreamDTO> execute(final PrincipalActionContext inActionContext) throws ExecutionException
{
GetStreamsUserIsFollowingRequest request = (GetStreamsUserIsFollowingRequest) inActionContext.getParams();
Long start = System.currentTimeMillis();
Long userId = getPersonIdByAccountIdMapper.execute(request.getAccountId());
log.debug("Lookup requested user id time: " + (System.currentTimeMillis() - start) + "(ms).");
Long currentUserId = inActionContext.getPrincipal().getId();
ArrayList<StreamDTO> results = new ArrayList<StreamDTO>();
PagedSet<StreamDTO> pagedResults = new PagedSet<StreamDTO>();
// get person/group ModelViews, which implement StreamDTO, and add to results;
start = System.currentTimeMillis();
results.addAll(personModelViewsMapper.execute(personIdsUserIsFollowingMapper.execute(userId)));
results.addAll(groupModelViewsMapper.execute(groupIdsUserIsFollowingMapper.execute(userId)));
log.debug("Data retrieval time: " + (System.currentTimeMillis() - start) + "(ms).");
// if no results, short-circuit here.
if (results.isEmpty())
{
return pagedResults;
}
// sort results;
start = System.currentTimeMillis();
Collections.sort(results, STREAMDTO_DISPLAYNAME_COMPARATOR);
log.debug("Data sort time:" + (System.currentTimeMillis() - start) + "(ms).");
// set up PagedSet result and return.
int total = results.size();
int startIndex = request.getStartIndex();
int endIndex = request.getEndIndex() >= total ? total - 1 : request.getEndIndex();
// Note that the end index in the request is INCLUSIVE but the end index for subList() is EXCLUSIVE, so account
// for the difference.
ArrayList<StreamDTO> trimmedResults = new ArrayList<StreamDTO>(results.subList(startIndex, endIndex + 1));
start = System.currentTimeMillis();