protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

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

    User receiverUser = UserLocalServiceUtil.getUserById(activity.getReceiverUserId());

    if (!SocialRelationLocalServiceUtil.hasRelation(
            themeDisplay.getUserId(),
            activity.getReceiverUserId(),
            SocialRelationConstants.TYPE_BI_FRIEND)
        && (themeDisplay.getUserId() != activity.getReceiverUserId())) {

      return null;
    }

    int activityType = activity.getType();

    // Link

    WallEntry wallEntry = WallEntryLocalServiceUtil.getWallEntry(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathFriendlyURLPublic()
            + StringPool.SLASH
            + HtmlUtil.escapeURL(receiverUser.getScreenName())
            + "/profile/-/wall/"
            + activity.getClassPK();

    // Title

    String title = StringPool.BLANK;

    if (activityType == WallActivityKeys.ADD_ENTRY) {
      title =
          themeDisplay.translate(
              "activity-social-networking-wall-add-entry",
              new Object[] {creatorUserName, receiverUserName});
    }

    // Body

    StringBuilder sb = new StringBuilder();

    sb.append("<a href=\"");
    sb.append(link);
    sb.append("\">");
    sb.append(HtmlUtil.escape(cleanContent(wallEntry.getComments())));
    sb.append("</a>");

    String body = sb.toString();

    return new SocialActivityFeedEntry(link, title, body);
  }
Esempio n. 2
0
  public String getPathFriendlyURL(boolean privateLayout, ThemeDisplay themeDisplay) {

    if (privateLayout) {
      if (isUser()) {
        return themeDisplay.getPathFriendlyURLPrivateUser();
      } else {
        return themeDisplay.getPathFriendlyURLPrivateGroup();
      }
    } else {
      return themeDisplay.getPathFriendlyURLPublic();
    }
  }
Esempio n. 3
0
  /**
   * Submit.
   *
   * @return the string
   */
  public void submit() {
    // Query q = new Query();
    // q.setSearchterm(query);

    ThemeDisplay themeDisplay = LiferayFacesContext.getInstance().getThemeDisplay();
    Layout layout = themeDisplay.getLayout();
    String currentPage = layout.getFriendlyURL();

    FacesContext facesContext = FacesContext.getCurrentInstance();
    Object responseObject = facesContext.getExternalContext().getResponse();
    if (responseObject != null && responseObject instanceof ActionResponse) {
      ActionResponse actionResponse = (ActionResponse) responseObject;
      // actionResponse.setEvent(new
      // QName("http://fokus.fraunhofer.de/odplatform", "querydatasets"),
      // q);

      if (query != null && !query.isEmpty()) {
        log.info("searching for '{}'", query);
        // String escapedQuery = StringEscapeUtils.escapeHtml(query);
        String escapedQuery = StringUtils.escapeColonString(query);
        // msg 8:5.2014 actionResponse.setRenderParameter("searchterm",
        // query);
        escapedQuery = StringUtils.removeBlankStrings(query);
        log.info("escapedQuery:" + escapedQuery);
        actionResponse.setRenderParameter("searchterm", escapedQuery);
      } else {
        actionResponse.removePublicRenderParameter("searchterm");
      }

      actionResponse.removePublicRenderParameter("searchcategory");
    }

    // if (currentPage.equals("/home")) {
    String location = themeDisplay.getPortalURL();
    if (layout.isPublicLayout()) {
      location += themeDisplay.getPathFriendlyURLPublic();
    }

    try {
      location +=
          layout.hasScopeGroup()
              ? layout.getScopeGroup().getFriendlyURL()
              : layout.getGroup().getFriendlyURL();
      if (currentPage.equals("/home")) {
        location += "/suchen";
      } else {
        location += layout.getFriendlyURL();
      }
    } catch (PortalException e) {
      log.error("add group to url", e);
    } catch (SystemException e) {
      log.error("add group to url", e);
    }

    try {
      facesContext.getExternalContext().redirect(location);
    } catch (IOException e) {
      log.error("redirect to result page", e);
    }
    // }

  }