IssueAuthorizationDto issueAuthorizationDto = authorizationDtoMap.get(project);
if (issueAuthorizationDto == null) {
issueAuthorizationDto = new IssueAuthorizationDto()
- .setProjectUuid(project)
- .setPermission(UserRole.USER);
+ .setProjectUuid(project);
issueAuthorizationDto.setUpdatedAt(updatedAt);
}
if (group != null) {
return getField(IssueAuthorizationNormalizer.IssueAuthorizationField.PROJECT.field());
}
- public String permission() {
- return getField(IssueAuthorizationNormalizer.IssueAuthorizationField.PERMISSION.field());
- }
-
public List<String> groups() {
return (List<String>) getField(IssueAuthorizationNormalizer.IssueAuthorizationField.GROUPS.field());
}
public static final class IssueAuthorizationField extends Indexable {
public static final IndexField PROJECT = add(IndexField.Type.STRING, "project");
- public static final IndexField PERMISSION = add(IndexField.Type.STRING, "permission");
public static final IndexField GROUPS = add(IndexField.Type.STRING, "groups");
public static final IndexField USERS = add(IndexField.Type.STRING, "users");
public static final IndexField UPDATED_AT = add(IndexField.Type.DATE, BaseNormalizer.UPDATED_AT_FIELD);
- public static final Set<IndexField> ALL_FIELDS = ImmutableSet.of(PROJECT, PERMISSION, GROUPS, USERS, UPDATED_AT);
+ public static final Set<IndexField> ALL_FIELDS = ImmutableSet.of(PROJECT, GROUPS, USERS, UPDATED_AT);
}
@Override
Preconditions.checkNotNull(dto.getProjectUuid(), "Project uuid is null");
update.put(IssueAuthorizationField.PROJECT.field(), dto.getProjectUuid());
- update.put(IssueAuthorizationField.PERMISSION.field(), dto.getPermission());
update.put(IssueAuthorizationField.USERS.field(), dto.getUsers());
update.put(IssueAuthorizationField.GROUPS.field(), dto.getGroups());
update.put(IssueAuthorizationField.UPDATED_AT.field(), dto.getUpdatedAt());
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.sonar.api.issue.Issue;
-import org.sonar.api.web.UserRole;
import org.sonar.core.issue.db.IssueDto;
import org.sonar.server.issue.IssueQuery;
import org.sonar.server.issue.filter.IssueFilterParameters;
QueryBuilders.filteredQuery(
QueryBuilders.matchAllQuery(),
FilterBuilders.boolFilter()
- .must(FilterBuilders.termFilter(IssueAuthorizationNormalizer.IssueAuthorizationField.PERMISSION.field(), UserRole.USER), groupsAndUser)
+ .must(groupsAndUser)
.cache(true))
);
}
IssueAuthorizationDoc issueAuthorizationDoc = index.getByKey(project.uuid());
assertThat(issueAuthorizationDoc).isNotNull();
assertThat(issueAuthorizationDoc.project()).isEqualTo("ABCD");
- assertThat(issueAuthorizationDoc.permission()).isEqualTo("user");
assertThat(issueAuthorizationDoc.groups()).containsExactly("devs");
assertThat(issueAuthorizationDoc.users()).containsExactly("john");
assertThat(issueAuthorizationDoc.updatedAt()).isNotNull();
IssueAuthorizationDoc issueAuthorizationDoc = index.getByKey(project.uuid());
assertThat(issueAuthorizationDoc).isNotNull();
assertThat(issueAuthorizationDoc.project()).isEqualTo("ABCD");
- assertThat(issueAuthorizationDoc.permission()).isEqualTo("user");
assertThat(issueAuthorizationDoc.groups()).containsExactly("devs");
assertThat(issueAuthorizationDoc.users()).containsExactly("john");
assertThat(issueAuthorizationDoc.updatedAt()).isNotNull();
IssueAuthorizationDoc issueAuthorizationDoc = index.getNullableByKey(project.uuid());
assertThat(issueAuthorizationDoc).isNotNull();
assertThat(issueAuthorizationDoc.project()).isEqualTo(project.uuid());
- assertThat(issueAuthorizationDoc.permission()).isEqualTo(UserRole.USER);
assertThat(issueAuthorizationDoc.users()).containsExactly(user.getLogin());
assertThat(issueAuthorizationDoc.groups()).isEmpty();
}
IssueAuthorizationDoc issueAuthorizationDoc = index.getNullableByKey(project.uuid());
assertThat(issueAuthorizationDoc).isNotNull();
assertThat(issueAuthorizationDoc.project()).isEqualTo(project.uuid());
- assertThat(issueAuthorizationDoc.permission()).isEqualTo(UserRole.USER);
assertThat(issueAuthorizationDoc.users()).containsExactly(user2.getLogin());
assertThat(issueAuthorizationDoc.groups()).isEmpty();
}
return this;
}
- public String getPermission() {
- return permission;
- }
-
- public IssueAuthorizationDto setPermission(String permission) {
- this.permission = permission;
- return this;
- }
-
public List<String> getGroups() {
return groups;
}
public void getter_and_setter() throws Exception {
IssueAuthorizationDto dto = new IssueAuthorizationDto()
.setProjectUuid("Sample")
- .setPermission("user")
.setGroups(newArrayList("sonar-users"))
.setUsers(newArrayList("john"));
assertThat(dto.getKey()).isEqualTo("Sample");
assertThat(dto.getProjectUuid()).isEqualTo("Sample");
- assertThat(dto.getPermission()).isEqualTo("user");
assertThat(dto.getGroups()).containsExactly("sonar-users");
assertThat(dto.getUsers()).containsExactly("john");
}
public void add_group() throws Exception {
IssueAuthorizationDto dto = new IssueAuthorizationDto()
.setProjectUuid("Sample")
- .setPermission("user")
.setGroups(newArrayList("sonar-users"))
.setUsers(newArrayList("john"));
public void add_user() throws Exception {
IssueAuthorizationDto dto = new IssueAuthorizationDto()
.setProjectUuid("Sample")
- .setPermission("user")
.setGroups(newArrayList("sonar-users"))
.setUsers(newArrayList("john"));