Browse Source

Cleaned up the function soap_call(). It was using watchdog incorrectly, causing the function to attempt to serialize non-serializable data.

pull/80/head
Nigel Banks 13 years ago
parent
commit
0ba035d4da
  1. 103
      api/fedora_item.inc

103
api/fedora_item.inc

@ -18,6 +18,22 @@ class Fedora_Item {
public $datastreams = NULL;
private static $connection_helper = NULL;
private static $instantiated_pids = array();
private static $SoapManagedFunctions = array(
'ingest',
'addDataStream',
'addRelationship',
'export',
'getDatastream',
'getDatastreamHistory',
'getNextPID',
'getRelationships',
'modifyDatastreamByValue',
'modifyDatastreamByReference',
'purgeDatastream',
'purgeObject',
'modifyObject',
'setDatastreamState'
);
/**
* Create an object to represent an item in the Fedora repository.
@ -164,7 +180,6 @@ class Fedora_Item {
return $returnvalue;
}
/**
* Wrapper to add new or modify existing datastream
* @global url $base_url
@ -662,11 +677,9 @@ class Fedora_Item {
/**
* Set the object to a deleted state
*/
function move_to_trash($log_message = 'Flagged deleted using Islandora API.')
{
function move_to_trash($log_message = 'Flagged deleted using Islandora API.') {
// Loop through the datastreams and mark them deleted
foreach($this->get_datastreams_list_as_array() as $dsid)
{
foreach ($this->get_datastreams_list_as_array() as $dsid) {
$this->set_datastream_state($dsid, 'D');
}
@ -899,75 +912,45 @@ class Fedora_Item {
}
/**
* Soap call
* @param type $function_name
* @param type $params_array
* @param type $quiet
* @return type
* Make a soap call to the fedora API.
*
* @param string $function
* The name of the soap function to call.
* @param array $parameters
* Paramters to pass onto the soap call
* @param boolean $quiet
* If TRUE suppress drupal messages.
*
* @return mixed
* The return value from the soap function if successful, NULL otherwise.
*/
static function soap_call($function_name, $params_array, $quiet = FALSE) {
static function soap_call($function, $parameters, $quiet = FALSE) {
if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper();
}
switch ($function_name) {
case 'ingest':
case 'addDataStream':
case 'addRelationship':
case 'export':
case 'getDatastream':
case 'getDatastreamHistory':
case 'getNextPID':
case 'getRelationships':
case 'modifyDatastreamByValue':
case 'modifyDatastreamByReference':
case 'purgeDatastream':
case 'purgeObject':
case 'modifyObject':
case 'setDatastreamState':
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ?
variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl') :
variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
try {
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
$soap_client = self::$connection_helper->getSoapClient($url);
if (empty($soap_client)) {
if (!$quiet) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
}
else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
}
watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
drupal_set_message(t('Error trying to get SOAP client connection.'));
}
watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
return NULL;
}
break;
default:
try {
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
} catch (Exception $e) {
if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ?
drupal_set_message(t('Insufficient permissions to call SOAP function "%func".', array('%func' => $function)), 'error') :
drupal_set_message(t('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error');
}
watchdog('fedora_repository', 'Error Trying to call SOAP function "%func". Exception Occured: @e', array('%func' => $function, '@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
return NULL;
}
}
return $result;
}

Loading…
Cancel
Save