public String generateCloseTag(Node node) { if (node == null) return null; switch (node.getNodeType()) { case Node.ELEMENT_NODE: { ElementImpl element = (ElementImpl) node; if (element.isCommentTag()) { if (element.isJSPTag()) return JSPTag.COMMENT_CLOSE; return COMMENT_CLOSE; } if (element.isJSPTag()) return JSPTag.TAG_CLOSE; if (element.isEmptyTag()) return EMPTY_CLOSE; return TAG_CLOSE; } case Node.COMMENT_NODE: { CommentImpl comment = (CommentImpl) node; if (comment.isJSPTag()) return JSPTag.COMMENT_CLOSE; return COMMENT_CLOSE; } case Node.DOCUMENT_TYPE_NODE: return TAG_CLOSE; case Node.PROCESSING_INSTRUCTION_NODE: return PI_CLOSE; case Node.CDATA_SECTION_NODE: return CDATA_CLOSE; default: break; } return null; }
/** * generateComment method * * @return java.lang.String * @param comment org.w3c.dom.Comment */ public String generateComment(Comment comment) { if (comment == null) return null; String data = comment.getData(); int length = (data != null ? data.length() : 0); StringBuffer buffer = new StringBuffer(length + 8); CommentImpl impl = (CommentImpl) comment; if (!impl.isJSPTag()) buffer.append(COMMENT_OPEN); else buffer.append(JSPTag.COMMENT_OPEN); if (data != null) buffer.append(data); if (!impl.isJSPTag()) buffer.append(COMMENT_CLOSE); else buffer.append(JSPTag.COMMENT_CLOSE); return buffer.toString(); }
@Override public Object clone() { CommentImpl commentImpl = new CommentImpl(); commentImpl.setCommentId(getCommentId()); commentImpl.setQuestionId(getQuestionId()); commentImpl.setAnswerId(getAnswerId()); commentImpl.setUserId(getUserId()); commentImpl.setMessage(getMessage()); commentImpl.setCreated(getCreated()); commentImpl.resetOriginalValues(); return commentImpl; }
public void add(Comment comment) { CommentImpl commentImpl = (CommentImpl) comment; _branch.add(commentImpl.getWrappedComment()); }
public boolean remove(Comment comment) { CommentImpl commentImpl = (CommentImpl) comment; return _branch.remove(commentImpl.getWrappedComment()); }
public Comment create( Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, Map<String, JSONObject> commentProperties, boolean dispatchEvent, boolean modifyIssueUpdateDate) { if (textFieldCharacterLengthValidator.isTextTooLong(body)) { final long maximumNumberOfCharacters = textFieldCharacterLengthValidator.getMaximumNumberOfCharacters(); String errorMessage = getText("field.error.text.toolong", String.valueOf(maximumNumberOfCharacters)); throw new IllegalArgumentException(errorMessage); } // create new instance of comment CommentImpl comment = new CommentImpl( projectRoleManager, author, updateAuthor, body, groupLevel, roleLevelId, created, updated, issue); // create persistable generic value Map<String, Object> fields = new HashMap<String, Object>(); fields.put("issue", issue.getId()); fields.put("type", ActionConstants.TYPE_COMMENT); ApplicationUser commentAuthor = comment.getAuthorApplicationUser(); ApplicationUser commentUpdateAuthor = comment.getUpdateAuthorApplicationUser(); fields.put("author", commentAuthor == null ? null : commentAuthor.getKey()); fields.put("updateauthor", commentUpdateAuthor == null ? null : commentUpdateAuthor.getKey()); fields.put("body", comment.getBody()); fields.put("level", comment.getGroupLevel()); fields.put("rolelevel", comment.getRoleLevelId()); fields.put("created", new Timestamp(comment.getCreated().getTime())); fields.put("updated", new Timestamp(comment.getUpdated().getTime())); GenericValue commentGV = EntityUtils.createValue(COMMENT_ENTITY, fields); // set the ID on comment object comment.setId(commentGV.getLong(COMMENT_ID)); // Update the issue object if required if (modifyIssueUpdateDate) { // JRA-36334: Only modify the Issue updated date if it would move forward - we don't want it // to go back in time if (comment.getUpdated().getTime() > issue.getUpdated().getTime()) { IssueFactory issueFactory = ComponentAccessor.getComponentOfType(IssueFactory.class); MutableIssue mutableIssue = issueFactory.getIssue(issue.getGenericValue()); // JRA-15723: Use the comments updated time for the updated time of the issue. This allows // users to // import old comments without setting the updated time on the issue to now, but to the date // of the old comments. mutableIssue.setUpdated(new Timestamp(comment.getUpdated().getTime())); issue.store(); } } if (commentProperties != null) { setProperties(author, comment, commentProperties); } // Dispatch an event if required if (dispatchEvent) { Map<String, Object> params = new HashMap<String, Object>(); params.put("eventsource", IssueEventSource.ACTION); dispatchIssueCommentAddedEvent(comment, params); } return comment; }