Initial examples module
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 0000000..28cc03a
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ 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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>airavata-mft</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mft-examples</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <artifactId>mft-api-client</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/examples/src/main/java/org/apache/airavata/mft/examples/BoxExample.java b/examples/src/main/java/org/apache/airavata/mft/examples/BoxExample.java
new file mode 100644
index 0000000..d8b6dd6
--- /dev/null
+++ b/examples/src/main/java/org/apache/airavata/mft/examples/BoxExample.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.airavata.mft.examples;
+
+public class BoxExample {
+}
diff --git a/examples/src/main/java/org/apache/airavata/mft/examples/DriveExample.java b/examples/src/main/java/org/apache/airavata/mft/examples/DriveExample.java
new file mode 100644
index 0000000..2a23736
--- /dev/null
+++ b/examples/src/main/java/org/apache/airavata/mft/examples/DriveExample.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.airavata.mft.examples;
+
+public class DriveExample {
+}
diff --git a/examples/src/main/java/org/apache/airavata/mft/examples/LocalExample.java b/examples/src/main/java/org/apache/airavata/mft/examples/LocalExample.java
new file mode 100644
index 0000000..af77098
--- /dev/null
+++ b/examples/src/main/java/org/apache/airavata/mft/examples/LocalExample.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.airavata.mft.examples;
+
+import org.apache.airavata.mft.api.client.MFTApiClient;
+import org.apache.airavata.mft.api.service.*;
+
+import java.util.Iterator;
+
+public class LocalExample {
+ public static void main(String args[]) throws Exception {
+ MFTApiServiceGrpc.MFTApiServiceBlockingStub client = MFTApiClient.buildClient("localhost", 7004);
+
+ String sourceId = "remote-ssh-resource2";
+ String sourceToken = "local-ssh-cred";
+ String destId = "10mb-file";
+ String destToken = "";
+ String mftAuthorizationToken = "43ff79ac-e4f2-473c-9ea1-04eee9509a53";
+
+ TransferApiRequest request = TransferApiRequest.newBuilder()
+ .setMftAuthorizationToken(mftAuthorizationToken)
+ .setSourceId(sourceId)
+ .setSourceToken(sourceToken)
+ .setSourceType("SCP")
+ .setDestinationId(destId)
+ .setDestinationToken(destToken)
+ .setDestinationType("LOCAL")
+ .setAffinityTransfer(false).build();
+
+ TransferApiResponse transferApiResponse = client.submitTransfer(request);
+ while(true) {
+
+ try {
+ Iterator<TransferStateApiResponse> transferStates = client.getTransferStates(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("Got " + transferStates.next().getState());
+ TransferStateApiResponse transferState = client.getTransferState(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("State " + transferState.getState());
+ if ("COMPLETED".equals(transferState.getState()) || "FAILED".equals(transferState.getState())) {
+ break;
+ }
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ Thread.sleep(1000);
+ }
+ }
+}
diff --git a/examples/src/main/java/org/apache/airavata/mft/examples/S3Example.java b/examples/src/main/java/org/apache/airavata/mft/examples/S3Example.java
new file mode 100644
index 0000000..60aae80
--- /dev/null
+++ b/examples/src/main/java/org/apache/airavata/mft/examples/S3Example.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.airavata.mft.examples;
+
+import org.apache.airavata.mft.api.client.MFTApiClient;
+import org.apache.airavata.mft.api.service.*;
+
+import java.util.Iterator;
+
+public class S3Example {
+ public static void main(String args[]) throws Exception {
+ MFTApiServiceGrpc.MFTApiServiceBlockingStub client = MFTApiClient.buildClient("localhost", 7004);
+
+ String sourceId = "remote-ssh-resource2";
+ String sourceToken = "local-ssh-cred";
+ String destId = "s3-file";
+ String destToken = "s3-cred";
+ String mftAuthorizationToken = "43ff79ac-e4f2-473c-9ea1-04eee9509a53";
+
+ TransferApiRequest request = TransferApiRequest.newBuilder()
+ .setMftAuthorizationToken(mftAuthorizationToken)
+ .setSourceId(sourceId)
+ .setSourceToken(sourceToken)
+ .setSourceType("SCP")
+ .setDestinationId(destId)
+ .setDestinationToken(destToken)
+ .setDestinationType("S3")
+ .setAffinityTransfer(false).build();
+
+ TransferApiResponse transferApiResponse = client.submitTransfer(request);
+ while(true) {
+
+ try {
+ Iterator<TransferStateApiResponse> transferStates = client.getTransferStates(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("Got " + transferStates.next().getState());
+ TransferStateApiResponse transferState = client.getTransferState(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("State " + transferState.getState());
+ if ("COMPLETED".equals(transferState.getState()) || "FAILED".equals(transferState.getState())) {
+ break;
+ }
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ Thread.sleep(1000);
+ }
+ }
+}
diff --git a/examples/src/main/java/org/apache/airavata/mft/examples/SCPExample.java b/examples/src/main/java/org/apache/airavata/mft/examples/SCPExample.java
new file mode 100644
index 0000000..df9fca8
--- /dev/null
+++ b/examples/src/main/java/org/apache/airavata/mft/examples/SCPExample.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package org.apache.airavata.mft.examples;
+
+import org.apache.airavata.mft.api.client.MFTApiClient;
+import org.apache.airavata.mft.api.service.*;
+
+import java.util.Iterator;
+
+public class SCPExample {
+ public static void main(String args[]) throws Exception {
+ MFTApiServiceGrpc.MFTApiServiceBlockingStub client = MFTApiClient.buildClient("localhost", 7004);
+
+ String sourceId = "remote-ssh-resource2";
+ String sourceToken = "local-ssh-cred";
+ String destId = "remote-ssh-resource";
+ String destToken = "local-ssh-cred";
+ String mftAuthorizationToken = "43ff79ac-e4f2-473c-9ea1-04eee9509a53";
+
+ TransferApiRequest request = TransferApiRequest.newBuilder()
+ .setMftAuthorizationToken(mftAuthorizationToken)
+ .setSourceId(sourceId)
+ .setSourceToken(sourceToken)
+ .setSourceType("SCP")
+ .setDestinationId(destId)
+ .setDestinationToken(destToken)
+ .setDestinationType("SCP")
+ .setAffinityTransfer(false).build();
+
+ TransferApiResponse transferApiResponse = client.submitTransfer(request);
+ while(true) {
+
+ try {
+ Iterator<TransferStateApiResponse> transferStates = client.getTransferStates(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("Got " + transferStates.next().getState());
+ TransferStateApiResponse transferState = client.getTransferState(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
+ System.out.println("State " + transferState.getState());
+ if ("COMPLETED".equals(transferState.getState()) || "FAILED".equals(transferState.getState())) {
+ break;
+ }
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ Thread.sleep(1000);
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index d577bba..3182589 100755
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,7 @@
<module>admin</module>
<module>controller</module>
<module>api</module>
+ <module>examples</module>
</modules>
<url>http://airavata.apache.org/</url>