@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); }