Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.
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
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,31 @@ local.properties
#################
## Java
#################
# Compiled class file
*.class
*.jardesc

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

#################
## Visual Studio
#################
Expand Down Expand Up @@ -132,3 +154,43 @@ Thumbs.db
Desktop.ini

runtime.properties

###############
## Intellij
###############
# User-specific stuff
.idea/

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

*.log

19 changes: 13 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>WaarpFtpClient</artifactId>
<name>Ftp R66 client </name>
<version>3.0.7</version>
<name>Waarp Ftp R66 client </name>
<version>3.1.0</version>
<description>FTP client -wrapper of ftp4j- for Waarp solution</description>
<url>http://waarp.github.com/WaarpFtpClient</url>
<inceptionYear>2009</inceptionYear>
Expand Down Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpCommon</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -61,7 +61,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpFtp-Core</artifactId>
<version>3.0.8</version>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand All @@ -72,14 +72,20 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpFtp-Simpleimpl</artifactId>
<version>3.0.8</version>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>ftp4j</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -107,7 +113,8 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation
>true</showDeprecation>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/waarp/ftp/client/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/** Provides the version information of Waarp OpenR66. */
public final class Version {
/** The version identifier. */
public static final String ID = "3.0.7";
public static final String ID = "3.1.0";
/** Prints out the version identifier to stdout. */
public static void main(String[] args) { System.out.println(ID); }
private Version() { super(); }
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/waarp/ftp/client/WaarpFtp4jClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,35 @@ public boolean featureEnabled(String feature) {
}
}

/**
* @param remote
*
* @return True if deleted
*/
public boolean deleteFile(String remote) {
try {
logger.debug("DELE {}", remote);
ftpClient.deleteFile(remote);
return true;
} catch (IOException e) {
result = "Cannot execute operation Site";
logger.error(result, e);
return false;
} catch (IllegalStateException e) {
result = "Cannot execute operation Site";
logger.error(result, e);
return false;
} catch (FTPIllegalReplyException e) {
result = "Cannot execute operation Site";
logger.error(result, e);
return false;
} catch (FTPException e) {
result = "Cannot execute operation Site";
logger.error(result, e);
return false;
}
}

/**
*
* @param params
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/waarp/ftp/client/WaarpFtpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,6 @@ public boolean transferFile(String local, String remote, int getStoreOrAppend) {
logger.error(result);
return false;
}
if (!this.ftpClient.completePendingCommand()) {
result = "Cannot finalize store like operation";
logger.error(result);
return false;
}
return true;
} else {
output = new FileOutputStream(new File(local, remote));
Expand All @@ -328,11 +323,6 @@ public boolean transferFile(String local, String remote, int getStoreOrAppend) {
logger.error(result);
return false;
}
if (!this.ftpClient.completePendingCommand()) {
result = "Cannot finalize retrieve like operation";
logger.error(result);
return false;
}
return true;
}
} catch (IOException e) {
Expand Down
Empty file added src/test/java/.gitkeep
Empty file.
79 changes: 79 additions & 0 deletions src/test/java/org/waarp/ftp/FtpServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************************
* This file is part of Waarp Project (named also Waarp or GG).
*
* Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
* tags. See the COPYRIGHT.txt in the distribution for a full listing of
* individual contributors.
*
* All Waarp Project is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Waarp . If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

package org.waarp.ftp;

import org.waarp.common.file.FileUtils;
import org.waarp.common.file.filesystembased.FilesystemBasedFileParameterImpl;
import org.waarp.common.logging.WaarpLogger;
import org.waarp.common.logging.WaarpLoggerFactory;
import org.waarp.common.logging.WaarpSlf4JLoggerFactory;
import org.waarp.ftp.core.exception.FtpNoConnectionException;
import org.waarp.ftp.simpleimpl.SimpleGatewayFtpServer;
import org.waarp.ftp.simpleimpl.config.FileBasedConfiguration;
import org.waarp.ftp.simpleimpl.control.SimpleBusinessHandler;
import org.waarp.ftp.simpleimpl.data.FileSystemBasedDataBusinessHandler;

import java.io.File;

public class FtpServer {
/**
* Internal Logger
*/
protected static WaarpLogger logger;
protected static File dir;
protected static FileBasedConfiguration configuration;

public static void startFtpServer(String config) {
WaarpLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(null));
if (logger == null) {
logger = WaarpLoggerFactory.getLogger(FtpServer.class);
}
ClassLoader classLoader = FtpServer.class.getClassLoader();
File file = new File(classLoader.getResource(config).getFile());
if (file.exists()) {
dir = file.getParentFile();
File base = new File("/tmp/GGFTP");
base.mkdir();
FileUtils.forceDeleteRecursiveDir(base);
configuration = new FileBasedConfiguration(
SimpleGatewayFtpServer.class, SimpleBusinessHandler.class,
FileSystemBasedDataBusinessHandler.class,
new FilesystemBasedFileParameterImpl());
if (!configuration.setConfigurationFromXml(file.getAbsolutePath())) {
logger.error("Bad configuration");
return;
}
configuration.setTIMEOUTCON(1000);
// Start server.
try {
configuration.serverStartup();
} catch (FtpNoConnectionException e) {
logger.error("FTP not started", e);
}
logger.info("FTP started");
}
}

public static void stopFtpServer() {
configuration.setShutdown(true);
configuration.getFtpInternalConfiguration().releaseResources();
}
}
Loading