You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/10/28 16:46:05 UTC
[16/20] airavata-php-gateway git commit: AIRAVATA-2156 Moved utility
method to URPUtilities
AIRAVATA-2156 Moved utility method to URPUtilities
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/b6eab429
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/b6eab429
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/b6eab429
Branch: refs/heads/develop
Commit: b6eab429899ba38e587a65f70cf9b6b7d187b29d
Parents: a90dfed
Author: Marcus Christie <ma...@iu.edu>
Authored: Thu Oct 27 11:02:07 2016 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Thu Oct 27 11:02:07 2016 -0400
----------------------------------------------------------------------
app/controllers/AccountController.php | 21 +++++----------------
app/libraries/URPUtilities.php | 14 +++++++++++++-
2 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/b6eab429/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index b5361b5..74e3690 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -471,8 +471,7 @@ class AccountController extends BaseController
$userResourceProfile = URPUtilities::get_or_create_user_resource_profile();
$userCredentialSummaries = URPUtilities::get_all_ssh_pub_keys_summary_for_user();
- $credentialSummaryMap = $this->create_credential_summary_map(URPUtilities::get_all_ssh_pub_keys_summary_for_user());
- $defaultCredentialSummary = $credentialSummaryMap[$userResourceProfile->credentialStoreToken];
+ $defaultCredentialSummary = $userCredentialSummaries[$userResourceProfile->credentialStoreToken];
foreach ($userCredentialSummaries as $credentialSummary) {
$credentialSummary->canDelete = ($credentialSummary->token != $defaultCredentialSummary->token);
}
@@ -491,8 +490,8 @@ class AccountController extends BaseController
$userResourceProfile->credentialStoreToken = $defaultToken;
URPUtilities::update_user_resource_profile($userResourceProfile);
- $credentialSummaryMap = $this->create_credential_summary_map(URPUtilities::get_all_ssh_pub_keys_summary_for_user());
- $description = $credentialSummaryMap[$defaultToken]->description;
+ $credentialSummaries = URPUtilities::get_all_ssh_pub_keys_summary_for_user();
+ $description = $credentialSummaries[$defaultToken]->description;
return Redirect::to("account/credential-store")->with("message", "SSH Key '$description' is now the default");
}
@@ -528,24 +527,14 @@ class AccountController extends BaseController
return Redirect::to("account/credential-store")->with("error-message", "You are not allowed to delete the default SSH key.");
}
- $credentialSummaryMap = $this->create_credential_summary_map(URPUtilities::get_all_ssh_pub_keys_summary_for_user());
- $description = $credentialSummaryMap[$credentialStoreToken]->description;
+ $credentialSummaries = URPUtilities::get_all_ssh_pub_keys_summary_for_user();
+ $description = $credentialSummaries[$credentialStoreToken]->description;
if (AdminUtilities::remove_ssh_token($credentialStoreToken)) {
return Redirect::to("account/credential-store")->with("message", "SSH Key '$description' was deleted");
}
}
- // TODO: move to URPUtilities?
- private function create_credential_summary_map($credentialSummaries) {
-
- $credentialSummaryMap = array();
- foreach ($credentialSummaries as $csIndex => $credentialSummary) {
- $credentialSummaryMap[$credentialSummary->token] = $credentialSummary;
- }
- return $credentialSummaryMap;
- }
-
public function getComputeResources(){
$userResourceProfile = URPUtilities::get_or_create_user_resource_profile();
return View::make("account/compute-resources", array(
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/b6eab429/app/libraries/URPUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php
index f0a6094..68aef94 100644
--- a/app/libraries/URPUtilities.php
+++ b/app/libraries/URPUtilities.php
@@ -55,9 +55,21 @@ class URPUtilities
$userId = Session::get('username');
$gatewayId = Session::get('gateway_id');
- return Airavata::getAllSSHPubKeysSummaryForUserInGateway(Session::get('authz-token'), $gatewayId, $userId);
+ return URPUtilities::create_credential_summary_map(
+ Airavata::getAllSSHPubKeysSummaryForUserInGateway(Session::get('authz-token'), $gatewayId, $userId));
}
+ // Create array of CredentialSummary objects where the token is the key
+ private static function create_credential_summary_map($credentialSummaries) {
+
+ $credentialSummaryMap = array();
+ foreach ($credentialSummaries as $csIndex => $credentialSummary) {
+ $credentialSummaryMap[$credentialSummary->token] = $credentialSummary;
+ }
+ return $credentialSummaryMap;
+ }
+
+
// Only used for testing
public static function delete_user_resource_profile()
{