コード例 #1
0
ファイル: Schedule.java プロジェクト: dajester2013/Lucee
  /** @throws PageException */
  private void doUpdate() throws PageException {
    String message = "missing attribute for tag schedule with action update";
    String detail = "required attributes are [startDate, startTime, URL, interval, operation]";

    Resource file = null;
    // if(publish) {
    if (!StringUtil.isEmpty(strFile) && !StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
      file = file.getRealResource(strFile);
    } else if (!StringUtil.isEmpty(strFile)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strFile);
    } else if (!StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
    }
    if (file != null)
      pageContext
          .getConfig()
          .getSecurityManager()
          .checkFileLocation(pageContext.getConfig(), file, serverPassword);

    // missing attributes
    if (startdate == null || starttime == null || url == null || interval == null)
      throw new ApplicationException(message, detail);

    // timeout
    if (requesttimeout < 0) requesttimeout = pageContext.getRequestTimeout();

    // username/password
    Credentials cr = null;
    if (username != null) cr = CredentialsImpl.toCredentials(username, password);

    try {

      ScheduleTask st =
          new ScheduleTaskImpl(
              task,
              file,
              startdate,
              starttime,
              enddate,
              endtime,
              url,
              port,
              interval,
              requesttimeout,
              cr,
              ProxyDataImpl.getInstance(proxyserver, proxyport, proxyuser, proxypassword),
              resolveurl,
              publish,
              hidden,
              readonly,
              paused,
              autoDelete);
      scheduler.addScheduleTask(st, true);
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }

    //
  }
コード例 #2
0
ファイル: Schedule.java プロジェクト: dajester2013/Lucee
  /** @throws PageException */
  private void doList() throws PageException {
    // if(tr ue) throw new PageRuntimeException("qqq");
    ScheduleTask[] tasks = scheduler.getAllScheduleTasks();
    final String v = "VARCHAR";
    String[] cols =
        new String[] {
          "task",
          "path",
          "file",
          "startdate",
          "starttime",
          "enddate",
          "endtime",
          "url",
          "port",
          "interval",
          "timeout",
          "username",
          "password",
          "proxyserver",
          "proxyport",
          "proxyuser",
          "proxypassword",
          "resolveurl",
          "publish",
          "valid",
          "paused",
          "autoDelete"
        };
    String[] types =
        new String[] {
          v, v, v, "DATE", "OTHER", "DATE", "OTHER", v, v, v, v, v, v, v, v, v, v, v, "BOOLEAN", v,
          "BOOLEAN", "BOOLEAN"
        };
    lucee.runtime.type.Query query = new QueryImpl(cols, types, tasks.length, "query");
    try {
      for (int i = 0; i < tasks.length; i++) {
        int row = i + 1;
        ScheduleTask task = tasks[i];
        query.setAt(KeyConstants._task, row, task.getTask());
        if (task.getResource() != null) {
          query.setAt(KeyConstants._path, row, task.getResource().getParent());
          query.setAt(KeyConstants._file, row, task.getResource().getName());
        }
        query.setAt("publish", row, Caster.toBoolean(task.isPublish()));
        query.setAt("startdate", row, task.getStartDate());
        query.setAt("starttime", row, task.getStartTime());
        query.setAt("enddate", row, task.getEndDate());
        query.setAt("endtime", row, task.getEndTime());
        query.setAt(KeyConstants._url, row, printUrl(task.getUrl()));
        query.setAt(KeyConstants._port, row, Caster.toString(HTTPUtil.getPort(task.getUrl())));
        query.setAt("interval", row, task.getStringInterval());
        query.setAt("timeout", row, Caster.toString(task.getTimeout() / 1000));
        query.setAt("valid", row, Caster.toString(task.isValid()));
        if (task.hasCredentials()) {
          query.setAt("username", row, task.getCredentials().getUsername());
          query.setAt("password", row, task.getCredentials().getPassword());
        }
        ProxyData pd = task.getProxyData();
        if (ProxyDataImpl.isValid(pd)) {
          query.setAt("proxyserver", row, pd.getServer());
          if (pd.getPort() > 0) query.setAt("proxyport", row, Caster.toString(pd.getPort()));
          if (ProxyDataImpl.hasCredentials(pd)) {
            query.setAt("proxyuser", row, pd.getUsername());
            query.setAt("proxypassword", row, pd.getPassword());
          }
        }
        query.setAt("resolveurl", row, Caster.toString(task.isResolveURL()));

        query.setAt("paused", row, Caster.toBoolean(task.isPaused()));
        query.setAt("autoDelete", row, Caster.toBoolean(((ScheduleTaskImpl) task).isAutoDelete()));
      }
      pageContext.setVariable(returnvariable, query);
    } catch (DatabaseException e) {
    }
  }