From c59290c9c76501846fe2454d27e0ab1090b22256 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 28 Mar 2012 13:22:16 -0300 Subject: [PATCH 1/3] ISLANDORA-548 Updated curl call in ObjectHelper The ObjectHelper.inc file uses the deprecated API-A Lite API, i.e. localhost:8080/fedora/get/{pid}/{dsID} This causes problems when XACML policies are in place that require access to certain datastreams based on fedoraRole. Basically, despite sending accurate credentials in the GET request, the fedoraRole is not recognized by fedora's AttributeFinderModule, and a user cannot access a particular datastream. The protected datastreams, however, are viewable in Fedora's admin console (while using the same credentials) since that uses the REST API. Updated the curl call to use the new REST API. --- ObjectHelper.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index fa6e2a06..31a0ccd2 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -122,8 +122,7 @@ class ObjectHelper { $dsID = variable_get('fedora_default_display_dsid', 'TN'); $mimeType = 'image/jpeg'; } - - $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $pid . '/' . $dsID; + $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content'; if ($version) { $url .= '/' . $version; //drupal_urlencode($version); } From 0b40b559811f0b2d60a10c1e643eb45fc1693bb3 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 28 Mar 2012 13:45:27 -0300 Subject: [PATCH 2/3] Added the quiet=true flag to fedora_item.inc In Fedora item when you call the constructor it automatically does a getObjectProfile soap call. This was reporting soap errors when called on an item that dosen't exist, we don't want to show the user this. --- api/fedora_item.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 7e4810e5..2809f384 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -59,7 +59,7 @@ class Fedora_Item { self::$connection_helper = new ConnectionHelper(); } - $raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => "")); + $raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => ""), TRUE); if (!empty($raw_objprofile)) { $this->objectProfile = $raw_objprofile->objectProfile; From 17a91d971cb44a5d794b40e87029228e448ab8a7 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 28 Mar 2012 22:45:35 -0300 Subject: [PATCH 3/3] ISLANDORA-479 Error replacing X Datastream When you tried to replace a datastream that was anything but managed, you would get a SOAP error. Changed this behavior so that you can replace a managed datastream, an inline xml datastream, and it gives a reasonable warning if you try to replace a reference or redirect datastream. --- fedora_repository.module | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index ff1825c9..42eb4c49 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -617,7 +617,7 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) { * @param type $collectionName * @return type */ -function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { +function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectionName = NULL) { if ($pid == NULL || $dsId == NULL) { drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); return ''; @@ -707,8 +707,20 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) { $dformat = $mimetype->getType($file->filepath); $item = new Fedora_Item($pid); + $info = $item->get_datastream_info($dsid); - $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); + if($info->datastream->controlGroup == 'M') { + $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); + } elseif ($info->datastream->controlGroup == 'X') { + if($dformat == 'text/xml') { + $item->modify_datastream_by_value(file_get_contents($file->filepath), $dsid, $dsLabel, $dformat); + } + else { + drupal_set_message('File must be of mimetype text/xml in order to replace inline XML datastream.', 'error'); + } + } else { + drupal_set_message('Cannot replace Redirect or Managed Datastream.', 'error'); + } $form_state['redirect'] = 'fedora/repository/' . $pid; }