Browse Source

Fix issue with downloading versioned datastreams.

Had to do with migration to use of newer REST API; it takes the version
parameter differently, as a query parameter instead of a position in the
URL.
pull/101/head
Adam Vessey 13 years ago
parent
commit
8cfdc902ab
  1. 14
      ObjectHelper.inc
  2. 3
      fedora_repository.module

14
ObjectHelper.inc

@ -72,7 +72,6 @@ class ObjectHelper {
return ' '; return ' ';
} }
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE) { if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE) {
if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { if (($cm = ContentModel::loadFromObject($pid)) == FALSE) {
drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error');
@ -91,7 +90,6 @@ class ObjectHelper {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if (isset($item->datastreams[$dsID])) { if (isset($item->datastreams[$dsID])) {
$mimeType = $item->datastreams[$dsID]['MIMEType']; $mimeType = $item->datastreams[$dsID]['MIMEType'];
if ($label == NULL) { if ($label == NULL) {
@ -123,8 +121,14 @@ class ObjectHelper {
$mimeType = 'image/jpeg'; $mimeType = 'image/jpeg';
} }
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content'; $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content';
$query_options = array();
if ($version) { if ($version) {
$url .= '/' . $version; //drupal_urlencode($version); $query_options['asOfDateTime'] = $version; //drupal_urlencode($version);
}
if ($query_options) {
$url = url($url, array(
'query' => $query_options,
));
} }
$ch = curl_init(); $ch = curl_init();
$user_agent = "Mozilla/4.0 pp(compatible; MSIE 5.01; Windows NT 5.0)"; $user_agent = "Mozilla/4.0 pp(compatible; MSIE 5.01; Windows NT 5.0)";
@ -184,7 +188,6 @@ class ObjectHelper {
$curl_out = curl_exec($ch); $curl_out = curl_exec($ch);
if ($curl_out !== FALSE) { if ($curl_out !== FALSE) {
$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
//dd($info, 'effective URL');
if ($url !== $info) { //Handle redirect streams (the final URL is not the same as the Fedora URL) if ($url !== $info) { //Handle redirect streams (the final URL is not the same as the Fedora URL)
//Add the parameters passed to Drupal, leaving out the 'q' //Add the parameters passed to Drupal, leaving out the 'q'
@ -195,7 +198,7 @@ class ObjectHelper {
} }
header('HTTP/1.1 307 Moved Temporarily'); header('HTTP/1.1 307 Moved Temporarily');
header('Location: ' . $info . '?' . http_build_query($query)); //Fedora seems to discard the query portion. header('Location: ' . url($info, array('query' => $query)));
} }
elseif ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { //If not anonymous, soap is force or we're using HTTPS elseif ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { //If not anonymous, soap is force or we're using HTTPS
//Have the webserver mediate the transfer (download and restream) //Have the webserver mediate the transfer (download and restream)
@ -211,6 +214,7 @@ class ObjectHelper {
} }
else { else {
//Curl error... //Curl error...
watchdog('fedora_repository', 'Curl error. Info: @info', array('@info' => print_r(curl_getinfo($ch), TRUE)), WATCHDOG_WARNING);
} }
} }
curl_close($ch); curl_close($ch);

3
fedora_repository.module

@ -2272,9 +2272,6 @@ function theme_fedora_repository_solution_packs_list($solution_packs) {
$header = array(); $header = array();
$rows = array(); $rows = array();
drupal_add_css(drupal_get_path('module', 'update') . '/update.css'); drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
return $output; return $output;
} }

Loading…
Cancel
Save