public List<WikiPage> getNodePages(long nodeId, int max) throws PortalException, SystemException {

    List<WikiPage> pages = new ArrayList<WikiPage>();

    int lastIntervalStart = 0;
    boolean listNotExhausted = true;

    while ((pages.size() < max) && listNotExhausted) {
      List<WikiPage> pageList =
          wikiPageLocalService.getPages(nodeId, true, lastIntervalStart, lastIntervalStart + max);

      lastIntervalStart += max;
      listNotExhausted = (pageList.size() == max);

      for (WikiPage page : pageList) {
        if (pages.size() >= max) {
          break;
        }

        if (WikiPagePermission.contains(getPermissionChecker(), page, ActionKeys.VIEW)) {

          pages.add(page);
        }
      }
    }

    return pages;
  }
  @Override
  protected boolean hasPermission(
      PermissionChecker permissionChecker, long classPK, String actionId)
      throws PortalException, SystemException {

    return WikiPagePermission.contains(permissionChecker, classPK, actionId);
  }
  @Override
  protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!WikiPagePermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) {

      return null;
    }

    String groupName = StringPool.BLANK;

    if (activity.getGroupId() != themeDisplay.getScopeGroupId()) {
      groupName = getGroupName(activity.getGroupId(), themeDisplay);
    }

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);

    int activityType = activity.getType();

    // Link

    WikiPageResource pageResource =
        WikiPageResourceLocalServiceUtil.getPageResource(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathMain()
            + "/wiki/find_page?pageResourcePrimKey="
            + activity.getClassPK();

    // Title

    String titlePattern = null;

    if (activityType == WikiActivityKeys.ADD_PAGE) {
      titlePattern = "activity-wiki-add-page";
    } else if (activityType == WikiActivityKeys.UPDATE_PAGE) {
      titlePattern = "activity-wiki-update-page";
    }

    if (Validator.isNotNull(groupName)) {
      titlePattern += "-in";
    }

    String pageTitle = wrapLink(link, HtmlUtil.escape(cleanContent(pageResource.getTitle())));

    Object[] titleArguments = new Object[] {groupName, creatorUserName, pageTitle};

    String title = themeDisplay.translate(titlePattern, titleArguments);

    // Body

    String body = StringPool.BLANK;

    return new SocialActivityFeedEntry(link, title, body);
  }