示例#1
0
  /** @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);
    }

    //
  }