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