Package com.sos.JSHelper.Exceptions

Examples of com.sos.JSHelper.Exceptions.JobSchedulerException


    try {
      strR = objOptions.getreplacing().doReplace(strR, strReplaceWith);
    }
    catch (Exception e) {
      e.printStackTrace(System.err);
      logger.error(e.getLocalizedMessage(), new JobSchedulerException("getreplacing().doReplace aborted with an exception", e));
    }
    return strR;
  }
View Full Code Here


    if (lngFileSize <= 0) { // if the file is compressed, then the original filesize may be to big
      lngFileSize = objDataSourceClient.getFileHandle(strSourceFileName).getFileSize();
    }
    if (lngFileSize != plngNoOfBytesTransferred) {
      logger.error(String.format("File-Size failure for file '%3$s'. No of bytes transferred '%1$d', size of file is '%2$d'", plngNoOfBytesTransferred,
          lngFileSize, strSourceFileName), new JobSchedulerException("FileSize"));
      this.setStatus(enuTransferStatus.transfer_aborted);
      throw new JobSchedulerException("FileSize");
    }
    if (lngOriginalFileSize != plngNoOfBytesTransferred) {
      logger.error(String.format("File-Size failure. No of bytes transferred '%1$d', original size of file '%2$d'", plngNoOfBytesTransferred,
          lngOriginalFileSize), new JobSchedulerException("FileSize"));
      this.setStatus(enuTransferStatus.transfer_aborted);
      throw new JobSchedulerException("FileSize");
    }
    this.setStatus(enuTransferStatus.transferred);
    // TODO Message "transferCompleted absetzen"
  }
View Full Code Here

        }
        if (!found) {
          message = "During triggering for " + objOptions.poll_timeout.value() + " minutes the file " + message + " has been changed repeatedly";
          if (objOptions.force_files.value() == true) {
            logger.error(message);
            throw new JobSchedulerException(message);
          }
          else {
            logger.info(message);
            return false;
          }
        }
      }
      return true;
    }
    catch (Exception e) {
      throw new JobSchedulerException("error in  " + conMethodName + " error while polling, cause: " + e);
    }
  }
