无法从JIRA的IssueEvent中获取已删除的注释ID,其类型为ISSUE_COMMENT_DELETED_ID

时间:2015-08-17 06:17:38

标签: java jira jira-plugin

这个问题是关于atlassian JIRA插件开发的。当我使用事件监听器来处理注释删除事件的JIRA的IssueEvent时,我可以捕获具有事件类型“com.atlassian.jira.event.type.EventType.ISSUE_COMMENT_DELETED_ID”的注释已删除事件。但我不知道如何获得在此活动中删除的评论ID。我已经为这种情况尝试了IssueEvent.getComment,但它返回null。

2 个答案:

答案 0 :(得分:1)

IssueEvent课程中有一个名为var client = redis.createClient(); client.hget('auth',"auth_inner_key", function (err, obj) { console.log(obj); }); 的常量,表示已删除的评论可能位于名为' params'这是IssueEvent对象的一部分(链接转到JavaDoc作为常量)。虽然这说明是"问题删除事件", MAY 能够帮助你。

要查看您的情况是否存在,您可以尝试(假设您已连接记录器并具有正确的日志记录设置级别):

COMMENTS_PARAM_NAME

并查看它是否打印到atlassian日志。

如果确实存在,那么您可以尝试使用它,如:

Map<String, Object> paramsMap = issueEvent.getParams();
for (String key : paramsMap.keySet()) {
    if (key.equals(IssueEvent.COMMENTS_PARAM_NAME)) {
        log.debug("Comments Param List Exists");
    }
}

N.B。 Map<String, Object> paramsMap = issueEvent.getParams(); List<Comment> deletedCommentsList = paramsMap.get(IssueEvent.COMMENTS_PARAM_NAME); // Do whatever you need to do with the Comments 方法继承自JiraEvent类。

答案 1 :(得分:1)

根据更改日志,您可以提取

 GenericValue genericValue = issueEvent.getChangeLog();
if (genericValue == null) {
    return;
}
List<GenericValue> changeItems = null;
try {
    changeItems = genericValue.getRelated("ChildChangeItem");
    String fieldName, fieldType;
    for (GenericValue changeItem : changeItems) {
        fieldType = (String) changeItem.get("fieldtype");
        fieldName = (String) changeItem.get("field");
        if ("JIRA".equalsIgnoreCase(fieldType) && IssueFieldConstants.COMMENT.equalsIgnoreCase(fieldName)) {        
            **Object commentId = changeItem.get("id");**        
            if (commentId != null && commentId.toString().length()>0) {

            } 
        }
    }       
} catch (GenericEntityException e) {}