Skip to content

Commit

Permalink
Merge pull request #99 from Maninda/0.4.x
Browse files Browse the repository at this point in the history
Correct Java Exception return and prepare for a release
  • Loading branch information
Maninda authored Jun 10, 2020
2 parents 4a6922f + d69861b commit f7af05f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following sections provide you details on how to use the FTP connector.

| | Version |
|:---------------------------:|:---------------------------:|
| Ballerina Language | 1.1.2 |
| Ballerina Language | 1.1.4 |

## Feature Overview

Expand Down
4 changes: 2 additions & 2 deletions ftp-compiler-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>module-ftp</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ftp-compiler-plugin</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>
<packaging>jar</packaging>
<name>FTP Module - Compiler Validation Utility</name>
<url>https://ballerina.io/</url>
Expand Down
4 changes: 2 additions & 2 deletions ftp-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>module-ftp</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<version>0.4.3</version>
<version>0.4.4</version>
<artifactId>ftp-utils</artifactId>
<packaging>jar</packaging>
<name>FTP Module - Java utility library</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.wso2.ei.b7a.ftp.core.client;

import org.ballerinalang.jvm.BRuntime;
import org.ballerinalang.jvm.values.ArrayValue;
import org.ballerinalang.jvm.values.MapValue;
import org.ballerinalang.jvm.values.ObjectValue;
import org.ballerinalang.stdlib.io.channels.base.Channel;
Expand All @@ -29,6 +28,7 @@
import org.wso2.ei.b7a.ftp.core.util.BallerinaFTPException;
import org.wso2.ei.b7a.ftp.core.util.FTPConstants;
import org.wso2.ei.b7a.ftp.core.util.FTPUtil;
import org.wso2.transport.remotefilesystem.Constants;
import org.wso2.transport.remotefilesystem.RemoteFileSystemConnectorFactory;
import org.wso2.transport.remotefilesystem.client.connector.contract.FtpAction;
import org.wso2.transport.remotefilesystem.client.connector.contract.VFSClientConnector;
Expand All @@ -54,7 +54,7 @@ private FTPClient() {
// private constructor
}

