Search in sources :

Example 66 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class UnsetBaselineAction method doHandle.

private void doHandle(Request request) {
    String projectKey = request.mandatoryParam(PARAM_PROJECT);
    String branchKey = trimToNull(request.param(PARAM_BRANCH));
    try (DbSession dbSession = dbClient.openSession(false)) {
        ProjectDto project = componentFinder.getProjectByKey(dbSession, projectKey);
        userSession.checkProjectPermission(UserRole.ADMIN, project);
        BranchDto branch = loadBranch(dbSession, project, branchKey);
        dbClient.newCodePeriodDao().delete(dbSession, project.getUuid(), branch.getUuid());
        dbSession.commit();
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) BranchDto(org.sonar.db.component.BranchDto)

Example 67 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class TagsWsSupport method updateProjectTags.

public void updateProjectTags(DbSession dbSession, String projectKey, List<String> providedTags) {
    List<String> validatedTags = checkAndUnifyTags(providedTags);
    ProjectDto project = componentFinder.getProjectByKey(dbSession, projectKey);
    updateTagsForProjectsOrApplication(dbSession, validatedTags, project);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto)

Example 68 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class TagsWsSupport method updateApplicationTags.

public void updateApplicationTags(DbSession dbSession, String applicationKey, List<String> providedTags) {
    List<String> validatedTags = checkAndUnifyTags(providedTags);
    ProjectDto application = componentFinder.getApplicationByKey(dbSession, applicationKey);
    updateTagsForProjectsOrApplication(dbSession, validatedTags, application);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto)

Example 69 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class StatusAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    String uuid = request.param(PARAM_PROJECT_ID);
    String key = request.param(PARAM_PROJECT_KEY);
    checkRequest(uuid == null ^ key == null, "Project id or project key must be provided, not both.");
    try (DbSession dbSession = dbClient.openSession(false)) {
        ProjectDto project = getProject(dbSession, uuid, key);
        userSession.checkProjectPermission(UserRole.ADMIN, project);
        WsResponse wsResponse = new WsResponse();
        checkDumps(project, wsResponse);
        SnapshotsStatus snapshots = checkSnapshots(dbSession, project);
        if (snapshots.hasLast) {
            wsResponse.setCanBeExported();
        } else if (!snapshots.hasAny) {
            wsResponse.setCanBeImported();
        }
        write(response, wsResponse);
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession)

Example 70 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class DeselectAction method handle.

@Override
public void handle(Request request, Response response) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        ProjectDto project = wsSupport.getProject(dbSession, request.mandatoryParam(PARAM_PROJECT_KEY));
        dissociateProject(dbSession, project);
        response.noContent();
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession)

Aggregations

ProjectDto (org.sonar.db.project.ProjectDto)283 Test (org.junit.Test)215 DbSession (org.sonar.db.DbSession)49 BranchDto (org.sonar.db.component.BranchDto)42 UserDto (org.sonar.db.user.UserDto)39 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)38 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)31 SnapshotDto (org.sonar.db.component.SnapshotDto)27 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)26 ComponentDto (org.sonar.db.component.ComponentDto)23 ComponentTesting.newPrivateProjectDto (org.sonar.db.component.ComponentTesting.newPrivateProjectDto)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)17 WebhookDto (org.sonar.db.webhook.WebhookDto)15 ApplicationProjectDto (org.sonar.db.project.ApplicationProjectDto)14 WebService (org.sonar.api.server.ws.WebService)13 DbClient (org.sonar.db.DbClient)12 PortfolioProjectDto (org.sonar.db.portfolio.PortfolioProjectDto)12 TestRequest (org.sonar.server.ws.TestRequest)11 TestResponse (org.sonar.server.ws.TestResponse)10 Projects (org.sonarqube.ws.Projects)10