Search in sources :

Example 6 with ConfigHelperOptions

use of com.thoughtworks.go.apiv11.admin.shared.representers.stages.ConfigHelperOptions 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 7 with ConfigHelperOptions

use of com.thoughtworks.go.apiv11.admin.shared.representers.stages.ConfigHelperOptions in project gocd by gocd.

the class AbstractMaterialTestController method buildSCMMaterialFromRequestBody.

public ScmMaterialConfig buildSCMMaterialFromRequestBody(Request req) {
    JsonReader jsonReader = GsonTransformer.getInstance().jsonReaderFrom(req.body());
    ConfigHelperOptions options = new ConfigHelperOptions(goConfigService.getCurrentConfig(), passwordDeserializer);
    return (ScmMaterialConfig) MaterialsRepresenter.fromJSON(jsonReader, options);
}
Also used : JsonReader(com.thoughtworks.go.api.representers.JsonReader) ConfigHelperOptions(com.thoughtworks.go.apiv10.admin.shared.representers.stages.ConfigHelperOptions) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig)

Aggregations

JsonReader (com.thoughtworks.go.api.representers.JsonReader)7 ConfigHelperOptions (com.thoughtworks.go.apiv10.admin.shared.representers.stages.ConfigHelperOptions)4 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 OutputListWriter (com.thoughtworks.go.api.base.OutputListWriter)3 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)3 ErrorGetter (com.thoughtworks.go.api.representers.ErrorGetter)3 UnprocessableEntityException (com.thoughtworks.go.config.exceptions.UnprocessableEntityException)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)3 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)3 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)3 Arrays.stream (java.util.Arrays.stream)3 HashMap (java.util.HashMap)3 StringUtils.equalsIgnoreCase (org.apache.commons.lang3.StringUtils.equalsIgnoreCase)3 ConfigHelperOptions (com.thoughtworks.go.apiv11.admin.shared.representers.stages.ConfigHelperOptions)2