Merge branch 'develop'
diff --git a/app/config/pga_config_default_template.php b/app/config/pga_config_default_template.php
deleted file mode 100644
index 9d6be07..0000000
--- a/app/config/pga_config_default_template.php
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-return array(
-    /**
-     * *****************************************************************
-     *  These are WSO2 Identity Server Related Configurations
-     * *****************************************************************
-     */
-
-    'wsis' => [
-
-        /**
-         * Admin Role Name
-         */
-        'admin-role-name' => 'admin',
-
-        /**
-         * Read only Admin Role Name
-         */
-        'read-only-admin-role-name' => 'admin-read-only',
-
-        /**
-         * Gateway user role
-         */
-        'user-role-name' => 'airavata-user',
-
-        /**
-         * Tenant Domain
-         */
-        'tenant-domain' => '',
-
-        /**
-         * Tenant admin's username
-         */
-        'admin-username' => 'scigap_admin',
-
-        /**
-         * Tenant admin's password
-         */
-        'admin-password' => 'sci9067@min',
-
-        /**
-         * OAuth client key
-         */
-        'oauth-client-key' => 'fI0fo8luZYsDMPqfIYH8fN6wtfMa',
-
-        /**
-         * OAuth client secret
-         */
-        'oauth-client-secret' => 'cRKUjG8jPUgWj7NxUNT5Tf5621Aa',
-
-        /**
-         * Identity server domain
-         */
-        'server' => 'idp.scigap.org',
-
-        /**
-         * Identity server url
-         */
-        'service-url' => 'https://idp.scigap.org:9443/',
-
-        /**
-         * Enable HTTPS server verification
-         */
-        'verify-peer' => true,
-
-        /**
-         * Path to the server certificate file
-         */
-        'cafile-path' => app_path() . '/resources/security/idp_scigap_org.pem',
-
-        /**
-         * Allow self signed server certificates
-         */
-        'allow-self-signed-cert' => false
-    ],
-
-
-    /**
-     * *****************************************************************
-     *  These are Airavata Related Configurations
-     * *****************************************************************
-     */
-    'airavata' => [
-
-        /**
-         * Airavata API server location. Use tls:// as the protocol to
-         * connect TLS enabled Airavata
-         */
-        'airavata-server' => 'gw56.iu.xsede.org',
-
-        /**
-         * Airavata API server port
-         */
-        'airavata-port' => '8930',
-
-        /**
-         * Airavata API server thrift communication timeout
-         */
-        'airavata-timeout' => '1000000',
-
-        /**
-         * PGA Gateway ID
-         */
-        'gateway-id' => 'scigap',
-
-        /**
-         * Maximum size of a file which is allowed to upload to the server
-         */
-        'server-allowed-file-size' => 64,
-
-        /**
-         * directory in the web server where experiment data is staged. (relative to the PGA documents root)
-         */
-        'experiment-data-dir' => '/../experimentData',
-
-        /**
-         * absolute path of the data dir
-         */
-        'experiment-data-absolute-path' => 'C:\wamp\www\experimentData',
-
-       /**
-         * username for the user for accessing the experiment data over ssh
-         */
-        'ssh-user' => 'root',
-
-        /**
-         * Advanced experiments options
-         */
-        'advanced-experiment-options' => '',
-
-        /**
-         * Default queue name
-         */
-        'queue-name' => 'long',
-
-        /**
-         * Default node count
-         */
-        'node-count' => '1',
-
-        /**
-         * Default total core count
-         */
-        'total-cpu-count' => '16',
-
-        /**
-         * Default wall time limit
-         */
-        'wall-time-limit' => '30',
-
-        /**
-         * Enable app-catalog cache
-         */
-        'enable-app-catalog-cache' => true,
-
-        /**
-         * Life time of app catalog data cache in minutes
-         */
-        'app-catalog-cache-duration' => 5
-    ],
-
-    /**
-     * *****************************************************************
-     *  Portal Related Configurations
-     * *****************************************************************
-     */
-    'portal' => [
-    /**
-         * Whether this portal is the SciGaP admin portal
-         */
-        'super-admin-portal' => true,
-
-        /**
-         * Set the name of theme in use here
-         */
-        'theme' => 'base',
-
-        /**
-         * Portal title
-         */
-        'portal-title' => 'SciGaP Admin Portal',
-
-        /**
-         * Email address of the portal admin. Portal admin well get email notifications for events
-         * such as new user creation
-         */
-        'admin-emails' => ['sgg@iu.edu','eroma.abeysinghe@gmail.com','supun.nakandala@gmail.com'],
-
-        /**
-         * Email account that the portal should login to send emails
-         */
-        'portal-email-username' => 'pga.airavata@gmail.com',
-
-        /**
-         * Password for the portal's email account
-         */
-        'portal-email-password' => 'airavata12',
-
-        /**
-         * SMTP server on which the portal should connect
-         */
-        'portal-smtp-server-host' => 'smtp.gmail.com',
-
-        /**
-         * SMTP server port on which the portal should connect
-         */
-        'portal-smtp-server-port' => '587',
-
-        /**
-         * Set JIRA Issue Collector scripts here.
-         */
-        'jira-help' => 
-        [
-            /**
-             * Report Issue Script issued for your app by Atlassian JIRA
-             */
-            'report-issue-script' => '',
-            /**
-             * Collector id at the end of the above script
-             */
-            'report-issue-collector-id' => '',
-            /**
-             * Create Report Script issued for your app by Atlassian JIRA
-             */
-            'request-feature-script' => '',
-            /**
-             * Collector id at the end of the above script
-             */
-            'request-feature-collector-id' => ''
-        ],
-
-        /**
-         * Set Google Analytics Id here. ID format that generates from  
-         * creating tracker object should be 
-         *
-         * UA-XXXXX-Y 
-         *
-         * for it to be working correctly. Currently it is only set for 
-         * sending pageviews.
-         */
-        'google-analytics-id' => ''
-    ]
-);
\ No newline at end of file
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index d41bc2f..601ad8e 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -78,7 +78,7 @@
                 if(! in_array( "gateway-provider", $allRoles)){
                     WSIS::addRole( "gateway-provider");
                 }