View Full Code Here

        objVFS4Target.Options(objOptions);
      }

      ISOSVirtualFile objSourceFile = objDataSourceClient.getFileHandle(strSourceFileName);
      if (objSourceFile.notExists() == true) {
        throw new JobSchedulerException(".. file '" + strSourceFileName + "' does not exist ");
      }
      /**
       * hier nicht verwenden, weil es zu sp�t kommt.     
       */
      // if (CheckFileSizeIsChanging() == false) {
      // // TODO Exception ausl�sen
      // return;
      // }
     
      if (objOptions.TransferZeroByteFiles() == false && objSourceFile.isEmptyFile()) {
        this.TransferStatus(enuTransferStatus.transfer_skipped);
        return;
      }
     
      File subParent = null;
      String subPath = "";
      String strTargetFolderName = objOptions.TargetDir.Value();
      String localDir = objOptions.SourceDir.Value();
      boolean recursive = objOptions.recursive.value();
      if (recursive) {
        // TODO Das Erstellen des Verzeichnis mu� eine separate Methode werden
        // �berpr�fen, ob das Verzeichnis auf den Target (-Server) existiert, wenn nicht dann soll das gleiche Verzeichnis generiert
        // werden
        if (objSourceFile.getParentVfs() != null && objSourceFile.getParentVfsFile().isDirectory()) {
          subPath = strSourceFileName.substring((localDir.length() + 1)); // Unterverzeichnisse sind alle Verzeichnisse unterhalb
          // der localDir
          subParent = new File(subPath).getParentFile();
          if (subParent != null) {
            subPath = subPath.replaceAll("\\\\", File.separator);
            subPath = subPath.substring(0, subPath.length() - new File(strSourceFileName.toString()).getName().length() - 1);
            logger.debug(".. creating sub-directory on data-target: " + subPath);
            String[] ftpFiles = objDataTargetClient.listNames(strTargetFolderName + "/" + subPath);
            if (ftpFiles == null || ftpFiles.length == 0) {
              objDataTargetClient.mkdir(strTargetFolderName + File.separator + subPath);
            }
          }
        }
      }
      this.getTargetFile(objOptions); // TODO Namen �ndern
      // if (subParent != null && recursive) {
      // // fleTransferFile = new File((subParent != null ? subParent.getName() + "/" : "") + fleTransferFile.getName());
      // // strTransferFilename = (subParent != null ? subPath + "/" : "") + fleTransferFile.getName();
      // }
      if (objOptions.transactional.value() == true) {
        this.setTransactionalLocalFile();
      }

      String strOp = objOptions.operation.Value();
      if (strOp.equalsIgnoreCase("delete")) {
        objSourceFile.delete();
        logger.debug(String.format("filename '%1$s' deleted", strSourceFileName));
        this.setStatus(enuTransferStatus.deleted);
        return;
      }

      if (strOp.equalsIgnoreCase("rename")) {
        String strNewFileName = MakeFileNameReplacing(strSourceFileName);
        logger.debug(String.format("filename %1$s, renamed to %2$s", strSourceFileName, strNewFileName));
        objSourceFile.rename(strNewFileName);
        this.setStatus(enuTransferStatus.renamed);
        return;
      }

      ISOSVirtualFile objTargetFile = objDataTargetClient.getFileHandle(MakeFullPathName(objOptions.TargetDir.Value(), strTargetFileName));
      if (strTargetFileName.equalsIgnoreCase(strTargetTransferName) == false) {
        objTargetTransferFile = objDataTargetClient.getFileHandle(MakeFullPathName(objOptions.TargetDir.Value(), strTargetTransferName));
      }
      else {
        objTargetTransferFile = objTargetFile;
      }

      if (objOptions.compress_files.value() == true) {
        objSourceTransferFile = objDataSourceClient.getFileHandle(strSourceTransferName);
        this.lngFileSize = objSourceTransferFile.getFileSize();
        lngOriginalFileSize = this.lngFileSize;
      }
      else {
        strSourceTransferName = getFileNameWithoutPath(strSourceTransferName);
        objSourceTransferFile = objDataSourceClient.getFileHandle(MakeFullPathName(objOptions.SourceDir.Value(), strSourceTransferName));
      }
      this.flgFileExists = objTargetFile.FileExists();
      if (objOptions.DoNotOverwrite() && flgFileExists == true) {
        logger.debug("data-target(-server) reply [filename exists] [" + strTargetFileName + "]: " + objDataTargetClient.getReplyString());
        this.setNotOverwritten();
        return;
      }
      /*
       * Hier kann �ber die Streams auch, ohne Zwischendatei, von einem Server
       * zum anderen, der Transfer stattfinden. Input = Server1, Output = Server2.
       * Es ist damit auch ein Server2Server f�r FTP (SFTP und FTPs??) m�glich.
       *
       * Es gibt f�r FTP auch die andere M�glichkeit �ber Server2Server, siehe apache-Klassen.
       */
      // InputStream objInputStream = objSourceTransferFile.getFileInputStream();
      // OutputStream objOutputStream = null;
      // if (objOptions.append_files.value() == true) {
      // objOutputStream = objTargetTransferFile.getFileAppendStream();
      // }
      // else {
      // objOutputStream = objTargetTransferFile.getFileOutputStream();
      // }
      // this.doTransfer(objInputStream, objOutputStream);
      this.doTransfer(objSourceTransferFile, objTargetTransferFile);
      if (objOptions.isAtomicTransfer()) {
        if (objOptions.transactional.value() == false) {
          if (objOptions.overwrite_files.value() == true & flgFileExists == true) {
            // hier werden Dateien gel�scht, vor dem umbenennen.
            // Besser: auch erstmal umbenennen und dann erst l�schen
            objTargetFile.delete();
          }
          objTargetTransferFile.rename(MakeFullPathName(objOptions.TargetDir.Value(), this.TargetFileName()));
        }
      }
      if (flgNewConnectionUsed == true) {
        objDataSourceClient.logout();
        objDataSourceClient.disconnect();
        objDataTargetClient.logout();
        objDataTargetClient.disconnect();
      }
    }
    catch (Exception e) {
      String strT = "error. unable to transfer data, reason: " + e;
      e.printStackTrace(System.err);
      // TODO rollback?
      logger.error(strT);
      throw new JobSchedulerException(strT, e);
    }
  }
View Full Code Here

  }

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

  } // putFile

  private void RaiseException(final Exception e, final String pstrM) {
    logger.error(pstrM);
    e.printStackTrace(System.err);
    throw new JobSchedulerException(pstrM, e);
  }
View Full Code Here

        objFTPClient = new FTPSClient(strProtocol);
      }
      catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new JobSchedulerException("can not create FTPSClient");
      }
      FTPClientConfig conf = new FTPClientConfig();
//      conf.setServerLanguageCode("fr");
//      objFTPClient.configure(conf);
      /**
 
View Full Code Here

    try {
      objVFSHandler.delete(strFileName);
    }
    catch (IOException e) {
      e.printStackTrace();
      throw new JobSchedulerException(String.format("%1$s failed", conMethodName), e);
    }
    return true;
  }
View Full Code Here

      strFileName = AdjustRelativePathName(strFileName);
      objO = objVFSHandler.getAppendFileStream(strFileName);
    }
    catch (Exception e) {
      e.printStackTrace();
      throw new JobSchedulerException(String.format("%1$s failed", conMethodName), e);
    }
    return objO;
  }
View Full Code Here

        }
      }
    }
    catch (Exception e) {
      e.printStackTrace();
      throw new JobSchedulerException(String.format("%1$s failed", conMethodName), e);
    }
    return objInputStream;
  }
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.