Documentation: Implement a POST request for FedoraResource entities

Created on 7 Feb 2017  路  10Comments  路  Source: Islandora/documentation

Implement a POST request to create fedora resources, exposing an endpoint at http://localhost:8000/fedora_resource/ that has the following behaviour:

  • Respects the drupal/symfony _format query parameter
  • Expects the bundle as a header, X-Islandora-Bundle, so the resource can be unambiguously created (only required when _format=jsonld)
  • Expects proper Content-Type header (despite the _format parameter)
  • Respects an optional checksum header to verify upload.

Possible responses:

  • Returns 201 with the newly created resource as the response
  • Returns 409 if checksum mismatch
drupal

Most helpful comment

@Natkeeran @whikloj @DiegoPino I'd say we just drop the checksum altogether then, since we're just creating metadata with FedoraResource entities. You'd have to post seperately to create Media entities for the binaries themselves, with a FedoraResource being like the fcr:metadata elbow.

I think it's fairly safe to assume it would only be JSON-LD, but if you're clever with how you set things up, you'd get the standard Drupal JSON and XML for free. There's no plans on supporting any other RDF format than JSON-LD.

The real hole you'll get sucked down when attempting this is you'll have to add denormalizing capabilities to https://github.com/Islandora-CLAW/claw-jsonld.

All 10 comments

@whikloj @ajs6f What do you think about this?

Expects the bundle as a header, X-Islandora-Bundle, so the resource can be unambiguously created (only required when _format=jsonld)

For the MVP, this would limit the use of the bundle resolver significantly. Basically just for data coming from fcrepo that's not in drupal yet.

馃憤 I like this. It also needs to respect JWTs.

I'm not sure what you would use the _format for as I can only think of sending your data as JSON-LD?

@dannylamb, can you please confirm the following steps to implement this endpoint:

  • Add a path to the route (islandora.routing.yml)
islandora.post:
  path: 'fedora_resource'
  defaults: { _controller: '\Drupal\islandora\Controller\FedoraResourcePOSTController::processPost' }
  methods:  [POST]
  requirements:
    _access: 'TRUE'
  • Implement the /islandora/src/Controller/FedoraResourcePOSTController.php.
  • Check checksum
  • If mismatch, return 404
  • If good, create the bundle as per the request
  • Return 201 with json-ld of the created bundle!

(Where should the actual implementation class go?)

@Natkeeran just a heads up, @dannylamb is on vacation until the 22nd.

@ruebot thank you for the info.

@Natkeeran I think you are on the right path. I'd say that you only need to verify the checksum if one exists (RFC 3230). But otherwise I think if you can make the rest work you'll have done a 馃憤 .

I have some questions around what @dannylamb needs here.

  1. Why 404 if checksum fails?
  2. Are we allowing people to send alternate RDF (for the MVP) or can we assume its all JSON-LD.
  3. Why return the entire object in the response and not just the URI?

But as I said, if you move forward and get something working. We can adjust it later.

  1. Mismatch should be a 409 Conflict.
  2. Probably stick with JSON-LD for now, unless there is an obvious needed use case we're missing.
  3. Either is fine by me.

@Natkeeran also: drop the checksum verification in case of someone POSTing just RDF variants (said differently, only binaries should have/allow checksum options). Mainly because there is just one known to me canonical-representation-algorithm-that-could-allow-checksums-for-RDF and it works just for JSON-LD and it is just too complex.
Also, Fedora 4 does not support checksumming for not binaries.

@whikloj @ruebot @DiegoPino

Thank you for the feedback. I'll give it a shot.

@Natkeeran @whikloj @DiegoPino I'd say we just drop the checksum altogether then, since we're just creating metadata with FedoraResource entities. You'd have to post seperately to create Media entities for the binaries themselves, with a FedoraResource being like the fcr:metadata elbow.

I think it's fairly safe to assume it would only be JSON-LD, but if you're clever with how you set things up, you'd get the standard Drupal JSON and XML for free. There's no plans on supporting any other RDF format than JSON-LD.

The real hole you'll get sucked down when attempting this is you'll have to add denormalizing capabilities to https://github.com/Islandora-CLAW/claw-jsonld.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dannylamb picture dannylamb  路  3Comments

dannylamb picture dannylamb  路  5Comments

ruebot picture ruebot  路  3Comments

acoburn picture acoburn  路  4Comments

ruebot picture ruebot  路  4Comments