Search in sources :

Example 31 with PropertyDto

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();
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Example 32 with PropertyDto

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;
}
Also used : PropertyQuery(org.sonar.db.property.PropertyQuery) PropertyDto(org.sonar.db.property.PropertyDto)

Example 33 with PropertyDto

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());
        }
    }
}
Also used : DbSession(org.sonar.db.DbSession) PropertyDto(org.sonar.db.property.PropertyDto)

Example 34 with PropertyDto

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"));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) PropertyDto(org.sonar.db.property.PropertyDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 35 with PropertyDto

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"));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) PropertyDto(org.sonar.db.property.PropertyDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Aggregations

PropertyDto (org.sonar.db.property.PropertyDto)57 Test (org.junit.Test)25 ComponentDto (org.sonar.db.component.ComponentDto)23 OrganizationDto (org.sonar.db.organization.OrganizationDto)13 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)13 DbSession (org.sonar.db.DbSession)8 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)6 MapSettings (org.sonar.api.config.MapSettings)3 Settings (org.sonar.api.config.Settings)3 PropertyTesting.newComponentPropertyDto (org.sonar.db.property.PropertyTesting.newComponentPropertyDto)2 PropertyTesting.newGlobalPropertyDto (org.sonar.db.property.PropertyTesting.newGlobalPropertyDto)2 UserDto (org.sonar.db.user.UserDto)2 Date (java.util.Date)1 Matchers.anyString (org.mockito.Matchers.anyString)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 FilePathWithHashDto (org.sonar.db.component.FilePathWithHashDto)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 PropertyQuery (org.sonar.db.property.PropertyQuery)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1 TestResponse (org.sonar.server.ws.TestResponse)1