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));
}
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)));
}
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)));
}
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;
}
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)));
}
Aggregations