public boolean spooler_process() {

    try {
      String xml_document = "";
      Order order = spooler_task.order();
      Web_service_operation operation = order.web_service_operation();

      if (operation == null) throw new Exception("no web service operation available");

      Web_service_request request = operation.request();
      if (request == null) throw new Exception("no web service request available");
      Web_service_response response = operation.response();
      if (response == null) throw new Exception("no web service response available");

      if (spooler_task.params().value("response_stylesheet") != null
          && spooler_task.params().value("response_stylesheet").length() > 0) {
        // .. either transform the response from order parameters and payload
        Xslt_stylesheet stylesheet = spooler.create_xslt_stylesheet();
        stylesheet.load_file(spooler_task.params().value("response_stylesheet"));
        xml_document = stylesheet.apply_xml(order.xml());
        spooler_log.debug3("content of response transformation:\n" + xml_document);
        response.set_string_content(xml_document);
      } else {
        // .. or send an individual response (use order.params().xml() or order.xml_payload() to
        // access order data)
        response.set_string_content(
            "<response state=\"success\">" + order.params().xml() + "</response>");
      }

      response.send();
      spooler_log.info(
          "web service response successfully processed for order \"" + order.id() + "\"");

      return true;
    } catch (Exception e) {
      spooler_log.warn("error occurred processing web service response: " + e.getMessage());
      return false;
    }
  }
  public boolean spooler_process() {

    Order order = null;
    String orderId = "(none)";

    String host = spooler_log.mail().smtp();
    int port = 25;
    String queueDir = spooler_log.mail().queue_dir();

    String from = spooler_log.mail().from();
    String to = "";
    String cc = "";
    String bcc = "";
    String subject = "";
    String body = "";
    String contentType = "text/plain";
    String encoding = "Base64";

    String attachmentCharset = "iso-8859-1";
    String attachmentContentType = "application/octet-stream";
    String attachmentEncoding = "Base64";
    boolean cleanupAttachment = false;
    String[] attachments = {};

    try {

      try {
        if (spooler_job.order_queue() != null) {
          order = spooler_task.order();
          orderId = order.id();

          if (order.params().value("configuration_path") != null
              && order.params().value("configuration_path").length() > 0) {
            this.setConfigurationPath(order.params().value("configuration_path"));
          } else if (spooler_task.params().value("configuration_path") != null
              && spooler_task.params().value("configuration_path").length() > 0) {
            this.setConfigurationPath(spooler_task.params().value("configuration_path"));
          }

          if (order.params().value("configuration_file") != null
              && order.params().value("configuration_file").length() > 0) {
            this.setConfigurationFilename(order.params().value("configuration_file"));
          } else if (spooler_task.params().value("configuration_file") != null
              && spooler_task.params().value("configuration_file").length() > 0) {
            this.setConfigurationFilename(spooler_task.params().value("configuration_file"));
          }

          // load and assign configuration
          this.initConfiguration();
        }

        // prepare parameters and attributes
        this.prepare();

      } catch (Exception e) {
        throw new Exception("error occurred preparing order: " + e.getMessage());
      }

      if (doSendMail()) {

        try {
          if (this.getParameters().value("to") != null
              && this.getParameters().value("to").length() > 0) {
            to = this.getParameters().value("to");
          } else {
            throw new Exception("no value was specified for mandatory parameter [to]");
          }

          if (this.getParameters().value("subject") != null
              && this.getParameters().value("subject").length() > 0) {
            subject = this.getParameters().value("subject");
          } else {
            throw new Exception("no value was specified for mandatory parameter [subject]");
          }

          if (this.getParameters().value("host") != null
              && this.getParameters().value("host").length() > 0) {
            host = this.getParameters().value("host");
          }

          if (this.getParameters().value("port") != null
              && this.getParameters().value("port").length() > 0) {
            try {
              port = Integer.parseInt(this.getParameters().value("port"));
            } catch (Exception e) {
              throw new Exception(
                  "illegal, non-numeric value ["
                      + this.getParameters().value("port")
                      + "] for parameter [port]: "
                      + e.getMessage());
            }
          }

          if (this.getParameters().value("queue_directory") != null
              && this.getParameters().value("queue_directory").length() > 0) {
            queueDir = this.getParameters().value("queue_directory");
          }

          if (this.getParameters().value("from") != null
              && this.getParameters().value("from").length() > 0) {
            from = this.getParameters().value("from");
          }

          if (this.getParameters().value("cc") != null
              && this.getParameters().value("cc").length() > 0) {
            cc = this.getParameters().value("cc");
          }

          if (this.getParameters().value("bcc") != null
              && this.getParameters().value("bcc").length() > 0) {
            bcc = this.getParameters().value("bcc");
          }

          if (this.getParameters().value("body") != null
              && this.getParameters().value("body").length() > 0) {
            body = this.getParameters().value("body");
          }

          if (this.getParameters().value("content_type") != null
              && this.getParameters().value("content_type").length() > 0) {
            contentType = this.getParameters().value("content_type");
          }

          if (this.getParameters().value("encoding") != null
              && this.getParameters().value("encoding").length() > 0) {
            encoding = this.getParameters().value("encoding");
          }

          if (this.getParameters().value("attachment_charset") != null
              && this.getParameters().value("attachment_charset").length() > 0) {
            attachmentCharset = this.getParameters().value("attachment_charset");
          }

          if (this.getParameters().value("attachment_content_type") != null
              && this.getParameters().value("attachment_content_type").length() > 0) {
            attachmentContentType = this.getParameters().value("attachment_content_type");
          }

          if (this.getParameters().value("attachment_encoding") != null
              && this.getParameters().value("attachment_encoding").length() > 0) {
            attachmentEncoding = this.getParameters().value("attachment_encoding");
          }

          if (this.getParameters().value("attachment") != null
              && this.getParameters().value("attachment").length() > 0) {
            attachments = this.getParameters().value("attachment").split(";");
          }

          if (this.getParameters().value("cleanup_attachment") != null
              && this.getParameters().value("cleanup_attachment").length() > 0) {
            if (this.getParameters().value("cleanup_attachment").equals("1")
                || this.getParameters().value("cleanup_attachment").equalsIgnoreCase("true")
                || this.getParameters().value("cleanup_attachment").equalsIgnoreCase("yes")) {
              cleanupAttachment = true;
            }
          }

        } catch (Exception e) {
          throw new Exception("error occurred checking parameters: " + e.getMessage());
        }

        try { // to process order
          SOSMail sosMail = new SOSMail(host);

          sosMail.setPort(Integer.toString(port));
          sosMail.setQueueDir(queueDir);
          sosMail.setFrom(from);
          sosMail.setContentType(contentType);
          sosMail.setEncoding(encoding);

          String recipientsTo[] = to.split(",");
          for (int i = 0; i < recipientsTo.length; i++) {
            if (i == 0) sosMail.setReplyTo(recipientsTo[i].trim());
            sosMail.addRecipient(recipientsTo[i].trim());
          }

          String recipientsCC[] = cc.split(",");
          for (int i = 0; i < recipientsCC.length; i++) {
            sosMail.addCC(recipientsCC[i].trim());
          }

          String recipientsBCC[] = bcc.split(",");
          for (int i = 0; i < recipientsBCC.length; i++) {
            sosMail.addBCC(recipientsBCC[i].trim());
          }

          sosMail.setSubject(subject);
          sosMail.setBody(body);

          sosMail.setAttachmentCharset(attachmentCharset);
          sosMail.setAttachmentEncoding(attachmentEncoding);
          sosMail.setAttachmentContentType(attachmentContentType);

          for (int i = 0; i < attachments.length; i++) {
            File attachmentFile = new File(attachments[i]);
            SOSMailAttachment attachment = new SOSMailAttachment(sosMail, attachmentFile);
            attachment.setCharset(attachmentCharset);
            attachment.setEncoding(attachmentEncoding);
            attachment.setContentType(attachmentContentType);
            sosMail.addAttachment(attachment);
          }

          sosMail.setSOSLogger(this.getLogger());

          this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());

          if (!sosMail.send()) {
            this.getLogger()
                .warn(
                    "mail server is unavailable, mail for recipient ["
                        + to
                        + "] is queued in local directory ["
                        + sosMail.getQueueDir()
                        + "]:"
                        + sosMail.getLastError());
          }

          if (cleanupAttachment) {

            for (int i = 0; i < attachments.length; i++) {
              File attachmentFile = new File(attachments[i]);
              if (attachmentFile.exists() && attachmentFile.canWrite()) {
                SOSFile.deleteFile(attachmentFile);
              }
            }
          }

          sosMail.clearRecipients();

        } catch (Exception e) {
          throw new Exception(e.getMessage());
        }
      }
      return (spooler_task.job().order_queue() != null) ? true : false;

    } catch (Exception e) {
      spooler_log.warn("error occurred processing order [" + orderId + "]: " + e.getMessage());
      return false;
    } finally {
      try {
        this.cleanup();
      } catch (Exception e) {
      }
      ;
    }
  }
  public boolean spooler_process() {

    try {
      super.spooler_process();
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    boolean checkParallel = false;
    boolean parallelTransfer = false;
    String parallelTransferCheckSetback = "00:00:60";
    int parallelTransferCheckRetry = 60;
    Variable_set params = null;
    boolean rc = false;
    boolean isFilePath = false;
    boolean orderSelfDestruct = false;
    //		Properties schedulerParams = null;
    HashMap<String, String> schedulerParams = null;

    try {
      this.setLogger(new SOSSchedulerLogger(spooler_log));
      getLogger().info(JSVersionInfo.getVersionString());
      getLogger().info(conSVNVersion);

      try { // to get the job and order parameters
        params = getParameters();
        schedulerParams =
            objOptions.DeletePrefix(super.getSchedulerParameterAsProperties(params), "ftp_");
        schedulerParams.putAll(getParameterDefaults(params));
        checkParallel =
            sosString.parseToBoolean(
                sosString.parseToString(schedulerParams.get(conParameterCHECK_PARALLEL)));
        parallelTransfer =
            sosString.parseToBoolean(
                sosString.parseToString(schedulerParams.get(conParameterPARALLEL)));

      } catch (Exception e) {
        throw new JobSchedulerException("could not process job parameters: " + e.getMessage(), e);
      }

      try {
        if (checkParallel && spooler_job.order_queue() != null) {
          boolean bSuccess = true;
          String[] paramNames = sosString.parseToString(spooler.variables().names()).split(";");
          for (int i = 0; i < paramNames.length; i++) {

            if (paramNames[i].startsWith(
                "ftp_check_send_" + normalize(spooler_task.order().id()) + ".")) {
              if (sosString.parseToString(spooler.var(paramNames[i])).equals("0")) {
                // Anzahl der Wiederholungen merken
                String sRetry =
                    sosString.parseToString(
                        spooler
                            .variables()
                            .var("cur_transfer_retry" + normalize(spooler_task.order().id())));
                int retry = sRetry.length() == 0 ? 0 : Integer.parseInt(sRetry);
                --retry;
                spooler
                    .variables()
                    .set_var(
                        "cur_transfer_retry" + normalize(spooler_task.order().id()),
                        String.valueOf(retry));
                if (retry == 0) {
                  getLogger().debug("terminated cause max order setback reached: " + paramNames[i]);
                  spooler
                      .variables()
                      .set_var(
                          "terminated_cause_max_order_setback_"
                              + normalize(spooler_task.order().id()),
                          "1");
                  return false;
                }
                getLogger()
                    .debug(
                        "launching setback: "
                            + parallelTransferCheckRetry
                            + " * "
                            + parallelTransferCheckSetback);
                spooler_task.order().setback();
                return false;
              } else if (sosString.parseToString(spooler.var(paramNames[i])).equals("1")) {
                getLogger().debug("successfully terminated: " + paramNames[i]);
              } else if (sosString.parseToString(spooler.var(paramNames[i])).equals("2")) {
                bSuccess = false;
                getLogger().debug("terminated with error : " + paramNames[i]);
              }
            }
          }
          return bSuccess;
        } else if (sosString.parseToString(params.var("ftp_parent_order_id")).length() > 0) {
          // Hauptauftrag wurde wegen Erreichens von ftp_parallel_check_retry beendet -> die
          // restlichen Unterauftr�ge sollen
          // nicht durchlaufen
          String state =
              spooler
                  .variables()
                  .var(
                      "terminated_cause_max_order_setback_"
                          + normalize(params.var("ftp_parent_order_id")));
          if (state.equals("1")) return false;
        }

        if (sosString.parseToString(schedulerParams.get("file_path")).length() > 0) {
          isFilePath = true;
        } else {
          isFilePath = false;
        }

      } catch (Exception e) {
        throw (new Exception("invalid or insufficient parameters: " + e.getMessage()));
      }

      try { // to process ftp

        if (parallelTransfer && !isFilePath) {
          // nur die filelist holen um Parallelen transfer zu erm�glichen
          Properties p = new Properties();
          p.putAll((Properties) schedulerParams.clone());
          p.put("skip_transfer", "yes");
          // kb 2011-04--27 no longer needed due to too much trouble with this file / concept
          //					 createIncludeConfigurationFile("sos/net/sosftp/Configuration.xml",
          // "sos.net.sosftp.Configuration.xml");//Alle
          // Parametern sind hier auch g�ltig
          SOSConfiguration con =
              new SOSConfiguration(
                  null,
                  p,
                  sosString.parseToString(schedulerParams.get(conParameterSETTINGS)),
                  sosString.parseToString(schedulerParams.get(conParameterPROFILE)),
                  //							"sos/scheduler/ftp/SOSFTPConfiguration.xml", new
                  // SOSSchedulerLogger(spooler_log));
                  null,
                  new SOSSchedulerLogger(spooler_log));
          con.checkConfigurationItems();

          sos.net.sosftp.SOSFTPCommandSend ftpCommand =
              new sos.net.sosftp.SOSFTPCommandSend(con, new SOSSchedulerLogger(spooler_log));
          ftpCommand.setSchedulerJob(this);
          rc = ftpCommand.transfer();
          Vector<File> filelist = ftpCommand.getTransferredFilelist();
          Iterator iterator = filelist.iterator();

          if (isJobchain() == false) {
            // parallel transfer for standalone job
            while (iterator.hasNext()) {
              File fileName = (File) iterator.next();
              Variable_set newParams = params;
              newParams.set_var("ftp_file_path", fileName.getCanonicalPath());
              newParams.set_var("ftp_local_dir", "");
              getLogger()
                  .info(
                      "launching job for parallel transfer with parameter ftp_file_path: "
                          + fileName.getCanonicalPath());
              spooler.job(spooler_task.job().name()).start(params);
            }
            return signalSuccess();
          } else {
            // parallel transfer for order job
            while (iterator.hasNext()) {
              File fileName = (File) iterator.next();
              Variable_set newParams = spooler.create_variable_set();
              if (spooler_task.params() != null) newParams.merge(params);

              newParams.set_var("ftp_file_path", fileName.getCanonicalPath());
              newParams.set_var("ftp_parent_order_id", spooler_task.order().id());
              newParams.set_var("ftp_order_self_destruct", "1");

              Order newOrder = spooler.create_order();
              newOrder.set_state(spooler_task.order().state());
              newOrder.set_params(newParams);

              spooler.job_chain(spooler_task.order().job_chain().name()).add_order(newOrder);

              getLogger()
                  .info(
                      "launching order for parallel transfer with parameter ftp_file_path: "
                          + fileName.getCanonicalPath());

              spooler
                  .variables()
                  .set_var(
                      "ftp_order",
                      normalize(spooler_task.order().id())
                          + "."
                          + normalize(newOrder.id())
                          + "."
                          + "0");
              spooler
                  .variables()
                  .set_var(
                      "ftp_check_send_"
                          + normalize(spooler_task.order().id())
                          + "."
                          + normalize(newOrder.id()),
                      "0");
            }
            // am aktuellen Auftrag speichern, dass im Wiederholungsfall per setback() nicht erneut
            // Auftr�ge erzeugt werden
            // sollen, sondern dass deren Erledigungszustand gepr�ft wird:
            spooler_task.order().params().set_var("ftp_check_parallel", "yes");
            spooler_job.set_delay_order_after_setback(1, parallelTransferCheckSetback);
            spooler_job.set_max_order_setbacks(parallelTransferCheckRetry);
            spooler_task.order().setback();
            spooler
                .variables()
                .set_var(
                    "cur_transfer_retry" + normalize(spooler_task.order().id()),
                    String.valueOf(parallelTransferCheckRetry));
            return false;
          }
        }
        // end Parallel Transfer
        //				createIncludeConfigurationFile("sos/net/sosftp/Configuration.xml",
        // "sos.net.sosftp.Configuration.xml");// Alle Parametern
        //																														// sind hier auch
        //																														// g�ltig
        SOSConfiguration con =
            new SOSConfiguration(
                null,
                mapToProperties(schedulerParams),
                sosString.parseToString(schedulerParams.get(conParameterSETTINGS)),
                sosString.parseToString(schedulerParams.get(conParameterPROFILE)),
                //						"sos/scheduler/ftp/SOSFTPConfiguration.xml", new
                // SOSSchedulerLogger(spooler_log));
                null,
                new SOSSchedulerLogger(spooler_log));
        con.checkConfigurationItems();

        sos.net.sosftp.SOSFTPCommandSend ftpCommand =
            new sos.net.sosftp.SOSFTPCommandSend(con, new SOSSchedulerLogger(spooler_log));
        ftpCommand.setSchedulerJob(this);
        rc = ftpCommand.transfer();

        // return the number of transferred files
        createReturnParameter(ftpCommand);

        if (parallelTransfer && isFilePath && spooler_job.order_queue() != null) {
          spooler
              .variables()
              .set_var(
                  "ftp_check_send_"
                      + normalize(params.var("ftp_parent_order_id"))
                      + "."
                      + normalize(spooler_task.order().id()),
                  "1");
        }
        processResult(rc, "");

        spooler_job.set_state_text(ftpCommand.getState() != null ? ftpCommand.getState() : "");
        return (spooler_task.job().order_queue() == null) ? false : rc;

      } catch (Exception e) {
        rc = false;
        if (parallelTransfer && isFilePath && spooler_job.order_queue() != null) {
          spooler
              .variables()
              .set_var(
                  "ftp_check_send_"
                      + normalize(params.var("ftp_parent_order_id"))
                      + "."
                      + normalize(spooler_task.order().id()),
                  "2");
        }
        throw (new Exception("could not process file transfer: " + e, e));
      } finally {
        if (parallelTransfer) {
          if (orderSelfDestruct) {
            // find positive end state for parallel orders
            String state = "";
            sos.spooler.Job_chain_node node = spooler_task.order().job_chain_node();
            while (node != null) {
              node = node.next_node();
              if (node != null) state = node.state();
            }
            this.getLogger().debug9("..set state for parallel order job: " + state);
            // find positive end state
            spooler_task.order().set_state(state);
          }
        }
      }

    } catch (Exception e) {
      processResult(false, e.toString());
      spooler_job.set_state_text("ftp processing failed: " + e);
      spooler_log.warn("ftp processing failed: " + e);
      return false;
    }
  }