Browse Source

Merge branch '6.x' of git://github.com/Islandora/islandora into 6.x

pull/92/head
ppound 13 years ago
parent
commit
d5d2a36e4f
  1. 33
      CollectionClass.inc
  2. 13
      ContentModel.inc
  3. 23
      ObjectHelper.inc
  4. 6
      SecurityClass.inc
  5. 2
      api/fedora_collection.inc
  6. 278
      api/fedora_item.inc
  7. 17
      api/fedora_utils.inc
  8. 40
      fedora_repository.module
  9. 21
      fedora_repository.solutionpacks.inc
  10. 22
      formClass.inc
  11. 4
      plugins/FormBuilder.inc
  12. 2
      plugins/PersonalCollectionClass.inc
  13. 4
      plugins/Refworks.inc
  14. 2
      plugins/ShowStreamsInFieldSets.inc
  15. 2
      xsl/sparql_to_html.xsl

33
CollectionClass.inc

@ -45,11 +45,12 @@ class CollectionClass {
* @return type * @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
if (!isset($itqlquery)) { if (!isset($itqlquery)) {
// $query_string = $objectHelper->getStream($pid, 'QUERY', 0); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$itqlquery = $objectHelper->getStream($pid, 'QUERY', 0); $item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$itqlquery = $item->get_datastream_dissemination('QUERY');
}
} }
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset); return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
} }
@ -67,9 +68,6 @@ class CollectionClass {
function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) { function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!isset($limit)) {
$limit = 1000;
}
if (!isset($offset)) { if (!isset($offset)) {
$offset = 0; $offset = 0;
} }
@ -81,10 +79,14 @@ class CollectionClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$query_string = $itqlquery; $query_string = $itqlquery;
if (!isset($query_string)) { if (!isset($query_string)) {
$query_string = $objectHelper->getStream($pid, 'QUERY', 0); $query_string = NULL;
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query_string = $item->get_datastream_dissemination('QUERY');
}
if ($query_string == NULL) { if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri> $query_string = 'select $object $title $content from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content and $object <fedora-model:hasModel> $content
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '> and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>) or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
@ -343,7 +345,7 @@ class CollectionClass {
$thisClass = new $phpClass (); $thisClass = new $phpClass ();
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext);
if (!$returnValue) { if (!$returnValue) {
drupal_set_message('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue)); drupal_set_message(t('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue)));
return FALSE; return FALSE;
} }
} }
@ -448,7 +450,7 @@ class CollectionClass {
'pidNamespace' => $pidNameSpace 'pidNamespace' => $pidNameSpace
); );
$object = $soapClient->__soapCall('getNextPID', array( $object = $soapClient->__soapCall('getNextPID', array(
$params $params
)); ));
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error');
@ -463,7 +465,7 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass');
$personalCollectionClass = new PersonalCollectionClass(); $personalCollectionClass = new PersonalCollectionClass();
if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) {
drupal_set_message("Did not create a personal collection object for !u", array('!u' => $user->name)); drupal_set_message(t("Did not create a personal collection object for !u", array('!u' => $user->name)));
return FALSE; //creation failed don't save the collection pid in drupal db return FALSE; //creation failed don't save the collection pid in drupal db
} }
user_save($user, $personal_collection_pid); user_save($user, $personal_collection_pid);
@ -501,11 +503,10 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionManagement');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); module_load_include('inc', 'fedora_repository', 'BatchIngest');
global $base_url; global $base_url;
$tabset = array();
global $user; global $user;
$objectHelper = new ObjectHelper(); $tabset = array();
$item = new Fedora_Item($this->pid);
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query = $item->get_datastream_dissemination('QUERY'); $query = $item->get_datastream_dissemination('QUERY');
} }
@ -520,7 +521,7 @@ class CollectionClass {
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
if(!empty($policy)){ if (!empty($policy)) {
$content_models = $policy->getContentModels(); $content_models = $policy->getContentModels();
} }
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") {

13
ContentModel.inc

@ -429,12 +429,12 @@ class ContentModel extends XMLDatastream {
*/ */
public function getServices() { public function getServices() {
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and $object <fedora-model:isDeploymentOf> $deploymentOf and $object <fedora-model:isDeploymentOf> $deploymentOf
and $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0> and $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0>
and $object <fedora-model:isContractorOf> <info:fedora/' . $this->pid . '> and $object <fedora-model:isContractorOf> <info:fedora/' . $this->pid . '>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
@ -1374,6 +1374,7 @@ class ContentModel extends XMLDatastream {
else { else {
$status = $class->$methodName($param_array, $method->getAttribute('dsid'), $file, $method->getAttribute('modified_files_ext')); $status = $class->$methodName($param_array, $method->getAttribute('dsid'), $file, $method->getAttribute('modified_files_ext'));
if ($status !== TRUE) { if ($status !== TRUE) {
self::$errors[] = 'Execute Ingest Rules: method \'' . $className . '->' . $methodName . '\' failed.';
$ret = FALSE; $ret = FALSE;
} }
} }

23
ObjectHelper.inc

@ -122,8 +122,7 @@ class ObjectHelper {
$dsID = variable_get('fedora_default_display_dsid', 'TN'); $dsID = variable_get('fedora_default_display_dsid', 'TN');
$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') . '/get/' . $pid . '/' . $dsID;
if ($version) { if ($version) {
$url .= '/' . $version; //drupal_urlencode($version); $url .= '/' . $version; //drupal_urlencode($version);
} }
@ -383,8 +382,8 @@ class ObjectHelper {
$xsl->load($path . '/xsl/convertQDC.xsl'); $xsl->load($path . '/xsl/convertQDC.xsl');
$input = new DomDocument(); $input = new DomDocument();
$input->loadXML(trim($xmlstr)); $input->loadXML(trim($xmlstr));
} catch (exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Problem loading XSL file: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
} }
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);
@ -729,7 +728,7 @@ class ObjectHelper {
*/ */
function get_parent_objects($pid) { function get_parent_objects($pid) {
$query_string = 'select $object $title from <#ri> $query_string = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
@ -829,7 +828,7 @@ class ObjectHelper {
// Get title and descriptions for $pid // Get title and descriptions for $pid
$query_string = 'select $title $desc from <#ri> $query_string = 'select $title $desc from <#ri>
where $o <dc:title> $title where $o <fedora-model:label> $title
and $o <dc:description> $desc and $o <dc:description> $desc
and $o <mulgara:is> <info:fedora/' . $pid . '>'; and $o <mulgara:is> <info:fedora/' . $pid . '>';
@ -858,7 +857,7 @@ class ObjectHelper {
$query_string = 'select $o $title from <#ri> ' . $query_string = 'select $o $title from <#ri> ' .
// $query_string = 'select $o $title $desc from <#ri> '. // $query_string = 'select $o $title $desc from <#ri> '.
'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' . 'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' .
'and $o <dc:title> $title ' . 'and $o <fedora-model:label> $title ' .
// 'and $o <dc:description> $desc '. // 'and $o <dc:description> $desc '.
'and ( '; 'and ( ';
@ -924,12 +923,13 @@ class ObjectHelper {
// Before executing the query, we hve a base case of accessing the top-level collection // Before executing the query, we hve a base case of accessing the top-level collection
global $base_url; global $base_url;
if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) { if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); //$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url); $breadcrumbs[] = l(t('Home'), $base_url);
} }
else { else {
$query_string = 'select $parentObject $title $content from <#ri> $query_string = 'select $parentObject $title $content from <#ri>
where (<info:fedora/' . $pid . '> <dc:title> $title where (<info:fedora/' . $pid . '> <fedora-model:label> $title
and $parentObject <fedora-model:hasModel> $content and $parentObject <fedora-model:hasModel> $content
and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
@ -954,7 +954,8 @@ class ObjectHelper {
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) { if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); //$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url); $breadcrumbs[] = l(t('Home'), $base_url);
} }
elseif ($level > 0) { elseif ($level > 0) {
@ -963,7 +964,7 @@ class ObjectHelper {
} }
else { else {
$breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid); $breadcrumbs[] = l(t("Path Calculation Error"), 'fedora/repository/' . $pid);
} }
} }
} }

6
SecurityClass.inc

@ -71,9 +71,9 @@ class SecurityClass {
try { try {
$xml = new SimpleXMLElement($policyStream); $xml = new SimpleXMLElement($policyStream);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("No roles found in security policy, could not parse policy stream."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR);
//we may not want to send this to the screen. //we may not want to send this to the screen.
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => $e->getMessage())), 'error'); drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => check_plain($e->getMessage()))), 'error');
return NULL; return NULL;
} }
$xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy'); $xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy');
@ -110,7 +110,7 @@ class SecurityClass {
try { try {
$doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml'); $doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml');
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), t("Problem loading policy file."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR);
} }
$conditions = $doc->getElementsByTagName('Condition'); $conditions = $doc->getElementsByTagName('Condition');
foreach ($conditions as $condition) { foreach ($conditions as $condition) {

2
api/fedora_collection.inc

@ -77,7 +77,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb
} }
$query_string = 'select $object $title $content from <#ri> $query_string = 'select $object $title $content from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content and $object <fedora-model:hasModel> $content
and ('; and (';

278
api/fedora_item.inc

@ -1,11 +1,12 @@
<?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#');
/** /**
* Fedora Item Class * Fedora Item Class
@ -18,6 +19,22 @@ class Fedora_Item {
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();
private static $SoapManagedFunctions = array(
'ingest',
'addDataStream',
'addRelationship',
'export',
'getDatastream',
'getDatastreamHistory',
'getNextPID',
'getRelationships',
'modifyDatastreamByValue',
'modifyDatastreamByReference',
'purgeDatastream',
'purgeObject',
'modifyObject',
'setDatastreamState'
);
/** /**
* Create an object to represent an item in the Fedora repository. * Create an object to represent an item in the Fedora repository.
@ -42,8 +59,8 @@ class Fedora_Item {
self::$connection_helper = new ConnectionHelper(); 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)) { 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();
@ -57,8 +74,17 @@ class Fedora_Item {
} }
/** /**
* Exists * Forget this Object, do manually when memory constraints apply.
* @return type *
* Removes this object from the static list of $instantiated_pids
*/
function forget() {
unset(Fedora_Item::$instantiated_pids[$this->pid]);
}
/**
* Exists
* @return type
*/ */
function exists() { function exists() {
return (!empty($this->objectProfile)); return (!empty($this->objectProfile));
@ -72,7 +98,7 @@ class Fedora_Item {
* @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) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -107,13 +133,21 @@ class Fedora_Item {
* @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) {
global $base_url;
if (empty($datastream_label)) { if (empty($datastream_label)) {
$datastream_label = $datastream_id; $datastream_label = $datastream_id;
} }
// 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) {
$datastream_url = str_ireplace('https://', 'http://', $datastream_url);
}
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $datastream_id, 'dsID' => $datastream_id,
@ -142,7 +176,7 @@ class Fedora_Item {
* @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) {
$dir = file_directory_temp(); $dir = file_directory_temp();
@ -155,12 +189,35 @@ class Fedora_Item {
return $returnvalue; return $returnvalue;
} }
/**
* Wrapper to add new or modify existing datastream
* @global url $base_url
* @param url $external_url
* @param string $dsid
* @param string $label
* @param string $mime_type
* @param string $controlGroup
* @param boolean $force
* @param string $logMessage
* @param boolean $quiet
*/
function add_or_modify_by_reference($external_url, $dsid, $label, $mime_type, $controlGroup = 'M', $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
global $base_url;
if (array_key_exists($dsid, $this->datastreams)) {
$this->modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force, $logMessage, $quiet);
}
else {
$file_location = str_replace("$base_url/", '', $external_url);
$this->add_datastream_from_file($file_location, $dsid, $label, $mime_type, $controlGroup = 'M', $logMessage = NULL);
}
}
/** /**
* Add a relationship string to this object's RELS-EXT. * Add a relationship string to this object's RELS-EXT.
* does not support rels-int yet. * does not support rels-int yet.
* @param type $relationship * @param type $relationship
* @param type $object * @param type $object
* @param type $namespaceURI * @param type $namespaceURI
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) {
$ds_list = $this->get_datastreams_list_as_array(); $ds_list = $this->get_datastreams_list_as_array();
@ -237,6 +294,10 @@ class Fedora_Item {
$relationship = "hasModel"; $relationship = "hasModel";
$namespaceURI = FEDORA_MODEL_URI; $namespaceURI = FEDORA_MODEL_URI;
break; break;
case "isPageNumber":
$relationship = "isPageNumber";
$namespaceURI = ISLANDORA_PAGE_URI;
break;
} }
if (substr($object, 0, 12) != 'info:fedora/') { if (substr($object, 0, 12) != 'info:fedora/') {
@ -264,7 +325,7 @@ class Fedora_Item {
/** /**
* Export as foxml * Export as foxml
* @return type * @return type
*/ */
function export_as_foxml() { function export_as_foxml() {
$params = array( $params = array(
@ -345,15 +406,18 @@ class Fedora_Item {
* Get datastream dissemination * Get datastream dissemination
* @param type $dsid * @param type $dsid
* @param type $as_of_date_time * @param type $as_of_date_time
* @return string * @param type $quiet
* @return null
*/ */
function get_datastream_dissemination($dsid, $as_of_date_time = "") { function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
'asOfDateTime' => $as_of_date_time, 'asOfDateTime' => $as_of_date_time,
); );
$object = self::soap_call('getDataStreamDissemination', $params);
// Make soap call with quite
$object = self::soap_call('getDataStreamDissemination', $params, $quiet);
if (!empty($object)) { if (!empty($object)) {
$content = $object->dissemination->stream; $content = $object->dissemination->stream;
$content = trim($content); $content = trim($content);
@ -368,7 +432,7 @@ class Fedora_Item {
* 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 = "") { function get_datastream($dsid, $as_of_date_time = "") {
$params = array( $params = array(
@ -384,7 +448,7 @@ class Fedora_Item {
/** /**
* 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(
@ -406,7 +470,7 @@ class Fedora_Item {
* @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) {
$params = array( $params = array(
@ -574,8 +638,36 @@ class Fedora_Item {
return $relationships; return $relationships;
} }
function get_rdf_relationships() {
$relationships = array();
try {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) {
drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error');
return $relationships;
}
// Parse the RELS-EXT into an associative array.
$relsextxml = new DOMDocument();
$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 ($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'));
$relationships[$child->tagName][] = $value;
}
}
return $relationships;
}
function get_models() { function get_models() {
$relationships = array(); $relationships = array();
try { try {
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
@ -627,19 +719,47 @@ class Fedora_Item {
return FALSE; return FALSE;
} }
/**
* Set the object to a deleted state
*/
function move_to_trash($log_message = 'Flagged deleted using Islandora API.') {
// Loop through the datastreams and mark them deleted
foreach ($this->get_datastreams_list_as_array() as $dsid) {
$this->set_datastream_state($dsid, 'D');
}
// Create a message to mark the object deleted
$params = array(
'pid' => $this->pid,
'state' => 'D',
'logMessage' => $logMessage,
'label' => $this->objectProfile->objLabel,
'ownerId' => null,
);
// Send message to mark the object deleted
return self::soap_call('modifyObject', $params, $quiet);
}
/** /**
* Removes this object form the repository. * Removes this object form the repository.
* @param type $log_message * @param type $log_message
* @param type $force * @param type $force
* @return type * @return type
*/ */
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
$this->move_to_trash($log_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
); );
// Delete the object
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }
@ -650,7 +770,7 @@ class Fedora_Item {
* @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) {
$params = array( $params = array(
@ -667,7 +787,7 @@ class Fedora_Item {
/** /**
* URL * URL
* @global type $base_url * @global type $base_url
* @return type * @return type
*/ */
function url() { function url() {
global $base_url; global $base_url;
@ -677,7 +797,7 @@ class Fedora_Item {
/** /**
* Get Next PID in Namespace * Get Next PID in Namespace
* @param type $pid_namespace * @param type $pid_namespace
* @return type * @return type
*/ */
static function get_next_PID_in_namespace($pid_namespace = '') { static function get_next_PID_in_namespace($pid_namespace = '') {
@ -705,7 +825,7 @@ class Fedora_Item {
/** /**
* ingest from FOXML * ingest from FOXML
* @param type $foxml * @param type $foxml
* @return Fedora_Item * @return Fedora_Item
*/ */
static function ingest_from_FOXML($foxml) { static function ingest_from_FOXML($foxml) {
$params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); $params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested");
@ -716,7 +836,7 @@ class Fedora_Item {
/** /**
* 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) {
$foxml = new DOMDocument(); $foxml = new DOMDocument();
@ -726,7 +846,7 @@ class Fedora_Item {
/** /**
* 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
@ -754,7 +874,7 @@ class Fedora_Item {
* @param type $ownerId * @param type $ownerId
* @param type $logMessage * @param type $logMessage
* @param type $quiet * @param type $quiet
* @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) {
@ -778,7 +898,7 @@ class Fedora_Item {
* @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) {
$params = array( $params = array(
@ -806,7 +926,7 @@ class Fedora_Item {
* @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) {
$params = array( $params = array(
@ -839,74 +959,46 @@ class Fedora_Item {
} }
/** /**
* Soap call * Make a soap call to the fedora API.
* @param type $function_name *
* @param type $params_array * @param string $function
* @param type $quiet * The name of the soap function to call.
* @return type * @param array $parameters
* Paramters to pass onto the soap call
* @param boolean $quiet
* If TRUE suppress drupal messages.
*
* @return mixed
* The return value from the soap function if successful, NULL otherwise.
*/ */
static function soap_call($function_name, $params_array, $quiet = FALSE) { static function soap_call($function, $parameters, $quiet = FALSE) {
if (!self::$connection_helper) { if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
} }
switch ($function_name) { $url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ?
case 'ingest': variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl') :
case 'addDataStream': variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
case 'addRelationship': try {
case 'export': $soap_client = self::$connection_helper->getSoapClient($url);
case 'getDatastream': if (isset($soap_client)) {
case 'getDatastreamHistory': $result = $soap_client->__soapCall($function, array('parameters' => $parameters));
case 'getNextPID': }
case 'getRelationships': else {
case 'modifyDatastreamByValue': if (!$quiet) {
case 'modifyDatastreamByReference': drupal_set_message(t('Error trying to get SOAP client connection'));
case 'purgeDatastream':
case 'purgeObject':
case 'modifyObject':
case 'setDatastreamState':
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
try {
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
if (!$quiet) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
}
else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
}
watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
}
return NULL;
}
break;
default:
try {
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
}
return NULL;
} }
watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
return NULL;
}
} catch (Exception $e) {
if (!$quiet) {
preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ?
drupal_set_message(t('Insufficient permissions to call SOAP function "%func".', array('%func' => $function)), 'error') :
drupal_set_message(t('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error');
}
watchdog('fedora_repository', 'Error Trying to call SOAP function "%func". Exception: @e in @f(@l)\n@t', array('%func' => $function, '@e' => $e->getMessage(), '@f' => $e->getFile(), '@l' => $e->getLine(), '@t' => $e->getTraceAsString()), NULL, WATCHDOG_ERROR);
return NULL;
} }
return $result; return $result;
} }
@ -919,7 +1011,7 @@ class Fedora_Item {
* @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");
@ -974,16 +1066,16 @@ class Fedora_Item {
* @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 = '') {
return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner)); return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner));
} }
/** /**
* 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) {
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);

17
api/fedora_utils.inc

@ -236,8 +236,10 @@ function fix_dsid($dsid) {
function get_collections_as_option_array() { function get_collections_as_option_array() {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
@ -247,13 +249,22 @@ function get_collections_as_option_array() {
$list = explode("\n", $content); $list = explode("\n", $content);
array_shift($list); array_shift($list);
$list = preg_replace('/info:fedora\//', '', $list); $list = preg_replace('/info:fedora\//', '', $list);
foreach ($namespaces as $namespace) {
$trimmed_names[] = trim($namespace);
}
$options = array(); $options = array();
foreach ($list as $item) { //removes blanks foreach ($list as $item) { //removes blanks
if ($item) { if ($item) {
$parts = explode(',', $item); $parts = explode(',', $item);
$options[$parts[0]] = $parts[1]; $namespace = explode(':', $parts[0]);
$namespace = trim($namespace[0]);
$bool = in_array($namespace, $trimmed_names);
if (!$restricted || in_array($namespace, $trimmed_names)) {
$options[$parts[0]] = $parts[1];
}
} }
} }
unset($options['islandora:ContentModelCollection']); unset($options['islandora:ContentModelCollection']);
return $options; return $options;
} }
@ -277,7 +288,7 @@ function get_content_models_as_option_array() {
} }
} }
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)

40
fedora_repository.module

@ -143,7 +143,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
function fedora_repository_ingest_form_submit(array $form, array &$form_state) { function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) { if ($form_state['ahah_submission']) {
$form_state['submitted'] = false; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['storage']['xml']) { if ($form_state['storage']['xml']) {
@ -202,7 +202,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
function fedora_repository_ingest_form_validate($form, &$form_state) { function fedora_repository_ingest_form_validate($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) { if ($form_state['ahah_submission']) {
$form_state['submitted'] = false; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) {
@ -246,8 +246,11 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
if (!empty($file)) { if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) { if (!in_array($dformat, $allowedMimeTypes)) {
form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . form_set_error('ingest-file-location',
implode(' ', $allowedMimeTypes))); t('The uploaded file\'s mimetype') .
' (' . $dformat . ') ' .
t('is not associated with this Content Model. The allowed types are') .
' ' . implode(' ', $allowedMimeTypes));
file_delete($file); file_delete($file);
return; return;
} }
@ -505,7 +508,7 @@ function fedora_repository_purge_object_form_validate($form, &$form_state) {
foreach ($contentModels as $contentModel) { foreach ($contentModels as $contentModel) {
if ($contentModel->pid == 'islandora:collectionCModel') { if ($contentModel->pid == 'islandora:collectionCModel') {
$member_pids = get_related_items_as_array($pid, 'isMemberOfCollection'); $member_pids = get_related_items_as_array($pid, 'isMemberOfCollection');
if (is_array($member_pids) && ! empty($member_pids)){ if (is_array($member_pids) && ! empty($member_pids)) {
form_set_error('new_collection_pid', t("Please purge all members of this collection before deleting the collection itself.")); form_set_error('new_collection_pid', t("Please purge all members of this collection before deleting the collection itself."));
return; return;
} }
@ -614,7 +617,7 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) {
* @param type $collectionName * @param type $collectionName
* @return type * @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) { if ($pid == NULL || $dsId == NULL) {
drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error');
return ''; return '';
@ -704,8 +707,20 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$dformat = $mimetype->getType($file->filepath); $dformat = $mimetype->getType($file->filepath);
$item = new Fedora_Item($pid); $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; $form_state['redirect'] = 'fedora/repository/' . $pid;
} }
@ -879,6 +894,7 @@ function fedora_repository_access($op, $node, $account) {
* @param $dsID String * @param $dsID String
*/ */
function makeObject($pid, $dsID) { function makeObject($pid, $dsID) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!valid_pid($pid)) { if (!valid_pid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
@ -1008,6 +1024,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
); );
} }
} }
// Add a 'manage object' tab for all objects, where detailed list of content is shown. // Add a 'manage object' tab for all objects, where detailed list of content is shown.
$obj = new FedoraObjectDetailedContent($pid); $obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets(); $object_details = $obj->showFieldSets();
@ -1592,7 +1609,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$dc->set_element('dc:title', array('Installed Content Model')); $dc->set_element('dc:title', array('Installed Content Model'));
$dc->save(); $dc->save();
$cmodel_collection->add_datastream_from_string('select $object $title from <#ri> $cmodel_collection->add_datastream_from_string('select $object $title from <#ri>
where ($object <dc:title> $title where ($object <fedora-model:label> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
@ -2146,13 +2163,16 @@ function fedora_repository_display_schema($file) {
* @return type * @return type
*/ */
function fedora_repository_batch_reingest_object($object, &$context) { function fedora_repository_batch_reingest_object($object, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!empty($object) && is_array($object)) { if (!empty($object) && is_array($object)) {
$pid = $object['pid']; $pid = $object['pid'];
if (!valid_pid($pid)) { if (!valid_pid($pid)) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item->exists()) { if ($item->exists()) {
@ -2168,6 +2188,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$context['message'][] = "$new_item->pid installed."; $context['message'][] = "$new_item->pid installed.";
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array( $datastreams = array(
array( array(
@ -2181,10 +2202,13 @@ function fedora_repository_batch_reingest_object($object, &$context) {
} }
if (!empty($datastreams) && is_array($datastreams)) { if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (empty($object['foxml_file']) && !isset($new_item)) { if (empty($object['foxml_file']) && !isset($new_item)) {
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
} }
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
} }

21
fedora_repository.solutionpacks.inc

@ -46,19 +46,21 @@ function fedora_repository_solution_packs_page() {
* @param array $solution_pack * @param array $solution_pack
*/ */
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
// Check each object to see if it is in the repository. // Check each object to see if it is in the repository.
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_path; global $base_path;
$needs_update = FALSE; $needs_update = FALSE;
$needs_install = FALSE; $needs_install = FALSE;
$form = array(); $form = array();
$form['solution_pack_module'] = array( $form['solution_pack_module'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $solution_pack_module, '#value' => $solution_pack_module,
); );
if (!$form_state['submitted']) { if (!$form_state['submitted']) {
$form['soluction_pack_name'] = array( $form['solution_pack_name'] = array(
'#type' => 'markup', '#type' => 'markup',
'#value' => t($solution_pack_name), '#value' => t($solution_pack_name),
'#prefix' => '<h3>', '#prefix' => '<h3>',
@ -75,7 +77,6 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$table_header = array('PID', 'Status'); $table_header = array('PID', 'Status');
$table_rows = array(); $table_rows = array();
foreach ($objects as $object) { foreach ($objects as $object) {
$datastreams = NULL; $datastreams = NULL;
if (isset($object['pid'])) { if (isset($object['pid'])) {
@ -139,13 +140,16 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
); );
if (!$needs_install && !$needs_update) { if (!$needs_install && !$needs_update) {
$form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.');
$submit_button_text = t("Force Reinstallation of Fedora Objects");
} }
else { else {
$form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.');
$submit_button_text = t("Install Fedora Objects");
} }
$form['submit'] = array( $form['submit'] = array(
'#value' => t('Install'), '#value' => $submit_button_text,
'#disabled' => !$needs_install && !$needs_update,
'#type' => 'submit', '#type' => 'submit',
'#name' => $solution_pack_module, '#name' => $solution_pack_module,
); );
@ -159,7 +163,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
function fedora_repository_solution_pack_form_submit($form, &$form_state) { function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $form_state; $what = $form_state;
$module_name = $form_state['values']['solution_pack_module']; $module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke
$solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); $solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array( $batch = array(
'title' => t('Installing / updating solution pack objects'), 'title' => t('Installing / updating solution pack objects'),
'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module',
@ -181,7 +189,7 @@ function solution_pack_add_form($form_name, $form_xml) {
$object->name = $form_name; $object->name = $form_name;
$object->form = $form_xml; $object->form = $form_xml;
$result = drupal_write_record('xml_forms', $object); $result = drupal_write_record('xml_forms', $object);
drupal_set_message("Added $name"); drupal_set_message(t("Added @name", array("@name" => $form_name)));
} }
} }
@ -196,7 +204,6 @@ function solution_pack_add_form_association($content_model, $form_name) {
$object->title_field = "['titleInfo']['title']"; $object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl'; $object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object); $result = drupal_write_record('islandora_content_model_forms', $object);
drupal_set_message("Added association between $content_model$name"); drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name"=>$form_name)));
} }
} }

22
formClass.inc

@ -25,8 +25,8 @@ class formClass {
$items = array(); $items = array();
$items['admin/settings/fedora_repository'] = array( $items['admin/settings/fedora_repository'] = array(
'title' => t('Islandora Configure'), 'title' => t('Islandora Configuration'),
'description' => t('Enter the Islandora Collection information here'), 'description' => t("Configure Islandora's interaction with Fedora"),
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_repository_admin'), 'page arguments' => array('fedora_repository_admin'),
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),
@ -48,7 +48,6 @@ class formClass {
'file' => 'fedora_repository.solutionpacks.inc', 'file' => 'fedora_repository.solutionpacks.inc',
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
); );
$items['islandoracm.xsd'] = array( $items['islandoracm.xsd'] = array(
'title' => t('Islandora Content Model XML Schema Definition'), 'title' => t('Islandora Content Model XML Schema Definition'),
'page callback' => 'fedora_repository_display_schema', 'page callback' => 'fedora_repository_display_schema',
@ -379,7 +378,13 @@ class formClass {
// DC elements // DC elements
$previousElement = NULL; // Used in case we have to nest elements for qualified dublin core. $previousElement = NULL; // Used in case we have to nest elements for qualified dublin core.
$label = null;
foreach ($form_values as $key => $value) { foreach ($form_values as $key => $value) {
//echo ($key);
if ($key == 'dc:title-0') {
$label = $value;
}
$index = strrpos($key, '-'); $index = strrpos($key, '-');
$key = substr($key, 0, $index); $key = substr($key, 0, $index);
$test = substr($key, 0, 2); $test = substr($key, 0, 2);
@ -400,6 +405,13 @@ class formClass {
} }
} }
// Save the title
if ( $label != null )
{
$object = new Fedora_Item($form_values['pid']);
$object->modify_object($label);
}
$dom->appendChild($oai); $dom->appendChild($oai);
if (!$client) { if (!$client) {
@ -498,7 +510,7 @@ class formClass {
'#title' => t('Content models available'), '#title' => t('Content models available'),
'#options' => $potential_models, '#options' => $potential_models,
'#default_value' => $selected_model, '#default_value' => $selected_model,
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> '), '#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a>'),
), ),
), ),
'collection_pid' => array( 'collection_pid' => array(
@ -581,6 +593,8 @@ class formClass {
if (!$this->canShowIngestForm($collection_pid)) { if (!$this->canShowIngestForm($collection_pid)) {
return FALSE; return FALSE;
} }
drupal_set_title($collection_label);
if (module_exists('islandora_content_model_forms')) { if (module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
try { try {

4
plugins/FormBuilder.inc

@ -95,7 +95,7 @@ class FormBuilder {
try { try {
$xml = new SimpleXMLElement($policyStreamDoc); $xml = new SimpleXMLElement($policyStreamDoc);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Problem getting security policy.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE; return FALSE;
} }
@ -173,7 +173,7 @@ class FormBuilder {
$object = Fedora_Item::ingest_from_FOXML($dom); $object = Fedora_Item::ingest_from_FOXML($dom);
if (!empty($object->pid)) { if (!empty($object->pid)) {
// drupal_set_message("Item ". l($object->pid, 'fedora/repository/'. $object->pid) . " created successfully.", "status"); // drupal_set_message("Item ". l($object->pid, 'fedora/repository/'. $object->pid) . " created successfully.", "status");
drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/' . $object->pid))), "status"); drupal_set_message(t("Item !pid created successfully.", array('!pid' => l(check_plain($object->pid), 'fedora/repository/' . check_plain($object->pid)))), "status");
} }
if (!empty($_SESSION['fedora_ingest_files'])) { if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {

2
plugins/PersonalCollectionClass.inc

@ -75,7 +75,7 @@ class PersonalCollectionClass {
try { try {
$xml = new SimpleXMLElement($collectionTemplate); $xml = new SimpleXMLElement($collectionTemplate);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Problem creating personal collection policy, could not parse collection policy stream.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE; return FALSE;
} }

4
plugins/Refworks.inc

@ -83,7 +83,7 @@ class Refworks {
//$dom = dom_import_simplexml($xml);//test to see if it behaves better //$dom = dom_import_simplexml($xml);//test to see if it behaves better
//$xml = new SimpleXMLElement(trim(file_get_contents($file))); //$xml = new SimpleXMLElement(trim(file_get_contents($file)));
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error processing Refworks file:') . " " . $e->getMessage()); drupal_set_message(t('Error processing Refworks file: @message', array('@message' => $e->getMessage())));
return FALSE; return FALSE;
} }
$this->referenceList = array(); $this->referenceList = array();
@ -296,7 +296,7 @@ class Refworks {
$object = $client->__soapCall('ingest', array( $object = $client->__soapCall('ingest', array(
$params $params
)); ));
watchdog(t("FEDORA_REPOSITORY"), t("Successfully added repository item !pid - !it", array('!pid' => $pid, '!it' => $item_title)), NULL, WATCHDOG_INFO); watchdog(t("FEDORA_REPOSITORY"), "Successfully added repository item " . $pid . " - ". $item_title, NULL, WATCHDOG_INFO);
$deleteFiles = $form_values['delete_file']; //remove files from drupal file system $deleteFiles = $form_values['delete_file']; //remove files from drupal file system
if ($deleteFiles > 0) { if ($deleteFiles > 0) {

2
plugins/ShowStreamsInFieldSets.inc

@ -109,7 +109,7 @@ class ShowStreamsInFieldSets {
} }
$dc_html = $objectHelper->getFormattedDC($item); $dc_html = $objectHelper->getFormattedDC($item);
$dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />View Document</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); $dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />' . t('View Document') .'</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE));
$tabset['first_tab']['tabs']['view'] = array( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',

2
xsl/sparql_to_html.xsl

@ -173,7 +173,7 @@
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>

Loading…
Cancel
Save