Search in sources :

Example 96 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class InternalMaterialModificationsControllerV1 method modifications.

public String modifications(Request request, Response response) throws Exception {
    String fingerprint = request.params("fingerprint");
    Long after = afterCursor(request);
    Long before = beforeCursor(request);
    Integer pageSize = getPageSize(request);
    String pattern = request.queryParamOrDefault("pattern", "");
    HttpOperationResult result = new HttpOperationResult();
    MaterialConfig materialConfig = materialConfigService.getMaterialConfig(currentUsernameString(), fingerprint, result);
    if (!result.canContinue()) {
        return renderHTTPOperationResult(result, request, response);
    }
    List<Modification> modifications = materialService.getModificationsFor(materialConfig, pattern, after, before, pageSize);
    PipelineRunIdInfo info = materialService.getLatestAndOldestModification(materialConfig, pattern);
    return writerForTopLevelObject(request, response, writer -> ModificationsRepresenter.toJSON(writer, modifications, info, materialConfig.getFingerprint(), pattern, pageSize));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 97 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MaterialsRepresenter method fromJSON.

public static MaterialConfig fromJSON(JsonReader jsonReader, ConfigHelperOptions options) {
    String type = jsonReader.getString("type");
    JsonReader attributes = jsonReader.readJsonObject("attributes");
    return stream(Materials.values()).filter(material -> equalsIgnoreCase(type, material.name())).findFirst().map(material -> material.representer.fromJSON(attributes, options)).orElseThrow(() -> new UnprocessableEntityException(String.format("Invalid material type %s. It has to be one of 'git, svn, hg, p4, tfs, dependency, package, plugin'.", type)));
}
Also used : OutputListWriter(com.thoughtworks.go.api.base.OutputListWriter) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) HashMap(java.util.HashMap) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ConfigHelperOptions(com.thoughtworks.go.apiv11.admin.shared.representers.stages.ConfigHelperOptions) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonReader(com.thoughtworks.go.api.representers.JsonReader) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) StringUtils.equalsIgnoreCase(org.apache.commons.lang3.StringUtils.equalsIgnoreCase) Arrays.stream(java.util.Arrays.stream) UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) JsonReader(com.thoughtworks.go.api.representers.JsonReader)

Example 98 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MaterialsRepresenter method fromJSON.

public static MaterialConfig fromJSON(JsonReader jsonReader, ConfigHelperOptions options) {
    String type = jsonReader.getString("type");
    JsonReader attributes = jsonReader.readJsonObject("attributes");
    return stream(Materials.values()).filter(material -> equalsIgnoreCase(type, material.name())).findFirst().map(material -> material.representer.fromJSON(attributes, options)).orElseThrow(() -> new UnprocessableEntityException(String.format("Invalid material type %s. It has to be one of 'git, svn, hg, p4, tfs, dependency, package, plugin'.", type)));
}
Also used : OutputListWriter(com.thoughtworks.go.api.base.OutputListWriter) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) HashMap(java.util.HashMap) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonReader(com.thoughtworks.go.api.representers.JsonReader) ConfigHelperOptions(com.thoughtworks.go.apiv10.admin.shared.representers.stages.ConfigHelperOptions) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) StringUtils.equalsIgnoreCase(org.apache.commons.lang3.StringUtils.equalsIgnoreCase) Arrays.stream(java.util.Arrays.stream) UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) JsonReader(com.thoughtworks.go.api.representers.JsonReader)

Example 99 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigRepresenterV4 method fromJSON.

public static ConfigRepoConfig fromJSON(JsonReader jsonReader) {
    MaterialConfig material = MaterialsRepresenter.fromJSON(jsonReader.readJsonObject("material"));
    ConfigRepoConfig repo = new ConfigRepoConfig();
    jsonReader.readStringIfPresent("id", repo::setId);
    jsonReader.readStringIfPresent("plugin_id", repo::setPluginId);
    repo.setRepo(material);
    repo.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArrayHandlingEncryption(jsonReader, "configuration"));
    jsonReader.readArrayIfPresent("rules", array -> {
        repo.setRules(RulesRepresenter.fromJSON(array));
    });
    return repo;
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 100 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigMaterialsTest method shouldNotIncludePluggableSCMMaterialsWithAutoUpdateFalse.

@Test
public void shouldNotIncludePluggableSCMMaterialsWithAutoUpdateFalse() {
    PipelineConfig pipeline1 = pipelineWithManyMaterials(false);
    PluggableSCMMaterialConfig autoUpdateMaterialConfig = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id-1"), null, null, false);
    pipeline1.addMaterialConfig(autoUpdateMaterialConfig);
    PluggableSCMMaterialConfig nonAutoUpdateMaterialConfig = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id-2"), null, null, false);
    nonAutoUpdateMaterialConfig.getSCMConfig().setAutoUpdate(false);
    pipeline1.addMaterialConfig(nonAutoUpdateMaterialConfig);
    pipeline1.add(new StageConfig(new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval()));
    CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(pipeline1));
    Set<MaterialConfig> materialsBelongingToAutoPipelines = config.getAllUniqueMaterialsBelongingToAutoPipelines();
    assertThat(materialsBelongingToAutoPipelines.size(), is(4));
    assertThat(materialsBelongingToAutoPipelines, containsInAnyOrder(pipeline1.materialConfigs().get(1), pipeline1.materialConfigs().get(2), pipeline1.materialConfigs().get(3), pipeline1.materialConfigs().get(4)));
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12