Browse Source

Merge pull request #129 from jmacwilliams/6.x

Removing the random datastream-not-found exceptions from the fedora.log
pull/130/merge
Jonathan Green 13 years ago
parent
commit
9fbde2afe5
  1. 27
      ObjectHelper.inc
  2. 1
      api/fedora_export.inc
  3. 24
      api/fedora_item.inc
  4. 13
      formClass.inc

27
ObjectHelper.inc

@ -624,30 +624,9 @@ class ObjectHelper {
*
*/
function getStream($pid, $dsid, $showError = FALSE) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$soapHelper = new ConnectionHelper();
try {
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
$params = array(
'pid' => "$pid",
'dsID' => "$dsid",
'asOfDateTime' => ""
);
if (!isset($client)) {
drupal_set_message(t('Error connection to Fedora using soap client.'));
return NULL;
}
$object = $client->__soapCall('getDatastreamDissemination', array('parameters' => $params));
} catch (Exception $e) {
if ($showError) {
drupal_set_message(t('Error getting Datastream for %pid and %datastream<br />', array('%pid' => $pid, '%datastream' => $dsid)), 'error');
}
return NULL;
}
$content = $object->dissemination->stream;
$content = trim($content);
return $content;
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new fedora_item($pid);
return $item->get_datastream_dissemination($dsid);
}
/**

1
api/fedora_export.inc

@ -57,7 +57,6 @@ function export_objects_for_pid($pid, $dir, &$log) {
$file = $dir . '/' . $ds->label . '.' . get_file_extension($ds->MIMEType);
$paths[$ds->ID] = $file;
//$content = $ob_helper->getDatastreamDissemination($pid, $ds->ID);
if ($content = $ob_helper->getStream($pid, $ds->ID, FALSE)) {
if (!$fp = @fopen($file, 'w')) {
$log[] = log_line(t("Failed to open file %file to write datastream %dsid for pid %pid", array('%file' => $file, '%dsid' => $ds->ID, '%pid' => $pid)), 'error');

24
api/fedora_item.inc

@ -130,6 +130,7 @@ class Fedora_Item {
$datastream_url = drupal_urlencode($datastream_file);
$url = file_create_url($datastream_url);
// add_datastream_from_url forces a re-sync of the datastream list
$return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
if ($original_path != $datastream_file) {
@ -177,8 +178,10 @@ class Fedora_Item {
'logMessage' => ($logMessage != NULL) ? $logMessage : 'Ingested object ' . $datastream_id
);
return $this->soap_call('addDataStream', $params);
$soap_result = $this->soap_call('addDataStream', $params);
// make sure to refresh the datastream list after adding so this item stays in sync with the repository
$this->datastreams = $this->get_datastreams_list_as_array();
return $soap_result;
}
/**
@ -197,6 +200,7 @@ class Fedora_Item {
$tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str));
fclose($tmpfile);
// add_datastream_from_file forces a re-sync of the datastream list
$returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
unlink($tmpfilename);
return $returnvalue;
@ -513,6 +517,12 @@ RDF;
* @return null
*/
function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) {
if (!array_key_exists($dsid, $this->datastreams)) {
watchdog('fedora_repository', 'Requested invalid datastream dissemination @dsid on object @pid',
array('@dsid' => $dsid, '@pid' => $pid));
return NULL;
}
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -538,6 +548,11 @@ RDF;
* @return type
*/
function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) {
if (!array_key_exists($dsid, $this->datastreams)) {
watchdog('fedora_repository', 'Requested invalid datastream dissemination @dsid on object @pid',
array('@dsid' => $dsid, '@pid' => $pid));
return NULL;
}
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -859,7 +874,10 @@ RDF;
'logMessage' => $log_message,
'force' => $force,
);
return $this->soap_call('purgeDatastream', $params);
$soap_result = $this->soap_call('purgeDatastream', $params);
// make sure to refresh the datastream list after adding so this item stays in sync with the repository
$this->datastreams = $this->get_datastreams_list_as_array();
return $soap_result;
}
/**

13
formClass.inc

@ -817,15 +817,12 @@ class formClass {
* @return string
*/
function createQDCEditForm($pid, $dsid, $client, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$dsid = empty($dsid) ? 'QDC' : $dsid;
try {
$params = array('pid' => "$pid", 'dsID' => "$dsid", 'asOfDateTime' => "");
$object = $client->__soapCall('getDatastreamDissemination', array('parameters' => $params));
} catch (Exception $e) {
return array();
}
$content = $object->dissemination->stream;
$content = trim($content);
$item = new fedora_item($pid);
$content = trim($item->get_datastream_dissemination($dsid));
$doc = new DOMDocument();
if (!$doc->loadXML($content)) {
echo "error loading xml";

Loading…
Cancel
Save