From 15a09635819b9489075b6db7c2e961f0ab9fc7a2 Mon Sep 17 00:00:00 2001 From: ppound Date: Thu, 2 Feb 2012 13:07:07 -0400 Subject: [PATCH] updated soap connection to be session aware --- ConnectionHelper.inc | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/ConnectionHelper.inc b/ConnectionHelper.inc index 59f811e2..71a83bc9 100644 --- a/ConnectionHelper.inc +++ b/ConnectionHelper.inc @@ -1,7 +1,5 @@ _fixURL($url, 'anonymous', 'anonymous'), array( - 'login' => 'anonymous', - 'password' => 'anonymous', - 'exceptions' => $exceptions, - )); + 'login' => 'anonymous', + 'password' => 'anonymous', + 'exceptions' => $exceptions, + )); } catch (SoapFault $e) { drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); return NULL; @@ -78,15 +76,32 @@ class ConnectionHelper { else { try { $client = new SoapClient($this->_fixURL($url, $user->name, $user->pass), array( - 'login' => $user->name, - 'password' => $user->pass, - 'exceptions' => TRUE, - )); + 'login' => $user->name, + 'password' => $user->pass, + 'exceptions' => TRUE, + )); } catch (SoapFault $e) { drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); return NULL; } } + if (isset($_SESSION['islandora_soapcookies'])) { + + // just set the cookies + + $client->_cookies = ($_SESSION['islandora_soapcookies']); + } + else { + try { + //we need to make a call to set the cookie this extra call would only happen once per session + $client->__soapCall('describeRepository', array()); + } catch (exception $e) { + //connection is tested elsewhere so eat this for now here we just want the cookie + } + $_SESSION['islandora_soapcookies'] = $client->_cookies; + } + + return $client; }