Search in sources :

Example 11 with Localizable

use of com.thoughtworks.go.i18n.Localizable in project gocd by gocd.

the class PipelineConfigsService method updateXml.

public GoConfigOperationalResponse<PipelineConfigs> updateXml(String groupName, String xmlPartial, final String md5, Username username, HttpLocalizedOperationResult result) throws Exception {
    if (!userHasPermissions(username, groupName, result)) {
        return new GoConfigOperationalResponse<>(GoConfigValidity.valid(), null);
    }
    GoConfigValidity goConfigValidity = goConfigService.groupSaver(groupName).saveXml(xmlPartial, md5);
    if (!goConfigValidity.isValid()) {
        handleError(groupName, goConfigValidity, result);
        return new GoConfigOperationalResponse<>(goConfigValidity, null);
    }
    Localizable savedSuccessMessage = LocalizedMessage.string("SAVED_CONFIGURATION_SUCCESSFULLY");
    Localizable localizableMessage = goConfigValidity.wasMerged() ? LocalizedMessage.composite(savedSuccessMessage, LocalizedMessage.string("CONFIG_MERGED")) : savedSuccessMessage;
    result.setMessage(localizableMessage);
    PipelineConfigs pipelineConfigs = magicalGoConfigXmlLoader.fromXmlPartial(xmlPartial, BasicPipelineConfigs.class);
    return new GoConfigOperationalResponse<>(goConfigValidity, pipelineConfigs);
}
Also used : GoConfigOperationalResponse(com.thoughtworks.go.server.service.responses.GoConfigOperationalResponse) Localizable(com.thoughtworks.go.i18n.Localizable) GoConfigValidity(com.thoughtworks.go.config.validation.GoConfigValidity)

Example 12 with Localizable

use of com.thoughtworks.go.i18n.Localizable in project gocd by gocd.

the class BackupServiceIntegrationTest method shouldReturnBackupStartedBy.

@Test
public void shouldReturnBackupStartedBy() throws InterruptedException {
    assertThat(backupService.backupStartedBy(), is(nullValue()));
    final Semaphore waitForBackupToStart = new Semaphore(1);
    final Semaphore waitForAssertionToCompleteWhileBackupIsOn = new Semaphore(1);
    final HttpLocalizedOperationResult result = new HttpLocalizedOperationResult() {

        @Override
        public void setMessage(Localizable message) {
            waitForBackupToStart.release();
            super.setMessage(message);
            try {
                waitForAssertionToCompleteWhileBackupIsOn.acquire();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    };
    waitForAssertionToCompleteWhileBackupIsOn.acquire();
    waitForBackupToStart.acquire();
    Thread backupThd = new Thread(new Runnable() {

        public void run() {
            backupService.startBackup(admin, result);
        }
    });
    backupThd.start();
    waitForBackupToStart.acquire();
    String backupStartedBy = backupService.backupStartedBy();
    assertThat(ReflectionUtil.getField(backupService, "backupStartedBy"), is(backupStartedBy));
    waitForAssertionToCompleteWhileBackupIsOn.release();
    backupThd.join();
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Semaphore(java.util.concurrent.Semaphore) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Localizable(com.thoughtworks.go.i18n.Localizable) Test(org.junit.Test)

Aggregations

Localizable (com.thoughtworks.go.i18n.Localizable)12 Test (org.junit.Test)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 Localizer (com.thoughtworks.go.i18n.Localizer)2 Semaphore (java.util.concurrent.Semaphore)2 ConfigRepoConfigTest (com.thoughtworks.go.config.remote.ConfigRepoConfigTest)1 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)1 GoConfigOperationalResponse (com.thoughtworks.go.server.service.responses.GoConfigOperationalResponse)1 DateTime (org.joda.time.DateTime)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1