Search in sources :

Example 21 with ErrorGetter

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

the class StageRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, StageConfig stageConfig) {
    if (!stageConfig.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            new ErrorGetter(new HashMap<>()).toJSON(errorWriter, stageConfig);
        });
    }
    jsonWriter.addIfNotNull("name", stageConfig.name());
    jsonWriter.add("fetch_materials", stageConfig.isFetchMaterials());
    jsonWriter.add("clean_working_directory", stageConfig.isCleanWorkingDir());
    jsonWriter.add("never_cleanup_artifacts", stageConfig.isArtifactCleanupProhibited());
    jsonWriter.addChild("approval", approvalWriter -> ApprovalRepresenter.toJSON(approvalWriter, stageConfig.getApproval()));
    jsonWriter.addChildList("environment_variables", envVarsWriter -> EnvironmentVariableRepresenter.toJSON(envVarsWriter, stageConfig.getVariables()));
    jsonWriter.addChildList("jobs", getJobs(stageConfig));
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 22 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)

Example 23 with ErrorGetter

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

the class TaskRepresenter method toJSON.

public static void toJSON(OutputWriter jsonWriter, Task task) {
    if (!task.errors().isEmpty()) {
        jsonWriter.addChild("errors", errorWriter -> {
            HashMap<String, String> errorMapping = new HashMap<>();
            errorMapping.put("buildFile", "build_file");
            errorMapping.put("onCancelConfig", "on_cancel");
            errorMapping.put("runIf", "run_if");
            errorMapping.put("argListString", "arguments");
            errorMapping.put("src", "source");
            errorMapping.put("dest", "destination");
            errorMapping.put("pipelineName", "pipeline");
            new ErrorGetter(errorMapping).toJSON(errorWriter, task);
        });
    }
    jsonWriter.add("type", task instanceof PluggableTask ? "pluggable_task" : task.getTaskType());
    if (task instanceof PluggableTask) {
        jsonWriter.addChild("attributes", attributeWriter -> PluggableTaskRepresenter.toJSON(attributeWriter, (PluggableTask) task));
        return;
    }
    switch(task.getTaskType()) {
        case AntTask.TYPE:
            jsonWriter.addChild("attributes", attributeWriter -> AntTaskRepresenter.toJSON(attributeWriter, (AntTask) task));
            break;
        case NantTask.TYPE:
            jsonWriter.addChild("attributes", attributeWriter -> NantTaskRepresenter.toJSON(attributeWriter, (NantTask) task));
            break;
        case RakeTask.TYPE:
            jsonWriter.addChild("attributes", attributeWriter -> RakeTaskRepresenter.toJSON(attributeWriter, (RakeTask) task));
            break;
        case ExecTask.TYPE:
            jsonWriter.addChild("attributes", attributeWriter -> ExecTaskRepresenter.toJSON(attributeWriter, (ExecTask) task));
            break;
        case FetchTask.TYPE:
            jsonWriter.addChild("attributes", attributeWriter -> FetchTaskRepresenter.toJSON(attributeWriter, (AbstractFetchTask) task));
            break;
    }
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask)

Example 24 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 artifactTypeConfig) {
    if (!artifactTypeConfig.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, artifactTypeConfig);
        });
    }
    jsonWriter.add("type", artifactTypeConfig.getArtifactType().name());
    switch(artifactTypeConfig.getArtifactType()) {
        case test:
        case build:
            BuiltinArtifactConfigRepresenter.toJSON(jsonWriter, (BuiltinArtifactConfig) artifactTypeConfig);
            break;
        case external:
            ExternalArtifactConfigRepresenter.toJSON(jsonWriter, (PluggableArtifactConfig) artifactTypeConfig);
    }
}
Also used : HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 25 with ErrorGetter

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