@Override
  protected String getBody(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    String link = getLink(activity, serviceContext);

    String text = StringPool.BLANK;

    int activityType = activity.getType();

    if (activityType == JIRAActivityKeys.ADD_CHANGE) {
      JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(activity.getExtraData());

      text =
          interpretJIRAChangeItems(
              extraDataJSONObject.getJSONArray("jiraChangeItems"), serviceContext);
    } else if (activityType == JIRAActivityKeys.ADD_COMMENT) {
      long jiraActionId = GetterUtil.getLong(getJSONValue(activity.getExtraData(), "jiraActionId"));

      JIRAAction jiraAction = JIRAActionLocalServiceUtil.getJIRAAction(jiraActionId);

      text = HtmlUtil.escape(jiraAction.getBody());
    } else if (activityType == JIRAActivityKeys.ADD_ISSUE) {
      JIRAIssue jiraIssue = JIRAIssueLocalServiceUtil.getJIRAIssue(activity.getClassPK());

      text = HtmlUtil.escape(jiraIssue.getSummary());
    }

    return wrapLink(link, text);
  }
  @Override
  protected String getLink(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    StringBundler sb = new StringBundler(5);

    sb.append(PortletPropsValues.JIRA_URL);
    sb.append("/browse/");

    JIRAIssue jiraIssue = JIRAIssueLocalServiceUtil.getJIRAIssue(activity.getClassPK());

    sb.append(jiraIssue.getKey());

    int activityType = activity.getType();

    if (activityType == JIRAActivityKeys.ADD_COMMENT) {
      sb.append("#action_");

      long jiraActionId = GetterUtil.getLong(getJSONValue(activity.getExtraData(), "jiraActionId"));

      JIRAAction jiraAction = JIRAActionLocalServiceUtil.getJIRAAction(jiraActionId);

      sb.append(jiraAction.getJiraActionId());
    }

    return sb.toString();
  }
  /**
   * Adds the j i r a action to the database. Also notifies the appropriate model listeners.
   *
   * @param jiraAction the j i r a action
   * @return the j i r a action that was added
   */
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public JIRAAction addJIRAAction(JIRAAction jiraAction) {
    jiraAction.setNew(true);

    return jiraActionPersistence.update(jiraAction);
  }