airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [4/4] airavata-php-gateway git commit: minor fixes and enable experiment sharing
Date Mon, 11 Jul 2016 19:09:47 GMT
minor fixes and enable experiment sharing


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/2f58f919
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/2f58f919
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/2f58f919

Branch: refs/heads/grouper-integration
Commit: 2f58f9191718cf06805de9f3fcc27256739995e5
Parents: 460fa7f
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Mon Jul 11 14:44:56 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Mon Jul 11 14:44:56 2016 -0400

----------------------------------------------------------------------
 app/controllers/ExperimentController.php        |  17 +++++---
 app/libraries/ExperimentUtilities.php           |  43 +++++++++++++++++--
 app/libraries/ProjectUtilities.php              |   7 +--
 .../assets/Profile_avatar_placeholder_large.png | Bin 0 -> 2011 bytes
 app/views/experiment/create.blade.php           |   7 ++-
 5 files changed, 57 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2f58f919/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 2f225d1..7a49e6f 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -1,8 +1,6 @@
 <?php
 
 use Airavata\Model\Status\JobState;
-use Airavata\Model\Group\ResourceType;
-use Airavata\Model\Group\ResourcePermissionType;
 
 class ExperimentController extends BaseController
 {
@@ -27,7 +25,14 @@ class ExperimentController extends BaseController
     public function createView()
     {
         Session::forget('exp_create_continue');
-        return View::make('experiment/create');
+        $uids = GrouperUtilities::getAllGatewayUsers();
+        $users = array();
+        foreach ($uids as $uid) {
+            if (WSIS::usernameExists($uid)) {
+                $users[$uid] = WSIS::getUserProfile($uid);
+            }
+        }
+        return View::make('experiment/create', array("users" => json_encode($users)));
     }
 
     public function createSubmit()
@@ -54,7 +59,7 @@ class ExperimentController extends BaseController
             if( $serverLimit < $allowedFileSize)
                 $allowedFileSize = $serverLimit;
 
-            
+
             $experimentInputs = array(
                 "clonedExp" => $clonedExp,
                 "savedExp" => $savedExp,
@@ -114,7 +119,7 @@ class ExperimentController extends BaseController
             else
                 Session::forget("permissionDenied");
 
-        
+
             $project = ProjectUtilities::get_project($experiment->projectId);
             $expVal = ExperimentUtilities::get_experiment_values($experiment);
             $jobDetails = ExperimentUtilities::get_job_details($experiment->experimentId);
@@ -129,7 +134,7 @@ class ExperimentController extends BaseController
                 }
             }
             $expVal["jobDetails"] = $jobDetails;
