Exemplo n.º 1
0
 /*     */ @Transactional(propagation = Propagation.REQUIRED)
 /*     */ public void delete(Integer id) {
   /* 144 */ EopSite site = get(id);
   /*     */
   /* 146 */ Integer userid = site.getUserid();
   /* 147 */ Integer siteid = site.getId();
   /*     */
   /* 150 */ String sql = "show tables like '%_" + userid + "_" + siteid + "'";
   /* 151 */ List tableList = this.daoSupport.queryForList(sql, new StringMapper(), new Object[0]);
   /* 152 */ for (String tbName : tableList) {
     /* 153 */ sql = "drop table if exists " + tbName;
     /* 154 */ this.daoSupport.execute(sql, new Object[0]);
     /*     */ }
   /*     */
   /* 158 */ sql = "delete from eop_sitedomain where siteid = ?";
   /* 159 */ this.daoSupport.execute(sql, new Object[] {id});
   /* 160 */ sql = "delete from  eop_site  where id = ?";
   /* 161 */ this.daoSupport.execute(sql, new Object[] {id});
   /*     */
   /* 164 */ String userTplFile = EopSetting.EOP_PATH + "/user/" + userid + "/" + siteid;
   /*     */
   /* 166 */ String userStyleFile = EopSetting.IMG_SERVER_PATH + "/user/" + userid + "/" + siteid;
   /*     */
   /* 168 */ FileUtil.delete(userTplFile);
   /* 169 */ FileUtil.delete(userStyleFile);
   /*     */ }
Exemplo n.º 2
0
  @Transactional(propagation = Propagation.REQUIRED)
  public void delete(int id) {
    MultiSite childsite = this.get(id);
    List<Theme> list = themeManager.list(id); // 读取此站点的主题
    String contextPath = EopContext.getContext().getContextPath();
    for (Theme theme : list) {
      /** 删除模板静态资源文件* */
      String targetPath =
          EopSetting.IMG_SERVER_PATH + contextPath + "/themes/" + theme.getPath() + "_" + id;
      FileUtil.removeFile(new File(targetPath));

      /** 删除模板文件* */
      targetPath = EopSetting.EOP_PATH + contextPath + "/themes/" + theme.getPath() + "_" + id;
      FileUtil.removeFile(new File(targetPath));
    }

    /** 删除域名 */
    this.siteManager.deleteDomain(childsite.getDomain());

    /** 删除主题* */
    this.baseDaoSupport.execute("delete from theme where siteid = ?", id);

    /** 删除站点 */
    this.baseDaoSupport.execute("delete from site where siteid = ?", id);
  }
Exemplo n.º 3
0
  @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("安装示例数据出错...");
    }
  }
Exemplo n.º 4
0
  @Transactional(propagation = Propagation.REQUIRED)
  public void add(MultiSite site) {

    /** 读取父* */
    MultiSite parent = this.get(site.getParentid());

    /** 读取本级最大code* */
    String sql = "select max(code) code from site where parentid=? ";
    int maxcode = this.baseDaoSupport.queryForInt(sql, site.getParentid()); // cat code
    maxcode = maxcode == 0 ? maxcode = parent.getCode() : maxcode;
    int level = parent.getLevel() + 1; // 级别
    site.setCode(this.createCode(maxcode, level));
    site.setLevel(level);

    this.baseDaoSupport.insert("site", site);
    int siteid = this.baseDaoSupport.getLastId("site");

    Integer userid = EopContext.getContext().getCurrentSite().getUserid();
    EopSiteDomain eopSiteDomain = new EopSiteDomain();
    eopSiteDomain.setUserid(userid);
    eopSiteDomain.setDomain(site.getDomain());
    eopSiteDomain.setSiteid(EopContext.getContext().getCurrentSite().getId());
    siteManager.addDomain(eopSiteDomain);
    try {
      /**
       * 此处逻辑:先取出所指定的theme信息,取得其对应的文件目录,<br>
       * 然后修改theme.path并插入theme,取得插入的themeid并写回到site
       */
      site.setSiteid(siteid);
      Theme theme = this.themeManager.getTheme(site.getThemeid());
      String contextPath = EopContext.getContext().getContextPath();

      // 复制资源到静态资源服务器
      String basePath = EopSetting.IMG_SERVER_PATH + contextPath + "/themes/" + theme.getPath();
      String targetPath =
          EopSetting.IMG_SERVER_PATH + contextPath + "/themes/" + theme.getPath() + "_" + siteid;
      FileUtil.copyFolder(basePath, targetPath);
      // 复制theme
      basePath = EopSetting.EOP_PATH + contextPath + "/themes/" + theme.getPath();
      targetPath = EopSetting.EOP_PATH + contextPath + "/themes/" + theme.getPath() + "_" + siteid;
      FileUtil.copyFolder(basePath, targetPath);

      theme.setPath(theme.getPath() + "_" + siteid);
      theme.setSiteid(siteid);
      theme.setId(null);
      this.baseDaoSupport.insert("theme", theme);
      int themeid = this.baseDaoSupport.getLastId("theme");
      site.setThemeid(themeid);
      this.update(site);
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException("创建主题出错");
    }
  }
