Drupal Module that allows users to create Bags with Islandora Bagger. Can be run in "remote" or "local" mode, as explained below.
- An Islandora Bagger microservice
- Islandora 8. This module works with both Drupal 8 and Drupal 9.
- Context if you want to define which Islandora Bagger configuration files to use other than the default file. A requirement of Islandora so will already be installed.
- Clone this Github repo into your Islandora's
drupal/web/modules/contrib
directory. - Enable the module either under the "Admin > Extend" menu or by running
drush en -y islandora_bagger_integration
.
The admin settings form for this module requires the following:
- A choice of whether you are running it in local or remote mode.
- The absolute path on your Drupal server to the default Islandora Bagger configuration file. This file is used if no Contexts are configured to use an alternative configuration file.
- If using remote mode
- the URL of the Islandora Bagger REST endpoint. If you are running Islandora in the CLAW Vagrant, and Islandora Bagger on the host machine (i.e., same machine that is hosting the Vagrant), use
10.0.2.2
as your endpoint IP address instead oflocalhost
. - an option to add to the configuration file the email address of the user who requested the Bag be created. If checked, the user's email address will be added to the configuration file using the key
recipient_email
. In addition, if this option is checked, the message displayed to the user will indicate they will receive an email when their Bag is ready for download.
- the URL of the Islandora Bagger REST endpoint. If you are running Islandora in the CLAW Vagrant, and Islandora Bagger on the host machine (i.e., same machine that is hosting the Vagrant), use
- If running in local mode, the absolute path to the directory on your Drupal server where Islandora Bagger is installed.
- This directory needs to be writable by the web server process user, e.g., www-data on most Linux systems.
After you configure the admin setting, place the "Islandora Bagger Block" as you normally would any other block. You should restrict this block to the content types of your Islandora nodes, and to user roles who you want to be able to create Bags.
This module's interaction with Islandora Bagger can be configured in two ways:
- Using Islandora Bagger as a remote microservice ("remote" mode)
- In this mode, submitting the "Create Bag" form does not directly generate the Bag; rather, it sends a request to the remote Islandora Bagger's REST interface, which in turn populates its processing queue with the node ID and the configuration file to use when that node's Bag is created.
- In remote mode, this Drupal module does not notify the user when their Bag is ready; you will need to configure Islandora Bagger to send an email to the user indicating where they can get the Bag.
- Using Islandora Bagger as command-line utility ("local" mode)
- In this mode, submitting the "Create Bag" form calls out to Islandora Bagger on the server's shell, which then generates the Bag.
In both cases, end users generate a Bag for the current object by submitting a simple form (with just one button) in a block. If running in remote mode, the user is told that they will get an email indicating where they can download the Bag (the microservice needs to be configured to send this email); if running in local mode, the user is presented with a link where they can download the Bag.
The advantage of local mode is that the user is presented with the download link immediately after the Bag is generated. The disadvantage of the local mode is that creating the Bag is done synchronously, and there is a risk that, for objects that have very large files, the job will time out.
The advantage of the remote mode is that generating a Bag will never time out because clicking on the "Create Bag" button sends a simple REST request to the remote Islandora Bagger microservice, which then adds the request to a queue to be processed later. This is also a disadvantage, since the user doesn't get to download the Bag until later.
This module comes with two Context Reactions that provide control over the Islandora Bagger configuration.
One of those Reactions allows you to use Islandora Bagger configuration files other than the default. To enable this, do the following:
- Install Context and Context UI modules (requirements for Islandora, so will already be done).
- Create a Context or edit an existing Context.
- Define your Conditions.
- Add the "Islandora Bagger Config File" Reaction.
- Enter the absolute path on your Drupal server to the configuration file you want to use.
This module provides no mechanism for uploading configuration files via Drupal's web interface, so you will need access to the Drupal server's file system. Also, do not put configuration files in directories that are accessible via the web, since they contain credentials for accessing your Drupal's REST interface.
The other Reaction allows you to add options to the Islandora Bagger configuration file or override existing options. To enable this, do the following:
- Install Context and Context UI modules (requirements for Islandora, so will already be done).
- Create a Context or edit an existing Context.
- Define your Conditions.
- Add the "Islandora Bagger Config Options" Reaction.
- Enter the options you want to add or modify. Add one option per line, using YAML syntax. For example:
serialize: tgz
bag-info: Contact-Email: [email protected] | Custom-Tag: Some value.
plugins: AddBasicTags | AddMedia | AddFedoraTurtle
bag-info
,drupal_basic_auth
,drupal_media_tags
, plugins
, and post_bag_scripts
are pipe-separated lists. For bag-info
, each member of the list is a tag:value pair (separated by a colon). The other list options takes a pipe-separated list of values.
If the option's key exists in the configuration file, that option will be updated with the new value. If the option's key doesn't exist in the configuration file, it will be added. The only exception is bag-info
: for this option, its values provided in the Context Reaction will be merged with any existing values from the configuration file. For example, if the Reaction contains a tag "Contact-Email: [email protected]", and the configuration file contains a "Contact-Email" tag, the existing one will be replaced by the one from the Reaction. If the Reaction contains a tag that does not exist in the configuration file, it will be added as a new tag.
Islandora Bagger can be configured to register the creation of Bags with this module. Each Bag gets an entry in a database table. To do this, each Islandora Bagger configuration file needs to contain the following setting:
register_bags_with_islandora: true
This tells Islandora Bagger to send a REST request to this module to register the creation of the Bag. To configure this module to accept these requests, you must enable the REST endpoint:
- Go to Admin > Configure > Web services > REST.
- Find the "Islandora Bagger Integration Bag Log" resource and click on "Enable".
- Under "Granularity", choose "Resource".
- Under "Methods", choose "POST".
- Under "Accepted request formats", choose "json".
- Under "Authentication", choose "jwt_auth" (or "basic_auth" if using Islandora Bagger before JWT Auth).
- Save the configuration.
Then, back at the list of REST resources, for "Islandora Bagger Integration Bag Log" choose "Permissions" and in the "Islandora Bagger Integration" section, enable the "Log Bag creation" permission for the roles that can populate the log. The user identified in the Islandora Bagger configuration file (in the drupal_basic_auth
option) must be a member of the enabled roles.
The data created by this feature is accessible via Views, but (currently) in a very basic way - you can add fields from this data, but not filters or relationships (see issue to add these).
This module defines a hook that allows other modules to modify the Islandora Bagger configuration, in both remote and local modes. See islandora_bagger_integration.api.php
for details.
See issue list.