Predicate<String> canCommentOn(final Comment comment) { return username -> permissionManager.hasCreatePermission(userAccessor.getUserByName(username), comment.getContainer(), Comment.class); } }
@Override public Option<String> getSpaceKey() { final ContentEntityObject container = comment.getContainer(); if (container instanceof SpaceContentEntityObject) { return option(((SpaceContentEntityObject) container).getSpaceKey()); } else { return none(); } }
} 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())) {
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()); } }