Repository: airavata-php-gateway Updated Branches: refs/heads/grouper-integration 14f4f01a9 -> a6659e7e5
adding the grouper utilities class 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/a6659e7e Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/a6659e7e Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/a6659e7e Branch: refs/heads/grouper-integration Commit: a6659e7e50240819e4fb0472e0db171ed10f3136 Parents: 14f4f01 Author: scnakandala <[email protected]> Authored: Thu Jul 7 18:26:52 2016 -0400 Committer: scnakandala <[email protected]> Committed: Thu Jul 7 18:26:52 2016 -0400 ---------------------------------------------------------------------- app/controllers/ExperimentController.php | 2 + app/libraries/GrouperUtilities.php | 52 +++++++++++++++++++++-- app/views/partials/experiment-info.blade.php | 4 ++ 3 files changed, 55 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/a6659e7e/app/controllers/ExperimentController.php ---------------------------------------------------------------------- diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php index f5ca6ea..2f225d1 100755 --- a/app/controllers/ExperimentController.php +++ b/app/controllers/ExperimentController.php @@ -1,6 +1,8 @@ <?php use Airavata\Model\Status\JobState; +use Airavata\Model\Group\ResourceType; +use Airavata\Model\Group\ResourcePermissionType; class ExperimentController extends BaseController { http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/a6659e7e/app/libraries/GrouperUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/GrouperUtilities.php b/app/libraries/GrouperUtilities.php index d09acaf..1b38979 100644 --- a/app/libraries/GrouperUtilities.php +++ b/app/libraries/GrouperUtilities.php @@ -5,18 +5,64 @@ use Airavata\Model\Group\ResourcePermissionType; class GrouperUtilities { + /** + * @param $resourceId Experiment or Project ID + * @param $dataResourceType e.g Airavata\Model\Group\ResourceType:PROJECT,Airavata\Model\Group\ResourceType:EXPERIMENT + * @param $userPermissionMap A map of map<username,Airavata\Model\Group\ResourcePermissionType> + */ public static function shareResourceWithUsers($resourceId, $dataResourceType, $userPermissionMap) { - Airavata::shareResourceWithUsers(Session::get('authz-token'), $resourceId, $dataResourceType, $userPermissionMap); + $newUserPermissionsMap = []; + foreach($userPermissionMap as $key=> $value){ + if (strpos($key, '@') !== false) { + $parts = explode('@', $key); + $key = $parts[0] . "@" . Config::get('pga_config.airavata')['gateway-id']; + }else{ + $key = $key . "@" . Config::get('pga_config.airavata')['gateway-id']; + } + $newUserPermissionsMap[$key] = $value; + } + Airavata::shareResourceWithUsers(Session::get('authz-token'), $resourceId, $dataResourceType, $newUserPermissionsMap); } + /** + * @param $resourceId Experiment or Project ID + * @param $dataResourceType e.g Airavata\Model\Group\ResourceType:PROJECT,Airavata\Model\Group\ResourceType:EXPERIMENT + * @param $userPermissionMap A map of map<username,Airavata\Model\Group\ResourcePermissionType> + */ public static function revokeSharingOfResourceFromUsers($resourceId, $dataResourceType, $userPermissionMap) { - Airavata::revokeSharingOfResourceFromUsers(Session::get('authz-token'), $resourceId, $dataResourceType, $userPermissionMap); + $newUserPermissionsMap = []; + foreach($userPermissionMap as $key=> $value){ + if (strpos($key, '@') !== false) { + $parts = explode('@', $key); + $key = $parts[0] . "@" . Config::get('pga_config.airavata')['gateway-id']; + }else{ + $key = $key . "@" . Config::get('pga_config.airavata')['gateway-id']; + } + $newUserPermissionsMap[$key] = $value; + } + Airavata::revokeSharingOfResourceFromUsers(Session::get('authz-token'), $resourceId, $dataResourceType, $newUserPermissionsMap); } + /** + * @param $resourceId Experiment or Project ID + * @param $dataResourceType e.g Airavata\Model\Group\ResourceType:PROJECT,Airavata\Model\Group\ResourceType:EXPERIMENT + * @param $permissionType e.g Airavata\Model\Group\ResourcePermissionType::READ, Airavata\Model\Group\ResourcePermissionType::WRITE + * @return array array of usernames + */ public static function getAllAccessibleUsers($resourceId, $dataResourceType, $permissionType) { - return Airavata::getAllAccessibleUsers($resourceId, $dataResourceType, $permissionType); + $temp = Airavata::getAllAccessibleUsers(Session::get('authz-token'), $resourceId, $dataResourceType, $permissionType); + $userList = []; + foreach ($temp as $key => $u) { + if (strpos($u, '@') !== false) { + $parts = explode('@', $u); + $u = $parts[0]; + } + $userList[] = $u; + } + + return $userList; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/a6659e7e/app/views/partials/experiment-info.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/experiment-info.blade.php b/app/views/partials/experiment-info.blade.php index 9b17c17..2d1969d 100644 --- a/app/views/partials/experiment-info.blade.php +++ b/app/views/partials/experiment-info.blade.php @@ -48,6 +48,10 @@ <td><?php echo $project->name; ?></td> </tr> <tr> + <td><strong>Owner</strong></td> + <td><?php echo $project->owner; ?></td> + </tr> + <tr> <td><strong>Application</strong></td> <td><?php if (!empty($expVal["applicationInterface"])) { echo $expVal["applicationInterface"]->applicationName;
