Search in sources :

Example 31 with ErrorGetter

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

Example 32 with ErrorGetter

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

the class ApprovalRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, Approval approval) {
    if (!approval.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            new ErrorGetter(new HashMap<>()).toJSON(errorWriter, approval);
        });
    }
    jsonWriter.add("type", approval.getType());
    jsonWriter.add(Approval.ALLOW_ONLY_ON_SUCCESS, approval.isAllowOnlyOnSuccess());
    jsonWriter.addChild("authorization", authConfigWriter -> StageAuthorizationRepresenter.toJSON(authConfigWriter, approval.getAuthConfig()));
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 33 with ErrorGetter

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

the class TemplateConfigRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, PipelineTemplateConfig pipelineTemplateConfig) {
    jsonWriter.addLinks(linksWriter -> linksWriter.addLink("self", Routes.PipelineTemplateConfig.name(pipelineTemplateConfig.name().toString())).addAbsoluteLink("doc", Routes.PipelineTemplateConfig.DOC).addLink("find", Routes.PipelineTemplateConfig.find()));
    if (!pipelineTemplateConfig.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            HashMap<String, String> errorMapping = new HashMap<>();
            new ErrorGetter(new HashMap<>()).toJSON(errorWriter, pipelineTemplateConfig);
        });
    }
    jsonWriter.add("name", pipelineTemplateConfig.name());
    writeStages(jsonWriter, pipelineTemplateConfig);
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 34 with ErrorGetter

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

the class JobRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, JobConfig jobConfig) {
    if (!jobConfig.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            HashMap<String, String> errorMapping = new HashMap<>();
            errorMapping.put("runType", "run_instance_count");
            new ErrorGetter(errorMapping).toJSON(errorWriter, jobConfig);
        });
    }
    jsonWriter.addIfNotNull("name", jobConfig.name());
    addRunInstanceCount(jsonWriter, jobConfig);
    addTimeout(jsonWriter, jobConfig);
    jsonWriter.addIfNotNull("elastic_profile_id", jobConfig.getElasticProfileId());
    jsonWriter.addChildList("environment_variables", envVarsWriter -> EnvironmentVariableRepresenter.toJSON(envVarsWriter, jobConfig.getVariables()));
    jsonWriter.addChildList("resources", getResourceNames(jobConfig));
    jsonWriter.addChildList("tasks", tasksWriter -> TaskRepresenter.toJSONArray(tasksWriter, jobConfig.getTasks()));
    jsonWriter.addChildList("tabs", tabsWriter -> TabConfigRepresenter.toJSONArray(tabsWriter, jobConfig.getTabs()));
    jsonWriter.addChildList("artifacts", getArtifacts(jobConfig));
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 35 with ErrorGetter

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

the class TabConfigRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, Tab tab) {
    if (!tab.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            new ErrorGetter(new HashMap<>()).toJSON(errorWriter, tab);
        });
    }
    jsonWriter.add("name", tab.getName());
    jsonWriter.add("path", tab.getPath());
}
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