private void loadEveryDayForm(ActionForm form, ActionRequest req) {
    String[] everyDay = req.getParameterValues("everyDay");

    ContentImporterForm contentImporterForm = (ContentImporterForm) form;
    if (UtilMethods.isSet(everyDay) && contentImporterForm.isEveryInfo()) {
      for (String dayOfWeek : everyDay) {
        if (dayOfWeek.equals("MON")) contentImporterForm.setMonday(true);
        else if (dayOfWeek.equals("TUE")) contentImporterForm.setTuesday(true);
        else if (dayOfWeek.equals("WED")) contentImporterForm.setWednesday(true);
        else if (dayOfWeek.equals("THU")) contentImporterForm.setThusday(true);
        else if (dayOfWeek.equals("FRI")) contentImporterForm.setFriday(true);
        else if (dayOfWeek.equals("SAT")) contentImporterForm.setSaturday(true);
        else if (dayOfWeek.equals("SUN")) contentImporterForm.setSunday(true);
      }

      contentImporterForm.setEveryInfo(true);
      contentImporterForm.setEvery("isDays");
    } else {
      contentImporterForm.setEvery("");
      contentImporterForm.setMonday(false);
      contentImporterForm.setTuesday(false);
      contentImporterForm.setWednesday(false);
      contentImporterForm.setThusday(false);
      contentImporterForm.setFriday(false);
      contentImporterForm.setSaturday(false);
      contentImporterForm.setSunday(false);
    }
  }
  private static boolean _saveScheduler(
      ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form, User user)
      throws Exception {
    boolean result = false;
    ContentImporterForm contentImporterForm = (ContentImporterForm) form;

    SimpleDateFormat sdf = new SimpleDateFormat(WebKeys.DateFormats.DOTSCHEDULER_DATE2);

    Date startDate = null;
    if (contentImporterForm.isHaveStartDate()) {
      try {
        startDate = sdf.parse(contentImporterForm.getStartDate());
      } catch (Exception e) {
      }
    }

    Date endDate = null;
    if (contentImporterForm.isHaveEndDate()) {
      try {
        endDate = sdf.parse(contentImporterForm.getEndDate());
      } catch (Exception e) {
      }
    }

    Map<String, Object> properties = new HashMap<String, Object>(10);

    properties.put("structure", "" + contentImporterForm.getStructure());

    if ((contentImporterForm.getFields() != null) && (0 < contentImporterForm.getFields().length)) {
      StringBuilder fields = new StringBuilder(64);
      fields.ensureCapacity(8);
      for (String field : contentImporterForm.getFields()) {
        if (0 < fields.length()) fields.append("," + field);
        else fields.append(field);
      }

      properties.put("fields", fields.toString());
    }

    if (UtilMethods.isSet(contentImporterForm.getFilePath()))
      properties.put("filePath", contentImporterForm.getFilePath());

    if (UtilMethods.isSet(contentImporterForm.getReportEmail()))
      properties.put("reportEmail", contentImporterForm.getReportEmail());

    if (UtilMethods.isSet(contentImporterForm.getCsvSeparatorDelimiter()))
      properties.put("csvSeparatorDelimiter", contentImporterForm.getCsvSeparatorDelimiter());

    if (UtilMethods.isSet(contentImporterForm.getCsvTextDelimiter()))
      properties.put("csvTextDelimiter", contentImporterForm.getCsvTextDelimiter());

    if (UtilMethods.isSet(contentImporterForm.getLanguage()))
      properties.put("language", Long.toString(contentImporterForm.getLanguage()));

    if (contentImporterForm.isPublishContent()) properties.put("publishContent", "true");
    else properties.put("publishContent", "false");

    if (contentImporterForm.isDeleteAllContent()) properties.put("deleteAllContent", "true");
    else properties.put("deleteAllContent", "false");

    if (contentImporterForm.isSaveWithoutVersions()) properties.put("saveWithoutVersions", "true");
    else properties.put("saveWithoutVersions", "false");

    properties.put("haveCronExpression", contentImporterForm.isHaveCronExpression());

    String cronSecondsField = "0";
    String cronMinutesField = "0";
    String cronHoursField = "*";
    String cronDaysOfMonthField = "*";
    String cronMonthsField = "*";
    String cronDaysOfWeekField = "?";
    String cronYearsField = "*";

    String cronExpression = "";

    if (contentImporterForm.isHaveCronExpression()) {
      cronExpression = contentImporterForm.getCronExpression();
    } else {
      if (contentImporterForm.isAtInfo()) {
        if (UtilMethods.isSet(req.getParameter("at")) && req.getParameter("at").equals("isTime")) {
          cronSecondsField = req.getParameter("atTimeSecond");
          cronMinutesField = req.getParameter("atTimeMinute");
          cronHoursField = req.getParameter("atTimeHour");
        }

        if (UtilMethods.isSet(req.getParameter("at"))
            && req.getParameter("at").equals("isBetween")) {
          cronHoursField =
              req.getParameter("betweenFromHour") + "-" + req.getParameter("betweenToHour");
        }
      }

      if (contentImporterForm.isEveryInfo()) {
        if (UtilMethods.isSet(req.getParameter("every"))
            && req.getParameter("every").equals("isDate")) {
          cronDaysOfMonthField = req.getParameter("everyDateDay");

          try {
            cronMonthsField = "" + (Integer.parseInt(req.getParameter("everyDateMonth")) + 1);
          } catch (Exception e) {
          }

          cronYearsField = req.getParameter("everyDateYear");
        }

        if (UtilMethods.isSet(req.getParameter("every"))
            && req.getParameter("every").equals("isDays")) {
          cronDaysOfMonthField = "?";

          String[] daysOfWeek = req.getParameterValues("everyDay");

          cronDaysOfWeekField = "";
          for (String day : daysOfWeek) {
            if (cronDaysOfWeekField.length() == 0) {
              cronDaysOfWeekField = day;
            } else {
              cronDaysOfWeekField = cronDaysOfWeekField + "," + day;
            }
          }
        }
      }

      if (UtilMethods.isSet(req.getParameter("eachInfo"))) {
        if (UtilMethods.isSet(req.getParameter("eachHours"))) {
          try {
            int eachHours = Integer.parseInt(req.getParameter("eachHours"));
            cronHoursField = cronHoursField + "/" + eachHours;
          } catch (Exception e) {
          }
        }

        if (UtilMethods.isSet(req.getParameter("eachMinutes"))) {
          try {
            int eachMinutes = Integer.parseInt(req.getParameter("eachMinutes"));
            cronMinutesField = cronMinutesField + "/" + eachMinutes;
          } catch (Exception e) {
          }
        }
      }

      cronExpression =
          cronSecondsField
              + " "
              + cronMinutesField
              + " "
              + cronHoursField
              + " "
              + cronDaysOfMonthField
              + " "
              + cronMonthsField
              + " "
              + cronDaysOfWeekField
              + " "
              + cronYearsField;
    }
    CronScheduledTask job = new CronScheduledTask();
    job.setJobName(contentImporterForm.getJobName());
    job.setJobGroup(contentImporterForm.getJobGroup());
    job.setJobDescription(contentImporterForm.getJobDescription());
    job.setJavaClassName("org.dotcms.plugins.contentImporter.quartz.ContentImporterThread");
    job.setProperties(properties);
    job.setStartDate(startDate);
    job.setEndDate(endDate);
    job.setCronExpression(cronExpression);

    try {
      QuartzUtils.scheduleTask(job);
    } catch (Exception e) {
      Logger.error(EditContentImporterJobAction.class, e.getMessage(), e);
      return false;
    }

    SessionMessages.add(req, "message", "message.Scheduler.saved");

    return true;
  }