Package com.sos.VirtualFileSystem.Interfaces

Examples of com.sos.VirtualFileSystem.Interfaces.ISOSVirtualFile


        objDataTargetClient = (ISOSVfsFileTransfer) objVFS4Target;
        objVFS4Target.setTarget();
        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) {
View Full Code Here


  }

  @Override
  public ISOSVirtualFile getFileHandle(String pstrFilename) {
    final String conMethodName = conClassName + "::getFileHandle";
    ISOSVirtualFile objFtpFile = new SOSVfsFtpFile(pstrFilename);
    logger.debug(String.format("%2$s: getFileHandle for %1$s ", pstrFilename, conMethodName));
    objFtpFile.setHandler(this);
    return objFtpFile;
  }
View Full Code Here

    String strName = objVirtualFile.getName();
    // strName = new File(strName).getAbsolutePath();
    // if (strName.startsWith("c:") == true) {
    // strName = strName.substring(3);
    // }
    ISOSVirtualFile objVF = (ISOSVirtualFile) this.getFileHandle(strName);
    OutputStream objOS = objVF.getFileOutputStream();
    InputStream objFI = objVirtualFile.getFileInputStream();
    // TODO Buffersize must be defined via Options-Class
    int lngBufferSize = 1024;
    byte[] buffer = new byte[lngBufferSize];
    int intBytesTransferred;
View Full Code Here

        logger.debug("Starting renameing of atomic files ...");

        for (SOSFileListEntry objListItem : objFileListEntries) {
          String strFromFilename = objListItem.TargetTransferName();
          String strToFilename = MakeFullPathName(objOptions.TargetDir.Value(), objListItem.TargetFileName());
          ISOSVirtualFile objF = null;
          if (objListItem.FileExists() == true) {
            objF = objDataTargetClient.getFileHandle(strToFilename);
            objF.delete();
          }
          objF = objDataTargetClient.getFileHandle(MakeFullPathName(objOptions.TargetDir.Value(), strFromFilename));
          objF.rename(strToFilename);
        }
      }
    }
    catch (Exception e) {
      e.printStackTrace(System.err);
View Full Code Here

          objSourceFileList.add(getSingleFileNames(), strSourceDir);
        }
        else {
          String fileSpec = objOptions.file_spec.Value();
          objDataSourceClient.changeWorkingDirectory(strSourceDir);
          ISOSVirtualFile objLocFile = objDataSourceClient.getFileHandle(strSourceDir);
          String strM = "source directory/file: " + strSourceDir + ", target directory: " + strRemoteDir + ", file regexp: " + fileSpec;
          logger.debug(strM);
          if (objLocFile.isDirectory() == true) {
            String[] strFileList = objDataSourceClient.getFilelist(strSourceDir, fileSpec, 0, flgRecurseFolders);
            objSourceFileList.add(strFileList, strSourceDir);
          }
          else {
            objSourceFileList.add(strSourceDir);
          }
        }
        // TODO implement polling for files

        // TODO in Options setzen anhand der Values in der Liste.
        if (zeroByteFiles == false) {
          // TODO in die SOSFileList einbauen (SkipZeroByteFiles)
          for (SOSFileListEntry objEntry : objSourceFileList.List()) {
            String strSourceFileName = objEntry.SourceFileName();
            ISOSVirtualFile objVF = objDataSourceClient.getFileHandle(strSourceFileName);
            if (objVF.FileExists()) {
              if (objVF.isEmptyFile()) {
                objEntry.setTransferSkipped();
                if (objOptions.remove_files.value()) {
                  objVF.delete();
                  objEntry.zeroByteCount++;
                }
              }
            }
            else {
View Full Code Here

    ISOSVfsFileTransfer objVFSHandler = pobjVirtualDir.getHandler();
    logger.debug("getFilelist from: "+pobjVirtualDir.getName());
    String[] filenames = objVFSHandler.getFilelist(pobjVirtualDir.getName(), ".*", 0, false);
    objHotFolderFileList.setHotFolderSrc(pobjVirtualDir);
    for (String filename : filenames) {
      ISOSVirtualFile objVirtualFile = objVFSHandler.getFileHandle(filename);
      String lowerFilename = filename.toLowerCase();
      try {
        if(objVirtualFile.isDirectory()) {
          logger.debug("load SchedulerHotFolder = " + filename);
          SchedulerHotFolder obj = objFactory.createSchedulerHotFolder(objVirtualFile);
          objHotFolderFileList.add(obj);
        }
        else if(lowerFilename.endsWith(JSObjJob.fileNameExtension)) {
View Full Code Here

    String strName = objVirtualFile.getName();
    // strName = new File(strName).getAbsolutePath();
    // if (strName.startsWith("c:") == true) {
    // strName = strName.substring(3);
    // }
    ISOSVirtualFile objVF = (ISOSVirtualFile) this.getFileHandle(strName);
    OutputStream objOS = objVF.getFileOutputStream();
    InputStream objFI = objVirtualFile.getFileInputStream();
    int lngBufferSize = 1024;
    byte[] buffer = new byte[lngBufferSize];
    int intBytesTransferred;
    long totalBytes = 0;
View Full Code Here

  }

  @Override
  public ISOSVirtualFile getFileHandle(String pstrFilename) {
    final String conMethodName = conClassName + "::getFileHandle";
    ISOSVirtualFile objFtpFile = new SOSVfsFtpFile(pstrFilename);
    logger.debug(String.format("%2$s: getFileHandle for %1$s ", pstrFilename, conMethodName));
    objFtpFile.setHandler(this);
    return objFtpFile;
  }
View Full Code Here

   * @return
   */
  @Override
  public ISOSVirtualFile getParentVfsFile() {
    File strP = super.getParentFile();
    ISOSVirtualFile objF = new SOSVfsFtpFile(strP.getAbsolutePath());
    objF.setHandler(getHandler());
    return objF;
  }
View Full Code Here

  @Override
  public ISOSVirtualFile getFileHandle(String pstrFilename) {
    final String conMethodName = conClassName + "::getFileHandle";

    ISOSVirtualFile objFtpFile = new SOSVfsFtpFile(pstrFilename);
    logger.debug(String.format("%2$s: getFileHandle for %1$s ", pstrFilename, conMethodName));
    objFtpFile.setHandler(this);
    return objFtpFile;
  }
View Full Code Here

TOP

Related Classes of com.sos.VirtualFileSystem.Interfaces.ISOSVirtualFile

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.