Browse Source

Added Checksum to view

pull/907/head
Alan Stanley 7 years ago
parent
commit
bf3953d2ef
  1. 38
      README.md
  2. 4
      composer.json
  3. 51
      islandora_fits.module

38
README.md

@ -1,2 +1,40 @@
# Islandora FITS # Islandora FITS
Config module to make Islandora aware of FITS microservice Config module to make Islandora aware of FITS microservice
## Installation
#### Install this module
Install and enable this module in the usual way
#### Install FITS Webservice
FITS xmls are generated from an easily installed web service.
Get the latest fits.zip and fits.war from https://projects.iq.harvard.edu/fits/downloads
(on my box I had to install a missing zip library with ‘sudo apt-get install php7.1-zip’)
Install following their instructions.
Copy the .war file to your webapps directory and test.
Edit the catalina.properties file on the Drupal server by adding the following two lines to the bottom of the file-
fits.home=/<path-to-fits>/fits
shared.loader=/<path-to-fits>/fits/lib/*.jar
Restart Tomcat and test with
`curl -k -F datafile="@/path/to/myfile.jpg" http://example.com:8080/fits/examine`
(note: the ‘@’ is required.)
#### Installing Microservice
Get code from https://github.com/roblib/CrayFits and install. This code can live anywhere, including an external server,
but most installations will have it at /var/www/html.
The App runs by entering php bin/console server:start *:8050 in the App root folder.
The server is stopped with php bin/console server:stop. On a production machine you'd probably want to configure an additonal port in Apache.
Note: The location of the fits webserver is stored in the .env file in the root dir of the Symfony app. This will have to be reconfigured if the Fits server is anywhere other than localhost:8080/fits
#### Adding FITs requests to the queue
Copy the file `assets/ca.islandora.alpaca.connector.ocr.blueprint.xml` to `/opt/karak/deploy` on your server. There is no need to restart.
#### Adding Checksum to Display
A pseudo field with the computed checksum can be added to Repository Item display. Naviage to `admin/structure/types/manage/islandora_object/display` to enable or disable display of `File Checksum`.

4
composer.json

@ -1,7 +1,7 @@
{ {
"name": "drupal/islandora_fits", "name": "islandora-rdm/islandora_fits",
"type": "drupal-module", "type": "drupal-module",
"description": "Enables Technical Metadata derivative generation", "description": "Enables Technical Metadata derivative generation.",
"keywords": ["Drupal"], "keywords": ["Drupal"],
"license": "GPL-2.0+", "license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/islandora_fits", "homepage": "https://www.drupal.org/project/islandora_fits",

51
islandora_fits.module

@ -120,5 +120,56 @@ function islandora_fits_media_insert(MediaInterface $media) {
islandora_fits_media_update($media); islandora_fits_media_update($media);
} }
/**
* Implements hook_entity_extra_field_info().
*/
function islandora_fits_entity_extra_field_info() {
$extra = [];
$extra['node']['islandora_object']['display']['islandora_fits_checksum'] = array(
'label' => t('File Checksum'),
'description' => t('Checksum as discovered by FITs webservice'),
'weight' => 100,
'visible' => TRUE,
);
return $extra;
}
/**
* Implements hook_entity_view().
*/
function islandora_fits_entity_view(array &$build, $entity, $display, $view_mode) {
$route_match_item = \Drupal::routeMatch()->getParameters()->all();
$current_entity = reset($route_match_item);
if ($entity === $current_entity) {
$medias = \Drupal::entityQuery(
'media')
->condition('field_media_of', $entity->id())
->condition('bundle', 'fits_technical_metadata')
->execute();
$mid = \reset($medias);
if ($mid) {
$fits = Media::load($mid);
$checksum = $fits->get('fits_ois_file_information_md5che')->value;
if ($checksum) {
$build['islandora_fits_checksum'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'field-islandora-checksum',
],
'checksum' => [
'#type' => 'item',
'#title' => t('MD5 Checksum'),
'internal_uri' => [
'#type' => 'markup',
'#markup' => $checksum,
],
],
];
}
}
}
}

Loading…
Cancel
Save