/** * @deprecated Use {@link #shortBeans(java.util.Collection, JiraBaseUrls, com.atlassian.jira.security.roles.ProjectRoleManager, com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.util.EmailFormatter)} */ @Deprecated public static Collection<CommentJsonBean> shortBeans(final Collection<Comment> comments, final JiraBaseUrls urls, final ProjectRoleManager projectRoleManager) { return shortBeans(comments, urls, projectRoleManager, ComponentAccessor.getComponent(JiraAuthenticationContext.class).getUser(), ComponentAccessor.getComponent(EmailFormatter.class)); }
public static Collection<CommentJsonBean> expandedShortBeans(final Collection<Comment> comments, final JiraBaseUrls urls, final ProjectRoleManager projectRoleManager, final DateTimeFormatterFactory dateTimeFormatterFactory, final RendererManager rendererManager, final String rendererType, final IssueRenderContext renderContext, final String expand, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { Collection<CommentJsonBean> result = Lists.newArrayListWithCapacity(comments.size()); for (Comment from : comments) { result.add(expandedShortBean(from, urls, projectRoleManager, dateTimeFormatterFactory, rendererManager, rendererType, renderContext, expand, loggedInUser, emailFormatter)); } return Lists.newArrayList(result); }
private void performEditOperation(CommentJsonBean commentJson, IssueInputParameters parameters, ErrorCollection errors) if (StringUtils.isNotEmpty(commentJson.getId())) parameters.getActionParameters().put(CommentSystemField.PARAM_COMMENT_ID, new String[] { commentJson.getId() }); if (commentJson.getBody() == null) Comment comment = commentManager.getCommentById(Long.valueOf(commentJson.getId())); if (comment != null) commentParams.add(commentJson.getBody());
public static Collection<CommentJsonBean> renderedShortBeans(final Collection<Comment> comments, final JiraBaseUrls urls, final ProjectRoleManager projectRoleManager, final DateTimeFormatterFactory dateTimeFormatterFactory, final RendererManager rendererManager, final String rendererType, final IssueRenderContext renderContext, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { Collection<CommentJsonBean> result = Lists.newArrayListWithCapacity(comments.size()); for (Comment from : comments) { result.add(renderedShortBean(from, urls, projectRoleManager, dateTimeFormatterFactory, rendererManager, rendererType, renderContext, loggedInUser, emailFormatter)); } return Lists.newArrayList(result); }
if (request.getId() != null && !request.getId().equals(commentId)) if (request.isVisibilitySet()) visibility = Visibilities.fromVisibilityBean(request.getVisibility(), projectRoleManager); .body(request.getBody()) .commentProperties(getCommentProperties(request.getProperties())) .visibility(visibility) .issue(issue)
@Override public Response apply(final CommentService.CommentParameters commentParameters) { Comment comment = commentService.create(user, commentValidationResult, true); CommentJsonBean entity; if (expand != null) { entity = CommentJsonBean.expandedShortBean(comment, jiraBaseUrls, projectRoleManager, dateTimeFormatterFactory, rendererManager, getCommentFieldRendererType(issue), issue.getIssueRenderContext(), expand, authContext.getUser(), emailFormatter); } else { entity = CommentJsonBean.shortBean(comment, jiraBaseUrls, projectRoleManager, authContext.getUser(), emailFormatter); } return Response.status(Response.Status.CREATED).location(getUri(entity)).entity(entity).cacheControl(never()).build(); } });
Visibility commentVisibility = Visibilities.fromVisibilityBean(request.getVisibility(), projectRoleManager); .body(request.getBody()) .commentProperties(getCommentProperties(request.getProperties())) .visibility(commentVisibility) .issue(issue)
if (commentBean.getVisibility() != null) final VisibilityJsonBean visibility = commentBean.getVisibility(); Long role; String group; role = null; comment = commentService.create(authContext.getUser(), fromIssue, commentBean.getBody(), group, role, false, errorCollection); comment = commentService.create(authContext.getUser(), fromIssue, commentBean.getBody(), false, errorCollection);
commentsWithPaginationJsonBean.setTotal(comments.size()); commentsWithPaginationJsonBean.setStartAt(0); commentsWithPaginationJsonBean.setComments(CommentJsonBean.shortBeans(comments, jiraBaseUrls, projectRoleManager, authenticationContext.getUser(), emailFormatter)); FieldJsonRepresentation fieldJsonRepresentation = new FieldJsonRepresentation(new JsonData(commentsWithPaginationJsonBean)); renderedBean.setTotal(comments.size()); renderedBean.setStartAt(0); renderedBean.setComments(CommentJsonBean.renderedShortBeans(comments, jiraBaseUrls, projectRoleManager, dateTimeFormatterFactory, rendererManager, fieldLayoutItem == null ? null : fieldLayoutItem.getRendererType(), issue.getIssueRenderContext(), authenticationContext.getUser(), emailFormatter)); fieldJsonRepresentation.setRenderedData(new JsonData(renderedBean));
CommentJsonBean.expandedShortBeans(commentsForUser, jiraBaseUrls, projectRoleManager, dateTimeFormatterFactory, rendererManager, getCommentFieldRendererType(issue), issue.getIssueRenderContext(), expand, authContext.getUser(), emailFormatter); commentJsonBeans = CommentJsonBean.shortBeans(commentsForUser, jiraBaseUrls, projectRoleManager, authContext.getUser(), emailFormatter);
final CommentJsonBean bean = new CommentJsonBean(); addNonRenderableStuff(bean, comment, urls, projectRoleManager, loggedInUser, emailFormatter); if (StringUtils.isNotBlank(rendererType)) bean.properties = getProperties(comment, urls);
if (standardOperation.equals(StandardOperation.REMOVE) || !commentJsonBean.isVisibilitySet()) VisibilityJsonBean commentVisibility = commentJsonBean.getVisibility(); String securityLevel = null; if (commentVisibility == null)
public static Collection<CommentJsonBean> shortBeans(final Collection<Comment> comments, final JiraBaseUrls urls, final ProjectRoleManager projectRoleManager, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { Collection<CommentJsonBean> result = Lists.newArrayListWithCapacity(comments.size()); for (Comment from : comments) { result.add(shortBean(from, urls, projectRoleManager, loggedInUser, emailFormatter)); } return result; }
private void performAddOperation(CommentJsonBean commentJson, IssueInputParameters parameters, ErrorCollection errors) { parameters.getActionParameters().put(CommentSystemField.CREATE_COMMENT, new String[] { "true" }); final List<String> commentParams = new ArrayList<String>(); commentParams.add(commentJson.getBody()); parameters.getActionParameters().put(IssueFieldConstants.COMMENT, commentParams.toArray(new String[commentParams.size()])); }
private void performRemoveOperation(CommentJsonBean commentJson, IssueInputParameters parameters, ErrorCollection errors) { parameters.getActionParameters().put(CommentSystemField.REMOVE_COMMENT, new String[] { "true" }); final List<String> commentParams = new ArrayList<String>(); if (StringUtils.isNotEmpty(commentJson.getId())) { parameters.getActionParameters().put(CommentSystemField.PARAM_COMMENT_ID, new String[] { commentJson.getId() }); } //The field validation for the comment field only works if there is a body in the action params. commentParams.add("DUMMY BODY"); parameters.getActionParameters().put(IssueFieldConstants.COMMENT, commentParams.toArray(new String[commentParams.size()])); } }
/** * @return null if the input is null * @deprecated Use {@link #expandedShortBean(com.atlassian.jira.issue.comments.Comment, JiraBaseUrls, com.atlassian.jira.security.roles.ProjectRoleManager, com.atlassian.jira.datetime.DateTimeFormatterFactory, com.atlassian.jira.issue.RendererManager, String, com.atlassian.jira.issue.fields.renderer.IssueRenderContext, String, com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.util.EmailFormatter)} */ @Deprecated public static CommentJsonBean expandedShortBean(Comment comment, JiraBaseUrls urls, ProjectRoleManager projectRoleManager, DateTimeFormatterFactory dateTimeFormatterFactory, RendererManager rendererManager, String rendererType, IssueRenderContext renderContext, final String expand) { return expandedShortBean(comment, urls, projectRoleManager, dateTimeFormatterFactory, rendererManager, rendererType, renderContext, expand, ComponentAccessor.getComponent(JiraAuthenticationContext.class).getUser(), ComponentAccessor.getComponent(EmailFormatter.class)); }
@Override public Response apply(final Map<String, JSONObject> properties) { Comment updatedComment = commentValidationResult.getComment().get(); commentService.update(user, commentValidationResult, true); CommentJsonBean bean; if (expand != null) { bean = CommentJsonBean.expandedShortBean(updatedComment, jiraBaseUrls, projectRoleManager, dateTimeFormatterFactory, rendererManager, getCommentFieldRendererType(issue), issue.getIssueRenderContext(), expand, authContext.getUser(), emailFormatter); } else { bean = CommentJsonBean.shortBean(updatedComment, jiraBaseUrls, projectRoleManager, authContext.getUser(), emailFormatter); } return Response.ok(bean).location(getUri(bean)).cacheControl(never()).build(); } });
if (commentBean != null) VisibilityJsonBean visibility = commentBean.getVisibility(); if (visibility != null) if (commentBean != null && commentBean.getBody() != null)
@Override public CommentJsonBean createBean(Comment comment, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { Assertions.notNull("comment", comment); return CommentJsonBean.shortBean(comment, jiraBaseUrls, projectRoleManager, loggedInUser, emailFormatter); }
private void validateCommentBody(CommentJsonBean commentBean) { if (commentBean.getBody() != null) { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); commentService.isValidCommentBody(commentBean.getBody(), errorCollection); if (errorCollection.hasAnyErrors()) { throw new RESTException(Response.Status.BAD_REQUEST, ErrorCollection.of(errorCollection)); } } }