protected void sendComments()

in src/main/java/com/atlassian/uwc/ui/ConverterEngine.java [2313:2363]


	protected void sendComments(Page page, RemoteWikiBroker broker, String pageId, ConfluenceServerSettings confSettings) {
		if (page.hasComments()) {
			log.debug("Sending comments for page: " + page.getName());
			try {
				for (Comment comment : page.getAllCommentData()) {
					if (comment == null) {
						log.error("Comment was null! SKIPPING");
						this.errors.addError(Feedback.CONVERTER_ERROR, "Comment should not be null!", true);
						continue; 
					}
					//create page that broker can use
					CommentForXmlRpc brokerComment = new CommentForXmlRpc();
					brokerComment.setPageId(pageId);
					String commentcontent = comment.text;
					if (!comment.isXhtml()) {
						commentcontent = getContentAsXhtmlFormat(broker, confSettings, comment.text);
					}
					brokerComment.setContent(commentcontent);
					//upload comment
					CommentForXmlRpc uploadedComment = broker.addComment(confSettings, brokerComment);
					if (comment.hasCreator()) {
						boolean usersMustExist = false;
						broker.setCreator(confSettings, comment.creator, uploadedComment.getId(), usersMustExist);
						broker.setLastModifier(confSettings, comment.creator, uploadedComment.getId(), usersMustExist);
					}
					if (comment.hasTimestamp()) {
						broker.setCreateDate(confSettings, comment.timestamp, uploadedComment.getId());
						broker.setLastModifiedDate(confSettings, comment.timestamp, uploadedComment.getId());
					}
				}
			} catch (Exception e) {
				String errorMessage = null;
				if (e.getMessage() == null) {
					log.error("Problem with comments!", e);
					return;
				}
				else if (e.getMessage().contains("NotPermittedException")) {
					errorMessage = "User is not permitted to add comments to page: " + page.getName() + "'";
				}
				else if (e.getMessage().contains("does not exist")) {
					errorMessage = "Cannot add comments to the page because it does not exist: " + page.getName();
				}
				else {
					errorMessage = "Could not send comments to page '" + page.getName() +"'";
				}
				log.error(Feedback.REMOTE_API_ERROR + ": " + errorMessage);
				this.errors.addError(Feedback.REMOTE_API_ERROR, errorMessage, true);
			}
		}
		//    	else log.debug("Page has no comments."); //DELETE
	}