Skip to content

Latest commit

 

History

History
 
 

Gemini

image Gemini

Contribution Guidelines LICENSE

Introduction

A path mapping service for Islandora 8. Gemini is what links content created in Drupal to data stored in Fedora. It has a very simple API and is built on top of a relational database using Doctrine's database abstraction layer.

Installation

  • Install the database of your choice that is compatible with Doctrine's DBAL.
  • Clone this repository.
  • Install composer. Install instructions here.
  • $ cd /path/to/Gemini and run $ composer install
  • Then either
    • For production, configure your web server appropriately (e.g. add a VirtualHost for Gemini in Apache) OR
    • For development, run the PHP built-in web server $ php -S localhost:8888 -t src from Gemini root.

Gemini runs on its own database, and requires one table. You'll need to set that up manually. For example, using MySQL:

create database gemini;
CREATE TABLE gemini.Gemini (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    drupal VARCHAR(2048) NOT NULL UNIQUE,
    fedora VARCHAR(2048) NOT NULL UNIQUE
) ENGINE=InnoDB;

Configuration

Gemini accepts configuration for Doctrine's DBAL as the db.options array in its config file file. Other settings such as the location of Gemini's log file and the base URL of your Fedora server are also in this configuration file. Reasonable defaults provided. Do not commit the configuration file with your MySQL credentials into Git!

Usage

Gemini associates URL paths between resources in Drupal and Fedora. To link the Drupal and Fedora URIs of a resource, a client must mint a new Fedora URI (using a POST) based on the UUID of the node or file in Drupal, and then persist the Gemini record linking the two URIs (using a PUT).

POST /

Mints a new Fedora URI:

curl -v -H "Authorization: Bearer islandora" -H "Content-Type: application/json" -d 'ab70127a-8579-4c17-af07-b3b1eceebb17' http://localhost:8000/gemini/

Returns for example:

< HTTP/1.1 200 OK
< Date: Mon, 29 Oct 2018 19:03:36 GMT
< Server: Apache/2.4.18 (Ubuntu)
< X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1
< Cache-Control: no-cache, private
< Vary: Accept-Encoding
< Content-Length: 82
< Content-Type: text/html; charset=UTF-8

http://localhost:8080/fcrepo/rest/ab/70/12/7a/ab70127a-8579-4c17-af07-b3b1eceebb17

PUT /{UUID}

Updates the entry corresponding to the UUID with the Drupal URL:

curl -v -H "Authorization: Bearer islandora" -X PUT -H "Content-Type: application/json" -d '{"drupal" : "http://localhost:8000/node/0001", "fedora" : "http://localhost:8080/fcrepo/rest/ab/70/12/7a/ab70127a-8579-4c17-af07-b3b1eceebb17"}' http://localhost:8000/gemini/ab70127a-8579-4c17-af07-b3b1eceebb17

If successful, returns for example:

HTTP/1.1 201 Created
< Date: Mon, 29 Oct 2018 19:17:41 GMT
< Server: Apache/2.4.18 (Ubuntu)
< X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1
< Cache-Control: no-cache, private
< Location: http://localhost:8000/gemini/ab70127a-8579-4c17-af07-b3b1eceebb17
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8

resulting in the creation of a new record in the Gemini database:

mysql> select * from Gemini where uuid = 'ab70127a-8579-4c17-af07-b3b1eceebb17'\G
*************************** 1. row ***************************
fedora_hash: 868afb07dbe25dc0539ba91ce4f0d9e5e2cebdc1124935590544abe14b54466ecf925113bcf057c3b1bbb9056e03e918dd60b50ad2047b9ecf44b60db8fb1a91
drupal_hash: 1cd9033dc7a45e4034bfba5b832f772b2b8a694ece2ac0c16bcc22a3563ee331a90adc843e3657e491ac550776eaff0ec2db521891da2a3a55609d817598b5da
       uuid: ab70127a-8579-4c17-af07-b3b1eceebb17
 drupal_uri: http://localhost:8000/node/0001
 fedora_uri: http://localhost:8080/fcrepo/rest/ab/70/12/7a/ab70127a-8579-4c17-af07-b3b1eceebb17
