Browse Source

Merge pull request #174 from willtp87/ISLANDORA-757

Islandora 757
pull/175/head
Jonathan Green 12 years ago
parent
commit
b928f45e36
  1. 242
      api/fedora_item.inc
  2. 236
      fedora_repository.install
  3. 2
      formClass.inc

242
api/fedora_item.inc

@ -1,9 +1,9 @@
<?php <?php
/** /**
* @file * @file
* Fedora Item * Fedora Item
*/ */
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#'); define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#'); define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#');
@ -21,9 +21,13 @@ define("RELS_TYPE_DATETIME", 4);
*/ */
class Fedora_Item { class Fedora_Item {
public $pid = NULL; // The $pid of the fedora object represented by an instance of this class. // The $pid of the fedora object represented by an instance of this class.
public $pid = NULL;
public $objectProfile = NULL; public $objectProfile = NULL;
private $datastreams_list = NULL; // A SimpleXML object to store a list of this item's datastreams public $ownerId = NULL;
// A SimpleXML object to store a list of this item's datastreams.
private $datastreams_list = NULL;
public $datastreams = NULL; public $datastreams = NULL;
private static $connection_helper = NULL; private static $connection_helper = NULL;
private static $instantiated_pids = array(); private static $instantiated_pids = array();
@ -41,7 +45,7 @@ class Fedora_Item {
'purgeDatastream', 'purgeDatastream',
'purgeObject', 'purgeObject',
'modifyObject', 'modifyObject',
'setDatastreamState' 'setDatastreamState',
); );
/** /**
@ -49,6 +53,8 @@ class Fedora_Item {
* Throws a SOAPException if the PID is not in the repository. * Throws a SOAPException if the PID is not in the repository.
* *
* @param string $pid * @param string $pid
* The Fedora PID to create an object for.
*
* @return Fedora_Item * @return Fedora_Item
*/ */
function __construct($pid) { function __construct($pid) {
@ -61,6 +67,7 @@ class Fedora_Item {
$this->objectProfile = & Fedora_Item::$instantiated_pids[$pid]->objectProfile; $this->objectProfile = & Fedora_Item::$instantiated_pids[$pid]->objectProfile;
$this->datastreams = & Fedora_Item::$instantiated_pids[$pid]->datastreams; $this->datastreams = & Fedora_Item::$instantiated_pids[$pid]->datastreams;
$this->datastreams_list = & Fedora_Item::$instantiated_pids[$pid]->datastreams_list; $this->datastreams_list = & Fedora_Item::$instantiated_pids[$pid]->datastreams_list;
$this->ownerId = & Fedora_Item::$instantiated_pids[$pid]->ownerId;
} }
else { else {
if (empty(self::$connection_helper)) { if (empty(self::$connection_helper)) {
@ -72,10 +79,12 @@ class Fedora_Item {
if (!empty($raw_objprofile)) { if (!empty($raw_objprofile)) {
$this->objectProfile = $raw_objprofile->objectProfile; $this->objectProfile = $raw_objprofile->objectProfile;
$this->datastreams = $this->get_datastreams_list_as_array(); $this->datastreams = $this->get_datastreams_list_as_array();
$this->ownerId = & Fedora_Item::getOwnerId($pid);
} }
else { else {
$this->objectProfile = ''; $this->objectProfile = '';
$this->datastreams = array(); $this->datastreams = array();
$this->ownerId = NULL;
} }
Fedora_Item::$instantiated_pids[$pid] = &$this; Fedora_Item::$instantiated_pids[$pid] = &$this;
} }
@ -92,6 +101,7 @@ class Fedora_Item {
/** /**
* Exists * Exists
*
* @return type * @return type
*/ */
function exists() { function exists() {
@ -100,12 +110,14 @@ class Fedora_Item {
/** /**
* Add datastream from file * Add datastream from file
*
* @param type $datastream_file * @param type $datastream_file
* @param type $datastream_id * @param type $datastream_id
* @param type $datastream_label * @param type $datastream_label
* @param type $datastream_mimetype * @param type $datastream_mimetype
* @param type $controlGroup * @param type $controlGroup
* @param type $logMessage * @param type $logMessage
*
* @return type * @return type
*/ */
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) {
@ -130,7 +142,7 @@ class Fedora_Item {
$datastream_url = drupal_urlencode($datastream_file); $datastream_url = drupal_urlencode($datastream_file);
$url = file_create_url($datastream_url); $url = file_create_url($datastream_url);
// add_datastream_from_url forces a re-sync of the datastream list // 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); $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
if ($original_path != $datastream_file) { if ($original_path != $datastream_file) {
@ -141,12 +153,14 @@ class Fedora_Item {
/** /**
* Add datastream from url * Add datastream from url
*
* @param type $datastream_url * @param type $datastream_url
* @param type $datastream_id * @param type $datastream_id
* @param type $datastream_label * @param type $datastream_label
* @param type $datastream_mimetype * @param type $datastream_mimetype
* @param type $controlGroup * @param type $controlGroup
* @param type $logMessage * @param type $logMessage
*
* @return type * @return type
*/ */
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) {
@ -175,23 +189,25 @@ class Fedora_Item {
'dsState' => 'A', 'dsState' => 'A',
'checksumType' => 'DISABLED', 'checksumType' => 'DISABLED',
'checksum' => 'none', 'checksum' => 'none',
'logMessage' => ($logMessage != NULL) ? $logMessage : 'Ingested object ' . $datastream_id 'logMessage' => ($logMessage != NULL) ? $logMessage : 'Ingested object ' . $datastream_id,
); );
$soap_result = $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 // 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(); $this->datastreams = $this->get_datastreams_list_as_array();
return $soap_result; return $soap_result;
} }
/** /**
* Add datastream from string * Add datastream from string
*
* @param type $str * @param type $str
* @param type $datastream_id * @param type $datastream_id
* @param type $datastream_label * @param type $datastream_label
* @param type $datastream_mimetype * @param type $datastream_mimetype
* @param type $controlGroup * @param type $controlGroup
* @param type $logMessage * @param type $logMessage
*
* @return type * @return type
*/ */
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = NULL) { function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = NULL) {
@ -200,7 +216,7 @@ class Fedora_Item {
$tmpfile = fopen($tmpfilename, 'w'); $tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str)); fwrite($tmpfile, $str, strlen($str));
fclose($tmpfile); fclose($tmpfile);
// add_datastream_from_file forces a re-sync of the datastream list // 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); $returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
unlink($tmpfilename); unlink($tmpfilename);
return $returnvalue; return $returnvalue;
@ -208,7 +224,9 @@ class Fedora_Item {
/** /**
* Wrapper to add new or modify existing datastream * Wrapper to add new or modify existing datastream
*
* @global url $base_url * @global url $base_url
*
* @param url $external_url * @param url $external_url
* @param string $dsid * @param string $dsid
* @param string $label * @param string $label
@ -229,6 +247,12 @@ class Fedora_Item {
} }
} }
/**
*
* @param unknown_type $el
* @param unknown_type $object
* @param unknown_type $type
*/
protected function buildRelsStatement(&$el, $object, $type) { protected function buildRelsStatement(&$el, $object, $type) {
if ($type > 0) { if ($type > 0) {
$el->appendChild($el->ownerDocument->createTextNode($object)); $el->appendChild($el->ownerDocument->createTextNode($object));
@ -242,7 +266,7 @@ class Fedora_Item {
$el->setAttribute('rdf:datatype', 'http://www.w3.org/2001/XMLSchema#dateTime'); $el->setAttribute('rdf:datatype', 'http://www.w3.org/2001/XMLSchema#dateTime');
} }
else { else {
//plain literal. // Plain literal.
} }
} }
else { else {
@ -268,8 +292,9 @@ class Fedora_Item {
* - 2: string (explicitly typed) * - 2: string (explicitly typed)
* - 3: integer * - 3: integer
* - 4: dateTime * - 4: dateTime
*
* @return ??? * @return ???
* Value returned from SOAP call for modify_datastream. * Value returned from SOAP call for modify_datastream.
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) {
static $relsextxml = NULL; static $relsextxml = NULL;
@ -300,7 +325,7 @@ RDF;
$relsextxml->loadXML($relsext); $relsextxml->loadXML($relsext);
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description');
if ($description->length == 0) { if ($description->length == 0) {
//XXX: This really shouldn't be done; lower case d doesn't fit the schema. Warn users to fix the data and generators, pending deprecation. // XXX: This really shouldn't be done; lower case d doesn't fit the schema. Warn users to fix the data and generators, pending deprecation.
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description');
if ($description->length > 0) { if ($description->length > 0) {
drupal_set_message(t('RDF with lower case "d" in "description" encountered. Should be uppercase! PID: %pid', array('%pid' => $this->pid)), 'warning'); drupal_set_message(t('RDF with lower case "d" in "description" encountered. Should be uppercase! PID: %pid', array('%pid' => $this->pid)), 'warning');
@ -322,12 +347,14 @@ RDF;
* Extension of add_relationship, which acts on RELS-INT. * Extension of add_relationship, which acts on RELS-INT.
* *
* @param $dsid * @param $dsid
* A string containing either the base dsid (EXAMPLE) or URI to the datastream (info:fedora/pid/EXAMPLE) * A string containing either the base dsid (EXAMPLE)
* or URI to the datastream (info:fedora/pid/EXAMPLE)
*/ */
function add_dsid_relationship($dsid, $relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) { function add_dsid_relationship($dsid, $relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) {
static $relsxml = NULL; static $relsxml = NULL;
if ($relsxml === NULL) { if ($relsxml === NULL) {
$relsxml = new DOMDocument(); //Avoid new instantiations in long-running processes // Avoid new instantiations in long-running processes.
$relsxml = new DOMDocument();
} }
$f_prefix = 'info:fedora/'; $f_prefix = 'info:fedora/';
@ -357,7 +384,7 @@ RDF;
} }
} }
//Create the description element if we didn't find it... // Create the description element if we didn't find it...
if ($description === NULL) { if ($description === NULL) {
$description = $relsxml->createElementNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf:Description'); $description = $relsxml->createElementNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf:Description');
$description->setAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf:about', $dsid); $description->setAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf:about', $dsid);
@ -382,7 +409,9 @@ RDF;
* @param string $relationship * @param string $relationship
* The predicate/relationship tag to delete * The predicate/relationship tag to delete
* @param string $object * @param string $object
* The object to be related to. (NULL/value for which empty() evaluates to true will remove all relations of the given type, ignoring $literal_value) * The object to be related to. (NULL/value for which empty()
* evaluates to true will remove all relations of the given type,
* ignoring $literal_value)
* @param string $namespaceURI * @param string $namespaceURI
* The predicate namespace. * The predicate namespace.
* @param int $literal_value * @param int $literal_value
@ -399,11 +428,12 @@ RDF;
if ($relsext && $relsextxml->loadXML($relsext)) { if ($relsext && $relsextxml->loadXML($relsext)) {
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
// iterate backwards so if we delete something our pointer doesn't get out of sync // Iterate backwards so if we delete something our pointer doesn't get out of sync.
for ($i = $rels->length; $i > 0; $i--) { for ($i = $rels->length; $i > 0; $i--) {
$rel = $rels->item($i - 1); $rel = $rels->item($i - 1);
// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted // 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. 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) || 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_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_PLAIN_LITERAL) && $rel->textContent == $object) ||
@ -415,20 +445,21 @@ RDF;
} }
} }
//Save changes. // Save changes.
if ($modified) { if ($modified) {
$this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); $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 whether or not we've introduced any changes.
return $modified; return $modified;
} }
/** /**
* Extension of purge_relationships, which acts on RELS-INT. * Extension of purge_relationships, which acts on RELS-INT.
* *
* @param $dsid * @param string $dsid
* A string containing either the base dsid (EXAMPLE) or URI to the datastream (info:fedora/pid/EXAMPLE) * A string containing either the base dsid (EXAMPLE)
* or URI to the datastream (info:fedora/pid/EXAMPLE)
*/ */
function purge_dsid_relationships($dsid, $relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) { function purge_dsid_relationships($dsid, $relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) {
$f_prefix = 'info:fedora/'; $f_prefix = 'info:fedora/';
@ -448,11 +479,12 @@ RDF;
if ($dsid === NULL || $desc->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'about') == $dsid) { if ($dsid === NULL || $desc->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'about') == $dsid) {
$rels = $desc->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $desc->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
// iterate backwards so if we delete something our pointer doesn't get out of sync // Iterate backwards so if we delete something our pointer doesn't get out of sync.
for ($i = $rels->length; $i>0; $i--) { for ($i = $rels->length; $i>0; $i--) {
$rel = $rels->item($i-1); $rel = $rels->item($i-1);
// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted // 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. // 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.
if (
empty($object) || 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_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_PLAIN_LITERAL) && $rel->textContent == $object) ||
@ -470,13 +502,13 @@ RDF;
} }
} }
//Save changes. // Save changes.
if ($modified) { if ($modified) {
$this->modify_datastream($relsxml->saveXML(), 'RELS-INT', "Fedora Datastream Relationship Metadata", 'text/xml'); $this->modify_datastream($relsxml->saveXML(), 'RELS-INT', "Fedora Datastream Relationship Metadata", 'text/xml');
} }
} }
//Return whether or not we've introduced any changes. // Return whether or not we've introduced any changes.
return $modified; return $modified;
} }
@ -543,6 +575,7 @@ RDF;
/** /**
* Export as foxml * Export as foxml
*
* @return type * @return type
*/ */
function export_as_foxml() { function export_as_foxml() {
@ -561,6 +594,7 @@ RDF;
* @param string $pattern to search for, including wildcards. * @param string $pattern to search for, including wildcards.
* @param string $field The field to search on, e.g. pid, title, cDate. See http://www.fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-findObjects for details * @param string $field The field to search on, e.g. pid, title, cDate. See http://www.fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-findObjects for details
* @param int $max_results not used at this time * @param int $max_results not used at this time
*
* @return Array of pid => title pairs that match the results * @return Array of pid => title pairs that match the results
*/ */
static function find_objects_by_pattern($pattern = '*', $field = 'pid', $max_results = 100, $resultFields = array()) { static function find_objects_by_pattern($pattern = '*', $field = 'pid', $max_results = 100, $resultFields = array()) {
@ -622,9 +656,11 @@ RDF;
/** /**
* Get datastream dissemination * Get datastream dissemination
*
* @param type $dsid * @param type $dsid
* @param type $as_of_date_time * @param type $as_of_date_time
* @param type $quiet * @param type $quiet
*
* @return null * @return null
*/ */
function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) { function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) {
@ -652,8 +688,10 @@ RDF;
/** /**
* Get datastream * Get datastream
*
* @param type $dsid * @param type $dsid
* @param type $as_of_date_time * @param type $as_of_date_time
*
* @return type * @return type
*/ */
function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) { function get_datastream($dsid, $as_of_date_time = '', $quiet = TRUE) {
@ -672,13 +710,15 @@ RDF;
/** /**
* Get datastream history * Get datastream history
*
* @param type $dsid * @param type $dsid
*
* @return type * @return type
*/ */
function get_datastream_history($dsid) { function get_datastream_history($dsid) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid 'dsID' => $dsid,
); );
$object = self::soap_call('getDatastreamHistory', $params); $object = self::soap_call('getDatastreamHistory', $params);
$ret = FALSE; $ret = FALSE;
@ -691,10 +731,12 @@ RDF;
/** /**
* Get dissemination * Get dissemination
*
* @param type $service_definition_pid * @param type $service_definition_pid
* @param type $method_name * @param type $method_name
* @param type $parameters * @param type $parameters
* @param type $as_of_date_time * @param type $as_of_date_time
*
* @return string * @return string
*/ */
function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = NULL) { function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = NULL) {
@ -717,8 +759,8 @@ RDF;
} }
/** /**
* Retrieves and returns a SimpleXML list of this item's datastreams, and stores them * Retrieves and returns a SimpleXML list of this item's datastreams,
* as an instance variable for caching purposes. * and stores them as an instance variable for caching purposes.
* *
* @return SimpleXMLElement * @return SimpleXMLElement
*/ */
@ -726,7 +768,7 @@ RDF;
//if ( empty( $this->datastreams_list ) ) { //if ( empty( $this->datastreams_list ) ) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'asOfDateTime' => "" 'asOfDateTime' => "",
); );
$this->datastreams_list = $this->soap_call('listDataStreams', $params); $this->datastreams_list = $this->soap_call('listDataStreams', $params);
@ -735,7 +777,7 @@ RDF;
} }
/** /**
* * DatastreamControlGroup controlGroup - String restricted to the values of "X", "M", "R", or "E" (InlineXML,Managed Content,Redirect, or External Referenced). * DatastreamControlGroup controlGroup - String restricted to the values of "X", "M", "R", or "E" (InlineXML,Managed Content,Redirect, or External Referenced).
* String ID - The datastream ID (64 characters max). * String ID - The datastream ID (64 characters max).
* String versionID - The ID of the most recent datastream version * String versionID - The ID of the most recent datastream version
* String[] altIDs - Alternative IDs for the datastream, if any. * String[] altIDs - Alternative IDs for the datastream, if any.
@ -752,21 +794,23 @@ RDF;
* *
* @param string $dsid * @param string $dsid
*
* @return datastream object * @return datastream object
* get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need * get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need
*/ */
function get_datastream_info($dsid, $as_of_date_time = '') { function get_datastream_info($dsid, $as_of_date_time = '') {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
'asOfDateTime' => $as_of_date_time 'asOfDateTime' => $as_of_date_time,
); );
return $this->soap_call('getDatastream', $params); return $this->soap_call('getDatastream', $params);
} }
/** /**
* Returns an associative array of this object's datastreams. Results look like this: * Returns an associative array of this object's datastreams.
* Results look like this:
* *
* 'DC' => * 'DC' =>
* array * array
@ -831,6 +875,7 @@ RDF;
* Currently the Fedora API call getRelationships is reporting an uncaught * Currently the Fedora API call getRelationships is reporting an uncaught
* exception so we will parse the RELS-EXT ourselves and simulate the * exception so we will parse the RELS-EXT ourselves and simulate the
* documented behaviour. * documented behaviour.
*
* @param String $relationship - filter the results to match this string. * @param String $relationship - filter the results to match this string.
*/ */
function get_relationships($relationship = NULL) { function get_relationships($relationship = NULL) {
@ -864,9 +909,9 @@ RDF;
* Retrieves RELS-EXT values from item * Retrieves RELS-EXT values from item
* *
* @param array $namespaces * @param array $namespaces
*
* @return array * @return array
*/ */
function get_rdf_relationships($namespaces = null) { function get_rdf_relationships($namespaces = null) {
if ($namespaces == NULL) { if ($namespaces == NULL) {
$namespaces = array( $namespaces = array(
@ -918,6 +963,7 @@ RDF;
/** /**
* Creates a RELS-EXT XML stream from the supplied array and saves it to * Creates a RELS-EXT XML stream from the supplied array and saves it to
* the item on the server. * the item on the server.
*
* @param <type> $relationships * @param <type> $relationships
*/ */
function save_relationships($relationships) { function save_relationships($relationships) {
@ -936,7 +982,6 @@ RDF;
} }
// Do the messy work constructing the RELS-EXT XML. Because addRelationship is broken. // Do the messy work constructing the RELS-EXT XML. Because addRelationship is broken.
return FALSE; return FALSE;
} }
@ -944,12 +989,12 @@ RDF;
* Set the object to a deleted state * Set the object to a deleted state
*/ */
function move_to_trash($log_message = 'Flagged deleted using Islandora API.', $quiet = TRUE) { function move_to_trash($log_message = 'Flagged deleted using Islandora API.', $quiet = TRUE) {
// Loop through the datastreams and mark them deleted // Loop through the datastreams and mark them deleted.
foreach ($this->get_datastreams_list_as_array() as $dsid => $info) { foreach ($this->get_datastreams_list_as_array() as $dsid => $info) {
$this->set_datastream_state($dsid, 'D'); $this->set_datastream_state($dsid, 'D');
} }
// Create a message to mark the object deleted // Create a message to mark the object deleted.
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'state' => 'D', 'state' => 'D',
@ -958,7 +1003,7 @@ RDF;
'ownerId' => null, 'ownerId' => null,
); );
// Send message to mark the object deleted // Send message to mark the object deleted.
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
@ -970,29 +1015,31 @@ RDF;
*/ */
function purge($log_message = 'Purged using Islandora API.', $force = FALSE) { function purge($log_message = 'Purged using Islandora API.', $force = FALSE) {
// Flag the object to be deleted first // Flag the object to be deleted first.
$this->move_to_trash($log_message); $this->move_to_trash($log_message);
// Create the delete message // Create the delete message.
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'logMessage' => $log_message, 'logMessage' => $log_message,
'force' => $force 'force' => $force,
); );
$this->forget(); $this->forget();
// Delete the object // Delete the object.
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }
/** /**
* Purge datastream * Purge datastream
*
* @param type $dsID * @param type $dsID
* @param type $start_date * @param type $start_date
* @param type $end_date * @param type $end_date
* @param type $log_message * @param type $log_message
* @param type $force * @param type $force
*
* @return type * @return type
*/ */
function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) { function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) {
@ -1005,7 +1052,7 @@ RDF;
'force' => $force, 'force' => $force,
); );
$soap_result = $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 // 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(); $this->datastreams = $this->get_datastreams_list_as_array();
return $soap_result; return $soap_result;
} }
@ -1013,17 +1060,20 @@ RDF;
/** /**
* URL * URL
* @global type $base_url * @global type $base_url
*
* @return type * @return type
*/ */
function url() { function url() {
return url('fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''), array( return url('fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''), array(
'absolute' => TRUE 'absolute' => TRUE,
)); ));
} }
/** /**
* Get Next PID in Namespace * Get Next PID in Namespace
*
* @param $pid_namespace string * @param $pid_namespace string
*
* @return string * @return string
*/ */
static function get_next_PID_in_namespace($pid_namespace = '', $number_of_pids = 1) { static function get_next_PID_in_namespace($pid_namespace = '', $number_of_pids = 1) {
@ -1051,14 +1101,16 @@ RDF;
/** /**
* ingest from FOXML * ingest from FOXML
*
* @param type $foxml * @param type $foxml
*
* @return Fedora_Item * @return Fedora_Item
*/ */
static function ingest_from_FOXML(DOMDocument $foxml) { static function ingest_from_FOXML(DOMDocument $foxml) {
$params = array( $params = array(
'objectXML' => $foxml->saveXML(), 'objectXML' => $foxml->saveXML(),
'format' => 'info:fedora/fedora-system:FOXML-1.1', 'format' => 'info:fedora/fedora-system:FOXML-1.1',
'logMessage' => 'Fedora Object Ingested' 'logMessage' => 'Fedora Object Ingested',
); );
$object = self::soap_call('ingest', $params); $object = self::soap_call('ingest', $params);
return new Fedora_Item($object->objectPID); return new Fedora_Item($object->objectPID);
@ -1066,7 +1118,9 @@ RDF;
/** /**
* ingest from FOXML file * ingest from FOXML file
*
* @param type $foxml_file * @param type $foxml_file
*
* @return type * @return type
*/ */
static function ingest_from_FOXML_file($foxml_file) { static function ingest_from_FOXML_file($foxml_file) {
@ -1077,12 +1131,13 @@ RDF;
/** /**
* ingest from FOXML files in directory * ingest from FOXML files in directory
*
* @param type $path * @param type $path
*/ */
static function ingest_from_FOXML_files_in_directory($path) { static function ingest_from_FOXML_files_in_directory($path) {
// Open the directory // Open the directory.
$dir_handle = @opendir($path); $dir_handle = @opendir($path);
// Loop through the files // Loop through the files.
while ($file = readdir($dir_handle)) { while ($file = readdir($dir_handle)) {
if ($file == "." || $file == ".." || strtolower(substr($file, strlen($file) - 4)) != '.xml') { if ($file == "." || $file == ".." || strtolower(substr($file, strlen($file) - 4)) != '.xml') {
continue; continue;
@ -1094,29 +1149,32 @@ RDF;
} }
} }
// Close // Close.
closedir($dir_handle); closedir($dir_handle);
} }
/** /**
* Modify Object * Modify Object
*
* @param $label string * @param $label string
* @param $state string * @param $state string
* @param $ownerId string * @param $ownerId string
* @param $logMessage string * @param $logMessage string
* @param $quiet boolean * @param $quiet boolean
*
* @return type * @return type
*/ */
function modify_object($label = '', $state = NULL, $ownerId = NULL, $logMessage = 'Modified by Islandora API', $quiet=TRUE) { function modify_object($label = '', $state = NULL, $ownerId = NULL, $logMessage = 'Modified by Islandora API', $quiet=TRUE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'ownerId' => (($ownerId !== NULL) ? //Default to the current owner if none is provided. // Default to the current owner if none is provided..
'ownerId' => (($ownerId !== NULL) ?
$ownerId : $ownerId :
$this->objectProfile->objOwnerId), $this->ownerId),
'state' => $state, 'state' => $state,
'label' => $label, 'label' => $label,
'logMessage' => $logMessage 'logMessage' => $logMessage,
); );
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
@ -1130,15 +1188,16 @@ RDF;
* *
* @param $url * @param $url
* A string containing an HTTP(S) URL to attempt. * A string containing an HTTP(S) URL to attempt.
*
* @return string * @return string
* The results of the HTTP request if successful; boolean FALSE otherwise. * The results of the HTTP request if successful; boolean FALSE otherwise.
*/ */
protected static function try_http_get_content($url) { protected static function try_http_get_content($url) {
//Can throw a warning prior to 5.3.3 // Can throw a warning prior to 5.3.3.
$parsed_url = @parse_url($url); $parsed_url = @parse_url($url);
$supported_schemes = array( $supported_schemes = array(
'http', 'http',
'https' 'https',
); );
$content = FALSE; $content = FALSE;
@ -1182,7 +1241,8 @@ RDF;
/** /**
* Wrap modify by value and reference * Wrap modify by value and reference
* *
* Wrap modify by value and reference, so that the proper one gets called in the correct instance. (value if inline XML, reference otherwise) * Wrap modify by value and reference, so that the proper one gets called
* in the correct instance. (value if inline XML, reference otherwise)
* *
* First tries to treat the passed in value as a filename, tries using as contents second. * First tries to treat the passed in value as a filename, tries using as contents second.
* Coerces the data into what is required, and passes it on to the relevant function. * Coerces the data into what is required, and passes it on to the relevant function.
@ -1200,20 +1260,21 @@ RDF;
* @param string $logMessage * @param string $logMessage
* A message for the audit log. * A message for the audit log.
* @param boolean $quiet * @param boolean $quiet
* Error suppression? Refer to soap_call for usage (just passed along here). * Error suppression? Refer to soap_call for usage
* (just passed along here).
*/ */
function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API', $quiet=FALSE) { function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API', $quiet=FALSE) {
$toReturn = NULL; $toReturn = NULL;
//Determine if it's inline xml; if it is, modify by value // Determine if it's inline xml; if it is, modify by value.
if ($this->get_datastream($dsid)->controlGroup === 'X') { if ($this->get_datastream($dsid)->controlGroup === 'X') {
$content = '<null/>'; $content = '<null/>';
if (is_file($filename_or_content) && is_readable($filename_or_content)) { if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$content = file_get_contents($filename_or_content); $content = file_get_contents($filename_or_content);
} }
else { else {
//XXX: Get the contents to deal with fopen not being allowed for remote access // XXX: Get the contents to deal with fopen not being allowed for remote access
// in some OSs //in some OSs
$temp_content = self::try_http_get_content($filename_or_content); $temp_content = self::try_http_get_content($filename_or_content);
if ($temp_content !== FALSE) { if ($temp_content !== FALSE) {
$content = $temp_content; $content = $temp_content;
@ -1225,7 +1286,7 @@ RDF;
$toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage); $toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage);
} }
//Otherwise, write to web-accessible temp file and modify by reference. // Otherwise, write to web-accessible temp file and modify by reference.
else { else {
$file = ''; $file = '';
$created_temp = FALSE; $created_temp = FALSE;
@ -1237,14 +1298,14 @@ RDF;
$created_temp = ($original_path != $file); $created_temp = ($original_path != $file);
} }
else { else {
//XXX: Get the contents to deal with fopen not being allowed for remote access // XXX: Get the contents to deal with fopen not being allowed for remote access
// in some OSs // in some OSs
$temp_content = self::try_http_get_content($filename_or_content); $temp_content = self::try_http_get_content($filename_or_content);
if ($temp_content !== FALSE) { if ($temp_content !== FALSE) {
$filename_or_content = $temp_content; $filename_or_content = $temp_content;
} }
//Push contents to a web-accessible file // Push contents to a web-accessible file.
$file = file_save_data($filename_or_content, file_create_filename($label, file_directory_path())); $file = file_save_data($filename_or_content, file_create_filename($label, file_directory_path()));
$created_temp = TRUE; $created_temp = TRUE;
} }
@ -1265,6 +1326,7 @@ RDF;
/** /**
* Modify datastream by reference * Modify datastream by reference
*
* @param type $external_url * @param type $external_url
* @param type $dsid * @param type $dsid
* @param type $label * @param type $label
@ -1272,6 +1334,7 @@ RDF;
* @param type $force * @param type $force
* @param type $logMessage * @param type $logMessage
* @param type $quiet * @param type $quiet
*
* @return type * @return type
*/ */
function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
@ -1294,13 +1357,14 @@ RDF;
'checksumType' => 'DISABLED', 'checksumType' => 'DISABLED',
'checksum' => 'none', 'checksum' => 'none',
'logMessage' => $logMessage, 'logMessage' => $logMessage,
'force' => $force 'force' => $force,
); );
return self::soap_call('modifyDatastreamByReference', $params, $quiet); return self::soap_call('modifyDatastreamByReference', $params, $quiet);
} }
/** /**
* Modify datastream by value * Modify datastream by value
*
* @param type $content * @param type $content
* @param type $dsid * @param type $dsid
* @param type $label * @param type $label
@ -1308,6 +1372,7 @@ RDF;
* @param type $force * @param type $force
* @param type $logMessage * @param type $logMessage
* @param type $quiet * @param type $quiet
*
* @return type * @return type
*/ */
function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
@ -1322,11 +1387,18 @@ RDF;
'checksumType' => 'DISABLED', 'checksumType' => 'DISABLED',
'checksum' => 'none', 'checksum' => 'none',
'logMessage' => $logMessage, 'logMessage' => $logMessage,
'force' => $force 'force' => $force,
); );
return self::soap_call('modifyDatastreamByValue', $params, $quiet); return self::soap_call('modifyDatastreamByValue', $params, $quiet);
} }
/**
*
* @param unknown_type $dsid
* @param unknown_type $state
* @param unknown_type $log_message
* @param unknown_type $quiet
*/
function set_datastream_state($dsid, $state, $log_message = 'Modified by Islandora API', $quiet = FALSE) { function set_datastream_state($dsid, $state, $log_message = 'Modified by Islandora API', $quiet = FALSE) {
$valid_states = array('A', 'D', 'I'); $valid_states = array('A', 'D', 'I');
if (array_search($state, $valid_states) !== FALSE) { if (array_search($state, $valid_states) !== FALSE) {
@ -1395,21 +1467,24 @@ RDF;
* @param string $state The initial state, A - Active, I - Inactive, D - Deleted * @param string $state The initial state, A - Active, I - Inactive, D - Deleted
* @param type $label * @param type $label
* @param type $owner * @param type $owner
*
* @return DOMDocument * @return DOMDocument
*/ */
static function create_object_FOXML($pid = '', $state = 'A', $label = 'Untitled', $owner = '') { static function create_object_FOXML($pid = '', $state = 'A', $label = 'Untitled', $owner = '') {
$foxml = new DOMDocument("1.0", "UTF-8"); $foxml = new DOMDocument("1.0", "UTF-8");
$foxml->formatOutput = TRUE; $foxml->formatOutput = TRUE;
if (empty($pid)) { if (empty($pid)) {
// Call getNextPid // Call getNextPid.
$pid = self::get_next_PID_in_namespace(); $pid = self::get_next_PID_in_namespace();
} }
if (empty($owner)) { if (empty($owner)) {
global $user; global $user;
if (!empty($user->uid)) { // Default to current Drupal user. // Default to current Drupal user.
if (!empty($user->uid)) {
$owner = $user->uid; $owner = $user->uid;
} }
else { // We are not inside Drupal // We are not inside Drupal.
else {
$owner = 'fedoraAdmin'; $owner = 'fedoraAdmin';
} }
} }
@ -1420,7 +1495,7 @@ RDF;
$root_element->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd"); $root_element->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
$foxml->appendChild($root_element); $foxml->appendChild($root_element);
// FOXML object properties section // FOXML object properties section.
$object_properties = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:objectProperties"); $object_properties = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:objectProperties");
$state_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property"); $state_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state"); $state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state");
@ -1444,10 +1519,12 @@ RDF;
/** /**
* ingest new item * ingest new item
*
* @param type $pid * @param type $pid
* @param type $state * @param type $state
* @param type $label * @param type $label
* @param type $owner * @param type $owner
*
* @return type * @return type
*/ */
static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') { static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') {
@ -1456,7 +1533,9 @@ RDF;
/** /**
* fedora item exists * fedora item exists
*
* @param type $pid * @param type $pid
*
* @return type * @return type
*/ */
static function fedora_item_exists($pid) { static function fedora_item_exists($pid) {
@ -1464,13 +1543,26 @@ RDF;
return $item->exists(); return $item->exists();
} }
/* * ******************************************************
* Relationship Functions
* ****************************************************** */
/** /**
* Returns an associative array of relationships that this item has * This function will retrieve the ownerId
* in its RELS-EXT. * object property from Fedora using the SOAP API.
*
* @param string $PID
* The Fedora PID to retrieve the
*/ */
} static function getOwnerId($PID) {
$params = array(
'query' => array(array('property' => 'pid', 'operator' => 'eq', 'value' => $object_id)),
'resultFields' => array('pid', 'ownerId'),
'maxResults' => 1,
);
$response = Fedora_Item::soap_call('findObjects', $params);
if (!$response) {
return FALSE;
}
return $response->result->resultList->objectFields->ownerId;
}
}

236
fedora_repository.install

@ -1,106 +1,134 @@
<?php <?php
/** /**
* @file fedora_repository.install * @file fedora_repository.install
*/ */
/** /**
* Implementation of hook_enable(). * Implementation of hook_enable().
*/ */
function fedora_collections_enable() { function fedora_collections_enable() {
//nothing to do as we do not currently touch the drupal database. //nothing to do as we do not currently touch the drupal database.
//other than the variables table //other than the variables table
} }
/** /**
* Implementation of hook_requirements(). * Implementation of hook_requirements().
* *
* @return * @return
* An array describing the status of the site regarding available updates. * An array describing the status of the site regarding available updates.
* If there is no update data, only one record will be returned, indicating * If there is no update data, only one record will be returned, indicating
* that the status of core can't be determined. If data is available, there * that the status of core can't be determined. If data is available, there
* will be two records: one for core, and another for all of contrib * will be two records: one for core, and another for all of contrib
* (assuming there are any contributed modules or themes enabled on the * (assuming there are any contributed modules or themes enabled on the
* site). In addition to the fields expected by hook_requirements ('value', * site). In addition to the fields expected by hook_requirements ('value',
* 'severity', and optionally 'description'), this array will contain a * 'severity', and optionally 'description'), this array will contain a
* 'reason' attribute, which is an integer constant to indicate why the * 'reason' attribute, which is an integer constant to indicate why the
* given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or * given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or
* UPDATE_UNKNOWN). This is used for generating the appropriate e-mail * UPDATE_UNKNOWN). This is used for generating the appropriate e-mail
* notification messages during update_cron(), and might be useful for other * notification messages during update_cron(), and might be useful for other
* modules that invoke update_requirements() to find out if the site is up * modules that invoke update_requirements() to find out if the site is up
* to date or not. * to date or not.
* *
* @see _update_message_text() * @see _update_message_text()
* @see _update_cron_notify() * @see _update_cron_notify()
*/ */
function fedora_repository_requirements($phase) { function fedora_repository_requirements($phase) {
$requirements = array(); $requirements = array();
$t = get_t(); //May not have access to the regular t() function; and so Drupal provides... $t = get_t(); //May not have access to the regular t() function; and so Drupal provides...
if ($phase == 'install') { if ($phase == 'install') {
// Test for SOAP // Test for SOAP
$requirements['fedora-soap']['title'] = $t("PHP SOAP extension library"); $requirements['fedora-soap']['title'] = $t("PHP SOAP extension library");
if (!class_exists('SoapClient')) { if (!class_exists('SoapClient')) {
$requirements['fedora-soap']['value'] = $t("Not installed"); $requirements['fedora-soap']['value'] = $t("Not installed");
$requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR; $requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR;
$requirements['fedora-soap']['description'] = $t('Ensure that the PHP SOAP extension is installed.'); $requirements['fedora-soap']['description'] = $t('Ensure that the PHP SOAP extension is installed.');
} }
else { else {
$requirements['fedora-soap']['value'] = $t("Installed"); $requirements['fedora-soap']['value'] = $t("Installed");
$requirements['fedora-soap']['severity'] = REQUIREMENT_OK; $requirements['fedora-soap']['severity'] = REQUIREMENT_OK;
} }
// Test for Curl // Test for Curl
$requirements['curl']['title'] = $t('PHP Curl extension library'); $requirements['curl']['title'] = $t('PHP Curl extension library');
if (!function_exists('curl_init')) { if (!function_exists('curl_init')) {
$requirements['curl']['value'] = $t("Not installed"); $requirements['curl']['value'] = $t("Not installed");
$requirements['curl']['severity'] = REQUIREMENT_ERROR; $requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = $t("Ensure that the PHP Curl extension is installed."); $requirements['curl']['description'] = $t("Ensure that the PHP Curl extension is installed.");
} }
else { else {
$requirements['curl']['value'] = $t("Installed"); $requirements['curl']['value'] = $t("Installed");
$requirements['curl']['severity'] = REQUIREMENT_OK; $requirements['curl']['severity'] = REQUIREMENT_OK;
} }
// Test for DOM // Test for DOM
$requirements['dom']['title'] = $t("PHP DOM XML extension library"); $requirements['dom']['title'] = $t("PHP DOM XML extension library");
if (!method_exists('DOMDocument', 'loadHTML')) { if (!method_exists('DOMDocument', 'loadHTML')) {
$requirements['dom']['value'] = $t("Not installed"); $requirements['dom']['value'] = $t("Not installed");
$requirements['dom']['severity'] = REQUIREMENT_ERROR; $requirements['dom']['severity'] = REQUIREMENT_ERROR;
$requirements['dom']['description'] = $t("Ensure that the PHP DOM XML extension is installed."); $requirements['dom']['description'] = $t("Ensure that the PHP DOM XML extension is installed.");
} }
else { else {
$requirements['dom']['value'] = $t("Installed"); $requirements['dom']['value'] = $t("Installed");
$requirements['dom']['severity'] = REQUIREMENT_OK; $requirements['dom']['severity'] = REQUIREMENT_OK;
} }
// Test for XSLT // Test for XSLT
$requirements['xsl']['title'] = $t("PHP XSL extension library"); $requirements['xsl']['title'] = $t("PHP XSL extension library");
if (!class_exists('XSLTProcessor')) { if (!class_exists('XSLTProcessor')) {
$requirements['xslt']['value'] = $t("Not installed"); $requirements['xslt']['value'] = $t("Not installed");
$requirements['xslt']['severity'] = REQUIREMENT_ERROR; $requirements['xslt']['severity'] = REQUIREMENT_ERROR;
$requirements['xslt']['description'] = $t("Ensure that the PHP XSL extension is installed."); $requirements['xslt']['description'] = $t("Ensure that the PHP XSL extension is installed.");
} }
else { else {
$requirements['xslt']['value'] = $t("Installed"); $requirements['xslt']['value'] = $t("Installed");
$requirements['xslt']['severity'] = REQUIREMENT_OK; $requirements['xslt']['severity'] = REQUIREMENT_OK;
} }
} }
elseif ($phase == 'runtime') { elseif ($phase == 'runtime') {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$requirements['fedora-repository']['title'] = $t("Fedora server"); $requirements['fedora-repository']['title'] = $t("Fedora server");
if (!fedora_available()) { if (!fedora_available()) {
$requirements['fedora-repository']['value'] = $t("Not available"); $requirements['fedora-repository']['value'] = $t("Not available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR;
$requirements['fedora-repository']['description'] = $t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => url('admin/settings/fedora_repository'))); $requirements['fedora-repository']['description'] = $t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => url('admin/settings/fedora_repository')));
} }
else { else {
$requirements['fedora-repository']['value'] = $t("Available"); $requirements['fedora-repository']['value'] = $t("Available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_OK; $requirements['fedora-repository']['severity'] = REQUIREMENT_OK;
} }
} }
return $requirements; return $requirements;
} }
/**
* Implements hook_update_N().
*
* This function will try and update the SOAP WSDLs
* as they were set wrong in previous releases.
*/
function fedora_repository_update_6001() {
// Get variables to check for update.
$API_A_WSDL = variable_get('fedora_soap_url', $default = NULL);
$API_M_WSDL = variable_get('fedora_soap_manage_url', $default = NULL);
// Update API A if necessary.
$A_WSDL = parse_url($API_A_WSDL, PHP_URL_PATH) . '?' . parse_url($API_A_WSDL, PHP_URL_QUERY);
if ($A_WSDL == '/fedora/services/access?wsdl') {
variable_set('fedora_soap_url', str_replace('/fedora/services/access?wsdl', '/fedora/wsdl?api=API-A', $API_A_WSDL));
}
// Update API M if necessary.
$M_WSDL = parse_url($API_M_WSDL, PHP_URL_PATH) . '?' . parse_url($API_M_WSDL, PHP_URL_QUERY);
if ($M_WSDL == '/fedora/services/management?wsdl') {
variable_set('fedora_soap_manage_url', str_replace('/fedora/services/management?wsdl', '/fedora/wsdl?api=API-M', $API_M_WSDL));
}
return array(
array('success' => TRUE, 'query' => 'Please check your WSDL paths in Islandora\'s config, this update requires them to be set correctly: access; /fedora/wsdl?api=API-A, management; /fedora/wsdl?api=API-M'),
);
}

2
formClass.inc

@ -232,7 +232,7 @@ class formClass {
$form['fedora_soap_url'] = array( $form['fedora_soap_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora SOAP Url'), '#title' => t('Fedora SOAP Url'),
'#default_value' => variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'), '#default_value' => variable_get('fedora_soap_url', 'http://localhost:8080/fedora/wsdl?api=API-A'),
'#description' => t('The URL to use for SOAP connections'), '#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -12, '#weight' => -12,

Loading…
Cancel
Save