Search in sources :

Example 1 with InternalFileSystemOperations

use of com.axway.ats.agent.components.system.operations.clients.InternalFileSystemOperations in project ats-framework by Axway.

the class RemoteFileSystemOperations method copyFileTo.

public void copyFileTo(String fromFile, String toMachine, String toFile, boolean failOnError) {
    try {
        Integer copyFileStartPort = getCopyFilePortProperty(ActionLibraryConfigurator.getInstance().getCopyFileStartPort());
        Integer copyFileEndPort = getCopyFilePortProperty(ActionLibraryConfigurator.getInstance().getCopyFileEndPort());
        InternalFileSystemOperations toRemoteFSOperations = new InternalFileSystemOperations(toMachine);
        if (copyFileStartPort != null && copyFileStartPort > 0 && copyFileEndPort != null && copyFileEndPort > 0) {
            toRemoteFSOperations.setCopyFilePortRange(copyFileStartPort, copyFileEndPort);
        }
        int port = toRemoteFSOperations.openFileTransferSocket();
        this.remoteFileSystemOperations.sendFileTo(fromFile, toFile, HostUtils.splitAddressHostAndPort(HostUtils.getAtsAgentIpAndPort(toMachine))[0], port, failOnError);
        toRemoteFSOperations.waitForFileTransferCompletion(port);
    } catch (Exception e) {
        String message = new StringBuilder().append("Unable to copy file ").append(fromFile).append(" from ").append(this.atsAgent).append(" to file ").append(toFile).append(" on ").append(toMachine).toString();
        throw new FileSystemOperationException(message, e);
    }
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) InternalFileSystemOperations(com.axway.ats.agent.components.system.operations.clients.InternalFileSystemOperations) FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException)

Example 2 with InternalFileSystemOperations

use of com.axway.ats.agent.components.system.operations.clients.InternalFileSystemOperations in project ats-framework by Axway.

the class RemoteFileSystemOperations method copyDirectoryTo.

public void copyDirectoryTo(String fromDirName, String toMachine, String toDirName, boolean isRecursive, boolean failOnError) {
    try {
        InternalFileSystemOperations toRemoteFSOperations = new InternalFileSystemOperations(toMachine);
        int port = toRemoteFSOperations.openFileTransferSocket();
        remoteFileSystemOperations.sendDirectoryTo(fromDirName, toDirName, HostUtils.splitAddressHostAndPort(HostUtils.getAtsAgentIpAndPort(toMachine))[0], port, isRecursive, failOnError);
        toRemoteFSOperations.waitForFileTransferCompletion(port);
    } catch (Exception e) {
        String message = new StringBuilder().append("Unable to copy directory ").append(fromDirName).append(" from ").append(this.atsAgent).append(" to ").append(toDirName).append(" on ").append(toMachine).toString();
        throw new FileSystemOperationException(message, e);
    }
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) InternalFileSystemOperations(com.axway.ats.agent.components.system.operations.clients.InternalFileSystemOperations) FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException)

Aggregations

InternalFileSystemOperations (com.axway.ats.agent.components.system.operations.clients.InternalFileSystemOperations)2 FileSystemOperationException (com.axway.ats.common.filesystem.FileSystemOperationException)2