-                $userRoles["new"] = array("gateway-provider");
+                $userRoles["new"] = array("gateway-provider", "admin");
             }
             $userRoles["deleted"] = array();
             WSIS::updateUserRoles( $username, $userRoles);
@@ -292,20 +292,26 @@
     }
 
     public function dashboard(){
-        if( Session::has("gateway-provider")){
+
+        $userProfile = Session::get("user-profile");
+
+        if( in_array( "gateway-provider", $userProfile["roles"]) ) {
             $gatewayOfUser = "";
-            //var_dump( Session::get("authz-token")->accessToken); exit;
-            $userProfile = Session::get("user-profile");
+
             $gatewaysInfo = CRUtilities::getAllGateways();
-            foreach( $gatewaysInfo as $index => $gateway){
-                if( $gateway->emailAddress == $userProfile["email"]){
+            var_dump( $gatewaysInfo); exit;
+            foreach ($gatewaysInfo as $index => $gateway) {
+                if ($gateway->emailAddress == $userProfile["email"]) {
                     Session::set("gateway_id", $gateway->gatewayId);
                     $gatewayOfUser = $gateway->gatewayId;
+                    Session::forget("super-admin");
                     break;
                 }
             }
-            if( $gatewayOfUser == ""){
-                Session::put("new-gateway-provider");
+            if ($gatewayOfUser == "") {
+                $userInfo["username"] = $userProfile["username"];
+                $userInfo["email"] = $userProfile["email"];
+                Session::put("new-gateway-provider", true);
             }
         }
 
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index f289e07..e27c30b 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -13,21 +13,29 @@
         
         $userProfile = Session::get("user-profile");
         Session::forget("new-gateway-provider");
-
-        if( in_array( "gateway-provider", $userProfile["roles"]) ){
-			$gatewayOfUser = "";
-        	$gatewaysInfo = CRUtilities::getAllGateways();
-            foreach( $gatewaysInfo as $index => $gateway){
-                if( $gateway->emailAddress == $userProfile["email"]){
+        if( in_array( "gateway-provider", $userProfile["roles"]) ) {
+            $gatewayOfUser = "";
+            $gatewaysInfo = CRUtilities::getAllGateways();
+            //var_dump( $gatewaysInfo); exit;
+            foreach ($gatewaysInfo as $index => $gateway) {
+                if ($gateway->identityServerUserName == $userProfile["username"]) {
                     Session::set("gateway_id", $gateway->gatewayId);
                     $gatewayOfUser = $gateway->gatewayId;
                     Session::forget("super-admin");
+                    Session::put("existing-gateway-provider", true);
+                    if( $gateway->gatewayApprovalStatus == 0){
+                    	Session::put("approvalStatus", "Requested");
+                    }
+                    elseif( $gateway->gatewayApprovalStatus == 3){
+                    	Session::put("approvalStatus", "Denied");
+                    }
                     break;
                 }
             }
-            if( $gatewayOfUser == ""){
-            	$userInfo["username"] = $userProfile["username"];
-            	$userInfo["email"] = $userProfile["email"];
+
+            if ($gatewayOfUser == "") {
+                $userInfo["username"] = $userProfile["username"];
+                $userInfo["email"] = $userProfile["email"];
                 Session::put("new-gateway-provider", true);
             }
         }
@@ -131,6 +139,12 @@
 		}
 	}
 
+	public function updateGatewayRequest(){
+		AdminUtilities::update_gateway_status( Input::get("gateway_id"), Input::get("status"));
+
+		return Redirect::to("admin/dashboard/gateway");
+	}
+
 	public function rolesView(){
 		$roles = WSIS::getAllRoles();
         Session::put("admin-nav", "manage-roles");
@@ -374,6 +388,43 @@
 		}
 	}
 
+
+	public function requestGateway(){
+		$inputs = Input::all();
+		
+		$rules = array(
+            "username" => "required|min:6",
+            "password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#*]).*$/",
+            "confirm_password" => "required|same:password",
+            "email" => "required|email",
+        );
+
+        $messages = array(
+            'password.regex' => 'Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$&*',
+        );
+
+        $checkValidation = array();
+        $checkValidation["username"] = $inputs["admin-username"];
+        $checkValidation["password"] = $inputs["admin-password"];
+        $checkValidation["confirm_password"] = $inputs["admin-password-confirm"];
+        $checkValidation["email"] = $inputs["email-address"];
+
+        $validator = Validator::make( $checkValidation, $rules, $messages);
+        if ($validator->fails()) {
+            Session::put("message", $validator->messages() );
+            return Redirect::to("admin/dashboard");
+        }
+        else{
+	        $gateway = AdminUtilities::request_gateway(Input::all());
+
+			//$tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);
+
+			Session::put("message", "Your request for Gateway " . $inputs["gateway-name"] . " has been created.");
+			
+            return Redirect::to("admin/dashboard");
+		}
+	}
+
     public function enableComputeResource(){
         $resourceId = Input::get("resourceId");
         $computeResource = CRUtilities::get_compute_resource($resourceId);
diff --git a/app/controllers/GatewayController.php b/app/controllers/GatewayController.php
new file mode 100644
index 0000000..48d42e5
--- /dev/null
+++ b/app/controllers/GatewayController.php
@@ -0,0 +1,40 @@
+<?php
+
+class GatewayController extends BaseController {
+
+	public function requestGateway(){
+		$inputs = Input::all();
+
+		$rules = array(
+            "username" => "required|min:6",
+            "password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#*]).*$/",
+            "confirm_password" => "required|same:password",
+            "email" => "required|email",
+        );
+
+        $messages = array(
+            'password.regex' => 'Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$&*',
+        );
+
+        $checkValidation = array();
+        $checkValidation["username"] = $inputs["admin-username"];
+        $checkValidation["password"] = $inputs["admin-password"];
+        $checkValidation["confirm_password"] = $inputs["admin-password-confirm"];
+        $checkValidation["email"] = $inputs["email-address"];
+
+        $validator = Validator::make( $checkValidation, $rules, $messages);
+        if ($validator->fails()) {
+            Session::put("message", implode(",", $validator->messages() ));
+            return Redirect::to("admin/dashboard");
+        }
+        else{
+	        $gateway = AdminUtilities::request_gateway(Input::all());
+
+			Session::put("message", "Your request for Gateway " . $inputs["gatewayName"] . " has been created.");
+			
+            return Redirect::to("admin/dashboard");
+		}
+	}
+
+
+}
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index edb095f..2057a29 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -1,6 +1,7 @@
 <?php
 
 use Airavata\Model\Workspace\Gateway;
+use Airavata\Model\Workspace\GatewayApprovalStatus;
 use Airavata\Model\Workspace\Notification;
 use Airavata\Model\Workspace\NotificationPriority;
 
@@ -22,6 +23,45 @@
         return Airavata::addGateway(Session::get('authz-token'), $gateway);
     }
 
+    public static function request_gateway( $inputs)
+    {
+        $gateway = new Gateway( $inputs);
+        $gateway->gatewayId = $inputs["gateway-name"];
+        $gateway->gatewayApprovalStatus = GatewayApprovalStatus::REQUESTED;
+        $gateway->domain = $inputs["domain"];
+        $gateway->gatewayName = $inputs["gateway-name"];
+        $gateway->emailAddress = $inputs["email-address"];
+        $gateway->gatewayAcronym = $inputs["gateway-acronym"];
+        $gateway->gatewayURL = $inputs["gateway-url"];
+        $gateway->gatewayAdminFirstName = $inputs["admin-firstname"];
+        $gateway->gatewayAdminLastName = $inputs["admin-lastname"];
+        $gateway->identityServerUserName = $inputs["admin-username"];
+        $gateway->identityServerPasswordToken  = $inputs["admin-password"];
+        $gateway->reviewProposalDescription = $inputs["project-details"];
+        $gateway->gatewayPublicAbstract - $inputs["public-project-description"];
+
+        return Airavata::addGateway(Session::get('authz-token'), $gateway);
+
+    }
+
+    public static function update_gateway_status( $gatewayId, $status){
+        $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
+        $gateway->gatewayApprovalStatus = intval( $status);
+        
+        if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway) ){
+            if( $gateway->gatewayApprovalStatus == GatewayApprovalStatus::APPROVED){
+                if( AdminUtilities::add_tenant( $gateway) ){
+                    Adminutilities::update_gateway_status( Input::get("gateway_id"), GatewayApprovalStatus::ACTIVE);
+                }
+            }
+
+        }
+    }
+
+    public static function add_tenant( $gateway){
+        return WSIS::createTenant(1, $gateway->identityServerUserName . "@" . $gateway->domain, $gateway->identityServerPasswordToken, $gateway->emailAddress,$gateway->gatewayAdminFirstName, $gateway->gatewayAdminLastName, $gateway->domain);
+    }
+
     /**
      * Method to get experiment execution statistics object
      * @param $fromTime
diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php
index cebfb90..df385a9 100644
--- a/app/libraries/Airavata/API/Airavata.php
+++ b/app/libraries/Airavata/API/Airavata.php
@@ -106,6 +106,7 @@
    * @param \Airavata\Model\Security\AuthzToken $authzToken
    * @param string $gatewayId
    * @param \Airavata\Model\Workspace\Gateway $updatedGateway
+   * @return bool
    * @throws \Airavata\API\Error\InvalidRequestException
    * @throws \Airavata\API\Error\AiravataClientException
    * @throws \Airavata\API\Error\AiravataSystemException
@@ -3638,7 +3639,7 @@
   public function updateGateway(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, \Airavata\Model\Workspace\Gateway $updatedGateway)
   {
     $this->send_updateGateway($authzToken, $gatewayId, $updatedGateway);
-    $this->recv_updateGateway();
+    return $this->recv_updateGateway();
   }
 
   public function send_updateGateway(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, \Airavata\Model\Workspace\Gateway $updatedGateway)
@@ -3682,6 +3683,9 @@
       $result->read($this->input_);
       $this->input_->readMessageEnd();
     }
+    if ($result->success !== null) {
+      return $result->success;
+    }
     if ($result->ire !== null) {
       throw $result->ire;
     }
@@ -3694,7 +3698,7 @@
     if ($result->ae !== null) {
       throw $result->ae;
     }
-    return;
+    throw new \Exception("updateGateway failed: unknown result");
   }
 
   public function getGateway(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId)
@@ -13763,6 +13767,10 @@
   static $_TSPEC;
 
   /**
+   * @var bool
+   */
+  public $success = null;
+  /**
    * @var \Airavata\API\Error\InvalidRequestException
    */
   public $ire = null;
@@ -13782,6 +13790,10 @@
   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,
@@ -13805,6 +13817,9 @@
         );
     }
     if (is_array($vals)) {
+      if (isset($vals['success'])) {
+        $this->success = $vals['success'];
+      }
       if (isset($vals['ire'])) {
         $this->ire = $vals['ire'];
       }
@@ -13839,6 +13854,13 @@
       }
       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();
@@ -13884,6 +13906,11 @@
   public function write($output) {
     $xfer = 0;
     $xfer += $output->writeStructBegin('Airavata_updateGateway_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);
diff --git a/app/libraries/Airavata/Model/Workspace/Types.php b/app/libraries/Airavata/Model/Workspace/Types.php
index b16d03c..1b516d8 100644
--- a/app/libraries/Airavata/Model/Workspace/Types.php
+++ b/app/libraries/Airavata/Model/Workspace/Types.php
@@ -569,6 +569,26 @@
    * @var string
    */
   public $reviewProposalDescription = null;
+  /**
+   * @var string
+   */
+  public $gatewayAdminFirstName = null;
+  /**
+   * @var string
+   */
+  public $gatewayAdminLastName = null;
+  /**
+   * @var string
+   */
+  public $gatewayAdminEmail = null;
+  /**
+   * @var string
+   */
+  public $identityServerUserName = null;
+  /**
+   * @var string
+   */
+  public $identityServerPasswordToken = null;
 
   public function __construct($vals=null) {
     if (!isset(self::$_TSPEC)) {
@@ -609,6 +629,26 @@
           'var' => 'reviewProposalDescription',
           'type' => TType::STRING,
           ),
+        10 => array(
+          'var' => 'gatewayAdminFirstName',
+          'type' => TType::STRING,
+          ),
+        11 => array(
+          'var' => 'gatewayAdminLastName',
+          'type' => TType::STRING,
+          ),
+        12 => array(
+          'var' => 'gatewayAdminEmail',
+          'type' => TType::STRING,
+          ),
+        13 => array(
+          'var' => 'identityServerUserName',
+          'type' => TType::STRING,
+          ),
+        14 => array(
+          'var' => 'identityServerPasswordToken',
+          'type' => TType::STRING,
+          ),
         );
     }
     if (is_array($vals)) {
@@ -639,6 +679,21 @@
       if (isset($vals['reviewProposalDescription'])) {
         $this->reviewProposalDescription = $vals['reviewProposalDescription'];
       }
+      if (isset($vals['gatewayAdminFirstName'])) {
+        $this->gatewayAdminFirstName = $vals['gatewayAdminFirstName'];
+      }
+      if (isset($vals['gatewayAdminLastName'])) {
+        $this->gatewayAdminLastName = $vals['gatewayAdminLastName'];
+      }
+      if (isset($vals['gatewayAdminEmail'])) {
+        $this->gatewayAdminEmail = $vals['gatewayAdminEmail'];
+      }
+      if (isset($vals['identityServerUserName'])) {
+        $this->identityServerUserName = $vals['identityServerUserName'];
+      }
+      if (isset($vals['identityServerPasswordToken'])) {
+        $this->identityServerPasswordToken = $vals['identityServerPasswordToken'];
+      }
     }
   }
 
@@ -724,6 +779,41 @@
             $xfer += $input->skip($ftype);
           }
           break;
+        case 10:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->gatewayAdminFirstName);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 11:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->gatewayAdminLastName);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 12:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->gatewayAdminEmail);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 13:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->identityServerUserName);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 14:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->identityServerPasswordToken);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
         default:
           $xfer += $input->skip($ftype);
           break;
@@ -782,6 +872,31 @@
       $xfer += $output->writeString($this->reviewProposalDescription);
       $xfer += $output->writeFieldEnd();
     }
+    if ($this->gatewayAdminFirstName !== null) {
+      $xfer += $output->writeFieldBegin('gatewayAdminFirstName', TType::STRING, 10);
+      $xfer += $output->writeString($this->gatewayAdminFirstName);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->gatewayAdminLastName !== null) {
+      $xfer += $output->writeFieldBegin('gatewayAdminLastName', TType::STRING, 11);
+      $xfer += $output->writeString($this->gatewayAdminLastName);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->gatewayAdminEmail !== null) {
+      $xfer += $output->writeFieldBegin('gatewayAdminEmail', TType::STRING, 12);
+      $xfer += $output->writeString($this->gatewayAdminEmail);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->identityServerUserName !== null) {
+      $xfer += $output->writeFieldBegin('identityServerUserName', TType::STRING, 13);
+      $xfer += $output->writeString($this->identityServerUserName);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->identityServerPasswordToken !== null) {
+      $xfer += $output->writeFieldBegin('identityServerPasswordToken', TType::STRING, 14);
+      $xfer += $output->writeString($this->identityServerPasswordToken);
+      $xfer += $output->writeFieldEnd();
+    }
     $xfer += $output->writeFieldStop();
     $xfer += $output->writeStructEnd();
     return $xfer;
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 042b31a..171965a 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -507,7 +507,6 @@
 
     public static function getAllGateways()
     {
-
         if (Session::has("super-admin"))
             $gateways = Airavata::getAllGateways(Session::get('authz-token'));
         else {
diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php
index 1ac6502..16fefc8 100644
--- a/app/libraries/ProjectUtilities.php
+++ b/app/libraries/ProjectUtilities.php
@@ -133,6 +133,7 @@
         $project->name = "Default Project";
         $project->gatewayId = Config::get('pga_config.airavata')['gateway-id'];
         $project->description = "This is the default project for user " . $project->owner;
+        $project->gatewayId = Config::get('pga_config.airavata')['gateway-id'];
 
 
         $projectId = null;
diff --git a/app/routes.php b/app/routes.php
index cd0b20f..a574d21 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -312,6 +312,8 @@
 
 Route::post("admin/remove-pwd-token", "AdminController@removePWD");
 
+//GatewayProviders
+Route::get("provider/request-gateway", "AdminController@requestGateway");
 
 //notices
 Route::get("admin/dashboard/notices", "AdminController@noticesView");
@@ -329,6 +331,8 @@
 Route::post("admin/add-gateway", "AdminController@addGateway");
 Route::get("admin/add-gateway", "AdminController@addGateway");
 
+Route::get("admin/update-gateway-request", "AdminController@updateGatewayRequest");
+
 /*
 * Theme Pages Routes
 */
diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php
index 58c2d69..917319b 100644
--- a/app/views/account/dashboard.blade.php
+++ b/app/views/account/dashboard.blade.php
@@ -22,17 +22,74 @@
         @if( Session::has('new-gateway-provider') )
         <div class="row">
             <div class="col-md-offset-2 col-md-8">
-                <form id="add-tenant-form" action="{{ URL::to("/") }}/provider/add-gateway">
+                <form id="add-tenant-form" action="{{ URL::to('/') }}/provider/request-gateway">
                     <div class="col-md-12 text-center" style="margin-top:50px;">
-                        <h3>Register your gateway now!</h3>
-                        <button type="button" class="btn btn-default toggle-add-tenant"><span
-                                class="glyphicon glyphicon-plus"></span>Add a new gateway
-                        </button>
+                        <h3>Request your gateway now!</h3>
                     </div>
-                    @include('partials/add-gateway-block', $userInfo)
+                    <div class="form-group required">
+                        <label class="control-label">Gateway Name</label>
+                        <input type="text" name="gateway-name" class="form-control" required="required"/>
+                    </div>
+                    <div class="form-group">
+                        <label class="control-label">Gateway Acronym <i>(optional)</i></label>
+                        <input type="text" name="gateway-acronym" class="form-control"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Domain</label>
+                        <input type="text" name="domain" class="form-control"/>
+                    </div>
+
+                    <div class="form-group required">
+                        <label class="control-label">Gateway URL</label>
+                        <input type="text" name="gateway-url" class="form-control"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Gateway Admin Username</label>
+                        <input type="text" name="admin-username" value="{{ Session::get('username') }}" readonly="true" class="form-control" required="required"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Gateway Admin Password</label>
+                        <input type="password" name="admin-password" class="form-control" required="required"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Admin Password Confirmation</label>
+                        <input type="password" name="admin-password-confirm" class="form-control" required="required"/>
+                    </div>
+
+                    <div class="form-group required">
+                        <label class="control-label">Admin First Name</label>
+                        <input type="text" name="admin-firstname" class="form-control" required="required"/>
+                    </div>
+
+                    <div class="form-group required">
+                        <label class="control-label">Admin Last Name</label>
+                        <input type="text" name="admin-lastname" class="form-control" required="required"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Gateway Email</label>
+                        <input type="text" name="email-address" class="form-control" required="required"/>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Project Details</label>
+                        <textarea type="text" name="project-details" class="form-control" required="required"></textarea>
+                    </div>
+                    <div class="form-group required">
+                        <label class="control-label">Public Project Description</label>
+                        <textarea type="text" name="public-project-description" class="form-control" required="required"></textarea>
+                    </div>
+                    <input type="submit" value="Send Request" class="btn btn-primary"/>
+                    <input type="reset" value="Reset" class="btn">
                 </form>
             </div>
         </div>
+        @elseif( Session::has("existing-gateway-provider") )
+            @if( Session::get("approvalStatus") == "Requested")
+                <blockquote>Gateway you have request is yet to be approved. Please log back in after sometime.</blockquote>
+            @elseif( Session::get("approvalStatus") == "Denied")
+                <div class="well alert alert-danger">Unfortunately, Your Request has been denied at this moment.</div>
+            @else
+                <blockquote>Download Credentials | Get Started with your PGA View</blockquote>
+            @endif
         @elseif( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only') )
         <div class="row text-center breathing-space">
             <h1>Let's get started!</h1>
@@ -257,45 +314,6 @@
         $(".add-tenant").slideDown();
     });
 
-    $("#add-tenant-form").submit(function (event) {
-        event.preventDefault();
-        event.stopPropagation();
-        var formData = $("#add-tenant-form").serialize();
-        $("#add-gateway-loading").modal("show");
-        $(".loading-gif").removeClass("hide");
-        $.ajax({
-            type: "POST",
-            data: formData,
-            url: '{{ URL::to("/") }}/admin/add-gateway',
-            success: function (data) {
-                if( data.gateway == $(".gatewayName").val() ){
-                    $(".gateway-success").html("Gateway has been added. The page will be reloaded in a moment.").removeClass("hide");
-                    setTimeout( function(){
-                        location.reload();
-                    }, 2000);
-                }
-                else if( data == 0){
-                    $(".gateway-error").html( "An unknown error occurred while trying to create the gateway.")
-                                        .removeClass("hide");
-                }
-                else{
-                    errors = data;
-                    $(".gateway-error").html("").removeClass("hide");
-                    for( input in data)
-                    {
-                        $(".gateway-error").append(" -- " + input + " : " + data[input] + "<br/><br/>");
-                    }
-                }
-            },
-            error: function( data){
-                var error = $.parseJSON( data.responseText);
-                $(".gateway-error").html(error.error.message).removeClass("hide");
-            }
-        }).complete(function () {
-            $("#add-gateway-loading").modal("hide");
-            $(".loading-gif").addClass("hide");
-        });
-    });
 
 </script>
 @stop
\ No newline at end of file
diff --git a/app/views/admin/manage-gateway.blade.php b/app/views/admin/manage-gateway.blade.php
index 3fb69da..4198db3 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -62,8 +62,44 @@
                     @include('partials/add-gateway-block')
                 </form>
             </div>
+            <div class="row">
+                <div class="col-md-12">
+                    <h3>Gateway Requests</h3>
+                    <table class="table table-striped table-bordered">
+                        <thead>
+                            <tr>
+                                <th>Gateway Name</th>
+                                <th>Admin Name</th>
+                                <th>Gateway URL</th>
+                                <th>Project Details</th>
+                                <th>Project Abstract</th>
+                                <th>Actions</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                        @foreach( $gateways as $indexGP => $gp )
+                            @if( $gp->gatewayApprovalStatus == 0)
+                            <tr>
+                                <td>{{$gp->gatewayName }}</td>
+                                <td>{{ $gp->gatewayAdminFirstName }} {{ $gp->gatewayAdminLastName }} </td>
+                                <td>{{ $gp->gatewayURL }}</td>
+                                <td>{{ $gp->reviewProposalDescription}}</td>
+                                <td>{{ $gp->gatewayPublicAbstract}}</td>
+                                <td>
+                                    <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=1"><input type="button" class="btn btn-primary" value="Approve"/></a>
+                                    <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=3"><input type="button" class="btn btn-danger" value="Deny"/></a>
+                                </td>
+                            </tr>
+                            @endif
+                        @endforeach
+                        <!-- foreach code ends -->
+                        </tbody>
+                    </table>
+                </div>
+            </div>
 
             <div class="panel-group super-admin-gateways-view" id="accordion1">
+                <h3>Approved Gateways</h3>
                 @foreach( $gateways as $indexGP => $gp )
                     @include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
                 @endforeach
diff --git a/app/views/home.blade.php b/app/views/home.blade.php
index a780157..5a89b31 100755
--- a/app/views/home.blade.php
+++ b/app/views/home.blade.php
@@ -28,8 +28,8 @@
         </p>
         <p><a href="https://github.com/apache/airavata-php-gateway"
                 target="_blank">See the code <span class="glyphicon glyphicon-new-window"></span></a></p>
-        <p><a href="https://cwiki.apache.org/confluence/display/AIRAVATA/XSEDE+2015+Tutorial"
-            target="_blank">XSEDE 2015 tutorial documentation <span class="glyphicon glyphicon-new-window"></span></a>
+        <p><a href="https://cwiki.apache.org/confluence/display/AIRAVATA/XSEDE+2016+Tutorials"
+            target="_blank">XSEDE 2016 tutorial documentation <span class="glyphicon glyphicon-new-window"></span></a>
         </p>
     </div>
 </div>