From 9885b504aac0d6197afbb4a2446b0c488a0d820d Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Fri, 3 Jun 2011 10:31:19 -0300 Subject: [PATCH 1/8] Updated fedora_repository.info for the release --- fedora_repository.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.info b/fedora_repository.info index b96ad9df..aec1d272 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -4,5 +4,5 @@ dependencies[] = imageapi dependencies[] = tabs description = Shows a list of items in a fedora collection. package = Fedora Repository -version = 6.1dev +version = 6.x-11.1.0 core = 6.x From 1621d43ad5ae0b2af89e0a09d94cf0095e061f69 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Fri, 3 Jun 2011 10:43:24 -0300 Subject: [PATCH 2/8] Updated fedora_repository.info for release 11.1.1 --- fedora_repository.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.info b/fedora_repository.info index aec1d272..9961a508 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -4,5 +4,5 @@ dependencies[] = imageapi dependencies[] = tabs description = Shows a list of items in a fedora collection. package = Fedora Repository -version = 6.x-11.1.0 +version = 6.x-11.1.1 core = 6.x From d00be1a4a935daaac77c175296f5fe1e20892f6e Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Mon, 16 Apr 2012 10:19:08 -0300 Subject: [PATCH 3/8] Updated version to 12.1-RC1 --- fedora_repository.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.info b/fedora_repository.info index 018910bf..6d3135d1 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -4,5 +4,5 @@ dependencies[] = tabs dependencies[] = islandora_content_model_forms description = Shows a list of items in a fedora collection. package = Islandora -version = 6.x-dev +version = 6.x-12.1-RC1 core = 6.x From a6929d8c281beff690fe83b6ae137c35296aab9e Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 17 Apr 2012 10:03:06 -0300 Subject: [PATCH 4/8] new version --- plugins/fedora_imageapi.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fedora_imageapi.info b/plugins/fedora_imageapi.info index 3a9deea7..e94cc30c 100644 --- a/plugins/fedora_imageapi.info +++ b/plugins/fedora_imageapi.info @@ -3,5 +3,5 @@ description = Adds image manipulation support through a REST interface package = Islandora Dependencies dependencies[] = fedora_repository dependencies[] = imageapi -version = 11.3.1 +version = 6.x-12.1-RC1 core = 6.x From 7b3463ba5acc59378f06b639018d5879b3c0e1fe Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Thu, 5 Jul 2012 11:14:07 -0300 Subject: [PATCH 5/8] added mappings for mkv and wmv files --- MimeClass.inc | 2 ++ fedora_repository.module | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MimeClass.inc b/MimeClass.inc index dacde76c..97825c41 100644 --- a/MimeClass.inc +++ b/MimeClass.inc @@ -175,6 +175,8 @@ class MimeClass { "movie" => "video/x-sgi-movie", "flv" => "video/x-flv", "swf" => "application/x-shockwave-flash", + 'mkv' => "video/x-matroska", + 'wmv' => 'video/x-ms-wmv', // audio: "mp3" => "audio/mpeg", "mp4a" => "audio/mp4", diff --git a/fedora_repository.module b/fedora_repository.module index 6b59ed9a..677fb8be 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -125,7 +125,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'ContentModel'); - +var_dump($form_state); $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); $err = TRUE; From bdf38c6a01f8da1d8ecb7791fc73d7864919ff48 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Thu, 5 Jul 2012 11:20:16 -0300 Subject: [PATCH 6/8] removed debug message --- fedora_repository.module | 1 - 1 file changed, 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index 677fb8be..04e9f355 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -125,7 +125,6 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'ContentModel'); -var_dump($form_state); $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); $err = TRUE; From fcaa12f57f4e68aa93ce1ec03bd7ec41c14149ca Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Fri, 6 Jul 2012 08:27:38 -0300 Subject: [PATCH 7/8] Made version numbers conform --- fedora_repository.info | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fedora_repository.info b/fedora_repository.info index 00f29b64..018910bf 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -3,9 +3,6 @@ dependencies[] = imageapi dependencies[] = tabs dependencies[] = islandora_content_model_forms description = Shows a list of items in a fedora collection. - package = Islandora - -version = 6.x-11.1.1 - +version = 6.x-dev core = 6.x From 1bb2f4805f51d58a2cce80247b59605b37c39f80 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Thu, 16 Aug 2012 14:42:50 -0300 Subject: [PATCH 8/8] updated get_ref_relationships to accomodate new namespaces --- api/fedora_item.inc | 137 +++++++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 58 deletions(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 03de0605..7ce42b57 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -118,7 +118,7 @@ class Fedora_Item { drupal_set_message(t('The datastream file %datastream_file could not be read! (likely due to permissions...)', array('%datastream_file' => $datastream_file)), 'warning'); return; } - + if (empty($datastream_mimetype)) { // Get mime type from the file extension. $mimetype_helper = new MimeClass(); @@ -158,7 +158,7 @@ class Fedora_Item { // Fedora has some problems getting files from HTTPS connections sometimes, so if we are getting a file // from the local drupal, we try to pass a HTTP url instead of a HTTPS one. - if(stripos($datastream_url, 'https://') !== FALSE && stripos($datastream_url, $base_url) !== FALSE) { + if (stripos($datastream_url, 'https://') !== FALSE && stripos($datastream_url, $base_url) !== FALSE) { $datastream_url = str_ireplace('https://', 'http://', $datastream_url); } @@ -255,7 +255,7 @@ class Fedora_Item { if ($relsextxml === NULL) { $relsextxml = new DOMDocument(); //Avoid new instantiations in long-running processes } - + $ds_list = $this->get_datastreams_list_as_array(); $f_prefix = 'info:fedora/'; if (!array_key_exists('RELS-EXT', $ds_list)) { @@ -269,7 +269,7 @@ RDF; } $relsext = $this->get_datastream_dissemination('RELS-EXT'); - + if ($literal_value == REL_TYPE_URI && strpos($object, $f_prefix) !== 0) { $object = $f_prefix . $object; } @@ -308,7 +308,7 @@ RDF; } $description->appendChild($newrel); - + return $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'application/rdf+xml'); //print ($description->dump_node()); /* @@ -341,37 +341,37 @@ RDF; */ function purge_relationships($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) { $relsext = $this->get_datastream_dissemination('RELS-EXT'); - + $relsextxml = new DomDocument(); $relsextxml->loadXML($relsext); $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { // iterate backwards so if we delete something our pointer doesn't get out of sync - for ($i = $rels->length; $i>0; $i--) { - $rel = $rels->item($i-1); + for ($i = $rels->length; $i > 0; $i--) { + $rel = $rels->item($i - 1); // foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted - if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. - empty($object) || - (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || - (($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) || - (($literal_value == RELS_TYPE_STRING) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#string' && $rel->textContent == $object) || - (($literal_value == RELS_TYPE_INT) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#int' && intval($rel->textContent) == $object)) { + if (//If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. + empty($object) || + (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || + (($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) || + (($literal_value == RELS_TYPE_STRING) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#string' && $rel->textContent == $object) || + (($literal_value == RELS_TYPE_INT) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#int' && intval($rel->textContent) == $object)) { $rel->parentNode->removeChild($rel); $modified = TRUE; } } } - + //Save changes. if ($modified) { $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); } - + //Return whether or not we've introduced any changes. return $modified; } - + /** * Removes the given relationship from the item's RELS-EXT and re-saves it. * @@ -529,7 +529,7 @@ RDF; 'dsID' => $dsid, 'asOfDateTime' => $as_of_date_time, ); - + // Make soap call with quite $object = self::soap_call('getDataStreamDissemination', $params, $quiet); if (!empty($object)) { @@ -684,7 +684,7 @@ RDF; if (!is_array($this->datastreams_list->datastreamDef)) { $xml_list = array($xml_list); } - + foreach ($xml_list as $ds) { if (!is_object($ds)) { print_r($ds); @@ -752,8 +752,26 @@ RDF; return $relationships; } - function get_rdf_relationships() { + /** + * Retrieves RELS-EXT values from item + * + * @param array $namespaces + * @return array + */ + function get_rdf_relationships($namespaces = null) { + if ($namespaces == NULL) { + $namespaces = array( + RELS_EXT_URI, + FEDORA_MODEL_URI, + ISLANDORA_PAGE_URI, + ISLANDORA_RELS_EXT_URI, + ISLANDORA_RELS_INT_URI, + ); + } + if (!is_array($namespaces)) { + $namespaces = array($namespaces); + } $relationships = array(); try { $relsext = $this->get_datastream_dissemination('RELS-EXT'); @@ -767,13 +785,16 @@ RDF; $relsextxml->loadXML($relsext); $relsextxml->normalizeDocument(); $allTags = array(); - $allTags[] = $relsextxml->getElementsByTagNameNS(RELS_EXT_URI, '*'); - $allTags[] = $relsextxml->getElementsByTagNameNS(FEDORA_MODEL_URI, '*'); - $allTags[] = $relsextxml->getElementsByTagNameNS(ISLANDORA_PAGE_URI, '*'); + foreach ($namespaces as $namespace) { + $allTags[] = $relsextxml->getElementsByTagNameNS($namespace, '*'); + } + foreach ($allTags as $tags) { foreach ($tags as $child) { - $value = preg_replace('/info:fedora\//','',$child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource')); - + $value = preg_replace('/info:fedora\//', '', $child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource')); + if (!$value) { + $value = $child->textContent; + } $relationships[$child->tagName][] = $value; } } @@ -980,9 +1001,9 @@ RDF; $params = array( 'pid' => $this->pid, - 'ownerId' => (($ownerId !== NULL)? //Default to the current owner if none is provided. - $ownerId: - $this->objectProfile->objOwnerId), + 'ownerId' => (($ownerId !== NULL) ? //Default to the current owner if none is provided. + $ownerId : + $this->objectProfile->objOwnerId), 'state' => $state, 'label' => $label, 'logMessage' => $logMessage @@ -1016,32 +1037,32 @@ RDF; $components = explode('/', $parsed_url['path']); $components = array_map('rawurlencode', $components); $fixed_url = url( - t( - '!scheme://!user:!pass@!host:!port/!path', - array( - '!scheme' => $parsed_url['scheme'], - '!user' => rawurlencode($parsed_url['user']), - '!pass' => rawurlencode($parsed_url['pass']), - '!host' => $parsed_url['host'], - '!port' => $parsed_url['port'], - '!path' => implode('/', $components), - ) - ), - array( - 'query' => $parsed_url['query'], - 'fragment' => $parsed_url['fragment'], - ) + t( + '!scheme://!user:!pass@!host:!port/!path', + array( + '!scheme' => $parsed_url['scheme'], + '!user' => rawurlencode($parsed_url['user']), + '!pass' => rawurlencode($parsed_url['pass']), + '!host' => $parsed_url['host'], + '!port' => $parsed_url['port'], + '!path' => implode('/', $components), + ) + ), + array( + 'query' => $parsed_url['query'], + 'fragment' => $parsed_url['fragment'], + ) ); $result = drupal_http_request($fixed_url); - if ((int)($result->code / 100) === 2) { + if ((int) ($result->code / 100) === 2) { $content = $result->data; } else { watchdog('fedora_repository', 'Failed making HTTP request to @URL. Info: @info', array( '@URL' => $fixed_url, '@info' => print_r($result, TRUE), - ), 'warning'); + ), 'warning'); } } @@ -1091,7 +1112,7 @@ RDF; $content = $filename_or_content; } } - + $toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage); } //Otherwise, write to web-accessible temp file and modify by reference. @@ -1099,7 +1120,7 @@ RDF; $file = ''; $created_temp = FALSE; if (is_file($filename_or_content) && is_readable($filename_or_content)) { - $file = $filename_or_content; + $file = $filename_or_content; $original_path = $file; // Temporarily move file to a web-accessible location. file_copy($file, file_directory_path()); @@ -1117,21 +1138,21 @@ RDF; $file = file_save_data($filename_or_content, file_create_filename($label, file_directory_path())); $created_temp = TRUE; } - + $parts = explode(DIRECTORY_SEPARATOR, $file); $parts = array_map('rawurlencode', $parts); $file_url = file_create_url(implode(DIRECTORY_SEPARATOR, $parts)); - + $toReturn = $this->modify_datastream_by_reference($file_url, $dsid, $label, $mime_type, $force, $logMessage); - + if ($created_temp && is_file($file) && is_writable($file)) { file_delete($file); } } - + return $toReturn; } - + /** * Modify datastream by reference * @param type $external_url @@ -1148,10 +1169,10 @@ RDF; // Fedora has some problems getting files from HTTPS connections sometimes, so if we are getting a file // from the local drupal, we try to pass a HTTP url instead of a HTTPS one. - if(stripos($external_url, 'https://') !== FALSE && stripos($external_url, $base_url) !== FALSE) { + if (stripos($external_url, 'https://') !== FALSE && stripos($external_url, $base_url) !== FALSE) { $external_url = str_ireplace('https://', 'http://', $external_url); } - + $params = array( 'pid' => $this->pid, 'dsID' => $dsid, @@ -1228,10 +1249,10 @@ RDF; self::$connection_helper = new ConnectionHelper(); } $url = ( - in_array($function, self::$SoapManagedFunctions)? - variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') : - variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl') - ); + in_array($function, self::$SoapManagedFunctions) ? + variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') : + variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl') + ); try { $soap_client = self::$connection_helper->getSoapClient($url); if (isset($soap_client)) {