You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/29 12:58:36 UTC
airavata-php-gateway git commit: AIRAVATA-2452 Loading profiles for
sharing from UserProfileService
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop b935db14e -> a06deae94
AIRAVATA-2452 Loading profiles for sharing from UserProfileService
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/a06deae9
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/a06deae9
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/a06deae9
Branch: refs/heads/develop
Commit: a06deae9413a555d63d8ec470c4a29ac592de58f
Parents: b935db1
Author: Marcus Christie <ma...@iu.edu>
Authored: Thu Jun 29 08:58:07 2017 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Thu Jun 29 08:58:23 2017 -0400
----------------------------------------------------------------------
app/libraries/SharingUtilities.php | 29 +++++++++++++++++++++++------
app/libraries/UserProfileUtilities.php | 5 +++++
2 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/a06deae9/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index 6cf7e7e..f10fef2 100755
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -77,19 +77,19 @@ class SharingUtilities {
$owner = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::OWNER);
foreach($read as $uid) {
- if ($uid !== Session::get('username') && Keycloak::usernameExists($uid)) {
+ if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid] = array('read' => true, 'write' => false);
}
}
foreach($write as $uid) {
- if ($uid !== Session::get('username') && Keycloak::usernameExists($uid)) {
+ if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid]['write'] = true;
}
}
foreach($owner as $uid) {
- if ($uid !== Session::get('username') && WSIS::usernameExists($uid)) {
+ if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid]['owner'] = true;
}
}
@@ -104,16 +104,33 @@ class SharingUtilities {
* @return An array [uid => [firstname => string, lastname => string, email => string]]
*/
public static function getUserProfiles($uids) {
- $uids = array_filter($uids, function($uid) {
- return ($uid !== Session::get('username') && Keycloak::usernameExists($uid));
+ // FIXME: instead of loading all user profiles it would be better to
+ // have the user search for users and just load profiles matching the search
+ $all_profiles = SharingUtilities::convertUserProfilesToSharingProfiles(UserProfileUtilities::get_all_user_profiles(0, 100000));
+ Log::debug("all_profiles", array($all_profiles));
+ $uids = array_filter($uids, function($uid) use ($all_profiles) {
+ return ($uid !== Session::get('username') && array_key_exists($uid, $all_profiles));
});
$profiles = array();
foreach ($uids as $uid) {
- $profiles[$uid] = Keycloak::getUserProfile($uid);
+ $profiles[$uid] = $all_profiles[$uid];
}
return $profiles;
}
+ private static function convertUserProfilesToSharingProfiles($user_profiles) {
+ $sharing_profiles = array();
+ foreach ($user_profiles as $user_profile) {
+ $sharing_profile = array(
+ 'firstname' => $user_profile->firstName,
+ 'lastname' => $user_profile->lastName,
+ 'email' => $user_profile->emails[0],
+ );
+ $sharing_profiles[$user_profile->userId] = $sharing_profile;
+ }
+ return $sharing_profiles;
+ }
+
/**
* Retrieve profile and permissions information for users with access to the given resource.
*
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/a06deae9/app/libraries/UserProfileUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/UserProfileUtilities.php b/app/libraries/UserProfileUtilities.php
index b266211..6717546 100644
--- a/app/libraries/UserProfileUtilities.php
+++ b/app/libraries/UserProfileUtilities.php
@@ -45,6 +45,11 @@ class UserProfileUtilities
return UserProfileService::updateUserProfile(Session::get('authz-token'), $userProfile);
}
+
+ public static function get_all_user_profiles($offset, $limit) {
+ return UserProfileService::getAllUserProfilesInGateway(
+ Session::get('authz-token'), Session::get('gateway_id'), $offset, $limit);
+ }
}
?>