Exemplo n.º 1
0
  protected String getUserName(long userId, ServiceContext serviceContext) {
    try {
      if (userId <= 0) {
        return StringPool.BLANK;
      }

      User user = UserLocalServiceUtil.getUserById(userId);

      if (user.getUserId() == serviceContext.getUserId()) {
        return HtmlUtil.escape(user.getFirstName());
      }

      String userName = user.getFullName();

      Group group = user.getGroup();

      if (group.getGroupId() == serviceContext.getScopeGroupId()) {
        return HtmlUtil.escape(userName);
      }

      String userDisplayURL = user.getDisplayURL(serviceContext.getThemeDisplay());

      userName =
          "******"user\" href=\"" + userDisplayURL + "\">" + HtmlUtil.escape(userName) + "</a>";

      return userName;
    } catch (Exception e) {
      return StringPool.BLANK;
    }
  }
Exemplo n.º 2
0
  protected SocialActivityFeedEntry doInterpret(
      SocialActivity activity, ServiceContext serviceContext) throws Exception {

    ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();

    SocialActivityFeedEntry socialActivityFeedEntry = doInterpret(activity, themeDisplay);

    if (socialActivityFeedEntry != _deprecatedMarkerSocialActivityFeedEntry) {

      return socialActivityFeedEntry;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!hasPermissions(permissionChecker, activity, ActionKeys.VIEW, serviceContext)) {

      return null;
    }

    String link = getLink(activity, serviceContext);

    String title = getTitle(activity, serviceContext);

    if (Validator.isNull(title)) {
      return null;
    }

    String body = getBody(activity, serviceContext);

    return new SocialActivityFeedEntry(link, title, body);
  }
  protected String getBody(String className, long classPK, ServiceContext serviceContext)
      throws Exception {

    StringBundler sb = new StringBundler(11);

    sb.append("<div class=\"activity-body document\">");
    sb.append("<span class=\"document-thumbnail\"><img src=\"");

    FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(classPK);

    FileVersion fileVersion = fileEntry.getFileVersion();

    String thumbnailSrc =
        DLUtil.getThumbnailSrc(fileEntry, fileVersion, null, serviceContext.getThemeDisplay());

    sb.append(thumbnailSrc);
    sb.append("\"></span>");
    sb.append("<div class=\"document-container\"><div class=\"title\">");
    sb.append(getPageTitle(className, classPK, serviceContext));
    sb.append("</div><div class=\"version\">");
    sb.append(serviceContext.translate("version-x", fileVersion.getVersion()));
    sb.append("</div><div class=\"document-content\">");

    AssetRenderer assetRenderer = getAssetRenderer(className, classPK);

    sb.append(StringUtil.shorten(assetRenderer.getSummary(serviceContext.getLocale()), 200));

    sb.append("</div></div></div>");

    return sb.toString();
  }
  @Override
  public boolean isVisible(User user, User selUser) {
    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String portletName = portletDisplay.getPortletName();

    if ((selUser != null) && portletName.equals(PortletKeys.MY_ACCOUNT)) {
      return false;
    }

    return true;
  }
  @Override
  protected String getPath(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    JournalArticle article = _journalArticleLocalService.getLatestArticle(activity.getClassPK());

    Layout layout = article.getLayout();

    if (layout != null) {
      String groupFriendlyURL =
          PortalUtil.getGroupFriendlyURL(layout.getLayoutSet(), serviceContext.getThemeDisplay());

      return groupFriendlyURL
          .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR)
          .concat(article.getUrlTitle());
    }

    return null;
  }