Browse Source

ISLANDORA-743 Before the hook was not firing at the right time.

pull/164/head
William Panting 12 years ago
parent
commit
f863d9f2a4
  1. 44
      fedora_repository.module
  2. 16
      fedora_repository.solutionpacks.inc

44
fedora_repository.module

@ -2233,7 +2233,9 @@ function fedora_repository_display_schema($file) {
/**
* fedora repository batch reingest object
* @param type $object
*
* @param array $object
* An array defining an object to ingest.
* @param type $context
* @return type
*/
@ -2249,23 +2251,22 @@ function fedora_repository_batch_reingest_object($object, &$context) {
}
// Does the object exist? If so, purge it.
//dd("About to test existence of PID: $pid");
$item = new Fedora_Item($pid);
if ($item->exists()) {
//dd(' Found');
$item->purge(t('Remove during re-install batch job'));
//dd(' Purged');
}
// Need to have this a couple places...
// (After trying from FOXML and later for individual DSs)
$new_item = NULL;
// Seems like this might be getting messed up due to scope?.
$datastreams = array();
$new_item = NULL; //Need to have this a couple places... (After trying from FOXML and later for individual DSs)
$datastreams = array(); //Seems like this might be getting messed up due to scope?
// Ingest the object from the source file.
// Ingest the object from the source file.
if (!empty($object['foxml_file'])) {
$foxml_file = $object['foxml_file'];
$new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
if ($new_item->exists()) {
// Batch operation was successful; can still add additional DSs, though
// Batch operation was successful; can still add additional DSs, though.
$context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid));
}
}
@ -2282,9 +2283,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$label = !empty($object['label']) ? $object['label'] : '';
if (!isset($new_item)) {
//dd(' Not found, creating');
$new_item = Fedora_Item::ingest_new_item($pid, 'A', $label);
//dd(' Created');
}
elseif (!empty($label)) {
$new_item->modify_object($label);
@ -2292,17 +2291,12 @@ function fedora_repository_batch_reingest_object($object, &$context) {
if (isset($new_item)) {
if (!empty($object['cmodel'])) {
//dd(' relating to cmodel');
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
//dd(' related to cmodel');
}
if (!empty($object['parent'])) {
//dd(' adding parent');
$new_item->add_relationship('isMemberOfCollection', $object['parent']);
//dd(' parent added');
}
foreach ((array)$datastreams as $ds) {
//dd("trying to add ds: {$ds['dsid']}");
foreach ((array) $datastreams as $ds) {
if ($ds['dsid'] == 'DC') {
$new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
}
@ -2315,7 +2309,21 @@ function fedora_repository_batch_reingest_object($object, &$context) {
}
/**
* Content model, collection view and collection policy datastreams may now optionally define a version
* This function will send the postprocess solution pack hook.
* It is referenced by the solution pack form's batch finished entry.
*
*/
function fedora_repository_solutionpack_send_postprocess($success, $results, $operations) {
// Hook to let solution pack objects be modified.
// Not using module_invoke so solution packs can be expanded by other modules.
if($success) {
module_invoke_all('postprocess_solution_pack', $_SESSION['solution_pack_module_name']);
}
}
/**
* Content model, collection view and collection policy datastreams may
* now optionally define a version
* number in their top-level XML element as an attribute, as in:
* <content_model name="Collection" version="2" ...
*

16
fedora_repository.solutionpacks.inc

@ -57,7 +57,9 @@ function fedora_repository_solution_packs_page() {
* Check for installed objects and add a 'Update' or 'Install' button if
* some objects are missing.
*
* @param array $solution_pack
* @param array &$form_state
* @param array $solution_pack_module
* @param array $solution_pack_name
*/
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
@ -201,15 +203,18 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object));
}
batch_set($batch);
// Used in postprocess hook.
$_SESSION['solution_pack_module_name'] = $module_name;
// Tell the batch to call the function to send out a postprocess hook.
$batch['finished'] = 'fedora_repository_solutionpack_send_postprocess';
// Hook to let solution pack objects be modified.
// Not using module_invoke so solution packs can be expanded by other modules.
module_invoke_all('postprocess_solution_pack', $module_name);
batch_set($batch);
}
/**
* Writes a form entry into the database.
*
* @param unknown_type $form_name
* @param unknown_type $form_xml
@ -226,6 +231,7 @@ function solution_pack_add_form($form_name, $form_xml) {
}
/**
* Writes a form association to the database
*
* @param unknown_type $content_model
* @param unknown_type $form_name

Loading…
Cancel
Save