Class AbstractExecFileTransfer

    • Constructor Detail

      • AbstractExecFileTransfer

        public AbstractExecFileTransfer()
    • Method Detail

      • transfer

        public java.lang.String transfer​(TransferState state)
                                  throws java.io.IOException,
                                         ServerError
        "Transfer" files by soft-linking them into place. This method is likely re-usable for other general "linking" strategies by overriding createProcessBuilder(File, File) and the other protected methods here.
        Throws:
        java.io.IOException
        ServerError
      • getLocalLocation

        protected java.io.File getLocalLocation​(OriginalFile root,
                                                OriginalFile ofile)
        Build a path of the form "root.path/root.name/file.path/file.name".
        Parameters:
        root - the root directory
        ofile - a path relative to the root
        Returns:
        the assembled path with separators suitable for the local filesystem
      • checkLocation

        protected void checkLocation​(java.io.File location,
                                     RawFileStorePrx rawFileStore)
                              throws ServerError,
                                     java.io.IOException
        Check that the target location: 1) doesn't exist and 2) is properly written to by the server. If either condition fails, no linking takes place.
        Parameters:
        location - the source file
        rawFileStore - the target on the server
        Throws:
        ServerError - if the raw file store could not be used
        java.io.IOException - for problems with the source file
      • failLocationCheck

        protected java.lang.RuntimeException failLocationCheck​(java.io.File location,
                                                               java.lang.String msg)
      • exec

        protected void exec​(java.io.File file,
                            java.io.File location)
                     throws java.io.IOException
        Executes a local command and fails on non-0 return codes.
        Parameters:
        file - the source file
        location - the target on the server
        Throws:
        java.io.IOException - for problems with the source file
      • checkTarget

        protected void checkTarget​(java.io.File location,
                                   TransferState state)
                            throws ServerError
        Check that the server can properly read the copied file. Like checkLocation(File, RawFileStorePrx) but after the invocation of exec(File, File), there is some chance, likely due to file permissions, that the server will not be able to read the transfered file. If so, raise an exception and leave the user to cleanup and modifications.
        Throws:
        ServerError
      • createProcessBuilder

        protected abstract java.lang.ProcessBuilder createProcessBuilder​(java.io.File file,
                                                                         java.io.File location)
        Creates a ProcessBuilder instance ready to have ProcessBuilder.start() called on it. The only critical piece of information should be the return code.
        Parameters:
        file - File to be copied.
        location - Location to copy to.
        Returns:
        an instance ready for performing the transfer