Browse Source

updated getStream function to use fedora_item to retrieve the datastream dissemination instead of calling soap directly, the result error filtering on the output

pull/129/head
Jason MacWilliams 13 years ago
parent
commit
13781d24f7
  1. 31
      ObjectHelper.inc

31
ObjectHelper.inc

@ -233,8 +233,8 @@ class ObjectHelper {
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)
if (($contentSize = self::getDatastreamSize($pid, $dsID, TRUE)) > 0) { if (($contentSize = self::getDatastreamSize($pid, $dsID, TRUE)) > 0) {
header("Content-Length: $contentSize"); header("Content-Length: $contentSize");
} }
$opts = array( $opts = array(
@ -624,30 +624,9 @@ class ObjectHelper {
* *
*/ */
function getStream($pid, $dsid, $showError = FALSE) { function getStream($pid, $dsid, $showError = FALSE) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$soapHelper = new ConnectionHelper(); $item = new fedora_item($pid);
try { return $item->get_datastream_dissemination($dsid);
$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;
} }
/** /**

Loading…
Cancel
Save