@Transactional(propagation = Propagation.REQUIRED) public void install(String productId, Node fragment) { boolean xmlData = true; String dataSqlPath = EopSetting.PRODUCTS_STORAGE_PATH + "/" + productId + "/example_data.xml"; try { File xmlFile = new File(dataSqlPath); if (!xmlFile.exists()) { // 如果example_data.xml不存在,执行旧版本 xmlData = false; dataSqlPath = getDataSqlPath(productId); } loggerPrint("安装datasqlPath:" + dataSqlPath); if (!"base".equals(productId)) { InstallUtil.putMessaage( "正在安装示例数据,可能要花费较长时间,请稍后 <img src='resource/com/enation/app/saas/widget/product/loading.gif'"); } else { InstallUtil.putMessaage("正在安装基础数据..."); } if (xmlData) { anyDBInstall(dataSqlPath); } else { if (new File(dataSqlPath).exists()) { // 安装示例数据 String content = FileUtil.read(dataSqlPath, "UTF-8"); // 解析文件头部CONST和EOPSITE命令,CONST用于替换下面的文本内容,EOPSITE用于更新eop_site表 content = parseConst(content); content = parseUserSiteID(content); content = this.filter(content); content = content + parseUserSiteID(eopsiteSQL); sqlFileExecutor.execute(content); } else { System.out.println(dataSqlPath + " not exist"); } } loggerPrint("示例数据安装完毕"); FileUtil.copyFolder( EopSetting.PRODUCTS_STORAGE_PATH + "/" + productId + "/attachment/", EopSetting.IMG_SERVER_PATH + EopContext.getContext().getContextPath() + "/attachment/"); // 非base应用copy init.sql if (!"base".equals(productId)) { FileUtil.copyFile( EopSetting.PRODUCTS_STORAGE_PATH + "/" + productId + "/init.sql", EopSetting.EOP_PATH + EopContext.getContext().getContextPath() + "/init.sql"); } } catch (Exception e) { e.printStackTrace(); this.logger.debug(e.getMessage(), e); throw new RuntimeException("安装示例数据出错..."); } }
private void copy(AdminTheme theme, boolean isCommon) throws Exception { EopSite site = EopContext.getContext().getCurrentSite(); // 公用模板由common目录复制,非公用由产品目录复制 String basePath = isCommon ? EopSetting.APP_DATA_STORAGE_PATH : EopSetting.PRODUCTS_STORAGE_PATH + "/" + theme.getProductId(); basePath = basePath + "/adminthemes"; String contextPath = EopContext.getContext().getContextPath(); // 复制图片至静态资源服务器 String targetPath = EopSetting.IMG_SERVER_PATH + contextPath + "/adminthemes/" + theme.getPath(); FileUtil.copyFolder(basePath + "/" + theme.getPath() + "/images", targetPath + "/images"); FileUtil.copyFile( basePath + "/" + theme.getPath() + "/preview.png", targetPath + "/preview.png"); FileUtil.copyFolder(basePath + "/" + theme.getPath() + "/css", targetPath + "/css"); FileUtil.copyFolder(basePath + "/" + theme.getPath() + "/js", targetPath + "/js"); FileUtil.copyFolder( basePath + "/" + theme.getPath(), EopSetting.EOP_PATH + contextPath + "/adminthemes/" + theme.getPath()); /* * 只考jsp到eop应用服务器中 IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".jsp"); IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter); FileUtils.copyDirectory( new File(basePath + "/" + theme.getPath() ) , new File(EopSetting.EOP_PATH + "/user/" + userid + "/" + siteid + "/adminthemes/" + theme.getPath()) , txtFiles ); */ }