return mapper(dbSession).selectUserPermissionsByTemplateIdAndUserLogins(templateId, Collections.emptyList());
}
+ /**
+ * @deprecated does not support organizations. Should return group ids.
+ */
+ @Deprecated
public List<String> selectGroupNamesByQueryAndTemplate(DbSession session, PermissionQuery query, long templateId) {
return mapper(session).selectGroupNamesByQueryAndTemplate(query, templateId, new RowBounds(query.getPageOffset(), query.getPageSize()));
}
return mapper(session).selectByUuid(templateUuid);
}
+ /**
+ * @deprecated does not support organizations. Should return group ids.
+ */
+ @Deprecated
public List<PermissionTemplateDto> selectAll(DbSession session, String nameMatch) {
String uppercaseNameMatch = toUppercaseSqlQuery(nameMatch);
return mapper(session).selectAll(uppercaseNameMatch);
}
+ /**
+ * @deprecated does not support organizations. Should return group ids.
+ */
+ @Deprecated
public List<PermissionTemplateDto> selectAll(DbSession session) {
return mapper(session).selectAll(null);
}
}
- public PermissionTemplateDto insert(DbSession session, PermissionTemplateDto permissionTemplate) {
- mapper(session).insert(permissionTemplate);
- session.commit();
-
- return permissionTemplate;
+ public PermissionTemplateDto insert(DbSession session, PermissionTemplateDto dto) {
+ mapper(session).insert(dto);
+ return dto;
}
/**
public PermissionTemplateDto update(DbSession session, PermissionTemplateDto permissionTemplate) {
mapper(session).update(permissionTemplate);
- session.commit();
-
return permissionTemplate;
}
/**
* Remove a group from all templates (used when removing a group)
*/
- public void deleteByGroup(DbSession session, Long groupId) {
+ public void deleteByGroup(DbSession session, long groupId) {
session.getMapper(PermissionTemplateMapper.class).deleteByGroupId(groupId);
}
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
-import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.user.GroupDto;
public ExpectedException expectedException = ExpectedException.none();
@Rule
public DbTester db = DbTester.create(system);
- private DbClient dbClient = db.getDbClient();
private DbSession dbSession = db.getSession();
private PermissionTemplateDbTester templateDb = new PermissionTemplateDbTester(db);
.setName("my template")
.setDescription("my description")
.setKeyPattern("myregexp"));
+ db.commit();
assertThat(permissionTemplate).isNotNull();
assertThat(permissionTemplate.getId()).isEqualTo(1L);
.setDescription("new_description")
.setKeyPattern("new_regexp");
underTest.update(dbSession, dto);
+ db.commit();
db.assertDbUnitTable(getClass(), "updatePermissionTemplate-result.xml", "permission_templates", "id", "name", "kee", "description");
}