Search in sources :

Example 36 with FileTransferException

use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.

the class ClientFactory method getClient.

/**
 * Returns a product specific {@link IFileTransferClient} that handles transfers via the specified {@link TransferProtocol}.
 *
 * @param protocol the {@link TransferProtocol} to use
 * @param port a custom port to use when connecting
 * @return the {@link IFileTransferClient} that handles transfers via the specified {@link TransferProtocol}
 * @throws FileTransferException
 * @see {@link TransferProtocol}
 */
public IFileTransferClient getClient(TransferProtocol protocol, int port) throws FileTransferException {
    switch(protocol) {
        case FTP:
            FtpClient ftp = new FtpClient();
            ftp.setCustomPort(port);
            return ftp;
        case FTPS:
            FtpsClient ftps = new FtpsClient();
            ftps.setCustomPort(port);
            return ftps;
        case SFTP:
            SftpClient sftp = new SftpClient();
            sftp.setCustomPort(port);
            return sftp;
        case HTTP:
            FileTransferHttpClient http = new FileTransferHttpClient();
            http.setCustomPort(port);
            return http;
        case HTTPS:
            FileTransferHttpClient https = new FileTransferHttpClient();
            https.setOverSsl(true);
            https.setCustomPort(port);
            return https;
        default:
            throw new FileTransferException("No implementation for the " + protocol + " protocol is currently available");
    }
}
Also used : FileTransferException(com.axway.ats.common.filetransfer.FileTransferException) FtpsClient(com.axway.ats.core.filetransfer.FtpsClient) SftpClient(com.axway.ats.core.filetransfer.SftpClient) FtpClient(com.axway.ats.core.filetransfer.FtpClient) FileTransferHttpClient(com.axway.ats.action.http.FileTransferHttpClient)

Aggregations

FileTransferException (com.axway.ats.common.filetransfer.FileTransferException)36 IOException (java.io.IOException)16 File (java.io.File)11 BaseTest (com.axway.ats.action.BaseTest)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 FileOutputStream (java.io.FileOutputStream)6 HttpEntity (org.apache.http.HttpEntity)5 HttpResponse (org.apache.http.HttpResponse)5 ClientProtocolException (org.apache.http.client.ClientProtocolException)5 CertificateException (java.security.cert.CertificateException)4 PublicAtsApi (com.axway.ats.common.PublicAtsApi)3 IFileTransferClient (com.axway.ats.core.filetransfer.model.IFileTransferClient)3 SftpException (com.jcraft.jsch.SftpException)3 FileInputStream (java.io.FileInputStream)3 FileNotFoundException (java.io.FileNotFoundException)3 OutputStream (java.io.OutputStream)3 HttpGet (org.apache.http.client.methods.HttpGet)3 HttpPost (org.apache.http.client.methods.HttpPost)3 SshCipher (com.axway.ats.common.filetransfer.SshCipher)2