Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang.StringUtils;
import org.onedatashare.transferservice.odstransferservice.Enum.EndpointType;

@Data
Expand All @@ -17,7 +18,9 @@ public static String[] uriFormat(AccountEndpointCredential credential, EndpointT
if(type.equals(EndpointType.sftp)){
noTypeUri = credential.getUri().replaceFirst("sftp://", "");
}else if(type.equals(EndpointType.ftp)){
noTypeUri = credential.getUri().replaceFirst("ftp://", "");
noTypeUri = credential.getUri().startsWith("ftps://") ?
credential.getUri().replaceFirst("ftps://", "")
: credential.getUri().replaceFirst("ftp://", "");
}
else{
noTypeUri = credential.getUri().replaceFirst("http://", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import lombok.SneakyThrows;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.commons.pool2.ObjectPool;
import org.onedatashare.transferservice.odstransferservice.Enum.EndpointType;
import org.onedatashare.transferservice.odstransferservice.controller.TransferController;
import org.onedatashare.transferservice.odstransferservice.model.credential.AccountEndpointCredential;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
Expand All @@ -17,6 +21,8 @@ public class FtpConnectionPool implements ObjectPool<FTPClient> {
private LinkedBlockingQueue<FTPClient> connectionPool;
private Boolean compression;

Logger logger = LoggerFactory.getLogger(FtpConnectionPool.class);

public FtpConnectionPool(AccountEndpointCredential credential, int bufferSize){
this.credential = credential;
this.bufferSize = bufferSize;
Expand All @@ -26,6 +32,10 @@ public FtpConnectionPool(AccountEndpointCredential credential, int bufferSize){
@Override
public void addObject() throws IOException {
FTPClient client = new FTPClient();
if(credential != null && credential.getUri().startsWith("ftps://")){
client = new FTPSClient();
logger.info("Using FTPS call");
}
String[] hostAndPort = AccountEndpointCredential.uriFormat(credential, EndpointType.ftp);
if(hostAndPort.length >1){
client.connect(hostAndPort[0], Integer.parseInt(hostAndPort[1]));
Expand Down