Search in sources :

Example 1 with GoConfigOperationalResponse

use of com.thoughtworks.go.server.service.responses.GoConfigOperationalResponse 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)

Aggregations

GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)1 Localizable (com.thoughtworks.go.i18n.Localizable)1 GoConfigOperationalResponse (com.thoughtworks.go.server.service.responses.GoConfigOperationalResponse)1