mjordan / riprap

A PREMIS-compliant fixity checking microservice.
MIT License
13 stars 7 forks source link

Create a FetchDigestFromDrupal plugin #44

Closed mjordan closed 4 years ago

mjordan commented 5 years ago

Not sure about best source of digests but will investigate and go from there.

mjordan commented 5 years ago

The "File Checksum" view allows us to get a SHA1 hash via REST like this:

curl -v -uadmin:islandora "http://localhost:8000/checksum/1"

results in [{"sha1":"39de4231b3885e3d456441c7885fb916f9a94131"}].

But it uses File IDs, not UUIDs, which are what are supplied by JSON:API. Maybe we should create our own view that takes the UUID as its parameter?

mjordan commented 5 years ago

I've modified the "File Checksum" view (not sure which module creates this view, probably filehash?) to use the file's UUID instead of its ID, and it appears to work. We could have islandora_riprap create its own version of this view on installation.

mjordan commented 4 years ago

Started off by creating a View to get a file's hash, but that returned the hash stored in the Drupal database for that file. Instead, added in https://github.com/mjordan/islandora_riprap/issues/33 a controller that uses PHP's hash_file() function to get the current hash for the file.

mjordan commented 4 years ago

Pseudocode for this plugin:

  1. The "Riprap resource list" View created by Islandora Riprap give us media IDs that are tagged with "Original File" (configurable)
  2. With that ID, the plugin will need to do a REST request for the media ID, which provides the media's file in the form
  "field_media_image": [
    {
      "target_id": 3,
      "alt": null,
      "title": null,
      "width": 800,
      "height": 1333,
      "target_type": "file",
      "target_uuid": "e97ad038-dcb3-4d81-aa91-c945b2fe092c",
      "url": "http:\\/\\/localhost:8000\\/sites\\/default\\/files\\/2019-03\\/1-Service%20File.jpg"
    }
  ],

(The fieldname of the file, in this case "field_media_image", varies by media type, e.g., field_media_audio, field_media_document, field_edited_text, field_media_file, field_media_image, field_media_video_file.)

  1. From this JSON, the plugin can get the file's URL and UUID.
  2. With the UUID, the plugin can then get the hash using the controller added in https://github.com/mjordan/islandora_riprap/issues/33.
mjordan commented 4 years ago

Resolved with c740b6140034f95b751e390c5f93063574f0b47e.