Page tree

Old Release

This documentation covers an old version of Fedora. Looking for another version? See all documentation.

Skip to end of metadata
Go to start of metadata

 

Request URI:  /fcr:transform/{program}

Methods: GET, POST

GET get a resource transformed with the default transform

Request Headers:

Example:

default transform
@prefix fedora : <http://fedora.info/definitions/v4/repository#>
id      = . :: xsd:string ;
title = dc:title :: xsd:string;
uuid = fedora:uuid :: xsd:string ; 


curl "http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform/default"

Response:

Status: 200 OK

Headers:

Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.11.v20130520)

Body:

[{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}]

Status:

200 OK: if the transform is applied successfully

400 Bad Request: if the program doesn't exist

404 Not Found: if the resource doesn't exist

Note

To reference a stored "program" in the GET form of the fcr:transform service, the LDPath transformation directive must be stored at the following path:

http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/<program-name>/<resource-type>

Where <program-name> can be any name, and <resource-type> is the type of Fedora resource on which the transform will be applied:

  • "fedora:Container"
  • "fedora:nonRdfSourceDescription"
  • "fedora:Resource"

Example:

  1. Store a new program.
curl -i -X PUT -H "Content-Type: application/rdf+ldpath" --data-binary "@post.txt" http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/newprogram/fedora:Container

Response

Status 201 Created
 
Headers:
Content-Type: text/plain
 
http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/newprogram/fedora:Container

2. Get a resource transformed with the stored transform

curl -i http://localhost:8080/rest/pid5/fcr:transform/newprogram

Response

Status 200 OK


Header:
Server: Apache-Coyote/1.1
Content-Type: application/json
 
Body:
[{"id":["http://localhost:8080/rest/pid5"],"title":["some-resource-title"],"description":[],"uuid":["caa7bc6c-b80b-4e30-8ec1-15e90937e3be"]}]

 


POST get a resource transformed with the supplied transform

 

Output formats: application/json,text/tab-separated-values,text/csv,text/sse,text/plain,application/sparql-results+json,application/sparql-results+xml,application/sparql-results+bio,text/turtle,text/rdf+n3,application/N-triples,application/rdf_xml

Example:

curl -X POST -H "Content-Type: application/rdf+ldpath" --data-binary "@post.txt" "http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform"

Body:
@prefix fcrepo : <http://fedora.info/definitions/v4/repository#>
id      = . :: xsd:string ;
title = dc:title :: xsd:string;
uuid = fcrepo:uuid :: xsd:string ;

Response:

Status: 200 OK

Headers:

Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.11.v20130520)

Body:

[{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}]

Status:

200 OK: if the transform is applied successfully

400 Bad Request: if there was an error parsing or processing the transform

404 Not Found: if the resources doesn't exist

  • No labels

7 Comments

  1. Does this functionality only provide a mapping of some of the node's properties or can it be used to access properties from relative nodes (parent, child, sibling...)? In the latter case, what would be the syntax to access those nodes?

    1. Can you provide a specific scenario?

      1. I would like to use this API method to aggregate some of a node's properties as well as other nodes' in a single call. 

        Example: I have /node123/node456/master. I would like to call http://repo.edu/rest/node123/node456/fcr:transform and get a document such as:

        [{"uuid" : ["07630a24-5a0b-4ba7-80ab-0691f68667ce"], "title" : ["my donkey singing Cole Porter"], "parent-title" : ["Hits"], "master-mimetype" : ["audio/flac"]}]

        Where "uuid" and "title" are properties of /node123/node456, "parent-title" is the "dc:title" property of /node123, and "master-mimetype" is taken from /node123/node456/master.

         

        1. It is possible to do some of what you are requesting. Something to be aware of is that the context of the LDPath query is limited to the triples that are loaded when you do a basic HTTP GET on the target resource.

          Therefore, triples related to the children of the target are available, but not so with the target's parent. 

          The following LDPath query provides successful results (but does not include properties, such as dc:title, of the target's parent):

          @prefix fcrepo : <http://fedora.info/definitions/v4/repository#>
          uuid = fcrepo:uuid :: xsd:string ;
          title = dc:title :: xsd:string ;
          parent = fcrepo:hasParent :: xsd:string ;
          master-mimetype = fcrepo:hasChild/fcrepo:hasContent/fcrepo:mimeType :: xsd:string ;


          LDPath syntax reference: http://wiki.apache.org/marmotta/LDPath

          1. Thanks, that is a big improvement. I will see if I can work around the parent title.

          2. If you say "the context of the LDPath query is limited to the triples that are loaded when you do a basic HTTP GET on the target resource", then I should not be able to display properties such as 

            master-mimetype = fcrepo:hasChild/fcrepo:hasContent/fcrepo:mimeType :: xsd:string ;

            Right? Because this is not retrieved when I send a GET request to the target resource. 

            In the same way I cannot seem to retrieve paths such as ldp:contains/dc:title . 

            Also, is only a subset of the LDPath syntax supported? e.g. I can get the parent URI with fcrepo:hasParent but not with ^ldp:contains

            1. There have been a few updates that affect the details, but not the functionality described in my original comment. You are correct that a simple GET on a target resource will not by default return the details of child resources. However, if you include the following "Prefer" header in your request to resource/fcr:transform, you will indeed have an RDF context that includes child properties.

              curl -XPOST -H"Content-Type: application/rdf+ldpath" --data-binary @transform.ldpath -H"Prefer: return=representation; include=\"http://fedora.info/definitions/v4/repository#EmbedResources\"" http://localhost:8080/rest/node123/node456/fcr:transform

              See: API documentation

              In the above request, the file transform.ldpath is below:

              @prefix fedora : <http://fedora.info/definitions/v4/repository#>
              @prefix ldp : <http://www.w3.org/ns/ldp#>
              @prefix  dc : <http://purl.org/dc/elements/1.1/>
              
              uuid = fedora:uuid :: xsd:string ;
              title = ldp:contains/dc:title :: xsd:string ;
              parent = fedora:hasParent :: xsd:string ;
              master-mimetype = ldp:contains/fedora:mimeType :: xsd:string ;

              Regarding your question on the degree of LDPath syntax support, and specifically the support for the "Reverse Property Selector", we use the implementation library supplied by Apache Marmotta for performing the LDPath processing. 
              https://github.com/fcrepo4/fcrepo4/blob/master/fcrepo-transform/pom.xml#L224

              As noted in the Marmotta/LDPath documentation:

              In most cases it is not possible to know the incoming links from external datasets to a resource.

              http://wiki.apache.org/marmotta/LDPath#Reverse_Property_Selections