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. 28
      api/fedora_item.inc

28
api/fedora_item.inc

@ -10,9 +10,9 @@ define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#');
define("ISLANDORA_RELS_EXT_URI", 'http://islandora.ca/ontology/relsext#');
define("ISLANDORA_RELS_INT_URI", "http://islandora.ca/ontology/relsint#");
define("RELS_TYPE_URI", 0);
define("RELS_TYPE_PLAIN_LITERAL", 1);
define("RELS_TYPE_STRING", 2);
define("RELS_TYPE_URI", 0);
define("RELS_TYPE_PLAIN_LITERAL", 1);
define("RELS_TYPE_STRING", 2);
define("RELS_TYPE_INT", 3);
define("RELS_TYPE_DATETIME", 4);
@ -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,9 @@ RDF;
* @return type
*/
function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) {
if (!array_key_exists($dsid, datastreams)) {
return NULL;
}
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -859,7 +872,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;
}
/**

Loading…
Cancel
Save