Documentation: Recast service strips out RDF from application/ld+json

Created on 8 May 2019  路  12Comments  路  Source: Islandora/documentation

Stumbled across this when investigating another issue related to media and recasting. Pretty much everything other than what gets recasted is stripped out of returned jsonld.

Original

[
   {
      "@id":"http://localhost:8080/fcrepo/rest/ae/6d/03/42/ae6d0342-3fbf-4ee3-9866-e5dd6f38e893",
      "http://fedora.info/definitions/v4/repository#created":[
         {
            "@value":"2019-05-03T13:41:29.862Z",
            "@type":"http://www.w3.org/2001/XMLSchema#dateTime"
         }
      ],
      "@type":[
         "http://www.w3.org/ns/ldp#NonRDFSource",
         "http://fedora.info/definitions/v4/repository#Resource",
         "http://fedora.info/definitions/v4/repository#NonRdfSourceDescription",
         "http://fedora.info/definitions/v4/repository#Binary",
         "http://pcdm.org/use#ServiceFile",
         "http://pcdm.org/models#File"
      ],
      "http://schema.org/sameAs":[
         {
            "@value":"http://localhost:8000/sites/default/files/2019-05/12-Service%20File.jpg"
         }
      ],
      "http://schema.org/dateCreated":[
         {
            "@value":"2019-05-03T13:41:29+00:00",
            "@type":"http://www.w3.org/2001/XMLSchema#dateTime"
         }
      ],
      "http://www.loc.gov/premis/rdf/v1#hasSize":[
         {
            "@value":"808596",
            "@type":"http://www.w3.org/2001/XMLSchema#long"
         }
      ],
      "http://fedora.info/definitions/v4/repository#lastModifiedBy":[
         {
            "@value":"bypassAdmin"
         }
      ],
      "http://pcdm.org/models#fileOf":[
         {
            "@id":"http://localhost:8000/node/12?_format=jsonld"
         }
      ],
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#label":[
         {
            "@value":"12-Service File.jpg",
            "@language":"en"
         }
      ],
      "http://fedora.info/definitions/v4/repository#createdBy":[
         {
            "@value":"bypassAdmin"
         }
      ],
      "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasMimeType":[
         {
            "@value":"image/jpeg"
         }
      ],
      "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#filename":[
         {
            "@value":""
         }
      ],
      "http://fedora.info/definitions/v4/repository#hasFixityService":[
         {
            "@id":"http://localhost:8080/fcrepo/rest/ae/6d/03/42/ae6d0342-3fbf-4ee3-9866-e5dd6f38e893/fcr:fixity"
         }
      ],
      "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#height":[
         {
            "@value":"3639",
            "@type":"http://www.w3.org/2001/XMLSchema#int"
         }
      ],
      "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#width":[
         {
            "@value":"5400",
            "@type":"http://www.w3.org/2001/XMLSchema#int"
         }
      ],
      "http://schema.org/author":[
         {
            "@id":"http://localhost:8000/user/1?_format=jsonld"
         }
      ],
      "http://fedora.info/definitions/v4/repository#lastModified":[
         {
            "@value":"2019-05-03T13:41:31.842Z",
            "@type":"http://www.w3.org/2001/XMLSchema#dateTime"
         }
      ],
      "http://www.iana.org/assignments/relation/describedby":[
         {
            "@id":"http://localhost:8080/fcrepo/rest/ae/6d/03/42/ae6d0342-3fbf-4ee3-9866-e5dd6f38e893/fcr:metadata"
         }
      ],
      "http://schema.org/dateModified":[
         {
            "@value":"2019-05-03T13:41:29+00:00",
            "@type":"http://www.w3.org/2001/XMLSchema#dateTime"
         }
      ],
      "http://purl.org/dc/terms/title":[
         {
            "@value":"12-Service File.jpg",
            "@language":"en"
         }
      ]
   }
]

Recasted

[
   {
      "@id":"http:\/\/localhost:8080\/fcrepo\/rest\/ae\/6d\/03\/42\/ae6d0342-3fbf-4ee3-9866-e5dd6f38e893\/fcr:metadata",
      "http:\/\/pcdm.org\/models#fileOf":[
         {
            "@id":"http:\/\/localhost:8080\/fcrepo\/rest\/1d\/19\/9d\/62\/1d199d62-0b54-488b-9519-5b3a4b83774e"
         }
      ]
   }
]

Most helpful comment

All 12 comments

Also, I dont' think the fcr:metadata thing should be used as the subject of a triple, as it is in the Recasted version. That is the location of the metadata document. It is not the file itself, and the metadata document's location is not an entity which can be fileOf anything else. In the original, the subject was the fedora resource (sans /fcr:metadata).

The Recast service uses the Apix-Ldp-Resource URI when parsing the graph, which is why this happens.

I'll see what I can do to avoid this, short of hard-coding the removal of /fcr:metadata which would be an unfortunate lock to the community Fedora implementation.

Do you mean that I should have hit the binary uri instead of the /fcr:metadata path?
like: curl -H"Authorization: Bearer islandora" -H"Accept: text/turtle" -H"Apix-Ldp-Resource: http://localhost:8080/fcrepo/rest/2019-05/IMG_1878.PNG" http://localhost:8000/recast/replace

No no, basically in Fedora when you have http://localhost:8080/fcrepo/rest/binary it has a description at http://localhost:8080/fcrepo/rest/binary/fcr:metadata.

But the graph at http://localhost:8080/fcrepo/rest/binary/fcr:metadata has http://localhost:8080/fcrepo/rest/binary as the subject of the graph.

ie.

curl -H"Authorization: Bearer islandora" -H"Accept: text/turtle" http://localhost:8080/fcrepo/rest/binary/fcr:metadata

@prefix fedora: <http://fedora.info/definitions/v4/repository#>
...

<http://localhost:8080/fcrepo/rest/binary>
        rdf:type                    fedora:NonRdfSourceDescription ;
        rdf:type                    <http://pcdm.org/models#File> ;
        rdf:type                    <http://pcdm.org/use#OriginalFile> ;
...

When Recast parses the graph it is using the URL with /fcr:metadata as the subject which is incorrect. If I remove the URI and don't pass it to EasyRdf is assumes the current URL which still has /fcr:metadata.

So I am going to try checking if the object is a ldp:NonRdfSource and if it is look for a rel="describedby" or rel="describes" Link header so I can get the correct URI.

Ok, thanks for the clarification

@whikloj in the above example, the returned RDF states that

@prefix fedora: <http://fedora.info/definitions/v4/repository#>
<http://localhost:8080/fcrepo/rest/binary>
        rdf:type                    fedora:NonRdfSourceDescription ;

when I thought that type should belong to <http://localhost:8080/fcrepo/rest/binary/fcr:metadata>. Is that a bug?

@rosiel That is there from Fedora...I'll have to see if that should be there. We can get rid of those fedora:* triples using a -H"Prefer: return=representation; omit=\"http://fedora.info/definitions/v4/repository#ServerManaged\"" header

I don't want to get rid of them, it just doesn't fit the documentation of what things are. If Fedora is describing the binary as a fedora:NonRdfSourceDescription, and not the binary/fcr:metadata, then I think it's doing it wrong.

I agree with Rosie. If the returned subject is that of the binary itself, then I would expect a type of ldp:NonRdfResrouce, which is what I get when I HEAD the binary and look at the link headers.

If I were to HEAD the fcr:metadata url, I'd expect to see a link header for fedora:NonRdfSourceDescription.

++

Was this page helpful?
0 / 5 - 0 ratings