private final Boolean planned;
private final Boolean resolved;
private final Boolean hideRules;
+ private final Boolean hideComments;
private final Date createdAt;
private final Date createdAfter;
private final Date createdBefore;
this.planned = builder.planned;
this.resolved = builder.resolved;
this.hideRules = builder.hideRules;
+ this.hideComments = builder.hideComments;
this.createdAt = builder.createdAt;
this.createdAfter = builder.createdAfter;
this.createdBefore = builder.createdBefore;
return hideRules;
}
+ /**
+ * @since 5.1
+ */
+ @CheckForNull
+ public Boolean hideComments() {
+ return hideComments;
+ }
+
@CheckForNull
public Date createdAfter() {
return createdAfter == null ? null : new Date(createdAfter.getTime());
private Boolean planned = null;
private Boolean resolved = null;
private Boolean hideRules = false;
+ private Boolean hideComments = false;
private Date createdAt;
private Date createdAfter;
private Date createdBefore;
return this;
}
+ /**
+ * If true, comments will not be loaded
+ * If false, comments will be loaded
+ *
+ * @since 5.1
+ *
+ */
+ public Builder hideComments(@Nullable Boolean b) {
+ this.hideComments = b;
+ return this;
+ }
+
public Builder createdAt(@Nullable Date d) {
this.createdAt = d == null ? null : new Date(d.getTime());
return this;
public static final String ASSIGNED = "assigned";
public static final String PLANNED = "planned";
public static final String HIDE_RULES = "hideRules";
+ public static final String HIDE_COMMENTS = "hideComments";
public static final String CREATED_AFTER = "createdAfter";
public static final String CREATED_AT = "createdAt";
public static final String CREATED_BEFORE = "createdBefore";
public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS, TAGS,
ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC, COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS,
- PROJECTS, PROJECT_UUIDS, IGNORE_PAGING, PROJECT_KEYS, COMPONENT_KEYS, MODULE_UUIDS, DIRECTORIES, FILE_UUIDS, AUTHORS);
+ PROJECTS, PROJECT_UUIDS, IGNORE_PAGING, PROJECT_KEYS, COMPONENT_KEYS, MODULE_UUIDS, DIRECTORIES, FILE_UUIDS, AUTHORS, HIDE_COMMENTS);
public static final List<String> ALL_WITHOUT_PAGINATION = newArrayList(Iterables.filter(ALL, new Predicate<String>() {
@Override
.setDescription("To not return rules")
.setDefaultValue(false)
.setBooleanPossibleValues();
+ action.createParam(IssueFilterParameters.HIDE_COMMENTS)
+ .setDescription("To not return comments")
+ .setDefaultValue(false)
+ .setBooleanPossibleValues();
action.createParam(IssueFilterParameters.ACTION_PLANS)
.setDescription("Comma-separated list of action plan keys (not names)")
.setExampleValue("3f19de90-1521-4482-a737-a311758ff513");
DbSession session = dbClient.openSession(false);
try {
- List<DefaultIssueComment> comments = dbClient.issueChangeDao().selectCommentsByIssues(session, issueKeys);
- for (DefaultIssueComment issueComment : comments) {
- userLogins.add(issueComment.userLogin());
- commentsByIssues.put(issueComment.issueKey(), issueComment);
+ if (!BooleanUtils.isTrue(request.paramAsBoolean(IssueFilterParameters.HIDE_COMMENTS))) {
+ List<DefaultIssueComment> comments = dbClient.issueChangeDao().selectCommentsByIssues(session, issueKeys);
+ for (DefaultIssueComment issueComment : comments) {
+ userLogins.add(issueComment.userLogin());
+ commentsByIssues.put(issueComment.issueKey(), issueComment);
+ }
}
usersByLogin = getUsersByLogin(userLogins);
assertThat(show.isPost()).isFalse();
assertThat(show.isInternal()).isFalse();
assertThat(show.responseExampleAsString()).isNotEmpty();
- assertThat(show.params()).hasSize(38);
+ assertThat(show.params()).hasSize(39);
}
@Test
result.assertJson(this.getClass(), "issue_with_comment.json", false);
}
+ @Test
+ public void issue_with_comment_hidden() throws Exception {
+ db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
+ db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
+
+ ComponentDto project = insertComponent(ComponentTesting.newProjectDto("ABCD").setKey("MyProject"));
+ setDefaultProjectPermission(project);
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "BCDE").setKey("MyComponent"));
+ IssueDto issue = IssueTesting.newDto(newRule(), file, project)
+ .setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
+ db.issueDao().insert(session, issue);
+
+ tester.get(IssueChangeDao.class).insert(session,
+ new IssueChangeDto().setIssueKey(issue.getKey())
+ .setKey("COMMENT-ABCD")
+ .setChangeData("*My comment*")
+ .setChangeType(IssueChangeDto.TYPE_COMMENT)
+ .setUserLogin("john")
+ .setCreatedAt(DateUtils.parseDate("2014-09-09").getTime()));
+ tester.get(IssueChangeDao.class).insert(session,
+ new IssueChangeDto().setIssueKey(issue.getKey())
+ .setKey("COMMENT-ABCE")
+ .setChangeData("Another comment")
+ .setChangeType(IssueChangeDto.TYPE_COMMENT)
+ .setUserLogin("fabrice")
+ .setCreatedAt(DateUtils.parseDate("2014-09-10").getTime()));
+ session.commit();
+ tester.get(IssueIndexer.class).indexAll();
+
+ MockUserSession.set().setLogin("john");
+ WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.HIDE_COMMENTS, "true").execute();
+ result.assertJson(this.getClass(), "issue_with_comment_hidden.json", false);
+ assertThat(result.outputAsString()).doesNotContain("fabrice");
+ }
+
@Test
public void issue_with_action_plan() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("ABCD").setKey("MyProject"));
--- /dev/null
+{
+ "issues": [
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2"
+ }
+ ]
+}