Current Release

This documentation covers the current version of Fedora. Looking for another version? See all documentation.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Fedora implements the following container types, which are defined by the LDP specification:

  • ldp:BasicContainer
  • ldp:DirectContainer
  • ldp:IndirectContainer

This document describes the basic interactions for these object types within Fedora, and some specific behavior decisions the application makes.

BasicContainer

ldp:BasicContainer are created by default in PUT or POST requests if no interaction model or unsupported RDF serialization Content-Type is provided. They are ldp:containers, and as a result, objects which are created as children of these containers will create containment triples from the BasicContainer to the child object, using the ldp:contains predicate.

Interactions with these objects are documented in RESTful HTTP API - Containers, along with supported RDF serialization types.

DirectContainer

In addition to the behaviors defined for ldp:BasicContainers, ldp:DirectContainers are used to produce membership triples between a membership resource and the immediate children of the DirectContainer. For more information, refer to the LDP specification and LDP-PCDM-F4 In Action.

The membership resource of a DirectContainer is defined by the object of a ldp:membershipResource property. If this property is not set, by default a property with the DirectContainer itself is added. Any resource URI may be specified as the object, whether it is within the Fedora repository or not. Literal objects are disallowed. Only one membership resource may be specified per DirectContainer.

To specify which predicate to use for the membership triples, either a ldp:hasMemberRelation or ldp:isMemberOfRelation property with the desired predicate as its the object should be set on the DirectContainer. If the former property is set, for each child of the DirectContainer a membership property will be created with the membership resource as the subject and the child as the object. If the ldp:isMemberOfRelation is used, the subject and object will be reversed. If no property is provided, by default a ldp:hasMemberRelation property with the object ldp:member will be added to the DirectContainer. Only one membership predicate can be provided per DirectContainer.

To create a DirectContainer with default properties, simply provide the appropriate interaction model:

curl -XPUT http://localhost:8080/rest/direct_container -H'Link: <http://www.w3.org/ns/ldp#DirectContainer>;rel="type"'

To create a DirectContainer with a different membership resource and relation:

echo "
<> <http://www.w3.org/ns/ldp#membershipResource> <http://localhost:8080/rest/membership_resc> .
<> <http://www.w3.org/ns/ldp#hasMemberRelation> <http://example.com/hasMember> .
" |
curl -XPUT http://localhost:8080/rest/direct_container -H'Link: <http://www.w3.org/ns/ldp#DirectContainer>;rel="type"' -H"Content-Type: text/turtle" --data-binary "@-"

The properties of the DirectContainer may be updated after creation via PATCH or PUT.

Then to add a member to the container, create a child of direct_container:

curl -XPUT http://localhost:8080/rest/direct_container/member1

The membership triples produced will be included in GET responses to the membership resource if the DirectContainer specifies ldp:hasMemberRelation (<http://localhost:8080/rest/membership_resc> in the example above), or in the response for child objects if ldp:isMemberOfRelation was set.

curl http://localhost:8080/rest/membership_resc

@prefix ldp:   <http://www.w3.org/ns/ldp#> .
<http://localhost:8080/rest/membership_resc>
        <http://example.com/hasMember>  <http://localhost:8080/rest/direct_container/member1> ;
        ...

Membership triples are returned in responses from mementos of objects as well. It should be noted that even with autoversioning enabled, adding membership triples to a resource does not trigger a new memento of that resource. If the DirectContainer and its fcr:tombstone are deleted, any membership triples resulting from it will no longer appear in mementos. Similarly, deleting children of DirectContainers and their fcr:tombstones will remove membership triples involving those resources.

IndirectContainer

As ldp:IndirectContainers are a subclass of ldp:DirectContainer, everything described above applies here as well. Additionally, IndirectContainers add the ability to create membership triples to resources which are not the immediate children of the container, via proxy objects.

By default, IndirectContainers will have a ldp:insertedContentRelation property with the object ldp:MemberSubject. If the property has this object, then the container will function the same as a DirectContainer; membership triples will only be generated for immediate children of the container.

If any other predicate URI is provided as the object of this property, then membership will only be generated between the membership resource and resources referenced by the children of the IndirectContainer. These children are referred to as proxy objects. Only resources referenced by the children using the same predicate defined via the ldp:insertedContentRelation of the IndirectContainer will generate membership triples. Literal values referenced by these predicates will be ignored.

Only one member may be referenced per proxy, but the same member resource can be referenced by any number of proxy objects in any number of IndirectContainers.

To create an IndirectContainer with membership resource "http://localhost:8080/rest/membership_resc":

echo "
<> <http://www.w3.org/ns/ldp#membershipResource> <http://localhost:8080/rest/membership_resc>;
   <http://www.w3.org/ns/ldp#hasMemberRelation> <http://example.com/hasMember>;
   <http://www.w3.org/ns/ldp#insertedContentRelation> <http://example.com/proxyFor>
" |
curl -XPUT http://localhost:8080/rest/indirect_container -H'Link: <http://www.w3.org/ns/ldp#IndirectContainer>;rel="type"' -H"Content-Type: text/turtle" --data-binary "@-"

To add "http://localhost:8080/rest/member2" as a member of membership_resc, you could create a proxy as follows:

echo "
<> <http://example.com/proxyFor> <http://localhost:8080/rest/member2>" |
curl -XPUT http://localhost:8080/rest/indirect_container/proxy1 -H"Content-Type: text/turtle" --data-binary "@-"

At which point a GET request to membership_resc would return the membership triple:

curl http://localhost:8080/rest/membership_resc

@prefix ldp:   <http://www.w3.org/ns/ldp#> .
<http://localhost:8080/rest/membership_resc>
        <http://example.com/hasMember>  <http://localhost:8080/rest/member2> .
        ...

Deleting a proxy object will remove the membership triple generated by it, but will not affect the original referenced object otherwise. Deleting the proxy's tombstone will remove any membership triples produced by it in existing mementos.

  • No labels