Package com.sos.JSHelper.Exceptions

Examples of com.sos.JSHelper.Exceptions.JobSchedulerException


    }
    this.local_dir.Value(localDir);
    // TODO in die Options-Klasse, falls nicht schon drin ist ....
    if (localDir.startsWith("file://")) {
      if (new File(createURI(localDir)).exists() == false) {
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0010), localDir));
      }
    }
    if (replacing.IsNotEmpty() && replacement.IsEmpty()) {
      throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0020), replacing.getKey(), replacement.getKey()));
    }
    if (replacing.IsEmpty() && replacement.IsNotEmpty()) {
      // throw new JobSchedulerException("SOSVfs-E-0000: parameter is missing for specified parameter [replacement]: [replacing]");
      throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0020), replacement.getKey(), replacing.getKey()));
    }
    if (this.append_files.value() == true) {
      String strAppendFilesKey = append_files.getKey();
      if (isAtomicTransfer()) {
        String strT = getOptionNamesAsString(new SOSOptionElement[] { atomic_prefix, atomic_suffix });
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0050), strAppendFilesKey, strT));
      }
      if (this.compress_files.value() == true) {
        String strT = getOptionNamesAsString(new SOSOptionElement[] { compress_files });
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0050), strAppendFilesKey, strT));
      }

      if (compress_files.value() == true) {
        String strT = getOptionNamesAsString(new SOSOptionElement[] { append_files, compress_files });
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0030), strT));
      }

      // TODO this check must be done at the implementation layer of the protocol-class.
      if (this.protocol.equalsIgnoreCase("ftp")) {
        // oke
      }
      else {
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0040), strAppendFilesKey, this.protocol.Value()));
      }
    }
    // String strProt = this.protocol.Value();
    // if (strProt.equalsIgnoreCase("ftp")) {
    // this.host.CheckMandatory();
    // this.user.CheckMandatory();
    // this.host.CheckMandatory();
    // this.password.CheckMandatory();
    // }
    // else {
    // if (strProt.equalsIgnoreCase("sftp")) {
    // this.host.CheckMandatory();
    // if (BufferSize.value() > 32000) {
    // BufferSize.value(32000);
    // }
    // if (this.ssh_auth_file.IsNotEmpty()) {
    // }
    // else {
    // // if (this.ssh_auth_method.isPublicKey())
    // // throw new JobSchedulerException(
    // // "SOSVfs-E-0000: publickey specified, but no authentication filename was specified as parameter 'ssh_auth_file'");
    // }
    // }
    // }
    if (this.file_path.IsNotEmpty()) {
      if (this.file_spec.IsNotEmpty()) {
        this.file_path.Value("");
        // throw new
        // JobSchedulerException(String.format("SOSVfs-E-0000: 'file_path=%1$s' and 'file_spec=%2$s' specified, but only one of them is allowed",file_path.Value(),
        // file_spec.Value()));
        String strT = getOptionNamesAsString(new SOSOptionElement[] { file_path, file_spec });
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0030), strT));
      }
      if (this.RecurseSubFolders.value() == true) {
        String strT = getOptionNamesAsString(new SOSOptionElement[] { file_path, recursive });
        throw new JobSchedulerException(String.format(objMsg.getMsg(SOSVfs_E_0030), strT));
      }
    }
    if (this.local_dir.IsEmpty() && this.file_spec.IsNotEmpty()) {
      throw new JobSchedulerException(String.format(objMsg.getMsg(conParametersMissing), file_spec.getKey(), local_dir.getKey()));
    }

    if (this.zero_byte_transfer.String2Bool() == true) {
      TransferZeroByteFiles(true);
      setZeroByteFilesStrict(false);
View Full Code Here


    }
    catch (Exception e) {
      String strM = "error occurred reading environment: " + e.toString();
      e.printStackTrace();
      logger.error(strM, e);
      throw new JobSchedulerException(strM);
    }
  }
