airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/3] airavata-php-gateway git commit: adding group administration utilities to PGA
Date Tue, 12 Jul 2016 16:09:38 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/grouper-integration 1a0c25126 -> 3d001373d


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3d001373/app/libraries/Airavata/Model/Group/Types.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Model/Group/Types.php b/app/libraries/Airavata/Model/Group/Types.php
index c416f74..44f3db0 100644
--- a/app/libraries/Airavata/Model/Group/Types.php
+++ b/app/libraries/Airavata/Model/Group/Types.php
@@ -39,4 +39,197 @@ final class ResourcePermissionType {
   );
 }
 
+class GroupModel {
+  static $_TSPEC;
+
+  /**
+   * @var string
+   */
+  public $id = null;
+  /**
+   * @var string
+   */
+  public $name = null;
+  /**
+   * @var string
+   */
+  public $ownerId = null;
+  /**
+   * @var string
+   */
+  public $description = null;
+  /**
+   * @var string[]
+   */
+  public $members = null;
+
+  public function __construct($vals=null) {
+    if (!isset(self::$_TSPEC)) {
+      self::$_TSPEC = array(
+        1 => array(
+          'var' => 'id',
+          'type' => TType::STRING,
+          ),
+        2 => array(
+          'var' => 'name',
+          'type' => TType::STRING,
+          ),
+        3 => array(
+          'var' => 'ownerId',
+          'type' => TType::STRING,
+          ),
+        4 => array(
+          'var' => 'description',
+          'type' => TType::STRING,
+          ),
+        5 => array(
+          'var' => 'members',
+          'type' => TType::LST,
+          'etype' => TType::STRING,
+          'elem' => array(
+            'type' => TType::STRING,
+            ),
+          ),
+        );
+    }
+    if (is_array($vals)) {
+      if (isset($vals['id'])) {
+        $this->id = $vals['id'];
+      }
+      if (isset($vals['name'])) {
+        $this->name = $vals['name'];
+      }
+      if (isset($vals['ownerId'])) {
+        $this->ownerId = $vals['ownerId'];
+      }
+      if (isset($vals['description'])) {
+        $this->description = $vals['description'];
+      }
+      if (isset($vals['members'])) {
+        $this->members = $vals['members'];
+      }
+    }
+  }
+
+  public function getName() {
+    return 'GroupModel';
+  }
+
+  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::STRING) {
+            $xfer += $input->readString($this->id);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 2:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->name);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 3:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->ownerId);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 4:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->description);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 5:
+          if ($ftype == TType::LST) {
+            $this->members = array();
+            $_size0 = 0;
+            $_etype3 = 0;
+            $xfer += $input->readListBegin($_etype3, $_size0);
+            for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
+            {
+              $elem5 = null;
+              $xfer += $input->readString($elem5);
+              $this->members []= $elem5;
+            }
+            $xfer += $input->readListEnd();
+          } 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('GroupModel');
+    if ($this->id !== null) {
+      $xfer += $output->writeFieldBegin('id', TType::STRING, 1);
+      $xfer += $output->writeString($this->id);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->name !== null) {
+      $xfer += $output->writeFieldBegin('name', TType::STRING, 2);
+      $xfer += $output->writeString($this->name);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->ownerId !== null) {
+      $xfer += $output->writeFieldBegin('ownerId', TType::STRING, 3);
+      $xfer += $output->writeString($this->ownerId);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->description !== null) {
+      $xfer += $output->writeFieldBegin('description', TType::STRING, 4);
+      $xfer += $output->writeString($this->description);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->members !== null) {
+      if (!is_array($this->members)) {
+        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+      }
+      $xfer += $output->writeFieldBegin('members', TType::LST, 5);
+      {
+        $output->writeListBegin(TType::STRING, count($this->members));
+        {
+          foreach ($this->members as $iter6)
+          {
+            $xfer += $output->writeString($iter6);
+          }
+        }
+        $output->writeListEnd();
+      }
+      $xfer += $output->writeFieldEnd();
+    }
+    $xfer += $output->writeFieldStop();
+    $xfer += $output->writeStructEnd();
+    return $xfer;
+  }
+
+}
+
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3d001373/app/libraries/GrouperUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/GrouperUtilities.php b/app/libraries/GrouperUtilities.php
index ebe7e6f..a9e0b69 100644
--- a/app/libraries/GrouperUtilities.php
+++ b/app/libraries/GrouperUtilities.php
@@ -74,4 +74,68 @@ class GrouperUtilities
 
         return $userList;
     }
+
+    /**
+     * @param $group            Airavata/Model/Group/GrouoModel
+     */
+    public static function createGroup($group){
+        if (strpos($group->ownerId, '@') !== false) {
+            $parts = explode('@', $group->ownerId);
+            $group->ownerId = $parts[0] . "@" . Config::get('pga_config.airavata')['gateway-id'];
+        }else{
+            $group->ownerId = $group->ownerId . "@" . Config::get('pga_config.airavata')['gateway-id'];
+        }
+        Airavata::createGroup(Session::get('authz-token'),$group);
+    }
+
+
+    /**
+     * @param $group            Airavata/Model/Group/GrouoModel
+     */
+    public static function updateGroup($group){
+        if (strpos($group->ownerId, '@') !== false) {
+            $parts = explode('@', $group->ownerId);
+            $group->ownerId = $parts[0] . "@" . Config::get('pga_config.airavata')['gateway-id'];
+        }else{
+            $group->ownerId = $group->ownerId . "@" . Config::get('pga_config.airavata')['gateway-id'];
+        }
+        Airavata::updateGroup(Session::get('authz-token'),$group);
+    }
+
+
+    /**
+     * @param $groupId
+     * @param $ownerName
+     */
+    public static function deleteGroup($groupId, $ownerName){
+        if (strpos($ownerName, '@') !== false) {
+            $parts = explode('@', $ownerName);
+            $ownerName = $parts[0];
+        }
+
+        Airavata::deleteGroup(Session::get('authz-token'), $groupId, $ownerName, Config::get('pga_config.airavata')['gateway-id']);
+    }
+
+    /**
+     * @param $groupId
+     */
+    public static function getGroup($groupId){
+        return Airavata::getGroup(Session::get('authz-token'),$groupId);
+    }
+
+
+    /**
+     * @param $userName
+     * @return mixed
+     */
+    public static function getAllGroupsUserBelongs($userName){
+        if (strpos($userName, '@') !== false) {
+            $parts = explode('@', $userName);
+            $userName = $parts[0];
+        }
+
+        return Airavata::getAllGroupsUserBelongs(Session::get('authz-token'), $userName,
+            Config::get('pga_config.airavata')['gateway-id']);
+    }
+
 }
\ No newline at end of file


Mime
View raw message