示例#1
0
 if (!publishDateFlag) {
   String[] lastURLs = this.config.getUrlLevels()[(this.config.getUrlLevels().length - 1)].split("\\\n", -1);
   if (lastURLs.length != 1) {
     return;
   }
   RegexParser rpUrl = new RegexParser(lastURLs[0]);
   boolean numberFlag = true;
   for (int i = 0; i < set.size(); ++i) {
     String url = set.get(i).getReferURL();
     rpUrl.setText(url);
     if (rpUrl.match()) {
       String v = rpUrl.getMapx().getString("SortID");
       set.get(i).setProp2(v);
       if (!NumberUtil.isLong(v)) {
         numberFlag = false;
       }
     }
   }
   set.sort("Prop2", "asc", numberFlag);
   for (int i = set.size() - 1; i >= 0; --i) {
     set.get(i).setOrderFlag(OrderUtil.getDefaultOrder());
     set.get(i).setProp2(null);
   }
   set.update();
 }
示例#2
0
  public static Mapx getSiteInfo(String file) throws Exception {
    FileInputStream fin = null;
    try {
      fin = new FileInputStream(file);
      fin.read();
      byte[] bs = new byte[8];
      fin.read(bs);

      bs = new byte[4];
      if (!bufferRead(bs, fin)) {
        return null;
      }
      int len = NumberUtil.toInt(bs);
      byte[] bs = new byte[len];
      if (!bufferRead(bs, fin)) return null;
      int len;
      byte[] bs = new byte[4];
      if (!bufferRead(bs, fin)) {
        return null;
      }
      int len = NumberUtil.toInt(bs);
      byte[] bs = new byte[len];
      if (!bufferRead(bs, fin)) return null;
      int len;
      byte[] bs = ZipUtil.unzip(bs);
      DataTable dt = (DataTable) FileUtil.unserialize(bs);
      return dt.getDataRow(0).toCaseIgnoreMapx();
    } finally {
      if (fin != null)
        try {
          fin.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
    }
  }
示例#3
0
  public boolean importSite(String poolName) {
    User.UserData user = new User.UserData();
    user.setUserName("admin");
    user.setBranchInnerCode("86");
    user.setLogin(true);
    user.setManager(true);
    User.setCurrent(user);

    this.isNewSite =
        (("0".equals(this.map.getString("ID"))) || (StringUtil.isEmpty(this.map.getString("ID"))));
    this.NoRelas = SiteTableRela.getNoRelaArray();
    this.TableRelas = SiteTableRela.getRelas();
    this.da = new DataAccess();
    FileInputStream fin = null;
    try {
      fin = new FileInputStream(this.file);
      this.da.setAutoCommit(false);
      this.ExportCharset = ((fin.read() == 1) ? "GBK" : "UTF-8");
      byte[] bs = new byte[8];
      fin.read(bs);
      this.siteID = NumberUtil.toLong(bs);
      boolean flag = true;
      int i = 0;
      while (true) {
        bs = new byte[4];
        if (!bufferRead(bs, fin)) {
          break;
        }
        int len = NumberUtil.toInt(bs);
        bs = new byte[len];
        if (!bufferRead(bs, fin)) {
          flag = false;
          break;
        }
        Object obj = FileUtil.unserialize(bs);

        bs = new byte[4];
        if (!bufferRead(bs, fin)) {
          flag = false;
          break;
        }
        len = NumberUtil.toInt(bs);
        bs = new byte[len];
        if (!bufferRead(bs, fin)) {
          flag = false;
          break;
        }
        bs = ZipUtil.unzip(bs);
        this.task.setPercent(i * 100 / 200);
        dealOneEntry(bs, obj);
        ++i;
      }
      if (flag) {
        this.da.commit();
      } else {
        LogUtil.error("读取站点导出文件时发生错误!");
        this.da.rollback();
      }
      this.da.setAutoCommit(true);
      Site.updatePrivAndFile(this.map.getString("Alias"));
      return flag;
    } catch (Exception e1) {
      e1.printStackTrace();
      try {
        this.da.rollback();
      } catch (SQLException e) {
        e.printStackTrace();
      }
      return false;
    } finally {
      try {
        this.da.setAutoCommit(true);
      } catch (Exception e) {
        e.printStackTrace();
      }
      try {
        this.da.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
      try {
        fin.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }