Search in sources :

Example 1 with BulkChangeResult

use of org.sonar.server.qualityprofile.BulkChangeResult in project sonarqube by SonarSource.

the class BulkRuleActivationActions method bulkDeactivate.

private void bulkDeactivate(Request request, Response response) {
    BulkChangeResult result = profileService.bulkDeactivate(ruleQueryFactory.createRuleQuery(request), request.mandatoryParam(PROFILE_KEY));
    writeResponse(result, response);
}
Also used : BulkChangeResult(org.sonar.server.qualityprofile.BulkChangeResult)

Example 2 with BulkChangeResult

use of org.sonar.server.qualityprofile.BulkChangeResult in project sonarqube by SonarSource.

the class OldRestoreAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    qProfileWsSupport.checkQProfileAdminPermission();
    InputStream backup = request.paramAsInputStream(PARAM_BACKUP);
    InputStreamReader reader = null;
    try {
        checkArgument(backup != null, "A backup file must be provided");
        reader = new InputStreamReader(backup, StandardCharsets.UTF_8);
        BulkChangeResult result = backuper.restore(reader, null);
        writeResponse(response.newJsonWriter(), result);
    } finally {
        IOUtils.closeQuietly(reader);
        IOUtils.closeQuietly(backup);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BulkChangeResult(org.sonar.server.qualityprofile.BulkChangeResult) InputStream(java.io.InputStream)

Example 3 with BulkChangeResult

use of org.sonar.server.qualityprofile.BulkChangeResult in project sonarqube by SonarSource.

the class RestoreAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    qProfileWsSupport.checkQProfileAdminPermission();
    InputStream backup = request.paramAsInputStream(PARAM_BACKUP);
    InputStreamReader reader = null;
    try {
        checkArgument(backup != null, "A backup file must be provided");
        reader = new InputStreamReader(backup, StandardCharsets.UTF_8);
        BulkChangeResult result = backuper.restore(reader, null);
        writeResponse(response.newJsonWriter(), result);
    } finally {
        IOUtils.closeQuietly(reader);
        IOUtils.closeQuietly(backup);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BulkChangeResult(org.sonar.server.qualityprofile.BulkChangeResult) InputStream(java.io.InputStream)

Example 4 with BulkChangeResult

use of org.sonar.server.qualityprofile.BulkChangeResult in project sonarqube by SonarSource.

the class BulkRuleActivationActions method bulkActivate.

private void bulkActivate(Request request, Response response) {
    BulkChangeResult result = profileService.bulkActivate(ruleQueryFactory.createRuleQuery(request), request.mandatoryParam(PROFILE_KEY), request.param(SEVERITY));
    writeResponse(result, response);
}
Also used : BulkChangeResult(org.sonar.server.qualityprofile.BulkChangeResult)

Example 5 with BulkChangeResult

use of org.sonar.server.qualityprofile.BulkChangeResult in project sonarqube by SonarSource.

the class RestoreActionTest method restore_profile.

@Test
public void restore_profile() throws Exception {
    logInAsQProfileAdministrator();
    QualityProfileDto profile = QualityProfileDto.createFor("xoo-sonar-way-12345").setDefault(false).setLanguage("xoo").setName("Sonar way");
    BulkChangeResult restoreResult = new BulkChangeResult(profile);
    when(backuper.restore(any(Reader.class), (QProfileName) eq(null))).thenReturn(restoreResult);
    tester.newPostRequest("api/qualityprofiles", "restore").setParam("backup", "<polop><palap/></polop>").execute().assertJson(getClass(), "restore_profile.json");
    verify(backuper).restore(any(Reader.class), (QProfileName) eq(null));
}
Also used : BulkChangeResult(org.sonar.server.qualityprofile.BulkChangeResult) Reader(java.io.Reader) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Aggregations

BulkChangeResult (org.sonar.server.qualityprofile.BulkChangeResult)5 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)1 Test (org.junit.Test)1 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)1