Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new installation scripts #31

Merged
merged 6 commits into from
Jul 19, 2018
Merged
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endpoint ftp:Client client {
port:21
};

function main (string[] args) {
function main (string... args) {
// To create a folder in remote server
errorr? dirCreErr = client -> mkdir("/ballerina-user/sample-dir");
match dirCreErr {
Expand All @@ -58,7 +58,7 @@ function main (string[] args) {
}

// Upload file to a remote server
io:ByteChannel summaryChannel = io:openFile("/home/ballerina/prog/summary.bal", io:MODE_R);
io:ByteChannel summaryChannel = io:openFile("/home/ballerina/prog/summary.bal", io:READ);
error? filePutErr = client -> put("/ballerina-user/sample-dir/summary.bal", summaryChannel);
match filePutErr {
error err => {
Expand Down Expand Up @@ -89,7 +89,7 @@ function main (string[] args) {
var getResult = client -> get("/ballerina-user/sample-dir/stock.json");
match getResult {
io:ByteChannel channel => {
io:CharacterChannel characters = check io:createCharacterChannel(channel, "UTF-8");
io:CharacterChannel characters = check io:CharacterChannel(channel, "utf-8");
json stock = check characters.readJson();
_ = channel.close();
}
Expand All @@ -112,11 +112,13 @@ function main (string[] args) {
## How to install FTP Connectors
1. Download correct distribution.zip from [releases](https://github.com/wso2-ballerina/package-file/releases) that match with ballerina
version.
2. Unzip connector distribution and copy to all jars to <BALLERINA_HOME>/bre/lib folder.
2. Unzip package distribution.
3. Run the install.<sh|bat> script to install the package. You can uninstall the package by running uninstall.<sh|bat>.

| Ballerina Version | File Connector Version |
| ----------------- | ---------------------- |
| 0.95.0 | 0.95.0 |
| 0.963.0| 0.96.0 |
| 0.970.0| 0.97.0 |
| 0.975.0| 0.97.1 |
| 0.980.0| 0.97.3 |
138 changes: 82 additions & 56 deletions component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
~ under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.ballerinalang</groupId>
<artifactId>file-connector-parent</artifactId>
<version>0.97.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>ballerina-file</artifactId>
<artifactId>wso2-ftp</artifactId>
<packaging>jar</packaging>
<name>Ballerina - File System Implementation</name>
<url>http://ballerinalang.org</url>
Expand All @@ -35,6 +36,10 @@
<groupId>org.wso2.transport.file</groupId>
<artifactId>org.wso2.transport.remote-file-system</artifactId>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-builtin</artifactId>
Expand Down Expand Up @@ -71,10 +76,44 @@
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-builtin</artifactId>
<artifactId>ballerina-io</artifactId>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-io</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-runtime</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-task</artifactId>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-task</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-log-api</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-log-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
Expand All @@ -85,14 +124,8 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>ballerina/**</exclude>
</excludes>
<filtering>true</filtering>
</resource>
<!--<resource>-->
<!--<directory>${generated.ballerina.source.directory}</directory>-->
<!--<targetPath>META-INF/wso2</targetPath>-->
<!--</resource>-->
</resources>
<plugins>
<plugin>
Expand Down Expand Up @@ -148,51 +181,6 @@
<version>${maven.dependency.plugin.version}</version>
<inherited>false</inherited>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
<artifactItem>
<groupId>org.wso2.transport.file</groupId>
<artifactId>org.wso2.transport.remote-file-system</artifactId>
<version>${file.transport.version}</version>
<type>${project.packaging}</type>
</artifactItem>
<dependency>
<groupId>org.wso2.org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>${commons-vfs2.wso2.version}</version>
</dependency>
<artifactItem>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>${jsch.version}</version>
<type>${project.packaging}</type>
</artifactItem>
<artifactItem>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>${commons-net.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/distribution</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<useBaseVersion>true</useBaseVersion>
</configuration>
</execution>
<execution>
<id>unpack-dependencies</id>
<phase>generate-resources</phase>
Expand Down Expand Up @@ -269,6 +257,7 @@
</suiteXmlFiles>
<systemPropertyVariables>
<ballerina.home>${project.build.directory}</ballerina.home>
<java.util.logging.manager>org.ballerinalang.logging.BLogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down Expand Up @@ -359,6 +348,43 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>wso2-ftp-package-${project.version}</finalName>
<artifactSet>
<includes>
<include>org.ballerinalang:wso2-ftp</include>
<include>org.wso2.transport.file:org.wso2.transport.remote-file-system</include>
<include>com.jcraft:jsch</include>
<include>commons-net:commons-net</include>
<include>org.wso2.org.apache.commons:commons-vfs2</include>
</includes>

</artifactSet>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resources>
<resource>installation-scripts/install.bat</resource>
<resource>installation-scripts/install.sh</resource>
<resource>installation-scripts/uninstall.bat</resource>
<resource>installation-scripts/uninstall.sh</resource>
<resource>installation-scripts/README.txt</resource>
</resources>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
19 changes: 16 additions & 3 deletions component/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}-package-${project.version}.jar</source>
<outputDirectory>./dependencies</outputDirectory>
<fileMode>0644</fileMode>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}/distribution</directory>
<outputDirectory>distribution</outputDirectory>
<directory>${project.build.directory}/generated-balo/repo</directory>
<outputDirectory>./balo</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/classes/installation-scripts</directory>
<outputDirectory>.</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
</assembly>
</assembly>
4 changes: 1 addition & 3 deletions component/src/main/ballerina/ftp/client_action.bal
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ documentation {
F{{config}} The configurations of the client endpoint associated with this ClientActions instance.
}
public type ClientActions object {
public {
ClientEndpointConfiguration config;
}
public ClientEndpointConfiguration config;

documentation {
The `get()` function can be used to retrieve file content from a remote resource.
Expand Down
4 changes: 1 addition & 3 deletions component/src/main/ballerina/ftp/client_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ documentation {
Represents an FTP client that intracts with an FTP server.
}
public type Client object {
public {
ClientEndpointConfiguration config;
}
public ClientEndpointConfiguration config;

public function init(ClientEndpointConfiguration clientConfig) {
self.config = clientConfig;
Expand Down
8 changes: 3 additions & 5 deletions component/src/main/ballerina/ftp/listener_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ documentation {
Represents a service listener that monitors the FTP location.
}
public type Listener object {
private {
ListenerEndpointConfig config;
task:Appointment? appointment;
task:Timer? task;
}
ListenerEndpointConfig config;
task:Appointment? appointment;
task:Timer? task;

public function init(ListenerEndpointConfig listenerConfig) {
self.config = listenerConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.ballerinalang.bre.Context;
import org.ballerinalang.bre.bvm.BLangVMStructs;
import org.ballerinalang.bre.bvm.BlockingNativeCallableUnit;
import org.ballerinalang.model.values.BStruct;
import org.ballerinalang.model.values.BMap;
import org.ballerinalang.model.values.BString;
import org.ballerinalang.model.values.BValue;
import org.ballerinalang.util.codegen.PackageInfo;
import org.ballerinalang.util.codegen.StructureTypeInfo;
Expand All @@ -34,7 +35,7 @@
*/
abstract class AbstractFtpAction extends BlockingNativeCallableUnit {

static BStruct getClientErrorStruct(Context context) {
static BMap<String, BValue> getClientErrorStruct(Context context) {
PackageInfo packageInfo = context.getProgramFile().getPackageInfo(BALLERINA_BUILTIN);
final StructureTypeInfo structInfo = packageInfo.getStructInfo("error");
return BLangVMStructs.createBStruct(structInfo);
Expand Down Expand Up @@ -65,8 +66,8 @@ public boolean onMessage(RemoteFileSystemBaseMessage remoteFileSystemBaseMessage

@Override
public void onError(Throwable throwable) {
BStruct error = getClientErrorStruct(context);
error.setStringField(0, throwable.getMessage());
BMap<String, BValue> error = getClientErrorStruct(context);
error.put("message", new BString(throwable.getMessage()));
context.setReturnValues(error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import org.ballerinalang.bre.Context;
import org.ballerinalang.ftp.util.FtpConstants;
import org.ballerinalang.model.types.TypeKind;
import org.ballerinalang.model.values.BStruct;
import org.ballerinalang.nativeimpl.io.IOConstants;
import org.ballerinalang.nativeimpl.io.channels.base.Channel;
import org.ballerinalang.model.values.BMap;
import org.ballerinalang.model.values.BString;
import org.ballerinalang.model.values.BValue;
import org.ballerinalang.natives.annotations.Argument;
import org.ballerinalang.natives.annotations.BallerinaFunction;
import org.ballerinalang.natives.annotations.Receiver;
import org.ballerinalang.natives.annotations.ReturnType;
import org.ballerinalang.stdlib.io.channels.base.Channel;
import org.ballerinalang.stdlib.io.utils.IOConstants;
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 Down Expand Up @@ -60,9 +62,9 @@ public class Append extends AbstractFtpAction {

@Override
public void execute(Context context) {
BStruct clientConnector = (BStruct) context.getRefArgument(0);
BMap<String, BValue> clientConnector = (BMap<String, BValue>) context.getRefArgument(0);
String url = (String) clientConnector.getNativeData(FtpConstants.URL);
BStruct sourceChannel = (BStruct) context.getRefArgument(1);
BMap<String, BValue> sourceChannel = (BMap<String, BValue>) context.getRefArgument(1);
String path = context.getStringArgument(0);

Channel byteChannel = (Channel) sourceChannel.getNativeData(IOConstants.BYTE_CHANNEL_NAME);
Expand All @@ -79,8 +81,8 @@ public void execute(Context context) {
try {
connector = fileSystemConnectorFactory.createVFSClientConnector(propertyMap, connectorListener);
} catch (RemoteFileSystemConnectorException e) {
BStruct error = getClientErrorStruct(context);
error.setStringField(0, e.getMessage());
BMap<String, BValue> error = getClientErrorStruct(context);
error.put("message", new BString(e.getMessage()));
context.setReturnValues(error);
return;
}
Expand Down
Loading