Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Hypercube and Houdini to respect Apix-Ldp-Resource header #611

Closed
dannylamb opened this issue Apr 26, 2017 · 11 comments
Closed

Convert Hypercube and Houdini to respect Apix-Ldp-Resource header #611

dannylamb opened this issue Apr 26, 2017 · 11 comments
Assignees

Comments

@dannylamb
Copy link
Contributor

Relevant reading: https://github.com/fcrepo4-labs/fcrepo-api-x/blob/master/src/site/markdown/execution-and-routing.md#endpoint-example

When Api-X will foward a request to a microservice, it will enrich the message with an Apix-Ldp-Resource header. Instead of reading in the path from the url and combining that with the Fedora base url, we should simply use this header provided by Api-X in Hypercube and Houdini. This means the endpoints will not have any route parameters, and we'll need to use a before middleware to manually execute the FedoraResourceConverter and jam it into the request.

It's a bit tough to set things on the Request, so it may be easier to duplicate it and provide the response from Chullo in the attribute parameter.

Controllers will also need to be touched up to retrieve the response from Chullo, as it will no longer be provided as a route parameter.

@whikloj
Copy link
Member

whikloj commented Apr 26, 2017

Soooo this might be a good place for a couple questions and to reveal my lack of grasp of API-X.

To start, would Houdini and Hypercube be Resource scope services?

@whikloj whikloj self-assigned this Apr 28, 2017
@whikloj
Copy link
Member

whikloj commented Apr 28, 2017

@dannylamb So after reading the "Generic Endpoint Proxy" example you linked to I have a couple questions.

  1. Not exactly clear how we expose these API-X services, so would Houdini become

    Apix-Exposed-Uri: http://islandora.ca/services/objectFoo/svc:Houdini/convert/

  2. Using Houdini as the example, is the plan to continue to use the X-Islandora-Args header to determine resizing, etc? So in which case the request would come as

GET /houdini/convert
Host: islandora.ca
Accept: image/jpeg
User-Agent: whatever
X-Islandora-Args: -resize 10%
Apix-Ldp-Resource: http://fedora01.backend.local/repository/objectFoo/
Apix-Exposed-Uri: http://islandora.ca/services/objectFoo/svc:Houdini/convert/

@whikloj
Copy link
Member

whikloj commented Apr 28, 2017

It appears that instead we should be specify presets, so a request to /services/houdini would return a menu of possible choices (following in the API-X examples).

GET /services/houdini
Host: islandora.ca
Accept: */*
User-Agent: whatever
Apix-Ldp-Resource: http://fedora01.backend.local/repository/objectFoo/
Apix-Exposed-Uri: http://islandora.ca/services/objectFoo/svc:Houdini

which replies (I was going to do JSON-LD, but that is sooo painful to write by hand)

HTTP/1.1 200 OK
Content-Type: text/turtle; charset=UTF-8
Allow: HEAD, OPTIONS, GET
Content-Length: 123

@prefix islandApix: <http://islandora.ca/apixService>
<> a islandApix:serviceMenu ;
   islandApix:hasService <convert> ;
   islandApix:hasService <identify> .

<identify> a islandApix:subService .

<convert> a islandApix:subService ;   
   islandApix:provides ["image/jpeg", "image/tiff", "image/png", "image/gif"] ;
   islandApix:accepts  "X-Islandora-Args" .

Is that at all close to how this should work?

@dannylamb
Copy link
Contributor Author

I think maybe instead of thinking of it as two services, i'd treat each as its own service. E.g. http://localhost:8080/fcrepo/rest/some-image/svc:identify and http://localhost:8080/fcrepo/rest/some-image/svc:convert. Does that simplify things?

@whikloj
Copy link
Member

whikloj commented May 1, 2017

Sure, so the other part is do we define a set of service options or do we advertise the header somehow? Like do we say that svc:convert does a LargeImage and a MediumImage and a SmallImage or do we say define dimensions with this format in this header?

The latter seems more flexible but also harder to express in the "service menu" thingy.

@dannylamb dannylamb assigned dannylamb and unassigned whikloj Jun 2, 2017
@dannylamb
Copy link
Contributor Author

@whikloj I'm gonna do the coding quickly here to have the services accept those headers, and then we'll address your other concerns under the umbrella of #612.

@dannylamb
Copy link
Contributor Author

Testing Instructions

To deploy the changes:

  • vagrant ssh
  • cd /var/www/html/Crayfish
  • git remote add danny https://github.com/dannylamb/Crayfish.git
  • git fetch
  • git checkout issue-611
  • cd /var/www/html/Crayfish/Hypercube/vendor/islandora/crayfish-commons
  • git remote add danny https://github.com/dannylamb/Crayfish-Commons.git
  • git fetch
  • git checkout issue-611
  • cd /var/www/html/Crayfish/Houdini/vendor/islandora/crayfish-commons
  • git remote add danny https://github.com/dannylamb/Crayfish-Commons.git
  • git fetch
  • git checkout issue-611

Then ingest a tiff into Fedora, I put mine at http://localhost:8080/fcrepo/rest/test.tiff.

curl -i -H "Authorization: Bearer islandora" -H "Apix-Ldp-Resource: http://localhost:8080/fcrepo/rest/test.tiff" "http://localhost:8000/hypercube/" should return 200 and the OCR of the tiff.

curl -i -H "Authorization: Bearer islandora" -H "Apix-Ldp-Resource: http://localhost:8080/fcrepo/rest/test.tiff" "http://localhost:8000/houdini/identify" should return 200 and the json describing the image.

curl -H "Authorization: Bearer islandora" -H "Apix-Ldp-Resource: http://localhost:8080/fcrepo/rest/test.tiff" -H "Accept: image/png" "http://localhost:8000/houdini/convert" > test.png should return 200 and get you a png version of the image.

@dannylamb
Copy link
Contributor Author

@Islandora-CLAW/committers ^^

@whikloj
Copy link
Member

whikloj commented Jun 6, 2017

Nice work @dannylamb, I'll spin these up tonight. 👍

@whikloj
Copy link
Member

whikloj commented Jun 7, 2017

Worked as described

@whikloj
Copy link
Member

whikloj commented Jun 7, 2017

@whikloj whikloj closed this as completed Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants