Commit 5be05fd9 authored by Mark Jordan's avatar Mark Jordan
Browse files

Some cleanup.

parent b088e100
......@@ -2,13 +2,13 @@
## Introduction
[BagIt](https://wiki.ucop.edu/display/Curation/BagIt) is a specification for packaging content and metadata about that content into a format that can be shared between applications. This module provides a framework for generating Bags for Islandora objects. It is a fork of the [Islandora BagIt](https://github.com/Islandora/islandora_bagit) module. The main differences between it and this module are:
[BagIt](https://wiki.ucop.edu/display/Curation/BagIt) is a specification for packaging content and metadata about that content into a format that can be shared between applications. This module provides a framework for generating Bags for Islandora objects. It is Based on the [Islandora BagIt](https://github.com/Islandora/islandora_bagit) module. The main differences between it and this module are:
* this module does not provide a usere-facing option to generate Bags, it only provides a Drush command.
* this module does not provide implementations of Islandora hooks to detect when an object or datastream has been ingested or modified.
* this module replaces Islandora BagIt's plugins with submodules.
Islandora sites should not enable both this module and Islandora BagIt. Only one should be enabled since they share permissions and hook definitions.
Islandora sites can safely enable both this module and Islandora BagIt. However, if a site's requirements are met by Islandora BagIt, it is probably best to not enable this module as well.
## Requirements
......@@ -32,9 +32,18 @@ To install the Islandora BagIt Light module:
5. Enable the Libraries and Islandora BagIt Light modules like you would any other contrib modules.
## Usage
Bags can be created for individual Islandora objects or for lists of objects using Drush:
`drush -u 1 islandora-create-bag --pid=islandora:102 --ini_file=test.ini`
`drush -u 1 islandora-create-bag --pid_file=/tmp/pid_to_create_bags_for.txt --ini_file=test.ini`
The .ini file and PID file are documented below.
## Configuration
All configuration for this module is performed either via Drush options and .ini files.
All configuration for this module is performed via .ini files.
Sample .ini file:
......@@ -49,8 +58,8 @@ Sample .ini file:
; Defaults to 'BagItPHP'.
; bagit_library_directory = SomeOtherDir
; Log creation of Bags to the Drupal system log.
log_bag_creation = true
; Log creation of Bags to the Drupal system log. Defaults to TRUE.
; log_bag_creation = true
; Defaults to 'islandora_bagit_light_temp' within the directory configured
; in Drupal's "Temporary directory" admin setting. Note: this directory
......@@ -74,7 +83,7 @@ log_bag_creation = true
bag_name_prefix = 'islandora_object_bag-'
; Whether or not to create a zip or tgz archive of the Bag.
; Defaults to true;
; Defaults to true.
; serialize_bags = false
; Must be either 'tgz' or 'zip'. Defaults to 'zip'.
......@@ -104,26 +113,8 @@ Organization-Address = "Visit us at [site:url] any time you want."
You can insert Drupal tokens in tag values if the [Token](https://www.drupal.org/project/token) module is enabled. Most standard Drupal tokens won't apply to Islandora content, but some [types of tokens](https://www.drupal.org/node/390482), such as tokens that describe site information or users, might be applicable. The [Islandora Pathauto](https://github.com/Islandora/islandora_pathauto) module provides some Islandora-specific tokens, such as `[fedora:pid]`, `[fedora:namespace]`, and `[fedora:label]`. Any module that implements [hook_tokens](https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_tokens/7.x) can provide additional tokens.
## Submodules
### Extending and customizing the BagIt module
Islandora BagIt Light ...
Hooks are documented in islandora_bagit_light.api.php.
## Drush integration
Bags can be created for individual Islandora objects or for all objects in a given collection using Drush:
```drush --user=UID create-islandora-bag [object|collection] PID```
where UID is the user ID or user name of the fedoraAdmin user (or equivalent), 'object' or 'collection' indicates whether you want to create a Bag for a single object or a Bag for every member of a collection, and PID is the PID of the Islandora object or collection.
### Using a PID file
copies from Islandora DOI
This module provides a Drush command to assign DOIs to a list of objects identified in a "PID file." The PID file is a simple list of object PIDS, one PID per line, like this:
```
......@@ -134,9 +125,11 @@ islandora:107
islandora:2183
```
The command (using a file at `/tmp/pids.txt` containing the above list) is:
## Bundled submodules
`drush islandora_doi_assign_dois --user=admin --pid_file=/tmp/pids.txt`
### Extending and customizing the BagIt module
Hooks are documented in islandora_bagit_light.api.php.
## Permissions and security
......@@ -144,13 +137,8 @@ This module is intended for users who have a fairly high level of permissions on
## Known Issues
Fedora 3.8.0 fails to generate FOXML files requested using the 'archive' context ([JIRA ticket](https://jira.duraspace.org/browse/FCREPO-1384)). Earlier versions may succeed on exporting 'archive' FOXML files if the resulting FOXML is smaller than approximately 200 MB, but fail on larger files. The Islandora BagIt module triggers this set of errors if 'archive' FOXML files are generated from within one of its plugins ([JIRA ticket](https://jira.duraspace.org/browse/ISLANDORA-1193)). Until this issue is resolved in Fedora, users of the Islandora BagIt module should not use plugins that generate 'archive' FOXML, including plugin_object_foxml.inc distributed with versions of Islandora BagIt prior to 7.x-1.5. The other FOXML export contexts, 'public' and 'migrate' ([documentation](https://wiki.duraspace.org/display/FEDORA37/REST+API#RESTAPI-export)), can be used safely.
Some bags do not finish properly even with PHP CLI's php.ini set to ```max_input_time = -1``` ([JIRA ticket](https://jira.duraspace.org/browse/ISLANDORA-1403)). For better performance the CLI's php.ini should have the lines ```max_execution_time = 0``` and ```man_input_time = -1```, and well as including ```Timeout 86400``` in Apache2's apache2.conf.
## Documentation
Further documentation for this module is available at ...
* Fedora 3.8.0 fails to generate FOXML files requested using the 'archive' context ([JIRA ticket](https://jira.duraspace.org/browse/FCREPO-1384)). Earlier versions may succeed on exporting 'archive' FOXML files if the resulting FOXML is smaller than approximately 200 MB, but fail on larger files. The Islandora BagIt module triggers this set of errors if 'archive' FOXML files are generated from within one of its plugins ([JIRA ticket](https://jira.duraspace.org/browse/ISLANDORA-1193)). Until this issue is resolved in Fedora, users of the Islandora BagIt module should not use plugins that generate 'archive' FOXML, including plugin_object_foxml.inc distributed with versions of Islandora BagIt prior to 7.x-1.5. The other FOXML export contexts, 'public' and 'migrate' ([documentation](https://wiki.duraspace.org/display/FEDORA37/REST+API#RESTAPI-export)), can be used safely.
* Some Bags do not finish properly even with PHP CLI's php.ini set to ```max_input_time = -1``` ([JIRA ticket](https://jira.duraspace.org/browse/ISLANDORA-1403)). For better performance the CLI's php.ini should have the lines ```max_execution_time = 0``` and ```man_input_time = -1```, and well as including ```Timeout 86400``` in Apache2's apache2.conf.
## Troubleshooting/Issues
......@@ -159,9 +147,7 @@ Having problems or solved a problem? Check out the Islandora google groups for a
* [Islandora Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora)
* [Islandora Dev Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora-dev)
## Maintainers/Sponsors
Current maintainers:
## Maintainers
* [Mark Jordan](https://github.com/mjordan)
......
......@@ -28,6 +28,13 @@ function islandora_bagit_light_create_bag($pid, $ini) {
$tmp_dir = file_directory_temp() . '/islandora_bagit_light_tmp';
}
if (isset($ini['SYSTEM']['log_bag_creation'])) {
$log_bag_creation = $ini['SYSTEM']['log_bag_creation'];
}
else {
$log_bag_creation = TRUE;
}
if ($ini['SYSTEM']['bag_output_dir']) {
$bag_output_dir = $ini['SYSTEM']['bag_output_dir'];
}
......@@ -126,10 +133,10 @@ function islandora_bagit_light_create_bag($pid, $ini) {
if ($serialize_bags) {
$serialized_bag_path = $bag_output_dir . DIRECTORY_SEPARATOR . $bag_file_name;
$bag->package($serialized_bag_path, $bag_compression_type);
if ($delete_unserialized_bag) {
rrmdir($bag_output_path);
}
$bag_output_path = $serialized_bag_path . '.' . $bag_compression_type;
}
// Delete the temp directory created by file create plugins, if it exists.
......@@ -145,16 +152,13 @@ function islandora_bagit_light_create_bag($pid, $ini) {
$all_added_files = array_unique($all_added_files);
$serialized_all_added_files = implode(', ', $all_added_files);
if ($ini['SYSTEM']['log_bag_creation']) {
if (log_bag_creation) {
watchdog('islandora_bagit', 'Bag created for PID !pid (!files).',
array('!pid' => $islandora_object->id, '!files' => $serialized_all_added_files));
}
// @todo: this hook should be invoked even if the bag is not serialzied.
// Allow other modules to fire the post-Bag creation hook.
$serialized_bag_path .= '.' . $bag_compression_type;
module_invoke_all('islandora_bagit_bag_created', $pid, $serialized_bag_path);
module_invoke_all('islandora_bagit_bag_created', $pid, $bag_output_path);
// @todo: Return TRUE if Bag created, FALSE otherwise. Maybe we need to
// wrap some actions in try/catch?
......
......@@ -6,7 +6,7 @@
*/
/**
* Returns an array of files paths to add to the Bag's data directory..
* Returns an array of files to add to the Bag's data directory.
*
* @param object $islandora_object
* The Islandora object to create a Bag for.
......@@ -33,7 +33,7 @@ function hook_islandora_bagit_get_data_files($islandora_object, $tmp_ds_director
}
/**
* Informs other module that a Bag has been created.
* Informs other modules that a Bag has been created.
*
* @param string $pid
* The PID of the object the Bag was created for.
......
......@@ -20,7 +20,7 @@ function islandora_bagit_light_drush_help($command) {
*/
function islandora_bagit_light_drush_command() {
$items = array();
$items['create-islandora-bag'] = array(
$items['islandora-create-bag'] = array(
'description' => dt('Creates a Bag for an Islandora object.'),
'options' => array(
'pid' => dt('The PID for the object you want to create a Bag for.'),
......@@ -41,7 +41,7 @@ function islandora_bagit_light_drush_command() {
* @param string $pid
* The PID of the Islandora object to create a Bag for.
*/
function drush_islandora_bagit_light_create_islandora_bag() {
function drush_islandora_bagit_light_islandora_create_bag() {
module_load_include('inc', 'islandora_bagit_light', 'includes/utilities');
if (!file_exists('sites/all/libraries/BagItPHP')) {
return drush_set_error(DRUSH_FRAMEWORK_ERROR, dt('BagIt library not found.'));
......
......@@ -10,239 +10,11 @@
/**
* Implements hook_permission().
*/
function islandora_bagit_permission() {
function islandora_bagit_light_permission() {
return array(
'create Islandora Bags' => array(
'create Islandora Bags using BagIt Light' => array(
'title' => t('Create Bags'),
'description' => t('Create Bags using Islandora BagIt Light'),
),
);
}
/**
* Admin settings form builder.
*/
/*
function islandora_bagit_admin_settings() {
$form['islandora_bagit_library_dir'] = array(
'#title' => t('Location of the BagIt library'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_library_dir', 'BagItPHP'),
'#description' => t("Directory where the Scholars' Lab BagIt for PHP library
is installed, relative to sites/all/libraries. Do not use a leading or
trailing slash."),
'#maxlength' => 255,
'#required' => TRUE,
);
$form['islandora_bagit_bag_tmp_dir'] = array(
'#title' => t('Temporary directory for unserialized Bags'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_bag_tmp_dir', file_directory_temp()),
'#description' => t("Filesystem directory where the unserialized Bag
directories are written, named by PID. Needs to exist and to be
writable by the web server. Do not include the trailing slash."),
'#maxlength' => 255,
'#required' => TRUE,
);
$form['islandora_bagit_delete_unserialized_bag'] = array(
'#type' => 'checkbox',
'#title' => t('Delete unserialized (zipped) Bags.'),
'#default_value' => variable_get('islandora_bagit_delete_unserialized_bag', 1),
'#description' => t('Check this option if you want to automatically delete
unserialized Bags.'),
);
$bagit_output_dir = variable_get('file_public_path', conf_path() . '/files');
$form['islandora_bagit_bag_output_dir'] = array(
'#title' => t('Output directory for serialized Bags'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_bag_output_dir', $bagit_output_dir),
'#description' => t("Filesystem directory where serialized (.tgz or .zip) Bags
are written, named by PID. Needs to exist and to be writable by the web
server. Do not include the trailing slash. If you want users to be able to
download the Bags, this directory needs to be below your site's file system directory."),
'#maxlength' => 255,
'#required' => TRUE,
);
$form['islandora_bagit_create_on_ingest'] = array(
'#type' => 'checkbox',
'#title' => t('Create Bag on object ingest'),
'#default_value' => variable_get('islandora_bagit_create_on_ingest', 0),
'#description' => t('Check this option if you want to create a Bag for
an object when it is ingested.'),
);
$form['islandora_bagit_create_on_modify'] = array(
'#type' => 'checkbox',
'#title' => t('Create Bag on object modification'),
'#default_value' => variable_get('islandora_bagit_create_on_modify', 0),
'#description' => t('Check this option if you want to create a Bag for
an object when it or any of its datasteams are modified.'),
);
$form['islandora_bagit_provide_download_link'] = array(
'#type' => 'checkbox',
'#title' => t('Provide link to download the Bag'),
'#default_value' => variable_get('islandora_bagit_provide_download_link', 1),
'#description' => t("This link will work only if 'Output directory for
serialized Bags' is accessible via the web."),
);
$form['islandora_bagit_multiple_bag_type'] = array(
'#type' => 'select',
'#title' => t('Collection batch type'),
'#default_value' => variable_get('islandora_bagit_multiple_bag_type', 'object'),
'#options' => array(
'object' => t('one Bag per object'),
'collection' => t('one Bag per collection'),
),
'#description' => t('Choose whether collection-level batches create one Bag per object or one Bag per collection.'),
);
$form['islandora_bagit_serialize_collection_bags'] = array(
'#type' => 'checkbox',
'#title' => t('Serialize collection Bags.'),
'#default_value' => variable_get('islandora_bagit_serialize_collection_bags', 0),
'#description' => t('Check this option if you want to serialize (zip) one-Bag-per-collection Bags.'),
);
$description = t("Base name for the Bags. The object's PID is appended to this value.");
$default_bag_name = variable_get('islandora_bagit_bag_name', 'Bag-');
$form['islandora_bagit_bag_name'] = array(
'#title' => t('Bag name'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => $default_bag_name,
'#description' => $description,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['islandora_bagit_show_messages'] = array(
'#type' => 'checkbox',
'#title' => t('Display messages'),
'#default_value' => variable_get('islandora_bagit_show_messages', 1),
'#description' => t('Check this option if you want to display messages
associated with Bag creation to the end user.'),
);
$form['islandora_bagit_log_bag_creation'] = array(
'#type' => 'checkbox',
'#title' => t('Log the creation of Bags'),
'#default_value' => variable_get('islandora_bagit_log_bag_creation', 1),
'#description' => t('Check this option if you want to log the
creation of Bags to the Drupal watchdog.'),
);
$form['islandora_bagit_compression_type'] = array(
'#type' => 'select',
'#title' => t('Compression type'),
'#default_value' => variable_get('islandora_bagit_compression_type', 'tgz'),
'#options' => array(
'tgz' => t('tgz'),
'zip' => t('zip'),
),
'#description' => t('The compression used on serialized Bags.'),
);
$object_plugins = islandora_bagit_get_plugins('object');
foreach ($object_plugins as $plugin) {
$object_plugin_options[$plugin] = $plugin;
}
$form['islandora_bagit_object_plugins'] = array(
'#title' => t('Object plugins'),
'#type' => 'checkboxes',
'#options' => $object_plugin_options,
'#default_value' => variable_get('islandora_bagit_object_plugins', array('')),
'#description' => t("Object-level plugins. Plugins are fired in their order in this list and all add files to the same Bag. You should choose at least one plugin."),
);
$collection_plugins = islandora_bagit_get_plugins('collection');
foreach ($collection_plugins as $plugin) {
$collection_plugin_options[$plugin] = $plugin;
}
$form['islandora_bagit_collection_plugin'] = array(
'#title' => t('Collection plugins'),
'#type' => 'select',
'#options' => $collection_plugin_options,
'#default_value' => variable_get('islandora_bagit_collection_plugin', ''),
);
$form['islandora_bagit_baginfo_settings'] = array(
'#title' => t('Bag metadata'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t("Optional metadata written to the Bag's bag-info.txt file."),
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_transferring_organization'] = array(
'#title' => t('Organization transferring the content'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_transferring_organization', ''),
'#description' => t("Leave blank to omit from bag-info.txt."),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_transferring_organization_address'] = array(
'#title' => t('Mailing address of the organization'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_transferring_organization_address', ''),
'#description' => t("Leave blank to omit from bag-info.txt."),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_contact_name'] = array(
'#title' => t('Contact name'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_contact_name', ''),
'#description' => t("Person at the source organization who is responsible
for the content transfer. Leave blank to omit from bag-info.txt."),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_contact_phone'] = array(
'#title' => t('Contact phone'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_contact_phone', ''),
'#description' => t("International format telephone number of person or
position responsible. Leave blank to omit from bag-info.txt."),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_contact_email'] = array(
'#title' => t('Contact email'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => variable_get('islandora_bagit_contact_email', ''),
'#description' => t("Fully qualified email address of person or
position responsible. Leave blank to omit from bag-info.txt."),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_profile_uri'] = array(
'#type' => 'textfield',
'#title' => t('BagIt profile URI'),
'#default_value' => variable_get('islandora_bagit_profile_uri', ''),
'#description' => t('See https://github.com/ruebot/bagit-profiles for more information. Note that Islandora BagIt does not validate Bags against profiles.'),
'#maxlength' => 255,
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_bagging_date'] = array(
'#type' => 'checkbox',
'#title' => t('Bagging date'),
'#default_value' => variable_get('islandora_bagit_bagging_date', 0),
'#description' => t("Date (YYYY-MM-DD) that the content was prepared for
delivery."),
);
$form['islandora_bagit_baginfo_settings']['islandora_bagit_payload_octetstream_sum'] = array(
'#type' => 'checkbox',
'#title' => t('Octetstream sum'),
'#default_value' => variable_get('islandora_bagit_payload_octetstream_sum', FALSE),
'#description' => t('The "octetstream sum" of the payload.'),
);
return system_settings_form($form);
}
*/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment