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 2018/06/06 16:30:14 UTC
[airavata-php-gateway] 02/03: AIRAVATA-2797 using
isUserResourceProfileExists API method
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git
commit ecf6de27953cecd730f1c15a20fb228958af7736
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Jun 6 12:28:53 2018 -0400
AIRAVATA-2797 using isUserResourceProfileExists API method
---
app/libraries/Airavata/API/Airavata.php | 392 ++++++++++++++++++++-
.../Model/AppCatalog/UserResourceProfile/Types.php | 26 --
app/libraries/URPUtilities.php | 19 +-
3 files changed, 403 insertions(+), 34 deletions(-)
diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php
index 68464cd..cbb5274 100644
--- a/app/libraries/Airavata/API/Airavata.php
+++ b/app/libraries/Airavata/API/Airavata.php
@@ -3565,6 +3565,29 @@ interface AiravataIf {
*/
public function registerUserResourceProfile(\Airavata\Model\Security\AuthzToken $authzToken, \Airavata\Model\AppCatalog\UserResourceProfile\UserResourceProfile $userResourceProfile);
/**
+ * Check if User Resource Profile exists.
+ *
+ * @param userId
+ * The identifier for the requested user resource profile.
+ *
+ * @param gatewayID
+ * The identifier to link a gateway for the requested user resource profile.
+ *
+ * @return UserResourceProfile
+ * User Resource Profile Object.
+ *
+ *
+ * @param \Airavata\Model\Security\AuthzToken $authzToken
+ * @param string $userId
+ * @param string $gatewayID
+ * @return bool
+ * @throws \Airavata\API\Error\InvalidRequestException
+ * @throws \Airavata\API\Error\AiravataClientException
+ * @throws \Airavata\API\Error\AiravataSystemException
+ * @throws \Airavata\API\Error\AuthorizationException
+ */
+ public function isUserResourceProfileExists(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayID);
+ /**
* Fetch the given User Resource Profile.
*
* @param userId
@@ -3598,9 +3621,6 @@ interface AiravataIf {
*
* identityServerPwdCredToken:
*
- * isNull:
- * Indicates that this instance is just a container for a null value.
- *
*
* @throws \Airavata\API\Error\InvalidRequestException
* @throws \Airavata\API\Error\AiravataClientException
@@ -13383,6 +13403,71 @@ class AiravataClient implements \Airavata\API\AiravataIf {
throw new \Exception("registerUserResourceProfile failed: unknown result");
}
+ public function isUserResourceProfileExists(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayID)
+ {
+ $this->send_isUserResourceProfileExists($authzToken, $userId, $gatewayID);
+ return $this->recv_isUserResourceProfileExists();
+ }
+
+ public function send_isUserResourceProfileExists(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayID)
+ {
+ $args = new \Airavata\API\Airavata_isUserResourceProfileExists_args();
+ $args->authzToken = $authzToken;
+ $args->userId = $userId;
+ $args->gatewayID = $gatewayID;
+ $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
+ if ($bin_accel)
+ {
+ thrift_protocol_write_binary($this->output_, 'isUserResourceProfileExists', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
+ }
+ else
+ {
+ $this->output_->writeMessageBegin('isUserResourceProfileExists', TMessageType::CALL, $this->seqid_);
+ $args->write($this->output_);
+ $this->output_->writeMessageEnd();
+ $this->output_->getTransport()->flush();
+ }
+ }
+
+ public function recv_isUserResourceProfileExists()
+ {
+ $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
+ if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Airavata\API\Airavata_isUserResourceProfileExists_result', $this->input_->isStrictRead());
+ else
+ {
+ $rseqid = 0;
+ $fname = null;
+ $mtype = 0;
+
+ $this->input_->readMessageBegin($fname, $mtype, $rseqid);
+ if ($mtype == TMessageType::EXCEPTION) {
+ $x = new TApplicationException();
+ $x->read($this->input_);
+ $this->input_->readMessageEnd();
+ throw $x;
+ }
+ $result = new \Airavata\API\Airavata_isUserResourceProfileExists_result();
+ $result->read($this->input_);
+ $this->input_->readMessageEnd();
+ }
+ if ($result->success !== null) {
+ return $result->success;
+ }
+ if ($result->ire !== null) {
+ throw $result->ire;
+ }
+ if ($result->ace !== null) {
+ throw $result->ace;
+ }
+ if ($result->ase !== null) {
+ throw $result->ase;
+ }
+ if ($result->ae !== null) {
+ throw $result->ae;
+ }
+ throw new \Exception("isUserResourceProfileExists failed: unknown result");
+ }
+
public function getUserResourceProfile(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayID)
{
$this->send_getUserResourceProfile($authzToken, $userId, $gatewayID);
@@ -59057,6 +59142,307 @@ class Airavata_registerUserResourceProfile_result {
}
+class Airavata_isUserResourceProfileExists_args {
+ static $_TSPEC;
+
+ /**
+ * @var \Airavata\Model\Security\AuthzToken
+ */
+ public $authzToken = null;
+ /**
+ * @var string
+ */
+ public $userId = null;
+ /**
+ * @var string
+ */
+ public $gatewayID = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'authzToken',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\Model\Security\AuthzToken',
+ ),
+ 2 => array(
+ 'var' => 'userId',
+ 'type' => TType::STRING,
+ ),
+ 3 => array(
+ 'var' => 'gatewayID',
+ 'type' => TType::STRING,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['authzToken'])) {
+ $this->authzToken = $vals['authzToken'];
+ }
+ if (isset($vals['userId'])) {
+ $this->userId = $vals['userId'];
+ }
+ if (isset($vals['gatewayID'])) {
+ $this->gatewayID = $vals['gatewayID'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'Airavata_isUserResourceProfileExists_args';
+ }
+
+ public function read($input)
+ {
+ $xfer = 0;
+ $fname = null;
+ $ftype = 0;
+ $fid = 0;
+ $xfer += $input->readStructBegin($fname);
+ while (true)
+ {
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+ if ($ftype == TType::STOP) {
+ break;
+ }
+ switch ($fid)
+ {
+ case 1:
+ if ($ftype == TType::STRUCT) {
+ $this->authzToken = new \Airavata\Model\Security\AuthzToken();
+ $xfer += $this->authzToken->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->userId);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->gatewayID);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('Airavata_isUserResourceProfileExists_args');
+ if ($this->authzToken !== null) {
+ if (!is_object($this->authzToken)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('authzToken', TType::STRUCT, 1);
+ $xfer += $this->authzToken->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->userId !== null) {
+ $xfer += $output->writeFieldBegin('userId', TType::STRING, 2);
+ $xfer += $output->writeString($this->userId);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->gatewayID !== null) {
+ $xfer += $output->writeFieldBegin('gatewayID', TType::STRING, 3);
+ $xfer += $output->writeString($this->gatewayID);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class Airavata_isUserResourceProfileExists_result {
+ static $_TSPEC;
+
+ /**
+ * @var bool
+ */
+ public $success = null;
+ /**
+ * @var \Airavata\API\Error\InvalidRequestException
+ */
+ public $ire = null;
+ /**
+ * @var \Airavata\API\Error\AiravataClientException
+ */
+ public $ace = null;
+ /**
+ * @var \Airavata\API\Error\AiravataSystemException
+ */
+ public $ase = null;
+ /**
+ * @var \Airavata\API\Error\AuthorizationException
+ */
+ public $ae = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 0 => array(
+ 'var' => 'success',
+ 'type' => TType::BOOL,
+ ),
+ 1 => array(
+ 'var' => 'ire',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\API\Error\InvalidRequestException',
+ ),
+ 2 => array(
+ 'var' => 'ace',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\API\Error\AiravataClientException',
+ ),
+ 3 => array(
+ 'var' => 'ase',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\API\Error\AiravataSystemException',
+ ),
+ 4 => array(
+ 'var' => 'ae',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\API\Error\AuthorizationException',
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['success'])) {
+ $this->success = $vals['success'];
+ }
+ if (isset($vals['ire'])) {
+ $this->ire = $vals['ire'];
+ }
+ if (isset($vals['ace'])) {
+ $this->ace = $vals['ace'];
+ }
+ if (isset($vals['ase'])) {
+ $this->ase = $vals['ase'];
+ }
+ if (isset($vals['ae'])) {
+ $this->ae = $vals['ae'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'Airavata_isUserResourceProfileExists_result';
+ }
+
+ public function read($input)
+ {
+ $xfer = 0;
+ $fname = null;
+ $ftype = 0;
+ $fid = 0;
+ $xfer += $input->readStructBegin($fname);
+ while (true)
+ {
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+ if ($ftype == TType::STOP) {
+ break;
+ }
+ switch ($fid)
+ {
+ case 0:
+ if ($ftype == TType::BOOL) {
+ $xfer += $input->readBool($this->success);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 1:
+ if ($ftype == TType::STRUCT) {
+ $this->ire = new \Airavata\API\Error\InvalidRequestException();
+ $xfer += $this->ire->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRUCT) {
+ $this->ace = new \Airavata\API\Error\AiravataClientException();
+ $xfer += $this->ace->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::STRUCT) {
+ $this->ase = new \Airavata\API\Error\AiravataSystemException();
+ $xfer += $this->ase->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::STRUCT) {
+ $this->ae = new \Airavata\API\Error\AuthorizationException();
+ $xfer += $this->ae->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('Airavata_isUserResourceProfileExists_result');
+ if ($this->success !== null) {
+ $xfer += $output->writeFieldBegin('success', TType::BOOL, 0);
+ $xfer += $output->writeBool($this->success);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->ire !== null) {
+ $xfer += $output->writeFieldBegin('ire', TType::STRUCT, 1);
+ $xfer += $this->ire->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->ace !== null) {
+ $xfer += $output->writeFieldBegin('ace', TType::STRUCT, 2);
+ $xfer += $this->ace->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->ase !== null) {
+ $xfer += $output->writeFieldBegin('ase', TType::STRUCT, 3);
+ $xfer += $this->ase->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->ae !== null) {
+ $xfer += $output->writeFieldBegin('ae', TType::STRUCT, 4);
+ $xfer += $this->ae->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
class Airavata_getUserResourceProfile_args {
static $_TSPEC;
diff --git a/app/libraries/Airavata/Model/AppCatalog/UserResourceProfile/Types.php b/app/libraries/Airavata/Model/AppCatalog/UserResourceProfile/Types.php
index a35a7f8..83f5657 100644
--- a/app/libraries/Airavata/Model/AppCatalog/UserResourceProfile/Types.php
+++ b/app/libraries/Airavata/Model/AppCatalog/UserResourceProfile/Types.php
@@ -517,9 +517,6 @@ class UserStoragePreference {
*
* identityServerPwdCredToken:
*
- * isNull:
- * Indicates that this instance is just a container for a null value.
- *
*/
class UserResourceProfile {
static $_TSPEC;
@@ -552,10 +549,6 @@ class UserResourceProfile {
* @var string
*/
public $identityServerPwdCredToken = null;
- /**
- * @var bool
- */
- public $isNull = false;
public function __construct($vals=null) {
if (!isset(self::$_TSPEC)) {
@@ -598,10 +591,6 @@ class UserResourceProfile {
'var' => 'identityServerPwdCredToken',
'type' => TType::STRING,
),
- 8 => array(
- 'var' => 'isNull',
- 'type' => TType::BOOL,
- ),
);
}
if (is_array($vals)) {
@@ -626,9 +615,6 @@ class UserResourceProfile {
if (isset($vals['identityServerPwdCredToken'])) {
$this->identityServerPwdCredToken = $vals['identityServerPwdCredToken'];
}
- if (isset($vals['isNull'])) {
- $this->isNull = $vals['isNull'];
- }
}
}
@@ -722,13 +708,6 @@ class UserResourceProfile {
$xfer += $input->skip($ftype);
}
break;
- case 8:
- if ($ftype == TType::BOOL) {
- $xfer += $input->readBool($this->isNull);
- } else {
- $xfer += $input->skip($ftype);
- }
- break;
default:
$xfer += $input->skip($ftype);
break;
@@ -801,11 +780,6 @@ class UserResourceProfile {
$xfer += $output->writeString($this->identityServerPwdCredToken);
$xfer += $output->writeFieldEnd();
}
- if ($this->isNull !== null) {
- $xfer += $output->writeFieldBegin('isNull', TType::BOOL, 8);
- $xfer += $output->writeBool($this->isNull);
- $xfer += $output->writeFieldEnd();
- }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php
index c65197b..428f139 100644
--- a/app/libraries/URPUtilities.php
+++ b/app/libraries/URPUtilities.php
@@ -11,12 +11,14 @@ class URPUtilities
public static function get_or_create_user_resource_profile()
{
- $userResourceProfile = URPUtilities::get_user_resource_profile();
- // Check if user has UserResourceProfile by checking isNull flag
- if ($userResourceProfile->isNull)
+ if (!URPUtilities::is_user_resource_profile_exists())
{
$userResourceProfile = URPUtilities::create_user_resource_profile();
}
+ else
+ {
+ $userResourceProfile = URPUtilities::get_user_resource_profile();
+ }
return $userResourceProfile;
}
@@ -27,6 +29,13 @@ class URPUtilities
return Airavata::getUserResourceProfile(Session::get('authz-token'), $userId, $gatewayId);
}
+ public static function is_user_resource_profile_exists()
+ {
+ $userId = Session::get('username');
+ $gatewayId = Session::get('gateway_id');
+ return Airavata::isUserResourceProfileExists(Session::get('authz-token'), $userId, $gatewayId);
+ }
+
public static function create_user_resource_profile()
{
@@ -123,9 +132,9 @@ class URPUtilities
{
$userComputeResourcePreferencesById = array();
- $userResourceProfile = URPUtilities::get_user_resource_profile();
- if (!$userResourceProfile->isNull)
+ if (URPUtilities::is_user_resource_profile_exists())
{
+ $userResourceProfile = URPUtilities::get_user_resource_profile();
$userComputeResourcePreferences = $userResourceProfile->userComputeResourcePreferences;
// Put $userComputeResourcePreferences in a map keyed by computeResourceId
foreach( $userComputeResourcePreferences as $userComputeResourcePreference )
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.