use of org.sonar.db.permission.template.PermissionTemplateCharacteristicDto in project sonarqube by SonarSource.
the class SearchTemplatesActionTest method addPermissionTemplateWithProjectCreator.
private void addPermissionTemplateWithProjectCreator(String templateUuid, String permission, String templateName) {
dbClient.permissionTemplateCharacteristicDao().insert(dbSession, new PermissionTemplateCharacteristicDto().setUuid(Uuids.createFast()).setWithProjectCreator(true).setTemplateUuid(templateUuid).setPermission(permission).setCreatedAt(1_000_000_000L).setUpdatedAt(2_000_000_000L), templateName);
db.commit();
}
use of org.sonar.db.permission.template.PermissionTemplateCharacteristicDto in project sonarqube by SonarSource.
the class RemoveProjectCreatorFromTemplateAction method updateTemplateCharacteristic.
private void updateTemplateCharacteristic(DbSession dbSession, PermissionTemplateCharacteristicDto templatePermission) {
PermissionTemplateCharacteristicDto targetTemplatePermission = templatePermission.setUpdatedAt(system.now()).setWithProjectCreator(false);
dbClient.permissionTemplateCharacteristicDao().update(dbSession, targetTemplatePermission);
dbSession.commit();
}
use of org.sonar.db.permission.template.PermissionTemplateCharacteristicDto in project sonarqube by SonarSource.
the class AddProjectCreatorToTemplateAction method addTemplatePermission.
private void addTemplatePermission(DbSession dbSession, AddProjectCreatorToTemplateRequest request, PermissionTemplateDto template) {
long now = system.now();
dbClient.permissionTemplateCharacteristicDao().insert(dbSession, new PermissionTemplateCharacteristicDto().setUuid(Uuids.create()).setPermission(request.getPermission()).setTemplateUuid(template.getUuid()).setWithProjectCreator(true).setCreatedAt(now).setUpdatedAt(now), template.getName());
dbSession.commit();
}
use of org.sonar.db.permission.template.PermissionTemplateCharacteristicDto in project sonarqube by SonarSource.
the class AddProjectCreatorToTemplateAction method doHandle.
private void doHandle(AddProjectCreatorToTemplateRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, WsTemplateRef.newTemplateRef(request.getTemplateId(), request.getTemplateName()));
checkGlobalAdmin(userSession);
Optional<PermissionTemplateCharacteristicDto> templatePermission = dbClient.permissionTemplateCharacteristicDao().selectByPermissionAndTemplateId(dbSession, request.getPermission(), template.getUuid());
if (templatePermission.isPresent()) {
updateTemplatePermission(dbSession, templatePermission.get(), template.getName());
} else {
addTemplatePermission(dbSession, request, template);
}
}
}
use of org.sonar.db.permission.template.PermissionTemplateCharacteristicDto in project sonarqube by SonarSource.
the class AddProjectCreatorToTemplateAction method updateTemplatePermission.
private void updateTemplatePermission(DbSession dbSession, PermissionTemplateCharacteristicDto templatePermission, String templateName) {
PermissionTemplateCharacteristicDto targetTemplatePermission = templatePermission.setUpdatedAt(system.now()).setWithProjectCreator(true);
dbClient.permissionTemplateCharacteristicDao().update(dbSession, targetTemplatePermission, templateName);
dbSession.commit();
}
Aggregations