@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();
  }
  @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 Object[] getTitleArguments(
      String groupName,
      SocialActivity activity,
      String link,
      String title,
      ServiceContext serviceContext)
      throws Exception {

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

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

    return new Object[] {creatorUserName, jiraIssue.getKey()};
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof JIRAIssue)) {
      return false;
    }

    JIRAIssue jiraIssue = (JIRAIssue) obj;

    long primaryKey = jiraIssue.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  @Override
  public int compareTo(JIRAIssue jiraIssue) {
    int value = 0;

    value = DateUtil.compareTo(getModifiedDate(), jiraIssue.getModifiedDate());

    value = value * -1;

    if (value != 0) {
      return value;
    }

    return 0;
  }
  /**
   * Adds the j i r a issue to the database. Also notifies the appropriate model listeners.
   *
   * @param jiraIssue the j i r a issue
   * @return the j i r a issue that was added
   * @throws SystemException if a system exception occurred
   */
  public JIRAIssue addJIRAIssue(JIRAIssue jiraIssue) throws SystemException {
    jiraIssue.setNew(true);

    jiraIssue = jiraIssuePersistence.update(jiraIssue, false);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.reindex(jiraIssue);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }

    return jiraIssue;
  }