Browse Source

Merge branch 'master' of https://github.com/Islandora/islandora into test

pull/105/head
jonathangreen 14 years ago
parent
commit
e378055314
  1. 2
      CollectionPolicy.inc
  2. 14
      ConnectionHelper.inc
  3. 3
      MimeClass.inc
  4. 14
      ObjectHelper.inc
  5. 4
      README
  6. 10
      XMLDatastream.inc
  7. 2
      api/fedora_item.inc
  8. 7
      api/fedora_utils.inc
  9. 94
      fedora_repository.module
  10. 37
      ilives/book.inc
  11. 33
      ilives/fedora_ilives.test
  12. 132
      ilives/tests/fedora_ilives.test
  13. 83
      ilives/tests/test_files/mods_record.xml
  14. 22
      ilives/xml/book_collection_policy.xml
  15. 1
      plugins/ShowStreamsInFieldSets.inc
  16. 4
      plugins/slide_viewer.inc
  17. 52
      tests/fedora_repository.test
  18. 70
      tests/test_files/jabberwocky.pdf

2
CollectionPolicy.inc

@ -133,7 +133,7 @@ class CollectionPolicy extends XMLDatastream {
*/
public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) {
$ret = FALSE;
if (($cp = self::loadFromCollection($pid, $modelDsid)) === FALSE) {
if (($cp = self::loadFromCollection($pid )) === FALSE) { //removed second, non-existant variable
module_load_include('inc', 'fedora_repository', 'ContentModel');
if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) {
$newDom = new DOMDocument('1.0', 'utf-8');

14
ConnectionHelper.inc

@ -15,21 +15,16 @@ class ConnectionHelper {
}
function _fixURL($url, $_name, $_pass) {
if ($url == NULL) {
if (empty($url)) {
$url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
}
if ($_name == '' || $_pass == '') {
drupal_set_message(t('No credentials provided.'));
return NULL;
}
$creds = urlencode($_name) . ':'. urlencode($_pass);
if (strpos($url, 'http://') == 0) {
if (strpos($url, 'http://') === 0) {
$new_url = 'http://'. $creds . '@'. substr($url, 7);
}
elseif (strpos($url, 'https://') == 0) {
elseif (strpos($url, 'https://') === 0) {
$new_url = 'https://'. $creds . '@'. substr($url, 8);
}
else {
@ -41,9 +36,10 @@ class ConnectionHelper {
}
function getSoapClient($url = NULL, $exceptions = TRUE) {
if ($url == NULL) {
if (empty($url)) {
$url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
}
global $user;
if ($user->uid == 0) {
//anonymous user. We will need an entry in the fedora users.xml file

3
MimeClass.inc

@ -223,7 +223,8 @@ class MimeClass {
*/
public function get_mimetype( $filename, $debug = FALSE ) {
$ext = strtolower( array_pop( explode( '.', $filename ) ) );
$file_name_and_extension = explode( '.', $filename );
$ext = strtolower( array_pop( $file_name_and_extension ) );
if ( ! empty( $this->private_mime_types[$ext] ) ) {
if ( TRUE === $debug )

14
ObjectHelper.inc

@ -39,7 +39,7 @@ class ObjectHelper {
* @param $pid String
* @param $dsID String
*/
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = FALSE) {
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) {
global $user;
module_load_include('inc','fedora_repository','ContentModel');
if ($pid == NULL || $dsID == NULL) {
@ -998,7 +998,8 @@ class ObjectHelper {
*/
function getBreadcrumbs($pid, &$breadcrumbs, $level=10) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
// Before executing the query, we hve a base case of accessing the top-level collection
global $base_url;
$query_string = 'select $parentObject $title $content from <#ri>
where (<info:fedora/' . $pid . '> <dc:title> $title
and $parentObject <fedora-model:hasModel> $content
@ -1015,18 +1016,21 @@ class ObjectHelper {
$result = preg_split('/[\r\n]+/',do_curl($url));
array_shift($result); // throw away first line
$matches =str_getcsv(join("\n",$result));
if ($matches !== NULL) {
if ($matches !== FALSE) {
$parent = preg_replace('/^info:fedora\//','',$matches[0]);
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) {
$breadcrumbs[] = l(t('Home'), ''); // l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
} elseif ($level > 0) {
$this->getBreadcrumbs($parent, $breadcrumbs, $level - 1);
}
}
}
function warnIfMisconfigured($app) {
public static function warnIfMisconfigured($app) {
$messMap = array(
'Kakadu' => 'Full installation instructions for Kakadu can be found
<a href=http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=27&Itemid=23>Here</a>',

4
README

@ -7,3 +7,7 @@ https://wiki.duraspace.org/display/ISLANDORA/Islandora
Specifically the Islandora Guide:
https://wiki.duraspace.org/display/ISLANDORA/Islandora+Guide
All bugs, feature requests and improvement suggestions are tracked at the DuraSpace JIRA:
https://jira.duraspace.org/browse/ISLANDORA

10
XMLDatastream.inc

@ -92,11 +92,17 @@ abstract class XMLDatastream {
*/
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) {
libxml_use_internal_errors(true);
$this->pid = $pid;
$this->dsid = $dsid;
if ($xmlStr !== NULL) {
$this->xml = (is_object($xmlStr) && get_class($xmlStr) == DOMDocument) ? $xmlStr : DOMDocument::loadXML($xmlStr);
if(is_object($xmlStr) && get_class($xmlStr) == DOMDocument) {
$this->xml = $xmlStr;
}
else {
$this->xml = new DOMDocument();
$this->xml->loadXML($xmlStr);
}
}
}

2
api/fedora_item.inc

@ -96,7 +96,7 @@ class Fedora_Item {
'logMessage' => ($logMessage != null)?$logMessage: 'Ingested object '. $datastream_id
);
return $this->soap_call( 'addDataStream', $params )->datastreamID;
return $this->soap_call( 'addDataStream', $params );
}
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M',$logMessage = null) {

7
api/fedora_utils.inc

@ -66,11 +66,8 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
}
function fedora_available() {
$ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1);
// A bit of a hack but the SOAP parser will cause a fatal error if you give it the wrong URL.
// PHP SOAP is now an installation requirement so this check is all we need to do.
return (strpos($ret, 'wsdl:definitions') != FALSE);
$response = do_curl(variable_get('fedora_base_url', 'http://localhost:8080/fedora').'/describe');
return strstr($response, 'Repository Information HTML Presentation') !== FALSE;
}
/**

94
fedora_repository.module

@ -236,7 +236,12 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) {
global $base_url;
// $form['#redirect'] = "fedora/repository/$collectionPid/";
if (!user_access('purge objects and datastreams')) {
return NULL;
}
if ($pid == NULL) {
return NULL;
}
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$pid"
@ -307,8 +312,9 @@ function add_stream_form_submit($form, &$form_state) {
$pid = $form_state['values']['pid'];
$dsid = $form_state['values']['stream_id'];
$dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.;
$streamUrl = $base_url . '/' . drupal_urlencode($file);
$file_basename = basename($file);
$file_directory = dirname($file);
$streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename);
/* -----------------------------------------------------------------
* need a better way to get mimetypes
@ -332,14 +338,10 @@ function add_stream_form_submit($form, &$form_state) {
return;
}
$form_state['rebuild'] = TRUE;
//$form_state['redirect'] = $base_url."/fedora/repository/$pid";
// drupal_goto("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
function add_stream_form(&$form_state, $pid) {
//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', '');
module_load_include('inc', 'fedora_repository', 'formClass');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$addDataStreamForm = new formClass();
return $addDataStreamForm->createAddDataStreamForm($pid, $form_state);
}
@ -404,7 +406,6 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
function fedora_repository_purge_object_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$pid = $form_state['values']['pid'];
if (!isset($form_state['storage']['confirm'])) {
$form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form
@ -478,7 +479,7 @@ function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName
drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error');
return '';
}
$output .= drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel);
$output = drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel);
return $output;
}
@ -518,74 +519,34 @@ function fedora_repository_replace_stream_form_validate($form, &$form_state) {
}
function fedora_repository_replace_stream_form_submit($form, &$form_state) {
global $base_url;
$file = $form_state['values']['file'];
$pid = $form_state['values']['pid'];
$dsid = $form_state['values']['dsId'];
$dsLabel = $form_state['values']['dsLabel'];
// Remove the original file extension from the label and add the new one
$dsLabel = substr($form_state['values']['dsLabel'], 0, strrpos($form_state['values']['dsLabel'], '.'));
$indexOfDot = strrpos($dsLabel,'.');//use strrpos to get the last dot
if($indexOfDot !== FALSE){
$dsLabel = substr($dsLabel, 0, $indexOfDot);
$dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.;
}
module_load_include('inc', 'Fedora_Repository', 'MimeClass');
module_load_include('inc', 'Fedora_Repository', 'ObjectHelper');
module_load_include('inc', 'Fedora_Repository', 'ConnectionHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$streamUrl = file_create_url($file->filepath);
$file_basename = basename($file->filepath);
$file_directory = dirname($file->filepath);
$streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename);
/* -----------------------------------------------------------------
* need a better way to get mimetypes
* TODO: need a better way to get mimetypes
*/
$mimetype = new MimeClass();
$dformat = $mimetype->getType($file->filepath);
$item = new Fedora_Item($pid);
$controlGroup = "M";
$function = 'modifyDatastreamByReference';
$params = array(
'pid' => $pid,
'dsID' => $dsid,
'altIDs' => "",
'dsLabel' => $dsLabel,
'MIMEType' => $dformat,
'formatURI' => "URL",
'dsLocation' => $streamUrl,
'controlGroup' => "$controlGroup",
'dsState' => "A",
'checksumType' => "DISABLED",
'checksum' => "none",
'logMessage' => "datastream replaced",
'force' => FALSE,
);
if ($dformat == 'text/xml') {
$doc = new DOMDocument();
$doc->load($file->filepath);
$controlGroup = 'X';
$function = 'modifyDatastreamByValue';
$params['dsContent'] = $doc->saveXML();
unset($params['dsLocation']);
}
try {
$soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
if ($client == NULL) {
drupal_set_message(t('Error Getting Soap Client.'), 'error');
return;
}
$object = $client->__soapCall($function, array('parameters' => $params));
// Apply the add datastream rules.
$object_helper = new ObjectHelper();
$object_helper->get_and_do_datastream_rules($pid, $dsid, $file->filepath);
file_delete($file->filepath);
} catch (exception $e) {
drupal_set_message(t($e->getMessage()), 'error');
return;
}
$item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat);
drupal_goto('fedora/repository/' . $pid . '/-/' . $dsId);
$form_state['redirect'] = 'fedora/repository/' . $pid;
}
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
@ -1392,9 +1353,16 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos');
$tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
$cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X');
$cm = new Fedora_Item('demo:DualResImage');
try {
$cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X');
} catch (exception $e) {
}
$dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection');
try {
$cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X');
drupal_set_message("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", 'message');
} catch (exception $e) {

37
ilives/book.inc

@ -58,8 +58,12 @@ class IslandoraBook {
'#type' => 'textarea',
'#title' => 'MODS Record to Import',
'#rows' => 20,
'#value' => (!empty($mods_save) ? $mods_save['mods']['mods_record'] : ''),
);
if (!empty($mods_save)) {
$form['mods']['mods_record']['#value'] = $mods_save['mods']['mods_record'];
}
return $form;
}
@ -101,7 +105,7 @@ class IslandoraBook {
return TRUE;
}
public function handleIngestForm($form_values) {
public function handleIngestForm($form_values, &$form_state) {
/*
* process the metadata form
* Create fedora object
@ -113,40 +117,47 @@ class IslandoraBook {
return;
}
$mods_list_doc = new DomDocument();
$mods_list_doc->loadXML($form_values['mods']['mods_record']);
$mods_item_doc = new DomDocument();
$mods_item = $mods_list_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'mods')->item(0);
$new_mods_item = $mods_item_doc->importNode($mods_item, TRUE);
$mods_item_doc->appendChild($new_mods_item);
$mods_simple = simplexml_load_string($form_values['mods']['mods_record']);
$title_info = $mods_item_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'titleInfo')->item(0);
$title = '';
foreach ($mods_simple->children('http://www.loc.gov/mods/v3')->mods[0]->titleInfo[0]->children() as $child) {
if ($child->getName() == 'subTitle') {
// We don't care about subtitles for creating the item label.
continue;
}
$title .= $child;
foreach(array('nonSort', 'title') as $title_field) {
$title .= $title_info->getElementsByTagNameNS('http://www.loc.gov/mods/v3', $title_field)->item(0)->nodeValue;
}
$mods_text = $mods_item_doc->saveXML();
global $user;
$mimetype = new MimeClass();
$new_item = Fedora_Item::ingest_new_item(!empty($form_values['custom_pid']) ? $form_values['custom_pid'] : $form_values['pid'], 'A', $title,
$user->name);
$new_item->add_datastream_from_string($form_values['mods']['mods_record'], 'MODS',
$new_item->add_datastream_from_string($mods_text, 'MODS',
'MODS Metadata', 'text/xml', 'X');
$dc = transform_mods_to_dc($form_values['mods']['mods_record']);
$dc = transform_mods_to_dc($mods_text);
if ($dc) {
// Add the PID to a dc:identifier field.
$dc_doc = simplexml_load_string($dc);
$dc_item = $dc_doc->xpath('/srw_dc:dcCollection/srw_dc:dc[1]');
$dc_doc->registerXPathNamespace('oai_dc', 'http://www.openarchives.org/OAI/2.0/oai_dc/');
$dc_item = $dc_doc->xpath('//oai_dc:dc');
foreach($dc_item as $node) {
$node->addChild('identifier', $new_item->pid, 'http://purl.org/dc/elements/1.1/');
$node->addChild('dc:identifier', $new_item->pid, 'http://purl.org/dc/elements/1.1/');
}
$new_item->modify_datastream_by_value($dc_doc->saveXML(), 'DC', 'Dublin Core XML Metadata', 'text/xml');
}
$new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI);
$new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']);
drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($new_item->pid, 'fedora/repository/'. $new_item->pid))), "status");
}
public function buildAddPagesForm($form = array()) {
}

33
ilives/fedora_ilives.test

@ -1,33 +0,0 @@
<?php
class fedoraBookTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Fedora Ilives',
'description' => t('The Fedora repository book module.'),
'group' => t('fedora repository'),
);
}
protected function setUp() {
parent::setUp('fedora_ilives', 'fedora_repository');
// Create and login user.
$drupal_user = $this->drupalCreateUser(array('add fedora datastreams',
'edit fedora meta data',
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection'));
$this->drupalLogin($drupal_user);
}
public function testFedoraIlives() {
// Initially we are just testing that the module installs successfully from a clean Drupal. ISLANDORA-165.
$this->pass(drupal_get_path('module', 'fedora_ilives'));
}
}

132
ilives/tests/fedora_ilives.test

@ -0,0 +1,132 @@
<?php
// $Id$
/*
* Tests the functions of the Fedora Repository module.
*/
class FedoraBookTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Fedora Book',
'description' => t('The Fedora repository book content model.'),
'group' => t('fedora repository'),
);
}
function setUp() {
parent::setUp('fedora_repository', 'fedora_ilives', 'tabs');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
// Create and login user.
$repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams',
'edit fedora meta data',
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection',
'view detailed list of content'));
$this->drupalLogin($repository_user);
}
public function testBookCModel() {
// First add a book collection
$pid_list = array();
// Create a collection for ingesting book content model objects.
$ingest_form = array();
$ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM';
$this->drupalPost('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection', $ingest_form, 'Next');
$ingest_title = $this->randomName(32);
$ingest_form_step_2['dc:title'] = $ingest_title;
$ingest_form_step_2['dc:description'] = $this->randomName(256);
$ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_ilives') . '/xml/book_collection_policy.xml');
$this->drupalPost(NULL, $ingest_form_step_2, 'Ingest');
$this->assertPattern('/Item .* created successfully./', "Verified item created.");
$pid = $this->getIngestedPid();
$this->drupalGet("fedora/repository/$pid");
$pid_list[] = $pid;
// Now add a book into the new collection
$this->pass("Create book collection $pid below top-level collection.", 'fedora book');
$ingest_book_form = array();
$ingest_book_form['models'] = 'ilives:bookCModel/ISLANDORACM';
$this->drupalPost("fedora/ingestObject/$pid/", $ingest_book_form, 'Next');
$ingest_book_form_step_2 = array();
$ingest_book_form_step_2['mods[mods_record]'] = file_get_contents(drupal_get_path('module', 'fedora_ilives') . '/tests/test_files/mods_record.xml');
$this->outputScreenContents();
$this->drupalPost(NULL, $ingest_book_form_step_2, 'Ingest');
$this->outputScreenContents();
$book_pid = $this->getIngestedPid();
$pid_list[] = $book_pid;
if (!empty($book_pid)) {
$this->pass("Successfully ingested book object $book_pid.");
}
$this->cleanUpRepository($pid_list);
}
private function cleanUpRepository($pid_list = array()) {
$this->pass("This is the PID list to purge: ". implode(", ", $pid_list) );
foreach ($pid_list as $pid) {
$this->drupalPost("fedora/repository/purgeObject/$pid", array(), 'Purge');
$this->drupalPost(NULL, array(), 'Delete');
}
}
private function getIngestedPid() {
$subject = $this->drupalGetContent();
$pattern = '/">(.*)<\/a> created successfully./';
$matches = array();
$res = preg_match($pattern, $subject, $matches);
return $matches[1];
}
private function outputScreenContents($description = '', $basename = '') {
// This is a hack to get a directory that won't be cleaned up by SimpleTest.
$file_dir = file_directory_path() . '../simpletest_output_pages';
if (!is_dir($file_dir)) {
mkdir($file_dir, 0777, TRUE);
}
$output_path = "$file_dir/$basename.". $this->randomName(10) . '.html';
$rv = file_put_contents($output_path, $this->drupalGetContent());
$this->pass("$description: Contents of result page are ". l('here', $output_path));
}
protected function drupalCreateFedoraUser($permissions = array('access comments', 'access content', 'post comments', 'post comments without approval')) {
// Create a role with the given permission set.
if (!($rid = $this->drupalCreateRole($permissions))) {
return FALSE;
}
// Create a user assigned to that role.
$edit = array();
$edit['name'] = 'simpletestuser';
$edit['mail'] = $edit['name'] . '@example.com';
$edit['roles'] = array($rid => $rid);
$edit['pass'] = 'simpletestpass';
$edit['status'] = 1;
$account = user_save('', $edit);
$this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
if (empty($account->uid)) {
return FALSE;
}
// Add the raw password so that we can log in as this user.
$account->pass_raw = $edit['pass'];
return $account;
}
}

83
ilives/tests/test_files/mods_record.xml

@ -0,0 +1,83 @@
<?xml version="1.0"?>
<mods:modsCollection xmlns:mods="http://www.loc.gov/mods/v3" version="3.0">
<mods:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" version="3.0" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd">
<titleInfo>
<nonSort>The </nonSort>
<title>amazing Maurice and his educated rodents</title>
</titleInfo>
<name type="personal">
<namePart>Pratchett, Terry.</namePart>
<role>
<roleTerm authority="marcrelator" type="text">creator</roleTerm>
</role>
</name>
<typeOfResource>text</typeOfResource>
<genre authority="marc">novel</genre>
<originInfo>
<place>
<placeTerm type="code" authority="marccountry">enk</placeTerm>
</place>
<place>
<placeTerm type="text">London</placeTerm>
</place>
<publisher>Corgi Books</publisher>
<dateIssued>2002</dateIssued>
<dateIssued encoding="marc">2001</dateIssued>
<issuance>monographic</issuance>
</originInfo>
<language>
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</language>
<physicalDescription>
<form authority="marcform">print</form>
<extent>269 p. ; 22 cm.</extent>
</physicalDescription>
<abstract>A talking cat, intelligent rats, and a strange boy cooperate in a Pied Piper scam until they try to con the wrong town and are confronted by a deadly evil rat king.</abstract>
<targetAudience authority="marctarget">juvenile</targetAudience>
<note type="statement of responsibility">Terry Pratchett.</note>
<note>Carnegie Medal winner.</note>
<subject authority="lcsh">
<topic>Discworld (Imaginary place)</topic>
<topic>Fiction</topic>
</subject>
<subject authority="lcsh">
<topic>Discworld (Imaginary place)</topic>
<topic>Fiction</topic>
</subject>
<subject authority="lcsh">
<topic>Rats</topic>
<topic>Fiction</topic>
</subject>
<subject authority="lcsh">
<topic>Cats</topic>
<topic>Fiction</topic>
</subject>
<subject authority="lcsh">
<topic>Fantasy fiction</topic>
</subject>
<subject authority="lcsh">
<topic>Humorous stories</topic>
</subject>
<classification authority="lcc">PZ7.P8865 Am 2002</classification>
<relatedItem>
<titleInfo>
<title>Discworld series</title>
</titleInfo>
<name type="personal">
<namePart>Pratchett, Terry.</namePart>
</name>
</relatedItem>
<identifier type="isbn">006001234X (library binding)</identifier>
<identifier type="isbn">0385601239</identifier>
<identifier type="isbn">0552546933 (pbk.)</identifier>
<recordInfo>
<recordContentSource authority="marcorg">CaNWHRN</recordContentSource>
<recordCreationDate encoding="marc">010730</recordCreationDate>
<recordChangeDate encoding="iso8601">20020314 .0</recordChangeDate>
<languageOfCataloging>
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</languageOfCataloging>
</recordInfo>
</mods:mods>
</mods:modsCollection>

22
ilives/xml/book_collection_policy.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd">
<content_models>
<content_model dsid="ISLANDORACM" name="Book" namespace="islandora" pid="ilives:bookCModel"></content_model>
</content_models>
<search_terms>
<term field="dc.title">dc.title</term>
<term field="dc.creator">dc.creator</term>
<term default="true" field="dc.description">dc.description</term>
<term field="dc.date">dc.date</term>
<term field="dc.identifier">dc.identifier</term>
<term field="dc.language">dc.language</term>
<term field="dc.publisher">dc.publisher</term>
<term field="dc.rights">dc.rights</term>
<term field="dc.subject">dc.subject</term>
<term field="dc.relation">dc.relation</term>
<term field="dcterms.temporal">dcterms.temporal</term>
<term field="dcterms.spatial">dcterms.spatial</term>
<term field="fgs.DS.first.text">Full Text</term>
</search_terms>
<relationship>isMemberOfCollection</relationship>
</collection_policy>

1
plugins/ShowStreamsInFieldSets.inc

@ -57,7 +57,6 @@ class ShowStreamsInFieldSets {
*/
function showPDFPreview() {
global $base_url;
$tabset = array();
$tabset['my_tabset'] = array(

4
plugins/slide_viewer.inc

@ -44,8 +44,8 @@ class ShowSlideStreamsInFieldSets {
'#type' => 'tabpage',
'#title' => t('View'),
// This will be the content of the tab.
'#content' => '<a href="'. $base_url . '/fedora/repository/'. $this->pid . '/FULL_JPG/"><img src="'. $base_url .
'/fedora/imageapi/'. $this->pid . '/JPG/JPG.jpg'. '" /></a>'. '<p>'. drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
'#content' => '<img src="'. $base_url .
'/fedora/imageapi/'. $this->pid . '/JPG/JPG.jpg'. '" />'. '<p>'. drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
);
$ssifs = new ShowStreamsInFieldSets($this->pid);

52
tests/fedora_repository.test

@ -16,7 +16,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
}
function setUp() {
parent::setUp('fedora_repository');
parent::setUp('fedora_repository', 'tabs');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -26,13 +26,51 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection'));
'view fedora collection',
'view detailed list of content'));
$this->drupalLogin($repository_user);
}
public function testDatastreams() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pid_list = array();
// Test Add datastream form
$cm_item = fedora_item::ingest_new_item();
$cm_item->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI);
$cm_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository').'/content_models/STRICT_PDFCM.xml', 'ISLANDORACM');
$pids_list[] = $cm_item->pid;
// Ingest a new PDF object
$pdf_item = fedora_item::ingest_new_item();
$pdf_item->add_relationship('hasModel', $cm_item->pid, FEDORA_MODEL_URI);
$pids_list[] = $pdf_item->pid;
// Submit the add datastream form.
$add_stream_form = array();
$add_stream_form['pid'] = $pdf_item->pid;
$add_stream_form['stream_label'] = $this->randomName(20);
$rpath = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf');
$add_stream_form['files[add-stream-file-location]'] = $rpath;
$add_stream_form['stream_id'] = 'OBJ';
$this->drupalPost('fedora/repository/' . $pdf_item->pid, $add_stream_form, 'Add Datastream');
// Test replace datastream form
$this->assertText('The datastream has been uploaded', "Add initial datastream.", 'fedora datastreams');
$this->drupalGet('fedora/repository/'.$pdf_item->pid);
$this->assertText($add_stream_form['stream_label'], 'Datastream appears in DS list.', 'fedora datastreams');
$replace_stream_edit = array();
$replace_stream_rpath = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/jabberwocky.pdf');
$replace_stream_edit['files[file]'] = $replace_stream_rpath;
$this->drupalPost("fedora/repository/replaceStream/$pdf_item->pid/OBJ/NewLabel", $replace_stream_edit , 'Replace Datastream' );
$this->assertText('NewLabel', "Replacement datastream appears in DS list.", 'fedora datastreams');
$this->outputScreenContents();
}
/**
* Add an item based on a content model. Initially we will assume that the repository
* will be populated with the default content models and collections that are
@ -71,7 +109,8 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$this->drupalPost('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection', $ingest_form, 'Next');
// Required fields are file location, dc:title and dc:description
$ingest_form_step_2 = array();
$ingest_form_step_2['dc:title'] = $this->randomName(32);
$ingest_title = $this->randomName(32);
$ingest_form_step_2['dc:title'] = $ingest_title;
$ingest_form_step_2['dc:description'] = $this->randomName(256);
$ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml');
$this->drupalPost(NULL, $ingest_form_step_2, 'Ingest');
@ -79,6 +118,11 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$this->assertPattern('/Item .* created successfully./', "Verified item created.");
$pid = $this->getIngestedPid();
$this->drupalGet("fedora/repository/$pid");
$this->assertLink('Home');
$this->assertLink('Digital Repository');
$this->assertLink($ingest_title);
$pid_list[] = $pid;
$this->pass('Now attempting to ingest a PDF into the new collection.');
// Now try ingesting a PDF
@ -115,7 +159,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
return $matches[1];
}
private function outputScreenContents($description, $basename) {
private function outputScreenContents($description = '', $basename = '') {
// This is a hack to get a directory that won't be cleaned up by SimpleTest.
$file_dir = file_directory_path() . '../simpletest_output_pages';
if (!is_dir($file_dir)) {

70
tests/test_files/jabberwocky.pdf

@ -0,0 +1,70 @@
%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
/Producer (FOP 0.20.4) >>
endobj
5 0 obj
<< /Length 1072 /Filter [ /ASCII85Decode /FlateDecode ]
>>
stream
GauHJ9lHOU&A@P9+Ls=kZBT8uH`3C?<>7mEU"lXh$lJId`fU_(r;/e^nT\OkBiS.`mB/18H#MhjAhMNVqer1i"h%p;ji3^<nr7-Z)qT,-O)'$i?Bc^9'YCg:,Z[O>+",Ygb:k#?^)p.QT2p8$=c"\RZ*GD[][0DY/+O<7ns>P!GTc"qg3V`Elf8[ucC3n;8GLDbS'3NT:1+<%oP!8j3ZqfTj.pB[FXE`R[ZHEM`c<4@d[aPPJ*R]Z_sXd35cB^\jP4oZa'T+V>E'UA>ZQMi%G2r.!R?3Nr))oAp?cPdqg"4KHA3%^!;$:Z(f05.Z]&m)bllAbT#,#1m-;\03Q`aPEO7^jC6/bQG86_ufm60&D^VT\isRuBf8rXnJ`K]o?Ej,on&nG$?;bHX[iumsA;WDZ0[eo96Q#@uR1JFnAWbRK>`LK!oIL+PpHI@))$Ind..P7gba5:*<pMV6@OWWM)C=i$@6J"?0e!u]d4Y,i2c2Td>E+"ZS1D[5Z+XDmn@md9I^`JbRMH"cJ-`e@on;L\hL?)04l*?N!XK'[79UD5^D','$nRX+_>:2"[Tbm!hig+ucG0V"U;M]A@Q#-FT(]PW.G3\ulS!,5`_o=LV%lr$_%I270peU>CAQ]MT6m42[>O[2hHjQT7+@"cf0Wo%mL31Cd>qe:YOpAV0J&5T#9_q:_tm>aHoHj"K'Pq0'\4R^.[d#6QA_Mm.$CY,,?o"s]=t6uXP.:;5pR2AA2`cLe5ZiC*gAEJZ+g/2SgS)jgHpDm4-HW\[LP@:!GS@ceKJoV6V3_>"KW&8K*mtHg]FLM-2AVRX_:SGf5pZ2?%&,UE!\(Xk;k1K.SNd[TZE(6+;OQk9TLG/V66t[S1<%\oWD6EPtgoCpXBRVWL)Y!KT`,LM%1kdol(s=`o1IAASXrnJ'nGg,H7Y8V5AF/+MtRH3#.1.Smb%=<5;\#Z-eY>c]LQ*Kq/Za4/K7uBEUB16qt!cA+d[XoVT@cGtt:S;dM9:.CW5i@V]f^E-?'IB6=,Jrm@hE[NX7^6E-[Y397[B$\'nlrkW^BqLR)7hDj?*37`OQ2noBVcONh~>
endstream
endobj
6 0 obj
<< /Type /Page
/Parent 1 0 R
/MediaBox [ 0 0 576 792 ]
/Resources 3 0 R
/Contents 5 0 R
>>
endobj
7 0 obj
<< /Type /Font
/Subtype /Type1
/Name /F6
/BaseFont /Times-Italic
/Encoding /WinAnsiEncoding >>
endobj
8 0 obj
<< /Type /Font
/Subtype /Type1
/Name /F5
/BaseFont /Times-Roman
/Encoding /WinAnsiEncoding >>
endobj
1 0 obj
<< /Type /Pages
/Count 1
/Kids [6 0 R ] >>
endobj
2 0 obj
<< /Type /Catalog
/Pages 1 0 R
>>
endobj
3 0 obj
<<
/Font << /F6 7 0 R /F5 8 0 R >>
/ProcSet [ /PDF /ImageC /Text ] >>
endobj
xref
0 9
0000000000 65535 f
0000001560 00000 n
0000001618 00000 n
0000001668 00000 n
0000000015 00000 n
0000000071 00000 n
0000001235 00000 n
0000001341 00000 n
0000001451 00000 n
trailer
<<
/Size 9
/Root 2 0 R
/Info 4 0 R
>>
startxref
1756
%%EOF
Loading…
Cancel
Save