public static void initClientEndpoint(ObjectValue clientEndpoint, MapValue<Object, Object> config)
public static Object initClientEndpoint(ObjectValue clientEndpoint, MapValue<Object, Object> config)
throws BallerinaFTPException {

String protocol = config.getStringValue(FTPConstants.ENDPOINT_CONFIG_PROTOCOL);
Expand All @@ -72,14 +72,29 @@ public static void initClientEndpoint(ObjectValue clientEndpoint, MapValue<Objec
clientEndpoint.addNativeData(FTPConstants.ENDPOINT_CONFIG_PORT,
FTPUtil.extractPortValue(config.getIntValue(FTPConstants.ENDPOINT_CONFIG_PORT)));
clientEndpoint.addNativeData(FTPConstants.ENDPOINT_CONFIG_PROTOCOL, protocol);
Map<String, String> ftpConfig = new HashMap<>(3);
Map<String, String> ftpConfig = new HashMap<>(5);
MapValue secureSocket = config.getMapValue(FTPConstants.ENDPOINT_CONFIG_SECURE_SOCKET);
if (secureSocket != null) {
final MapValue privateKey = secureSocket.getMapValue(FTPConstants.ENDPOINT_CONFIG_PRIVATE_KEY);
if (privateKey != null) {
final String privateKeyPath = privateKey.getStringValue(FTPConstants.ENDPOINT_CONFIG_PATH);
if (privateKeyPath != null && !privateKeyPath.isEmpty()) {
ftpConfig.put(Constants.IDENTITY, privateKeyPath);
final String privateKeyPassword = privateKey.getStringValue(FTPConstants.ENDPOINT_CONFIG_PASS_KEY);
if (privateKeyPassword != null && !privateKeyPassword.isEmpty()) {
ftpConfig.put(Constants.IDENTITY_PASS_PHRASE, privateKeyPassword);
}
}
}
}
ftpConfig.put(FTPConstants.FTP_PASSIVE_MODE, String.valueOf(true));
ftpConfig.put(FTPConstants.USER_DIR_IS_ROOT, String.valueOf(false));
ftpConfig.put(FTPConstants.AVOID_PERMISSION_CHECK, String.valueOf(true));
clientEndpoint.addNativeData(FTPConstants.PROPERTY_MAP, ftpConfig);
return null;
}

public static ObjectValue get(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
public static Object get(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -100,7 +115,7 @@ public static ObjectValue get(ObjectValue clientConnector, String filePath) thro
return null;
}

public static void append(ObjectValue clientConnector, MapValue<Object, Object> inputContent)
public static Object append(ObjectValue clientConnector, MapValue<Object, Object> inputContent)
throws BallerinaFTPException {

try {
Expand Down Expand Up @@ -134,9 +149,10 @@ public static void append(ObjectValue clientConnector, MapValue<Object, Object>
} catch (RemoteFileSystemConnectorException | IOException e) {
throw new BallerinaFTPException(e.getMessage());
}
return null;
}

public static void put(ObjectValue clientConnector, MapValue<Object, Object> inputContent)
public static Object put(ObjectValue clientConnector, MapValue<Object, Object> inputContent)
throws BallerinaFTPException {

Map<String, String> propertyMap = new HashMap<>(
Expand Down Expand Up @@ -191,9 +207,10 @@ public static void put(ObjectValue clientConnector, MapValue<Object, Object> inp
log.error("Error in closing stream");
}
}
return null;
}

public static void delete(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
public static Object delete(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -212,9 +229,10 @@ public static void delete(ObjectValue clientConnector, String filePath) throws B
}
connector.send(null, FtpAction.DELETE);
future.complete(null);
return null;
}

public static boolean isDirectory(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
public static Object isDirectory(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -235,8 +253,7 @@ public static boolean isDirectory(ObjectValue clientConnector, String filePath)
return false;
}

public static ArrayValue list(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

public static Object list(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
(Map<String, String>) clientConnector.getNativeData(FTPConstants.PROPERTY_MAP));
Expand All @@ -256,7 +273,7 @@ public static ArrayValue list(ObjectValue clientConnector, String filePath) thro
return null;
}

public static void mkdir(ObjectValue clientConnector, String path) throws BallerinaFTPException {
public static Object mkdir(ObjectValue clientConnector, String path) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, path);
Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -275,9 +292,10 @@ public static void mkdir(ObjectValue clientConnector, String path) throws Baller
}
connector.send(null, FtpAction.MKDIR);
future.complete(null);
return null;
}

public static void rename(ObjectValue clientConnector, String origin, String destination)
public static Object rename(ObjectValue clientConnector, String origin, String destination)
throws BallerinaFTPException {

Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -297,9 +315,10 @@ public static void rename(ObjectValue clientConnector, String origin, String des
}
connector.send(null, FtpAction.RENAME);
future.complete(null);
return null;
}

public static void rmdir(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
public static Object rmdir(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
Expand All @@ -318,9 +337,10 @@ public static void rmdir(ObjectValue clientConnector, String filePath) throws Ba
}
connector.send(null, FtpAction.RMDIR);
future.complete(null);
return null;
}

public static int size(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {
public static Object size(ObjectValue clientConnector, String filePath) throws BallerinaFTPException {

String url = FTPUtil.createUrl(clientConnector, filePath);
Map<String, String> propertyMap = new HashMap<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private FTPConstants() {
public static final String PROPERTY_MAP = "map";
public static final String FTP_ORG_NAME = "wso2";
public static final String FTP_MODULE_NAME = "ftp";
public static final String FTP_MODULE_VERSION = "0.4.3";
public static final String FTP_MODULE_VERSION = "0.4.4";
public static final String FTP_LISTENER = "Listener";
public static final String FTP_SERVER_EVENT = "WatchEvent";
public static final String FTP_FILE_INFO = "FileInfo";
Expand Down
6 changes: 3 additions & 3 deletions ftp/Ballerina.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org_name = "wso2"
version = "0.4.3"
version = "0.4.4"
lockfile_version = "1.0.0"
ballerina_version = "1.1.2"
ballerina_version = "1.1.4"

[[imports."wso2/ftp:0.4.3"]]
[[imports."wso2/ftp:0.4.4"]]
org_name = "ballerinax"
name = "java"
version = "0.0.0"
6 changes: 3 additions & 3 deletions ftp/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
org-name= "wso2"
version= "0.4.3"
version= "0.4.4"
license= ["Apache-2.0"]
authors= ["WSO2"]
keywords= ["ftp"]
Expand All @@ -13,7 +13,7 @@ target = "java8"

[[platform.libraries]]
module = "utils/ftp-utils"
path = "../ftp-utils/target/ftp-utils-module-0.4.3.jar"
path = "../ftp-utils/target/ftp-utils-module-0.4.4.jar"
artifactId = "wso2-ftp"
version = "0.4.3"
version = "0.4.4"
groupId = "org.wso2.ei"
4 changes: 2 additions & 2 deletions ftp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<parent>
<artifactId>module-ftp</artifactId>
<groupId>org.wso2.ei</groupId>
<version>0.4.3</version>
<version>0.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>ftp</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>
<packaging>pom</packaging>
<name>FTP Module - Ballerina Implementation</name>
<url>https://ballerina.io/</url>
Expand Down
2 changes: 1 addition & 1 deletion ftp/src/ftp/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For instance, if the listener gets invoked for text files, the value `(.*).txt`

| | Version |
|:---------------------------:|:---------------------------:|
| Ballerina Language | 1.1.2 |
| Ballerina Language | 1.1.4 |

## Samples

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<groupId>org.wso2.ei</groupId>
<artifactId>module-ftp</artifactId>
<packaging>pom</packaging>
<version>0.4.3</version>
<version>0.4.4</version>
<name>Ballerina - FTP Module Parent</name>

<url>https://ballerina.io/</url>
Expand Down Expand Up @@ -191,7 +191,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<ballerina.version>1.1.0</ballerina.version>
<module.ftp.version>0.4.3</module.ftp.version>
<module.ftp.version>0.4.4</module.ftp.version>

<file.transport.version>6.0.57</file.transport.version>
<jsch.version>0.1.54</jsch.version>
Expand Down

0 comments on commit f7af05f

Please sign in to comment.