@Override public Map<String, ?> getComment(String authenticationToken, String commentId) { Comment comment = commentManager.getComment(Long.parseLong(commentId)); Map<String, Object> commentStruct = null; if (null != comment && permissionManager.hasPermission(AuthenticatedUserThreadLocal.getUser(), Permission.VIEW, comment)) { commentStruct = new Hashtable<String, Object>(); commentStruct.put("id", comment.getIdAsString()); if (null != comment.getParent()) commentStruct.put("parentId", comment.getParent().getIdAsString()); commentStruct.put("ownerId", comment.getOwner().getIdAsString()); commentStruct.put("content", comment.getBodyAsString()); if (StringUtils.isNotBlank(comment.getCreatorName())) commentStruct.put("creator", comment.getCreatorName()); commentStruct.put("created", comment.getCreationDate()); if (StringUtils.isNotBlank(comment.getLastModifierName())) commentStruct.put("lastModifier", comment.getLastModifierName()); commentStruct.put("lastModified", comment.getLastModificationDate()); } return commentStruct; }
Predicate<String> canCommentOn(final Comment comment) { return username -> permissionManager.hasCreatePermission(userAccessor.getUserByName(username), comment.getContainer(), Comment.class); } }
public Space getSpaceFromContentEntity(ContentEntityObject contentEntityObject) { if (contentEntityObject instanceof AbstractPage) return ((AbstractPage) contentEntityObject).getSpace(); if (contentEntityObject instanceof Comment) return getSpaceFromContentEntity(((Comment) contentEntityObject).getOwner()); return spaceManager.getSpace(((Draft) contentEntityObject).getDraftSpaceKey()); }
page = parentComment.getOwner(); return Either.right(URI.create(applicationProperties.getBaseUrl(UrlMode.CANONICAL) + newComment.getUrlPath()));
private static void fillLineTitleLink(final DetailLine detailLine) { final Addressable content = detailLine.getContent(); final String type = content.getType(); if (Comment.CONTENT_TYPE.equals(type)) { Comment comment = (Comment) content; ContentEntityObject owner = comment.getContainer(); detailLine.setTitle(owner.getDisplayTitle()); detailLine.setSubTitle(comment.getDisplayTitle()); detailLine.setRelativeLink(owner.getUrlPath()); detailLine.setSubRelativeLink(content.getUrlPath()); } else { detailLine.setTitle(content.getDisplayTitle()); detailLine.setRelativeLink(content.getUrlPath()); } }
ContentEntityObject commentOwner = ((Comment) contentObject).getOwner(); spaceKeys.addAll(getSpaceKeys(commentOwner, params));
@Override public Option<String> getSpaceKey() { final ContentEntityObject container = comment.getContainer(); if (container instanceof SpaceContentEntityObject) { return option(((SpaceContentEntityObject) container).getSpaceKey()); } else { return none(); } }
tinyUrlTarget = comment.getOwner(); velocityContext.put("comment", contentEntityObject);
} else if (e instanceof CommentEvent) { entityType = Comment.CONTENT_TYPE; final ContentEntityObject container = ((CommentEvent) e).getComment().getContainer(); if (container instanceof Spaced) { eventSpace = ((Spaced) container).getSpace();
private Option<ActivityObject> getTarget(URI baseUri, Comment comment) { ContentEntityObject owner = comment.getContainer(); // Make sure the owner is legit, with no missing pieces. if (owner == null) { log.debug("Encountered a comment with no owner: " + comment); return none(); } else if (owner.getType() == null) { log.debug("Encountered a comment with an owner with no type. Comment: " + comment + ", Owner: " + owner); return none(); } if (isBlogPost(owner)) { return some(activityObjectFactory.newActivityObject(baseUri, (BlogPost) owner)); } else if (isPage(owner)) { return some(activityObjectFactory.newActivityObject(baseUri, (Page) owner)); } else { return none(); } }
if (Comment.CONTENT_TYPE.equals(contentEntityObject.getType())) { Comment comment = (Comment) contentEntityObject; tinyUrlTarget = comment.getContainer(); context.put("comment", contentEntityObject); } else if (Page.CONTENT_TYPE.equals(contentEntityObject.getType())) {