public static void saveScript(String name, String content) throws IOException { File scriptFile = new File(workSpaceDir + "script/" + name); if (!scriptFile.exists()) { scriptFile.createNewFile(); } FileUtil.saveContent(content, scriptFile); }
public static void saveConfigFile(String file, String value) { String configDir = workSpaceDir + "config"; try { FileUtil.saveContent(value, new File(configDir, file)); reload(); } catch (IOException e) { logger.catching(e); } }
public static void saveTemplate(String appId, String value) { String templateDir = workSpaceDir; templateDir += "template"; File file = new File(templateDir + "/" + appId + ".vm"); try { if (!file.exists()) { file.createNewFile(); } FileUtil.saveContent(value, file); } catch (Exception e) { logger.catching(e); } }
private static void createFile(String path) { try { logger.info("create new file {}", path); String s = IOUtil.getContent(DeployStartServlet.class.getResourceAsStream("workspace/" + path)); File configFile = new File(workSpaceDir, path); if (!configFile.exists()) { configFile.createNewFile(); FileUtil.saveContent(s, configFile); } } catch (IOException e) { logger.catching(e); } }
public static void saveInstanceConfig() throws Exception { String configDir = workSpaceDir; configDir += "config"; File configFile = new File(configDir, "instance.json"); List<Instance> list = getInstances(); Collections.sort(list, (o1, o2) -> o1.priority - o2.priority); if (configFile.exists()) { String result = JSONUtil.toJson( list, new JSONPropertyFilter() { @Override public boolean apply(Object arg0, String name, Object arg2) { if (name.equals("alive") || name.equals("machine") || name.equals("priority")) { return false; } return true; } }, true); FileUtil.saveContent(result, configFile); } }