[ARVADOS] updated: d17ef1d036b4262f6c6c40324cc56d04d26581d3

git at public.curoverse.com git at public.curoverse.com
Sat May 3 09:34:55 EDT 2014


Summary of changes:
 doc/api/methods.html.textile.liquid                |   10 ++-
 sdk/cli/bin/arv-run-pipeline-instance              |    4 +-
 sdk/java/ArvadosSDKJavaUser.java                   |   10 +--
 .../main/java/org/arvados/sdk/java/Arvados.java    |   49 ++++++++----
 .../java/org/arvados/sdk/java/ArvadosTest.java     |   28 +++++++
 .../api/app/controllers/application_controller.rb  |   24 +++++-
 .../app/controllers/arvados/v1/jobs_controller.rb  |    2 +-
 .../arvados/v1/repositories_controller.rb          |    6 ++
 .../controllers/arvados/v1/schema_controller.rb    |   10 +++
 services/api/app/models/arvados_model.rb           |    3 +
 services/api/app/models/blob.rb                    |   19 ++++-
 services/api/app/models/log.rb                     |    4 +
 services/api/config/initializers/authorization.rb  |    4 +-
 .../20140423132913_add_object_owner_to_logs.rb     |   18 +++--
 services/api/lib/load_param.rb                     |   44 ++++++++++-
 services/api/test/fixtures/authorized_keys.yml     |   15 ++++
 services/api/test/fixtures/links.yml               |   14 ++++
 .../arvados/v1/repositories_controller_test.rb     |   42 ++++++++++
 services/api/test/integration/select_test.rb       |   82 ++++++++++++++++++++
 services/api/test/test_helper.rb                   |    2 +-
 services/api/test/unit/blob_test.rb                |   27 +++++++
 21 files changed, 367 insertions(+), 50 deletions(-)
 create mode 100644 services/api/test/fixtures/authorized_keys.yml
 create mode 100644 services/api/test/integration/select_test.rb

       via  d17ef1d036b4262f6c6c40324cc56d04d26581d3 (commit)
       via  c436da861845723ab18f56dba96052cf2569e539 (commit)
       via  6c8ba53502c29dc9174291c04f3c7bc84777f9cc (commit)
       via  307cf5007269a069b8c80dc14da134ec145cd292 (commit)
       via  1d5a33d2af1e39041177681c8d66007b40b20df4 (commit)
       via  dca6cfe9750d8d1be4f3b63895b8cb73cc6c4cfe (commit)
       via  0ed6856e2dd4c057e34ba5b2079cef0158ebc53f (commit)
       via  de54cdcea8dca015e3b08bb23f7221faa4814ef0 (commit)
       via  0df7a1c38affbc50a9c7d8834f9822e398860d91 (commit)
       via  b4a9aaa3d68129d6e948dde46cee63cd66597aba (commit)
       via  7ce745d5645dc49c2833c1c617fd488bf3a62307 (commit)
       via  fb72864bb6f2ee3ca702b914c97d06a76e01ab0d (commit)
       via  cd08497d1c914cd75fd8be08f9f3ef3bc75485f2 (commit)
       via  681496f40864418fc1ee46277941a40d3445107c (commit)
       via  c6068bbeea3ea9bfee45204c2990caef0d4ec1ae (commit)
       via  33b49fa0be7d8e0774c80ec315985dcdf8535962 (commit)
       via  83781a4f423a3671a5ec6d4b1cd6a0bbeacef3a6 (commit)
       via  fe78b629dc39298c5990a093e73b7c6231f387b0 (commit)
       via  7a73008bcd015300461c34ce852d660f8244e11f (commit)
      from  a74ae790b5a0682fa00423626103482c145e1b91 (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 d17ef1d036b4262f6c6c40324cc56d04d26581d3
Author: radhika <radhika at curoverse.com>
Date:   Sat May 3 09:33:21 2014 -0400

    2525: token, host name, and host insecure can also be passed to constructor similar to other SDKs. If so, the environment variables are ignored and passed in values are used.

diff --git a/sdk/java/ArvadosSDKJavaUser.java b/sdk/java/ArvadosSDKJavaUser.java
index 289d0c6..79b2c2d 100644
--- a/sdk/java/ArvadosSDKJavaUser.java
+++ b/sdk/java/ArvadosSDKJavaUser.java
@@ -26,21 +26,17 @@ public class ArvadosSDKJavaUser {
     String apiName = "arvados";
     String apiVersion = "v1";
 
-    Arvados arv = new Arvados(apiName);
+    Arvados arv = new Arvados(apiName, apiVersion);
 
     // Make a discover request. 
     System.out.println("Making an arvados discovery api request");
-    List<String> params = new ArrayList<String>();
-    params.add("discover");
-    params.add("arvados");
-    params.add("v1");
-
-    RestDescription restDescription = arv.discover(params);
+    RestDescription restDescription = arv.discover();
     System.out.println("Arvados discovery docuemnt:\n" + restDescription);
     
     // Make a users.list call
     System.out.println("Making an arvados users.list api call");
 
+    List<String> params = new ArrayList<String>();
     params = new ArrayList<String>();
     params.add("call");
     params.add("arvados");
diff --git a/sdk/java/src/main/java/org/arvados/sdk/java/Arvados.java b/sdk/java/src/main/java/org/arvados/sdk/java/Arvados.java
index 260b68d..66feadd 100644
--- a/sdk/java/src/main/java/org/arvados/sdk/java/Arvados.java
+++ b/sdk/java/src/main/java/org/arvados/sdk/java/Arvados.java
@@ -22,7 +22,6 @@ import java.io.File;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -33,16 +32,16 @@ import org.apache.log4j.Logger;
 
 public class Arvados {
   // HttpTransport and JsonFactory are thread-safe. So, use global instances.
-  private static HttpTransport HTTP_TRANSPORT;
-  private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
+  private HttpTransport HTTP_TRANSPORT;
+  private final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
 
   private static final Pattern METHOD_PATTERN = Pattern.compile("((\\w+)\\.)*(\\w+)");
 
-  private static String ARVADOS_API_TOKEN;
-  private static String ARVADOS_API_HOST;
-  private static boolean ARVADOS_API_HOST_INSECURE;
+  private String ARVADOS_API_TOKEN;
+  private String ARVADOS_API_HOST;
+  private boolean ARVADOS_API_HOST_INSECURE;
 
-  private static String ARVADOS_ROOT_URL;
+  private String ARVADOS_ROOT_URL;
 
   private static final Logger logger = Logger.getLogger(Arvados.class);
   
@@ -52,26 +51,41 @@ public class Arvados {
   String apiVersion = null;
   
   public Arvados (String apiName, String apiVersion){
+    this (apiName, apiVersion, null, null, null);
+  }
+  
+  public Arvados (String apiName, String apiVersion, String token, String host, String hostInsecure){
     try {
       this.apiName = apiName;
       this.apiVersion = apiVersion;
       
-      // Read needed environmental variables
-      ARVADOS_API_TOKEN = System.getenv().get("ARVADOS_API_TOKEN");
-      if (ARVADOS_API_TOKEN == null) {
-        throw new Exception("Missing environment variable: ARVADOS_API_TOKEN");
+      // Read needed environmental variables if they are not passed
+      if (token != null) {
+        ARVADOS_API_TOKEN = token;
+      } else {
+        ARVADOS_API_TOKEN = System.getenv().get("ARVADOS_API_TOKEN");
+        if (ARVADOS_API_TOKEN == null) {
+          throw new Exception("Missing environment variable: ARVADOS_API_TOKEN");
+        }
       }
 
-      ARVADOS_API_HOST = System.getenv().get("ARVADOS_API_HOST");      
-      if (ARVADOS_API_HOST == null) {
-        throw new Exception("Missing environment variable: ARVADOS_API_HOST");
+      if (host != null) {
+        ARVADOS_API_HOST = host;
+      } else {
+        ARVADOS_API_HOST = System.getenv().get("ARVADOS_API_HOST");      
+        if (ARVADOS_API_HOST == null) {
+          throw new Exception("Missing environment variable: ARVADOS_API_HOST");
+        }
       }
-
       ARVADOS_ROOT_URL = "https://" + ARVADOS_API_HOST;
       ARVADOS_ROOT_URL += (ARVADOS_API_HOST.endsWith("/")) ? "" : "/";
 
-      ARVADOS_API_HOST_INSECURE = "true".equals(System.getenv().get("ARVADOS_API_HOST_INSECURE")) ? true : false;
-
+      if (hostInsecure != null) {
+        ARVADOS_API_HOST_INSECURE = Boolean.valueOf(hostInsecure);
+      } else {
+        ARVADOS_API_HOST_INSECURE = "true".equals(System.getenv().get("ARVADOS_API_HOST_INSECURE")) ? true : false;
+      }
+      
       // Create HTTP_TRANSPORT object
       NetHttpTransport.Builder builder = new NetHttpTransport.Builder();
       if (ARVADOS_API_HOST_INSECURE) {
@@ -357,5 +371,4 @@ public class Arvados {
     throw new Exception(errorDetail);
   }
 
-
 }
diff --git a/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java b/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
index 77157e5..66345de 100644
--- a/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
+++ b/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
@@ -259,4 +259,32 @@ public class ArvadosTest {
   }
 
 
+  /**
+   * Test users.list api
+   * @throws Exception
+   */
+  @Test
+  public void testArvadosWithTokenPassed() throws Exception {
+    String token = System.getenv().get("ARVADOS_API_TOKEN");
+    String host = System.getenv().get("ARVADOS_API_HOST");      
+    String hostInsecure = System.getenv().get("ARVADOS_API_HOST_INSECURE");
+
+    Arvados arv = new Arvados("arvados", "v1", token, host, hostInsecure);
+
+    List<String> params = new ArrayList<String>();
+    params.add("call");
+    params.add("arvados");
+    params.add("v1");
+    params.add("users.list");
+
+    String response = arv.call(params);
+    assertTrue("Expected users.list in response", response.contains("arvados#userList"));
+    assertTrue("Expected users.list in response", response.contains("uuid"));
+
+    JSONParser parser = new JSONParser();
+    Object obj = parser.parse(response);
+    JSONObject jsonObject = (JSONObject) obj;
+    assertEquals("Expected kind to be users.list", "arvados#userList", jsonObject.get("kind"));
+  }
+
 }
\ No newline at end of file

commit c436da861845723ab18f56dba96052cf2569e539
Merge: a74ae79 6c8ba53
Author: radhika <radhika at curoverse.com>
Date:   Sat May 3 08:46:52 2014 -0400

    Merge branch 'master' into 2525-java-sdk


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


hooks/post-receive
-- 




More information about the arvados-commits mailing list