use of org.apache.commons.net.ftp.FTPClient in project azure-tools-for-java by Microsoft.
the class WebAppUtils method uploadWebConfig.
public static void uploadWebConfig(WebApp webApp, InputStream fileStream, IProgressIndicator indicator) throws IOException {
FTPClient ftp = null;
try {
PublishingProfile pp = webApp.getPublishingProfile();
ftp = getFtpConnection(pp);
if (indicator != null)
indicator.setText("Stopping the service...");
webApp.stop();
if (indicator != null)
indicator.setText("Uploading " + webConfigFilename + "...");
ftp.storeFile(ftpRootPath + webConfigFilename, fileStream);
if (indicator != null)
indicator.setText("Starting the service...");
webApp.start();
} finally {
if (ftp != null && ftp.isConnected()) {
ftp.disconnect();
}
}
}
use of org.apache.commons.net.ftp.FTPClient in project azure-tools-for-java by Microsoft.
the class AppServiceChangeSettingsDialog method editAppService.
protected WebApp editAppService(WebApp webApp, IProgressIndicator progressIndicator) throws Exception {
if (model.jdkDownloadUrl != null) {
progressIndicator.setText("Turning App Service into .Net based...");
//webApp.update().withNetFrameworkVersion(NetFrameworkVersion.V4_6).apply();
//progressIndicator.setText("Deploying custom jdk...");
//WebAppUtils.deployCustomJdk(webApp, model.jdkDownloadUrl, model.webContainer, progressIndicator);
} else {
FTPClient ftpClient = WebAppUtils.getFtpConnection(webApp.getPublishingProfile());
progressIndicator.setText("Deleting custom jdk artifacts, if any (takes a while)...");
WebAppUtils.removeCustomJdkArtifacts(ftpClient, progressIndicator);
// TODO: make cancelable
WebAppUtils.removeCustomJdkArtifacts(WebAppUtils.getFtpConnection(webApp.getPublishingProfile()), progressIndicator);
progressIndicator.setText("Applying changes...");
webApp.update().withJavaVersion(JavaVersion.JAVA_8_NEWEST).withWebContainer(model.webContainer).apply();
}
return webApp;
}
use of org.apache.commons.net.ftp.FTPClient in project camel by apache.
the class FtpBadLoginMockNoopConnectionLeakTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class);
endpoint.setFtpClient(new FTPClient() {
@Override
public boolean sendNoOp() throws IOException {
// return true as long as connection is established
return this.isConnected();
}
});
}
use of org.apache.commons.net.ftp.FTPClient in project ddf by codice.
the class TestFtp method createInsecureClient.
private FTPClient createInsecureClient() throws Exception {
FTPClient ftp = new FTPClient();
int attempts = 0;
while (true) {
try {
ftp.connect(FTP_SERVER, Integer.parseInt(FTP_PORT.getPort()));
break;
} catch (SocketException e) {
//a socket exception can be thrown if the ftp server is still in the process of coming up or down
Thread.sleep(1000);
if (attempts++ > 30) {
throw e;
}
}
}
showServerReply(ftp);
int connectionReply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(connectionReply)) {
fail("FTP server refused connection: " + connectionReply);
}
boolean success = ftp.login(USERNAME, PASSWORD);
showServerReply(ftp);
if (!success) {
fail("Could not log in to the FTP server.");
}
ftp.enterLocalPassiveMode();
ftp.setControlKeepAliveTimeout(300);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
return ftp;
}
use of org.apache.commons.net.ftp.FTPClient in project nifi by apache.
the class FTPTransfer method getInputStream.
@Override
public InputStream getInputStream(final String remoteFileName, final FlowFile flowFile) throws IOException {
final FTPClient client = getClient(flowFile);
InputStream in = client.retrieveFileStream(remoteFileName);
if (in == null) {
throw new IOException(client.getReplyString());
}
return in;
}
Aggregations