use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class GenerateAction method doHandle.
private GenerateWsResponse doHandle(DbSession dbSession, GenerateRequest request) {
String serverId = generator.generate(request.getOrganization(), request.getIp());
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(PERMANENT_SERVER_ID).setValue(serverId));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(ORGANISATION).setValue(request.getOrganization()));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(SERVER_ID_IP_ADDRESS).setValue(request.getIp()));
dbSession.commit();
LOG.info("Generated new server ID={}", serverId);
return GenerateWsResponse.newBuilder().setServerId(serverId).build();
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ComponentAction method isFavourite.
private boolean isFavourite(DbSession session, ComponentDto component) {
PropertyQuery propertyQuery = PropertyQuery.builder().setUserId(userSession.getUserId()).setKey("favourite").setComponentId(component.getId()).build();
List<PropertyDto> componentFavourites = dbClient.propertiesDao().selectByQuery(propertyQuery, session);
return componentFavourites.size() == 1;
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class LogServerId method start.
@Override
public void start() {
try (DbSession dbSession = dbClient.openSession(false)) {
String propertyKey = CoreProperties.PERMANENT_SERVER_ID;
PropertyDto serverIdProp = selectProperty(dbSession, propertyKey);
if (serverIdProp != null) {
// a server ID has been generated, let's print out the other useful information that can help debugging license issues
PropertyDto organizationProp = selectProperty(dbSession, CoreProperties.ORGANISATION);
PropertyDto ipAddressProp = selectProperty(dbSession, CoreProperties.SERVER_ID_IP_ADDRESS);
StringBuilder message = new StringBuilder("Server information:\n");
message.append(" - ID : ");
addQuotedValue(serverIdProp, message);
message.append(" - Organization : ");
addQuotedValue(organizationProp, message);
message.append(" - Registered IP: ");
addQuotedValue(ipAddressProp, message);
Loggers.get(LogServerId.class).info(message.toString());
}
}
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method return_project_with_two_modules.
@Test
public void return_project_with_two_modules() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
dbClient.componentDao().insert(dbSession, project);
addDefaultProfile();
// Project properties
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
ComponentDto module1 = ComponentTesting.newModuleDto(project);
dbClient.componentDao().insert(dbSession, module1);
// Module 1 properties
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module1.getId()));
// This property should not be found on the other module
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module1.getId()));
ComponentDto module2 = ComponentTesting.newModuleDto(project);
dbClient.componentDao().insert(dbSession, module2);
// Module 2 property
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION").setResourceId(module2.getId()));
dbSession.commit();
ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR", "sonar.jira.login.secured", "john"));
assertThat(ref.settings(module1.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR-SERVER", "sonar.jira.login.secured", "john", "sonar.coverage.exclusions", "**/*.java"));
assertThat(ref.settings(module2.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR-APPLICATION", "sonar.jira.login.secured", "john"));
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method return_provisioned_project_settings.
@Test
public void return_provisioned_project_settings() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
// No snapshot attached on the project -> provisioned project
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
dbClient.componentDao().insert(dbSession, project);
addDefaultProfile();
// Project properties
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
dbSession.commit();
ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR", "sonar.jira.login.secured", "john"));
}
Aggregations