Beispiel #1
0
  public ZCDeployJobSet getJobs(long siteID, ArrayList list, String operation) {
    ZCDeployJobSet jobSet = new ZCDeployJobSet();
    for (int j = 0; j < list.size(); j++) {
      String srcPath = (String) list.get(j);
      if (XString.isEmpty(srcPath)) {
        continue;
      }
      srcPath = srcPath.replace('\\', '/').replaceAll("///", "/").replaceAll("//", "/");

      String baseDir =
          Config.getContextRealPath() + Config.getValue("Statical.TargetDir").replace('\\', '/');
      baseDir = baseDir + "/" + SiteUtil.getAlias(siteID);

      baseDir = baseDir.replaceAll("///", "/");
      baseDir = baseDir.replaceAll("//", "/");
      srcPath = srcPath.replaceAll(baseDir, "");

      ZCDeployConfigSchema config = new ZCDeployConfigSchema();

      QueryBuilder qb =
          new QueryBuilder(
              " where UseFlag =1 and siteid=? and ? like concat(sourcedir,'%')", siteID, srcPath);
      if (Config.isSQLServer()) {
        qb.setSQL(" where siteid=? and charindex(sourcedir,?)=0");
      }
      if (Config.isDB2()) {
        qb.setSQL(" where siteid=? and locate(sourcedir,'" + srcPath + "')=0");
        qb.getParams().remove(qb.getParams().size() - 1);
      }

      ZCDeployConfigSet set = config.query(qb);

      for (int i = 0; i < set.size(); i++) {
        config = set.get(i);
        String target = config.getTargetDir();
        if (XString.isEmpty(target)) {
          target = "/";
        } else if (!target.endsWith("/")) {
          target = target + "/";
        }

        String filePath = srcPath;
        if (!config.getSourceDir().equals("/")) {
          filePath = srcPath.replaceAll(config.getSourceDir(), "");
        }
        target = dealFileName(target, filePath);

        ZCDeployJobSchema job = new ZCDeployJobSchema();
        job.setID(NoUtil.getMaxID("DeployJobID"));
        job.setConfigID(config.getID());
        job.setSource(baseDir + srcPath);
        job.setMethod(config.getMethod());
        job.setTarget(target);
        job.setSiteID(config.getSiteID());
        job.setHost(config.getHost());
        job.setPort(config.getPort());
        job.setUserName(config.getUserName());
        job.setPassword(config.getPassword());
        job.setRetryCount(0L);
        job.setStatus(0L);
        job.setOperation(operation);
        job.setAddTime(new Date());
        if (User.getCurrent() != null) job.setAddUser(User.getUserName());
        else {
          job.setAddUser("SYS");
        }

        jobSet.add(job);
      }
    }

    return jobSet;
  }
Beispiel #2
0
  public static void dealAutoIndex(long siteID, boolean autoIndex) {
    ZCFullTextSchema ft = new ZCFullTextSchema();
    ft.setSiteID(siteID);
    ft.setProp1("AutoIndex");
    ZCFullTextSet set = ft.query();
    if (!autoIndex) {
      if (set.size() == 0) {
        return;
      }
      long sourceID = set.get(0).getID();
      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setSourceID(sourceID);
      ZDScheduleSet sdSet = sd.query();
      if (sdSet.size() == 0) {
        return;
      }
      sd = sdSet.get(0);
      if ("N".equals(sd.getIsUsing())) {
        return;
      }
      sd.setIsUsing("N");
      sd.update();
    } else if (set.size() == 0) {
      ft.setID(NoUtil.getMaxID("FullTextID"));
      ft.setRelaText("-1");
      ft.setType("Article");
      ft.setName("全站索引-" + SiteUtil.getName(ft.getSiteID()));
      ft.setCode("AllArticle");
      ft.setAddUser("SYS");
      ft.setAddTime(new Date());

      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setAddTime(new Date());
      sd.setAddUser("SYS");
      sd.setCronExpression("*/3 * * * *");
      sd.setID(NoUtil.getMaxID("ScheduleID"));
      sd.setIsUsing("Y");
      sd.setPlanType("Period");
      sd.setTypeCode("IndexMaintenance");
      sd.setStartTime(new Date());
      sd.setSourceID(ft.getID());

      Transaction tran = new Transaction();
      tran.add(ft, OperateType.INSERT);
      tran.add(sd, OperateType.INSERT);
      tran.commit();
    } else {
      ft = set.get(0);
      long sourceID = set.get(0).getID();
      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setSourceID(sourceID);
      ZDScheduleSet sdSet = sd.query();
      if (sdSet.size() == 0) {
        sd.setAddTime(new Date());
        sd.setAddUser("SYS");
        sd.setCronExpression("*/3 * * * *");
        sd.setID(NoUtil.getMaxID("ScheduleID"));
        sd.setIsUsing("Y");
        sd.setPlanType("Period");
        sd.setTypeCode("IndexMaintenance");
        sd.setStartTime(new Date());
        sd.setSourceID(ft.getID());
        sd.insert();
      }
    }
  }