Browse Source

Using fedora item instead of object helper in some cause to prevent exceptions such as object not found in lower level storage.

pull/80/head
Nigel Banks 13 years ago
parent
commit
6bd33358ed
  1. 24
      CollectionClass.inc
  2. 10
      api/fedora_item.inc

24
CollectionClass.inc

@ -45,11 +45,12 @@ class CollectionClass {
* @return type * @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
if (!isset($itqlquery)) { if (!isset($itqlquery)) {
// $query_string = $objectHelper->getStream($pid, 'QUERY', 0); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$itqlquery = $objectHelper->getStream($pid, 'QUERY', 0); $item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$itqlquery = $item->get_datastream_dissemination('QUERY');
}
} }
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset); return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
} }
@ -78,7 +79,11 @@ class CollectionClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$query_string = $itqlquery; $query_string = $itqlquery;
if (!isset($query_string)) { if (!isset($query_string)) {
$query_string = $objectHelper->getStream($pid, 'QUERY', 0); $query_string = NULL;
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query_string = $item->get_datastream_dissemination('QUERY');
}
if ($query_string == NULL) { if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri> $query_string = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
@ -445,7 +450,7 @@ class CollectionClass {
'pidNamespace' => $pidNameSpace 'pidNamespace' => $pidNameSpace
); );
$object = $soapClient->__soapCall('getNextPID', array( $object = $soapClient->__soapCall('getNextPID', array(
$params $params
)); ));
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error');
@ -498,11 +503,10 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionManagement');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); module_load_include('inc', 'fedora_repository', 'BatchIngest');
global $base_url; global $base_url;
$tabset = array();
global $user; global $user;
$objectHelper = new ObjectHelper(); $tabset = array();
$item = new Fedora_Item($this->pid);
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query = $item->get_datastream_dissemination('QUERY'); $query = $item->get_datastream_dissemination('QUERY');
} }
@ -517,7 +521,7 @@ class CollectionClass {
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
if(!empty($policy)){ if (!empty($policy)) {
$content_models = $policy->getContentModels(); $content_models = $policy->getContentModels();
} }
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") {

10
api/fedora_item.inc

@ -934,21 +934,23 @@ class Fedora_Item {
variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
try { try {
$soap_client = self::$connection_helper->getSoapClient($url); $soap_client = self::$connection_helper->getSoapClient($url);
if (empty($soap_client)) { if (isset($soap_client)) {
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
}
else {
if (!$quiet) { if (!$quiet) {
drupal_set_message(t('Error trying to get SOAP client connection.')); drupal_set_message(t('Error trying to get SOAP client connection'));
} }
watchdog('fedora_repository', 'Error trying to get SOAP client connection.'); watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
return NULL; return NULL;
} }
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
} catch (Exception $e) { } catch (Exception $e) {
if (!$quiet) { if (!$quiet) {
preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ? 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('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'); 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); watchdog('fedora_repository', 'Error Trying to call SOAP function "%func". Exception: @e in @f(@l)\n@t', array('%func' => $function, '@e' => $e->getMessage(), '@f' => $e->getFile(), '@l' => $e->getLine(), '@t' => $e->getTraceAsString()), NULL, WATCHDOG_ERROR);
return NULL; return NULL;
} }
return $result; return $result;

Loading…
Cancel
Save