You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2017/04/05 19:11:06 UTC

[42/50] [abbrv] airavata git commit: Use AuthzToken (empty_token) in ProfileService client samples

Use AuthzToken (empty_token) in ProfileService client samples


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/52dd9bb2
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/52dd9bb2
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/52dd9bb2

Branch: refs/heads/develop
Commit: 52dd9bb2637fc11e28242fd1d04552e7f2f55765
Parents: e572553
Author: Gourav Shenoy <sh...@gmail.com>
Authored: Wed Apr 5 12:02:11 2017 -0400
Committer: Gourav Shenoy <sh...@gmail.com>
Committed: Wed Apr 5 12:02:11 2017 -0400

----------------------------------------------------------------------
 .../client/samples/TenantProfileSample.java       |  4 +++-
 .../profile/client/samples/UserProfileSample.java | 18 ++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/52dd9bb2/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/TenantProfileSample.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/TenantProfileSample.java b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/TenantProfileSample.java
index 51ee6a0..c2bb951 100644
--- a/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/TenantProfileSample.java
+++ b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/TenantProfileSample.java
@@ -1,5 +1,6 @@
 package org.apache.airavata.service.profile.client.samples;
 
+import org.apache.airavata.model.security.AuthzToken;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.GatewayApprovalStatus;
 import org.apache.airavata.service.profile.client.ProfileServiceClientFactory;
@@ -17,6 +18,7 @@ public class TenantProfileSample {
     private static final Logger logger = LoggerFactory.getLogger(TenantProfileSample.class);
     private static TenantProfileService.Client tenantProfileClient;
     private static String testGatewayId = null;
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
 
     public static void main(String[] args) throws Exception {
         try {
@@ -26,7 +28,7 @@ public class TenantProfileSample {
             tenantProfileClient = ProfileServiceClientFactory.createTenantProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
 
             // test addGateway
-            testGatewayId = tenantProfileClient.addGateway(getGateway(null));
+            testGatewayId = tenantProfileClient.addGateway(authzToken, getGateway("465"));
             assert (testGatewayId != null) : "Gateway creation failed!";
             System.out.println("Gateway created with gatewayId: " + testGatewayId);
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/52dd9bb2/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/UserProfileSample.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/UserProfileSample.java b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/UserProfileSample.java
index 2e1b879..861f2f5 100644
--- a/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/UserProfileSample.java
+++ b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/UserProfileSample.java
@@ -1,5 +1,6 @@
 package org.apache.airavata.service.profile.client.samples;
 
+import org.apache.airavata.model.security.AuthzToken;
 import org.apache.airavata.model.user.*;
 import org.apache.airavata.model.workspace.User;
 import org.apache.airavata.service.profile.client.ProfileServiceClientFactory;
@@ -21,7 +22,8 @@ public class UserProfileSample {
     private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class);
     private static UserProfileService.Client userProfileClient;
     private static String testUserId = null;
-    private static String testGatewayId = "test-gateway-1830144881";
+    private static String testGatewayId = "test-gateway-465";
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
 
     /**
      * Performs the following operations in sequence:
@@ -43,12 +45,12 @@ public class UserProfileSample {
             userProfileClient = ProfileServiceClientFactory.createUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
 
             // test add-user-profile
-            testUserId = userProfileClient.addUserProfile(getUserProfile(null));
+            testUserId = userProfileClient.addUserProfile(authzToken, getUserProfile(null));
             assert (testUserId != null) : "User creation failed. Null userId returned!";
             System.out.println("User created with userId: " + testUserId);
 
             // test find-user-profile
-            UserProfile userProfile = userProfileClient.getUserProfileById(testUserId, testGatewayId);
+            UserProfile userProfile = userProfileClient.getUserProfileById(authzToken, testUserId, testGatewayId);
             assert (userProfile != null) : "Could not find user with userId: " + testUserId + ", and gatewayID: " + testGatewayId;
             System.out.println("UserProfile: " + userProfile);
 
@@ -56,12 +58,12 @@ public class UserProfileSample {
             userProfile = getUserProfile(testUserId);
             String newUserName = userProfile.getUserName().replaceAll("username", "username-updated");
             userProfile.setUserName(newUserName);
-            boolean updateSuccess = userProfileClient.updateUserProfile(userProfile);
+            boolean updateSuccess = userProfileClient.updateUserProfile(authzToken, userProfile);
             assert (updateSuccess) : "User update with new userName: [" + newUserName + "], Failed!";
             System.out.println("User update with new userName: [" + newUserName + "], Successful!");
 
             // test get-all-userprofiles
-            List<UserProfile> userProfileList = userProfileClient.getAllUserProfilesInGateway(testGatewayId, 0, 5);
+            List<UserProfile> userProfileList = userProfileClient.getAllUserProfilesInGateway(authzToken, testGatewayId, 0, 5);
             assert (userProfileList != null && !userProfileList.isEmpty()) : "Failed to retrieve users for gateway!";
             System.out.println("Printing userList retrieved..");
             for (UserProfile userProfile1 : userProfileList) {
@@ -69,17 +71,17 @@ public class UserProfileSample {
             }
 
             // test find-user-profile-by-name
-            userProfile = userProfileClient.getUserProfileByName(newUserName, testGatewayId);
+            userProfile = userProfileClient.getUserProfileByName(authzToken, newUserName, testGatewayId);
             assert (userProfile != null) : "Could not find user with userName: " + newUserName;
             System.out.println("UserProfile: " + userProfile);
 
             // test delete-user-profile
-            boolean deleteSuccess = userProfileClient.deleteUserProfile(testUserId, testGatewayId);
+            boolean deleteSuccess = userProfileClient.deleteUserProfile(authzToken, testUserId, testGatewayId);
             assert (deleteSuccess) : "Delete user failed for userId: " + testUserId;
             System.out.println("Successfully deleted user with userId: " + testUserId);
 
             // test-check-user-exist
-            boolean userExists = userProfileClient.doesUserExist(newUserName, testGatewayId);
+            boolean userExists = userProfileClient.doesUserExist(authzToken, newUserName, testGatewayId);
             assert (!userExists) : "User should not exist, but it does.";
             System.out.println("User was deleted, hence does not exist!");
             System.out.println("*** DONE ***");