Browse Source

Prevent crash when loading and Fedora is down.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
2d93f6a8d8
  1. 4
      ConnectionHelper.inc
  2. 35
      api/fedora_utils.inc

4
ConnectionHelper.inc

@ -40,7 +40,7 @@ class ConnectionHelper {
return $new_url; return $new_url;
} }
function getSoapClient($url = NULL) { function getSoapClient($url = NULL, $exceptions = TRUE) {
if ($url == NULL) { if ($url == NULL) {
$url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); $url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
} }
@ -52,7 +52,7 @@ class ConnectionHelper {
$client = new SoapClient($this->_fixURL($url, 'anonymous', 'anonymous'), array( $client = new SoapClient($this->_fixURL($url, 'anonymous', 'anonymous'), array(
'login' => 'anonymous', 'login' => 'anonymous',
'password' => 'anonymous', 'password' => 'anonymous',
'exceptions' => TRUE, 'exceptions' => $exceptions,
)); ));
} }
catch (SoapFault $e) { catch (SoapFault $e) {

35
api/fedora_utils.inc

@ -69,18 +69,33 @@ function fedora_available() {
$ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1); $ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1);
// A bit of a hack but the SOAP parser will cause a fatal error if you give it the wrong URL. // A bit of a hack but the SOAP parser will cause a fatal error if you give it the wrong URL.
return (strpos($ret, 'wsdl:definitions') != FALSE); //return (strpos($ret, 'wsdl:definitions') != FALSE);
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$connection_helper = new ConnectionHelper();
$soap_client = $connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall('describeRepository'); try {
echo $result; $connection_helper = new ConnectionHelper();
}
else { $soap_client = $connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection.")); if (!empty($soap_client)) {
return NULL;
$result = $soap_client->__soapCall('describeRepository', array());
}
print 'why am I here?';
return TRUE;
}
catch (SoapFault $e) {
print 'what now?';
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return FALSE;
} }
} }
/** /**

Loading…
Cancel
Save