Пример #1
0
 private void prepareList()
 {
   if (this.list == null) {
     String path = Config.getContextRealPath() + CrawlConfig.getWebGatherDir();
     if ((!path.endsWith("/")) && (!path.endsWith("\\"))) {
       path = path + "/";
     }
     path = path + this.config.getID() + "/";
     File f = new File(path);
     if (!f.exists()) {
       f.mkdirs();
     }
     this.list = new DocumentList(path);
   }
 }
Пример #2
0
 public static void loadConfig() {
   if (map == null) {
     map = new Mapx();
     String path = Config.getContextRealPath() + "WEB-INF/classes/framework.xml";
     if (!(new File(path).exists())) {
       return;
     }
     SAXReader reader = new SAXReader(false);
     try {
       Document doc = reader.read(new File(path));
       Element root = doc.getRootElement();
       Element extend = root.element("extend");
       if (extend != null) {
         List types = extend.elements("action");
         for (int i = 0; i < types.size(); ++i) {
           Element type = (Element) types.get(i);
           String className = type.attributeValue("class");
           try {
             Object obj = Class.forName(className).newInstance();
             if (!(obj instanceof IExtendAction)) {
               LogUtil.getLogger().warn("类" + className + "必须继承IExtendAction!");
             }
             IExtendAction action = (IExtendAction) obj;
             ArrayList list = (ArrayList) map.get(action.getTarget());
             if (list == null) {
               list = new ArrayList();
             }
             list.add(action);
             map.put(action.getTarget(), list);
           } catch (InstantiationException e) {
             e.printStackTrace();
           } catch (IllegalAccessException e) {
             e.printStackTrace();
           } catch (ClassNotFoundException e) {
             e.printStackTrace();
           }
         }
       }
     } catch (DocumentException e) {
       e.printStackTrace();
     }
   }
 }
Пример #3
0
 public void dealFile(String fileName, byte[] bs) {
   try {
     bs = convertCharset(bs);
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
   fileName = fileName.substring("File:".length());
   this.task.setCurrentInfo("正在导入站点文件:" + fileName);
   String root =
       Config.getContextRealPath()
           + Config.getValue("Statical.TargetDir")
           + "/"
           + this.map.getString("Alias");
   root = root + "/";
   fileName = root + fileName;
   fileName = fileName.replaceAll("[\\\\/]+", "/");
   String dirName = fileName.substring(0, fileName.lastIndexOf('/'));
   File dir = new File(dirName);
   if (!dir.exists()) {
     dir.mkdirs();
   }
   FileUtil.writeByte(fileName, bs);
 }
Пример #4
0
  public void dealZCSite(DataRow dr) {
    if (this.isNewSite) {
      if ((LicenseInfo.getName().equals("TrailUser"))
          && (new QueryBuilder("select count(*) from ZCSite").executeInt() >= 1)) {
        throw new RuntimeException("站点数超出限制,请联系泽元软件更换License!");
      }
      this.newSiteID = NoUtil.getMaxID("SiteID");
      ZCSiteSchema site = new ZCSiteSchema();
      site.setValue(dr);
      site.setID(this.newSiteID);
      site.setName(this.map.getString("Name"));
      site.setAlias(this.map.getString("Alias"));
      site.setURL(this.map.getString("URL"));
      site.setHitCount(0L);
      site.setChannelCount(0L);
      site.setSpecialCount(0L);
      site.setMagzineCount(0L);
      site.setArticleCount(0L);
      site.setImageLibCount(1L);
      site.setVideoLibCount(1L);
      site.setAudioLibCount(1L);
      site.setAttachmentLibCount(1L);
      site.setBranchInnerCode(User.getBranchInnerCode());
      site.setAddTime(new Date());
      site.setAddUser(User.getUserName());
      site.setConfigXML(ConfigImageLib.imageLibConfigDefault);
      this.da.insert(site);
      Transaction trans = new Transaction();
      Site.addDefaultPriv(this.newSiteID, trans);
      trans.setDataAccess(this.da);
      trans.commit(false);
      addIDMapping("ZCSite", String.valueOf(this.siteID), String.valueOf(this.newSiteID));
    } else {
      ZCSiteSchema site = new ZCSiteSchema();
      site.setID(this.map.getString("ID"));
      this.newSiteID = site.getID();
      site.fill();

      this.task.setCurrentInfo("正在备份数据,可能需要较长时间,请耐心等待");

      SiteExporter se = new SiteExporter(site.getID());
      se.exportSite(
          Config.getContextRealPath()
              + "WEB-INF/data/backup/"
              + site.getAlias()
              + "_"
              + System.currentTimeMillis()
              + ".dat");

      addIDMapping("ZCSite", dr.getString("ID"), String.valueOf(site.getID()));
      this.da.deleteAndBackup(site);
      BlockingTransaction tran = new BlockingTransaction(this.da);
      Site.delSiteRela(site.getID(), tran);

      String sitePath =
          Config.getContextRealPath()
              + Config.getValue("Statical.TemplateDir")
              + "/"
              + site.getAlias();
      FileUtil.delete(sitePath);

      site = new ZCSiteSchema();
      site.setValue(dr);

      this.da.insert(site);
    }
  }