use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.
the class ParamRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, ParamConfig paramConfig) {
if (!paramConfig.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
new ErrorGetter(new HashMap<>()).toJSON(errorWriter, paramConfig);
});
}
jsonWriter.add("name", paramConfig.getName());
jsonWriter.add("value", paramConfig.getValue());
}
use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.
the class TimerRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, TimerConfig timerConfig) {
if (timerConfig == null) {
return;
}
if (!timerConfig.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
HashMap<String, String> mapping = new HashMap<>();
mapping.put("timerSpec", "spec");
new ErrorGetter(mapping).toJSON(errorWriter, timerConfig);
});
}
jsonWriter.add("spec", timerConfig.getTimerSpec());
jsonWriter.add("only_on_changes", timerConfig.getOnlyOnChanges());
}
use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.
the class TrackingToolRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, PipelineConfig pipelineConfig) {
HashMap<String, String> mapping = new HashMap<>();
mapping.put("projectIdentifier", "project_identifier");
mapping.put("baseUrl", "base_url");
mapping.put("link", "url_pattern");
if (pipelineConfig.getTrackingTool() != null) {
TrackingTool trackingTool = pipelineConfig.getTrackingTool();
if (!trackingTool.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
new ErrorGetter(mapping).toJSON(errorWriter, trackingTool);
});
}
jsonWriter.add("type", "generic");
jsonWriter.addChild("attributes", attributeWriter -> ExternalTrackingToolRepresenter.toJSON(attributeWriter, trackingTool));
}
}
use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.
the class ParamRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, ParamConfig paramConfig) {
if (!paramConfig.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
new ErrorGetter(new HashMap<>()).toJSON(errorWriter, paramConfig);
});
}
jsonWriter.add("name", paramConfig.getName());
jsonWriter.add("value", paramConfig.getValue());
}
use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.
the class MaterialsRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, MaterialConfig materialConfig) {
if (!materialConfig.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
HashMap<String, String> errorMapping = new HashMap<>();
errorMapping.put("materialName", "name");
errorMapping.put("folder", "destination");
errorMapping.put("autoUpdate", "auto_update");
errorMapping.put("filterAsString", "filter");
errorMapping.put("checkexternals", "check_externals");
errorMapping.put("serverAndPort", "port");
errorMapping.put("useTickets", "use_tickets");
errorMapping.put("pipelineName", "pipeline");
errorMapping.put("stageName", "stage");
errorMapping.put("pipelineStageName", "pipeline");
errorMapping.put("packageId", "ref");
errorMapping.put("scmId", "ref");
errorMapping.put("encryptedPassword", "encrypted_password");
new ErrorGetter(errorMapping).toJSON(errorWriter, materialConfig);
});
}
stream(Materials.values()).filter(material -> material.type == materialConfig.getClass()).findFirst().ifPresent(material -> {
jsonWriter.add("type", material.name().toLowerCase());
jsonWriter.addChild("attributes", attributeWriter -> material.representer.toJSON(attributeWriter, materialConfig));
});
}
Aggregations