Search in sources :

Example 41 with ErrorGetter

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());
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 42 with ErrorGetter

use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.

the class ServerSiteUrlsConfigRepresenter method toJSON.

public static void toJSON(OutputWriter writer, SiteUrls siteUrls) {
    writer.addLinks(outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", apiDocsUrl("#siteurls-config")).addLink("self", Routes.ServerSiteUrlsConfig.BASE)).add("site_url", siteUrls.getSiteUrl().toString()).add("secure_site_url", siteUrls.getSecureSiteUrl().toString());
    if (!siteUrls.getSiteUrl().errors().isEmpty() || !siteUrls.getSecureSiteUrl().errors().isEmpty()) {
        Map<String, String> fieldMapping = new HashMap<>();
        fieldMapping.put("siteUrl", "site_url");
        fieldMapping.put("secureSiteUrl", "secure_site_url");
        writer.addChild("errors", errorWriter -> {
            ErrorGetter errorGetter = new ErrorGetter(fieldMapping);
            errorGetter.toJSON(errorWriter, siteUrls.getSiteUrl());
            errorGetter.toJSON(errorWriter, siteUrls.getSecureSiteUrl());
        });
    }
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 43 with ErrorGetter

use of com.thoughtworks.go.api.representers.ErrorGetter in project gocd by gocd.

the class ArtifactRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, ArtifactTypeConfig artifactConfig) {
    if (!artifactConfig.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            HashMap<String, String> errorMapping = new HashMap<>();
            errorMapping.put("src", "source");
            errorMapping.put("dest", "destination");
            errorMapping.put("id", "artifact_id");
            errorMapping.put("storeId", "store_id");
            errorMapping.put("pluginId", "plugin_id");
            new ErrorGetter(errorMapping).toJSON(errorWriter, artifactConfig);
        });
    }
    jsonWriter.add("type", artifactConfig.getArtifactType().name());
    switch(artifactConfig.getArtifactType()) {
        case test:
        case build:
            BuiltinArtifactConfigRepresenter.toJSON(jsonWriter, (BuiltinArtifactConfig) artifactConfig);
            break;
        case external:
            ExternalArtifactConfigRepresenter.toJSON(jsonWriter, (PluggableArtifactConfig) artifactConfig);
    }
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Aggregations

ErrorGetter (com.thoughtworks.go.api.representers.ErrorGetter)43 HashMap (java.util.HashMap)43 TrackingTool (com.thoughtworks.go.config.TrackingTool)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)2 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)2 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)2 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)2 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)2 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)2 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)2 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1 ConfigurationPropertyRepresenter (com.thoughtworks.go.api.representers.ConfigurationPropertyRepresenter)1 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 PluginConfigurationRepresenter (com.thoughtworks.go.api.representers.PluginConfigurationRepresenter)1 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)1 Routes (com.thoughtworks.go.spark.Routes)1