use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchAction method toWsFavorite.
private static Favorite toWsFavorite(Favorite.Builder builder, SearchResults results, ComponentDto componentDto) {
OrganizationDto organization = results.organizationsByUuid.get(componentDto.getOrganizationUuid());
checkArgument(organization != null, "Organization with uuid '%s' not found for favorite with uuid '%s'", componentDto.getOrganizationUuid(), componentDto.uuid());
builder.clear().setOrganization(organization.getKey()).setKey(componentDto.key());
setNullable(componentDto.name(), builder::setName);
setNullable(componentDto.qualifier(), builder::setQualifier);
return builder.build();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ListAction method populateProjectFields.
private static Notification.Builder populateProjectFields(Notification.Builder notification, Long componentId, Map<String, OrganizationDto> organizationsByUuid, Map<Long, ComponentDto> projectsById) {
ComponentDto project = projectsById.get(componentId);
String organizationUuid = project.getOrganizationUuid();
OrganizationDto organizationDto = organizationsByUuid.get(organizationUuid);
checkArgument(organizationDto != null, "No organization for uuid '%s'", organizationUuid);
return notification.setOrganization(organizationDto.getKey()).setProject(project.getKey()).setProjectName(project.name());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class DefaultOrganizationProviderImpl method getDefaultOrganization.
private static DefaultOrganization getDefaultOrganization(DbClient dbClient) {
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<String> uuid = dbClient.internalPropertiesDao().selectByKey(dbSession, InternalProperties.DEFAULT_ORGANIZATION);
checkState(uuid.isPresent() && !uuid.get().isEmpty(), "No Default organization uuid configured");
Optional<OrganizationDto> dto = dbClient.organizationDao().selectByUuid(dbSession, uuid.get());
checkState(dto.isPresent(), "Default organization with uuid '%s' does not exist", uuid.get());
return toDefaultOrganization(dto.get());
}
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class OrganizationCreationImpl method insertOrganization.
private OrganizationDto insertOrganization(DbSession dbSession, NewOrganization newOrganization, Consumer<OrganizationDto> extendCreation) {
OrganizationDto res = new OrganizationDto().setUuid(uuidFactory.create()).setName(newOrganization.getName()).setKey(newOrganization.getKey()).setDescription(newOrganization.getDescription()).setUrl(newOrganization.getUrl()).setAvatarUrl(newOrganization.getAvatar());
extendCreation.accept(res);
dbClient.organizationDao().insert(dbSession, res);
return res;
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class OrganizationCreationImpl method create.
@Override
public OrganizationDto create(DbSession dbSession, int creatorUserId, NewOrganization newOrganization) throws KeyConflictException {
validate(newOrganization);
String key = newOrganization.getKey();
if (organizationKeyIsUsed(dbSession, key)) {
throw new KeyConflictException(format("Organization key '%s' is already used", key));
}
OrganizationDto organization = insertOrganization(dbSession, newOrganization, dto -> {
});
GroupDto group = insertOwnersGroup(dbSession, organization);
insertDefaultTemplate(dbSession, organization, group);
addCurrentUserToGroup(dbSession, group, creatorUserId);
dbSession.commit();
return organization;
}
Aggregations