View Full Code Here

      // objConf = new SOSConfiguration(settings.Value(), profile.Value(), null);
      if (objConf.getParameterAsProperties().size() <= 0) {
        String strM = String.format(objMsg.getMsg(SOSVfs_E_0060), profile.Value(), settings.Value());
        // String strM = String.format("SOSVfs-E-0000: Profile '%1$s' not found or is empty in file '%2$s'", profile.Value(),
        // settings.Value());
        logger.error(strM, new JobSchedulerException(strM));
        throw new JobSchedulerException(strM);
      }
      Properties objP = new Properties();
      objP.putAll(objGlobals);
      objP.putAll(objConf.getParameterAsProperties());
      while (true) {
        Properties objIncludes = new Properties();
        boolean flgIncludeFound = false;
        for (Object k : objP.keySet()) {
          String strKey = (String) k;
          String strValue = (String) objP.get(k);
          logger.debug("ReadSettingsFile() - Property. Key = " + strKey + ", val = " + strValue); //$NON-NLS-1$ //$NON-NLS-2$
          if (isIncludeDirective(strKey)) {
            String[] strValues = strValue.split(",");
            for (String strV : strValues) {
              SOSConfiguration config_ = new SOSConfiguration(settings.Value(), strV, objSOSLogger);
              if (config_.getParameterAsProperties().size() <= 0) {

                // String strM = String.format("SOSVfs-E-0000: Include '%1$s' not found or is empty in file '%2$s'", strV,
                // settings.Value());
                String strM = String.format(objMsg.getMsg(SOSVfs_E_0000), strV, settings.Value());
                logger.error(strM);
                throw new JobSchedulerException(strM);
              }
              objIncludes.putAll(config_.getParameterAsProperties());
            }
            flgIncludeFound = true;
          }
          else {
            if (isIniComment(strKey) == false) {
              // TODO check duplicate Entry but take into account, that includes are in effect
              objIncludes.put(strKey, strValue);
            }
          }
        } // for
        if (objIncludes.size() > 0 && flgIncludeFound == true) {
          objP = new Properties();
          objP.putAll(objIncludes);
        }
        else {
          break;
        }
      }
      HashMap<String, String> map = new HashMap<String, String>();
      for (Object k : objP.keySet()) {
        String strKey = (String) k;
        String strValue = (String) objP.get(k);
        if (hasVariableToSubstiture(strValue) == true) {
          logger.debug("ReadSettingsFile() - Key = " + strKey + ", value = " + strValue); //$NON-NLS-1$ //$NON-NLS-2$
          strValue = SubstituteVariables(strValue, objP, "${", "}");
          strValue = SubstituteVariables(strValue, objP, "%{", "}");
          strValue = SubstituteVariables(strValue, objP, "%", "%");
          strValue = SubstituteVariables(strValue, propSOSFtpEnvironmentVars, "${", "}");
          strValue = SubstituteVariables(strValue, propSOSFtpEnvironmentVars, "%{", "}");
          strValue = SubstituteVariables(strValue, propSOSFtpEnvironmentVars, "%", "%");
          strValue = SubstituteVariables(strValue, propAllEnvironmentVariables, "${", "}");
          strValue = SubstituteVariables(strValue, propAllEnvironmentVariables, "%{", "}");
          strValue = SubstituteVariables(strValue, propAllEnvironmentVariables, "%", "%");
          // TODO wrong place: has to come from the JS-Adapter as properties
          strValue = SubstituteVariables(strValue, schedulerParams, "${", "}");
          strValue = SubstituteVariables(strValue, schedulerParams, "%{", "}");
          strValue = SubstituteVariables(strValue, schedulerParams, "%", "%");
          if (hasVariableToSubstiture(strValue)) {
            String strM = String.format(objMsg.getMsg(SOSVfs_W_0070), strValue, strKey);

            logger.warn(strM);
          }
        }
        map.put(strKey, strValue);
      }
      this.setAllOptions(map);
      setChildClasses(map);
    }
    catch (Exception e) {
      e.printStackTrace();
      logger.error("ReadSettingsFile()", e); //$NON-NLS-1$
      throw new JobSchedulerException(e.getMessage(), e);
    }
  } // private void ReadSettingsFile
View Full Code Here

        } // while
      } // for
      return txt;
    }
    catch (Exception e) {
      throw new JobSchedulerException("can not substitute parameters in: " + txt, e);
    }
  }
View Full Code Here

          path = "file://" + path;
        }
        uri = new URI(path);
      }
      catch (Exception ex) {
        throw (new JobSchedulerException("SOSVfs-E-0000: error in createURI(): " + e.getMessage()));
      }
    }
    return uri;
  }
View Full Code Here

    catch (IOException e) {
      RaiseException(e, HostID(String.format(objMsg.getMsg(SOSVfs_E_0105), conMethodName)));
    }

    if (isNegativeCommandCompletion()) {
      throw new JobSchedulerException("..error occurred 'NegativeCommandCompletion' on the FTP server: " + getReplyString());
    }

  }
View Full Code Here

    long totalBytes = 0;
    try {
      // TODO get filesize and report as a message
      in = Client().retrieveFileStream(remoteFile);
      if (in == null) {
        throw new JobSchedulerException("Could not open stream for " + remoteFile + ". Perhaps the file does not exist. Reply from ftp server: "
            + getReplyString());
      }
      if (isPositiveCommandCompletion() == false) {
        throw new JobSchedulerException("..error occurred in getFile() [retrieveFileStream] on the FTP server for file [" + remoteFile + "]: "
            + getReplyString());
      }
      // TODO Buffersize must be an Option
      byte[] buffer = new byte[4096];
      out = new FileOutputStream(new File(localFile), append);
View Full Code Here

    if (flgStackTracePrinted == false) {
      e.printStackTrace(System.err);
      logger.error(pstrM);
      flgStackTracePrinted = true;
    }
    throw new JobSchedulerException(pstrM, e);
  }
View Full Code Here

    throw new JobSchedulerException(pstrM, e);
  }

  private void RaiseException(final String pstrM) {
    logger.error(pstrM);
    throw new JobSchedulerException(pstrM);
  }
View Full Code Here

      try {
        strTargetFileName = objO.getreplacing().doReplace(strTargetFileName, objO.getreplacement().Value());
      }
      catch (Exception e) {
        e.printStackTrace(System.err);
        logger.error(e.getLocalizedMessage(), new JobSchedulerException("getreplacing().doReplace aborted with an exception", e));
      }
      // String currPath = "";
      // String strParent = fleSourceTransferFile.getParent();
      // if (isNotEmpty(strParent)) {
      // currPath = normalized(strParent);
View Full Code Here

TOP

Related Classes of com.sos.JSHelper.Exceptions.JobSchedulerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.