-            
+
             $data = array(
                 "expId" => Input::get("expId"),
                 "experiment" => $experiment,

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2f58f919/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index da58102..58a3863 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -21,6 +21,8 @@ use Airavata\Model\Data\Replica\DataReplicaLocationModel;
 use Airavata\Model\Data\Replica\ReplicaLocationCategory;
 use Airavata\Model\Data\Replica\ReplicaPersistentType;
 use Airavata\Model\Application\Io\InputDataObjectType;
+use Airavata\Model\Group\ResourceType;
+use Airavata\Model\Group\ResourcePermissionType;
 
 class ExperimentUtilities
 {
@@ -77,7 +79,7 @@ class ExperimentUtilities
 
         $optFilesHtml = "";
 
-        if( count( $experimentInputs) > 0 ) { 
+        if( count( $experimentInputs) > 0 ) {
             foreach ($experimentInputs as $input) {
                 $matchingAppInput = null;
                 if ($input->type == DataType::URI) {
@@ -788,6 +790,8 @@ class ExperimentUtilities
         $experiment = ExperimentUtilities::assemble_experiment();
         $expId = null;
 
+        $share = $_POST['share-settings'];
+
         try {
             if ($experiment) {
                 $expId = Airavata::createExperiment(Session::get('authz-token'), Session::get("gateway_id"),
$experiment);
@@ -809,6 +813,8 @@ class ExperimentUtilities
             CommonUtilities::print_error_message('AiravataSystemException!<br><br>'
. $ase->getMessage());
         }
 
+        ExperimentUtilities::share_experiment($expId, json_decode($share));
+
         return $expId;
     }
 
@@ -932,14 +938,14 @@ class ExperimentUtilities
         if( is_object( $experiment->experimentStatus ) )
             $experimentStatusString = $expVal["experimentStates"][$experiment->experimentStatus->state];
         else
-            $experimentStatusString = $experiment->experimentStatus; 
+            $experimentStatusString = $experiment->experimentStatus;
 
         $expVal["experimentStatusString"] = $experimentStatusString;
         if ( $experimentStatusString == ExperimentState::FAILED)
             $expVal["editable"] = false;
 
         $expVal["cancelable"] = false;
-        if ( $experimentStatusString == ExperimentState::LAUNCHED 
+        if ( $experimentStatusString == ExperimentState::LAUNCHED
             || $experimentStatusString == ExperimentState::EXECUTING)
             $expVal["cancelable"] = true;
 
@@ -1303,5 +1309,34 @@ class ExperimentUtilities
         echo '</select>';
     }
 
+    private static function share_experiment($expId, $users) {
+        $wadd = array();
+        $wrevoke = array();
+        $radd = array();
+        $rrevoke = array();
+
+        foreach ($users as $user => $perms) {
+            if ($perms['write']) {
+                $wadd[$user] = ResourcePermissionType::WRITE;
+            }
+            else {
+                $wrevoke[$user] = ResourcePermissionType::WRITE;
+            }
+
+            if ($perms['read']) {
+                $radd[$user] = ResourcePermissionType::READ;
+            }
+            else {
+                $rrevoke[$user] = ResourcePermissionType::READ;
+            }
+        }
+
+        GrouperUtilities::shareResourceWithUsers($expId, ResourceType::Experiment, $wadd);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($expId, ResourceType::Experiment,
$wrevoke);
+
+        GrouperUtilities::shareResourceWithUsers($expId, ResourceType::Experiment, $radd);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($expId, ResourceType::Experiment,
$rrevoke);
+    }
+
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2f58f919/app/libraries/ProjectUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php
index 6bb3c67..14ea0d4 100644
--- a/app/libraries/ProjectUtilities.php
+++ b/app/libraries/ProjectUtilities.php
@@ -106,9 +106,6 @@ class ProjectUtilities
         $project->gatewayId = Config::get('pga_config.airavata')['gateway-id'];
 
         $share = $_POST['share-settings'];
-        $share = json_decode($share);
-        var_dump($share);
-        exit;
 
         $projectId = null;
 
@@ -298,9 +295,9 @@ class ProjectUtilities
         }
 
         GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $wadd);
-        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$wrevoke);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType::Project,
$wrevoke);
 
         GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $radd);
-        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$rrevoke);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType::Project,
$rrevoke);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2f58f919/app/resources/assets/Profile_avatar_placeholder_large.png
----------------------------------------------------------------------
diff --git a/app/resources/assets/Profile_avatar_placeholder_large.png b/app/resources/assets/Profile_avatar_placeholder_large.png
new file mode 100644
index 0000000..0989209
Binary files /dev/null and b/app/resources/assets/Profile_avatar_placeholder_large.png differ

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2f58f919/app/views/experiment/create.blade.php
----------------------------------------------------------------------
diff --git a/app/views/experiment/create.blade.php b/app/views/experiment/create.blade.php
index ca857a2..36de03d 100755
--- a/app/views/experiment/create.blade.php
+++ b/app/views/experiment/create.blade.php
@@ -52,10 +52,10 @@
             <label for="project-share">Sharing Settings</label><br />
             <button class="btn btn-default" name="project-share" id="project-share">Share
With Other Users</button> <br />
             <label>Show</label>
-            <div id="show-results-group" class="btn-group" role="group" aria-label="Show
Groups or Users">
+            <!-- <div id="show-results-group" class="btn-group" role="group" aria-label="Show
Groups or Users">
                 <button type="button" class="show-groups show-results-btn btn btn-primary">Groups</button>
                 <button type="button" class="show-users show-results-btn btn btn-default">Users</button>
-            </div>
+            </div> -->
             <label>Order By</label>
             <select class="order-results-selector">
                 <option value="username">Username</option>
@@ -83,6 +83,9 @@
 
 @section('scripts')
 @parent
+<script>
+var users = {{ $users }};
+</script>
 {{ HTML::script('js/sharing/sharing_utils.js') }}
 {{ HTML::script('js/sharing/share.js') }}
 @stop


Mime
View raw message