Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A2E75200BAE for ; Fri, 28 Oct 2016 18:45:53 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A1C5E160AE4; Fri, 28 Oct 2016 16:45:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 91B23160B0E for ; Fri, 28 Oct 2016 18:45:52 +0200 (CEST) Received: (qmail 81362 invoked by uid 500); 28 Oct 2016 16:45:51 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 80692 invoked by uid 99); 28 Oct 2016 16:45:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Oct 2016 16:45:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4106DE0FA0; Fri, 28 Oct 2016 16:45:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: smarru@apache.org To: commits@airavata.apache.org Date: Fri, 28 Oct 2016 16:46:05 -0000 Message-Id: <36b326021ebe4634a1f80985360af8ec@git.apache.org> In-Reply-To: <9128d98dc37b422785341693d8f2931d@git.apache.org> References: <9128d98dc37b422785341693d8f2931d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/20] airavata-php-gateway git commit: AIRAVATA-2156 Moved utility method to URPUtilities archived-at: Fri, 28 Oct 2016 16:45:53 -0000 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 Authored: Thu Oct 27 11:02:07 2016 -0400 Committer: Marcus Christie 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() {