Exemplo n.º 5
0
  /**
   * 执行升级操作
   *
   * @param appid
   * @param version
   */
  private void exeUpdate(String appid, String version) {

    String patchPath = EopSetting.EOP_PATH + "/patch/" + appid + "/" + version;
    String updateSql = patchPath + "/sql/update.sql";
    String cmsUpdateSql = patchPath + "/sql/cms_update.sql";

    // 执行升级数据库脚本
    if (new File(updateSql).exists()) {

      if (logger.isDebugEnabled()) {
        logger.debug("执行[" + updateSql + "]...");
      }

      String content = FileUtil.read(updateSql, "UTF-8");
      this.executeSql(content);

      if (logger.isDebugEnabled()) {
        logger.debug("执行[" + updateSql + "]成功.");
      }

    } else {
      if (logger.isDebugEnabled()) {
        logger.debug("[" + updateSql + "]不存在跳过.");
      }
    }

    // 执行cms相应升级数据库脚本
    if (new File(cmsUpdateSql).exists()) {
      if (logger.isDebugEnabled()) {
        logger.debug("执行[" + cmsUpdateSql + "]...");
      }

      String content = FileUtil.read(cmsUpdateSql, "UTF-8");

      if (logger.isDebugEnabled()) {
        logger.debug("执行内容[" + content + "]...");
      }

      this.batchSqlExecutor.executeForCms(content);

      if (logger.isDebugEnabled()) {
        logger.debug("执行[" + cmsUpdateSql + "]成功.");
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("复制[" + patchPath + "/web" + "]...");
    }

    FileUtil.copyFolder(patchPath + "/web", EopSetting.EOP_PATH);
    if (logger.isDebugEnabled()) {
      logger.debug("复制[" + patchPath + "/web" + "]成功.");
    }
  }
Exemplo n.º 6
0
 public static void main(String[] args) {
   String content =
       FileUtil.read(
           "D:/Works/Trunk/javamall/WebContent/products/eopsaler/example_data_mysql.sql", "UTF-8");
   // content = ExampleDataInstaller.parseConst(content);
   System.out.println(content.substring(0, 50));
 }
Exemplo n.º 7
0
  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
    );

     */
  }
Exemplo n.º 8
0
  /**
   * 解开升级包
   *
   * @param zipName
   */
  private void unZip(String appid, String version) {

    String zipPath = EopSetting.EOP_PATH + "/patch/" + appid + "/" + version + ".zip";
    if (this.logger.isDebugEnabled()) {
      this.logger.debug("解压升级包[" + zipPath + "]...");
    }

    FileUtil.unZip(zipPath, EopSetting.EOP_PATH + "/patch/" + appid + "/" + version, true);
    if (this.logger.isDebugEnabled()) {
      this.logger.debug("解压升级包[" + zipPath + "]完成");
    }
  }
Exemplo n.º 9
0
 /*     */ public void initData() /*     */ {
   /*     */ String tablenameperfix;
   /*     */ Iterator i$;
   /* 513 */ if ("2".equals(EopSetting.RUNMODE))
   /*     */ {
     /* 515 */ EopSite site = EopContext.getContext().getCurrentSite();
     /* 516 */ String productId = site.getProductid();
     /* 517 */ org.dom4j.Document setupDoc = this.setupLoader.load(productId);
     /*     */
     /* 519 */ tablenameperfix = "";
     /*     */
     /* 521 */ tablenameperfix = "_" + site.getUserid() + "_" + site.getId();
     /*     */
     /* 523 */ List listClean = setupDoc.getRootElement().element("clean").elements();
     /*     */
     /* 525 */ for (i$ = listClean.iterator(); i$.hasNext(); ) {
       Object o = i$.next();
       /* 526 */ org.dom4j.Element table = (org.dom4j.Element) o;
       /* 527 */ this.daoSupport.execute(
           "truncate table " + table.getText() + tablenameperfix, new Object[0]);
       /*     */ }
     /*     */
     /*     */ }
   /*     */
   /* 532 */ String sqlPath =
       EopSetting.EOP_PATH + EopContext.getContext().getContextPath() + "/init.sql";
   /*     */
   /* 534 */ File file = new File(sqlPath);
   /* 535 */ if (file.exists()) {
     /* 536 */ String content = FileUtil.read(sqlPath, "UTF-8");
     /*     */
     /* 538 */ if ("2".equals(EopSetting.RUNMODE)) {
       /* 539 */ EopSite site = EopContext.getContext().getCurrentSite();
       /* 540 */ content = content.replaceAll("<userid>", String.valueOf(site.getUserid()));
       /*     */
       /* 542 */ content = content.replaceAll("<siteid>", String.valueOf(site.getId()));
       /*     */ }
     /*     */ else {
       /* 545 */ content = content.replaceAll("_<userid>", "");
       /* 546 */ content = content.replaceAll("_<siteid>", "");
       /* 547 */ content = content.replaceAll("/user/<userid>/<siteid>", "");
       /* 548 */ content = content.replaceAll("<userid>", "1");
       /* 549 */ content = content.replaceAll("<siteid>", "1");
       /*     */ }
     /* 551 */ this.sqlFileExecutor.execute(content);
     /*     */ } else {
     /* 553 */ throw new RuntimeException("本站点初始化脚本不存在");
     /*     */ }
   /*     */ }
Exemplo n.º 10
0
  public String save() {
    if (logo != null) {
      if (FileUtil.isAllowUp(logoFileName)) {

      } else {
        this.msgs.add("不允许上传的文件格式,请上传gif,jpg,bmp格式文件。");
        return this.MESSAGE;
      }
    }
    brand.setDisabled(0);
    brand.setFile(this.logo);
    brand.setFileFileName(this.logoFileName);
    brandManager.add(brand);
    this.msgs.add("品牌添加成功");
    this.urls.put("品牌列表", "brand!list.do");
    return this.MESSAGE;
  }