[ARVADOS] updated: d70ff3d064c9a6da8b8678b249abf7f4b93b6370

git at public.curoverse.com git at public.curoverse.com
Tue May 6 23:00:25 EDT 2014


Summary of changes:
 sdk/java/ArvadosSDKJavaExample.java           |    1 -
 sdk/java/ArvadosSDKJavaExampleWithPrompt.java |   86 +++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 1 deletions(-)
 create mode 100644 sdk/java/ArvadosSDKJavaExampleWithPrompt.java

       via  d70ff3d064c9a6da8b8678b249abf7f4b93b6370 (commit)
      from  52a3016af3ff21b8fb5402bf70d0aab07f5ee486 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d70ff3d064c9a6da8b8678b249abf7f4b93b6370
Author: radhika <radhika at curoverse.com>
Date:   Tue May 6 22:59:11 2014 -0400

    2525: Add ArvadosSDKJavaExampleWithPrompt.java to serve as an easier tool to make quick calls to API server.

diff --git a/sdk/java/ArvadosSDKJavaExample.java b/sdk/java/ArvadosSDKJavaExample.java
index 3c47f66..050eaa6 100644
--- a/sdk/java/ArvadosSDKJavaExample.java
+++ b/sdk/java/ArvadosSDKJavaExample.java
@@ -1,6 +1,5 @@
 /**
  * This Sample test program is useful in getting started with working with Arvados Java SDK.
- * Please also see arvadso 
  * @author radhika
  *
  */
diff --git a/sdk/java/ArvadosSDKJavaExampleWithPrompt.java b/sdk/java/ArvadosSDKJavaExampleWithPrompt.java
new file mode 100644
index 0000000..f332869
--- /dev/null
+++ b/sdk/java/ArvadosSDKJavaExampleWithPrompt.java
@@ -0,0 +1,86 @@
+/**
+ * This Sample test program is useful in getting started with using Arvados Java SDK.
+ * This program creates an Arvados instance using the configured environment variables.
+ * It then provides a prompt to input method name and input parameters. 
+ * The program them invokes the API server to execute the specified method.  
+ * 
+ * @author radhika
+ */
+
+import org.arvados.sdk.java.Arvados;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class ArvadosSDKJavaExampleWithPrompt {
+  /**
+   * Make sure the following environment variables are set before using Arvados:
+   * ARVADOS_API_TOKEN, ARVADOS_API_HOST and ARVADOS_API_HOST_INSECURE Set
+   * ARVADOS_API_HOST_INSECURE to true if you are using self-singed certificates
+   * in development and want to bypass certificate validations.
+   * 
+   * Please refer to http://doc.arvados.org/api/index.html for a complete list
+   * of the available API methods.
+   */
+  public static void main(String[] args) throws Exception {
+    String apiName = "arvados";
+    String apiVersion = "v1";
+
+    System.out.print("Welcome to Arvados Java SDK");
+    System.out.println("You can use this example to call API methods");
+    System.out.println("Enter ^C when you want to quit");
+
+    // use configured env variables for API TOKEN, HOST and HOST_INSECURE
+    Arvados arv = new Arvados(apiName, apiVersion);
+
+    while (true) {
+      // prompt for resource
+      System.out.println("\n\nEnter Resource name (for example users): ");
+
+      // read resource name
+      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+      String resourceName = in.readLine().trim();
+
+      // read method name
+      System.out.println("\nEnter method name (for example get): ");
+      String methodName = in.readLine().trim();
+
+      // read method parameters
+      System.out
+          .println("\nEnter parameter name, value (for example uuid, uuid-value): ");
+      Map paramsMap = new HashMap();
+      String param = "";
+      try {
+        do {
+          param = in.readLine();
+          if (param.isEmpty())
+            break;
+
+          String[] params = param.split(",");
+          paramsMap.put(params[0].trim(), params[1].trim());
+
+          System.out.println("\nEnter parameter name, value (for example uuid, uuid-value): ");
+        } while (!param.isEmpty());
+      } catch (Exception e) {
+        System.out.println (e.getMessage());
+        System.out.println ("\nStart over");
+        continue;
+      }
+
+      // Make a "call" for the given resource name and method name
+      try {
+        System.out.println ("Making a call for " + resourceName + " " + methodName);
+        Map response = arv.call(resourceName, methodName, paramsMap);
+        System.out.println(response);
+      } catch (Exception e){
+        System.out.println (e.getMessage());
+        System.out.println ("\nStart over");
+      }
+    }
+  }
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list