All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bdware.ypkdeploy.Entry Maven / Gradle / Ivy

The newest version!
package org.bdware.ypkdeploy;

import com.google.gson.Gson;

import java.util.List;

public class Entry {
    static class DeployEntry {
        List generateTasks;
        List deployTasks;
    }

    static class GenerateTask {
        public String dir;
        public String template;
        public String commvar;
        public String files;
        public boolean isBatch;
    }

    public static void goByStr(String str) {
        DeployEntry entry = new Gson().fromJson(str, DeployEntry.class);
        generateJson(entry.generateTasks);
        deployYpk(entry.deployTasks);
    }

    private static void deployYpk(List deployTasks) {
        if (deployTasks == null)
            return;
        for (String deployTask : deployTasks) {
            HTTPTool.deploy(deployTask);
        }
    }

    private static void generateJson(List generateTaskList) {
        if (generateTaskList == null)
            return;
        for (GenerateTask task : generateTaskList) {
            if (task.isBatch) {
                DeployConfGenerator.batchGenerateDeployConf(task.dir, task.template, task.commvar,
                        task.files);
            } else
                DeployConfGenerator.generateDeployConf(task.dir, task.template, task.commvar,
                        task.files);
        }
    }

    public static void goByPath(String path) {
        String conf = DeployConfGenerator.getFileContent(path);
        goByStr(conf);
    }

    public static void main(String[] args) {
        System.out.println("Usage: set deployentry.json or ");
        if (args.length > 0)
            goByPath(args[0]);
        else
            goByPath("./deployentry.json");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy