Browse Source

added checks to get_datastream and get_datastream_dissemination to filter for missing datastreams, also updated add_datastream_from_* and purge_datastrea to resync the datastream list so the checks are consistent

pull/129/head
Jason MacWilliams 13 years ago
parent
commit
cfe5efd06b
  1. 22
      api/fedora_item.inc

22
api/fedora_item.inc

@ -130,6 +130,7 @@ class Fedora_Item {
$datastream_url = drupal_urlencode($datastream_file); $datastream_url = drupal_urlencode($datastream_file);
$url = file_create_url($datastream_url); $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); $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
if ($original_path != $datastream_file) { if ($original_path != $datastream_file) {
@ -177,8 +178,10 @@ class Fedora_Item {
'logMessage' => ($logMessage != NULL) ? $logMessage : 'Ingested object ' . $datastream_id 'logMessage' => ($logMessage != NULL) ? $logMessage : 'Ingested object ' . $datastream_id
); );
$soap_result = $this->soap_call('addDataStream', $params);
return $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'); $tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str)); fwrite($tmpfile, $str, strlen($str));
fclose($tmpfile); 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); $returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
unlink($tmpfilename); unlink($tmpfilename);
return $returnvalue; return $returnvalue;
@ -513,6 +517,12 @@ RDF;
* @return null * @return null
*/ */
function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) { 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( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
@ -538,6 +548,9 @@ RDF;
* @return type * @return type
*/ */
function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) { function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) {
if (!array_key_exists($dsid, datastreams)) {
return NULL;
}
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
@ -859,7 +872,10 @@ RDF;
'logMessage' => $log_message, 'logMessage' => $log_message,
'force' => $force, '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;
} }
/** /**

Loading…
Cancel
Save