dateCreated: 2018-10-29 14:17:42
dateUpdated: 2018-10-29 14:17:42
1 row in set (0.00 sec)

GET /{UUID}

Fetches the Drupal/Fedora URIs corresponding to a UUID:

curl -H "Authorization: Bearer islandora" http://localhost:8000/gemini/ab70127a-8579-4c17-af07-b3b1eceebb17

This request returns, for example:

< HTTP/1.1 200 OK
< Date: Mon, 29 Oct 2018 20:31:25 GMT
< Server: Apache/2.4.18 (Ubuntu)
< X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1
< Cache-Control: no-cache, private
< Content-Length: 163
< Content-Type: application/json
{
   "drupal":"http:\/\/localhost:8000\/node\/0001",
   "fedora":"http:\/\/localhost:8080\/fcrepo\/rest\/ab\/70\/12\/7a\/ab70127a-8579-4c17-af07-b3b1eceebb17"
}

GET /by_uri

Fetches the alternate URI from Gemini for the one provided in a X-Islandora-URI header and returns:

  • 200 OK and the URI in a Location header, if it exists in Gemini.
  • 404 Not Found, if it doesn't exist in Gemini.

curl -i -H"Authorization: Bearer islandora" -H"X-Islandora-URI: http://localhost:8000/node/2" http://localhost:8000/gemini/by_uri

This request returns:

HTTP/1.1 200 OK
Date: Thu, 23 May 2019 19:23:15 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Powered-By: PHP/7.2.18-1+ubuntu16.04.1+deb.sury.org+1
Location: http://localhost:8080/fcrepo/rest/cf/5d/46/74/cf5d4674-282b-499c-9ebc-4c4815d4f9ac
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8

Requesting with the URI from this Location: header should return the original URI.

curl -i -H"Authorization: Bearer islandora" -H"X-Islandora-URI: http://localhost:8080/fcrepo/rest/cf/5d/46/74/cf5d4674-282b-499c-9ebc-4c4815d4f9ac" http://localhost:8000/gemini/by_uri

HTTP/1.1 200 OK
Date: Thu, 23 May 2019 19:25:27 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Powered-By: PHP/7.2.18-1+ubuntu16.04.1+deb.sury.org+1
Location: http://localhost:8000/node/2
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8

If a mapping cannot be found then a 404 response is returned.

curl -i -H"Authorization: Bearer islandora" -H"X-Islandora-URI: http://localhost:8000/node/99" http://localhost:8000/gemini/by_uri

HTTP/1.1 404 Not Found
Date: Thu, 23 May 2019 19:26:36 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Powered-By: PHP/7.2.18-1+ubuntu16.04.1+deb.sury.org+1
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8

DELETE /{UUID}

Purges the entry corresponding to the UUID from Gemini's database:

curl -v -X DELETE -H "Authorization: Bearer islandora" http://localhost:8000/gemini/ab70127a-8579-4c17-af07-b3b1eceebb17

If successful, this request returns, for example:

< HTTP/1.1 204 No Content
< Date: Mon, 29 Oct 2018 19:51:39 GMT
< Server: Apache/2.4.18 (Ubuntu)
< X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1
< Cache-Control: no-cache, private
< Content-Type: text/html; charset=UTF-8

Maintainers

Current maintainers:

Development

If you would like to contribute, please get involved by attending our weekly Tech Call. We love to hear from you!

If you would like to contribute code to the project, you need to be covered by an Islandora Foundation Contributor License Agreement or Corporate Contributor License Agreement. Please see the Contributors pages on Islandora.ca for more information.

We recommend using the islandora-playbook to get started.

License

MIT