private void validateEditComment(
     ErrorCollection errorCollection,
     Issue issue,
     Map<String, Object> commentParams,
     String body,
     Visibility visibility,
     ApplicationUser user) {
   if (commentParams.get(PARAM_COMMENT_ID) != null) {
     try {
       commentService.isValidCommentBody(body, errorCollection);
       final Long commentIdAsLong = Long.valueOf((String) commentParams.get(PARAM_COMMENT_ID));
       commentService.hasPermissionToEdit(
           new JiraServiceContextImpl(user, errorCollection), commentIdAsLong);
       commentService.isValidCommentVisibility(user, issue, visibility, errorCollection);
       validateCommentProperties(commentParams, errorCollection);
     } catch (NumberFormatException ex) {
       errorCollection.addError(IssueFieldConstants.COMMENT, "invalid comment id specified.");
     }
   } else {
     errorCollection.addError(IssueFieldConstants.COMMENT, "no comment id specified.");
   }
 }
  private void validateCreateComment(
      ErrorCollection errorCollection,
      Issue issue,
      Map<String, Object> commentParams,
      String body,
      Visibility visibility,
      ApplicationUser user) {
    // Validate user has the correct permissions IF we are actually adding a comment
    if (StringUtils.isNotBlank(body)) {
      commentService.hasPermissionToCreate(user, issue, errorCollection);
    }
    boolean allowEmptyComments = true;
    if (commentParams.get(CREATE_COMMENT) != null) {
      allowEmptyComments = false;
    }

    commentService.isValidCommentBody(body, errorCollection, allowEmptyComments);

    // Validate the group and role level settings
    commentService.isValidCommentVisibility(user, issue, visibility, errorCollection);
    validateCommentProperties(commentParams, errorCollection);
  }