Re: Question regarding POST versus PUT for creating an LDPC

hi Arnaud and Cody, 

> Hi Cody, 
> The spec allows creating resources using PUT [1] but it recommends to POST to a container as a way to do so [2]. The spec further specifies that containers can be created the same way, since they are resources. [3] 
> 
> [1] 4.4.6 LDPR servers MAY choose to allow the creation of new resources using HTTP PUT. 
> [2] 5.4.1 LDPC clients SHOULD create member resources by submitting a representation as the entity body of the HTTP POST to a known LDPC. 
> [3] 5.4.4 For servers that support create, LDPC servers MUST create an LDPR from a RDF representation in the request entity body. The LDPR could also be a LDPC, therefore servers may allow the creations of LDPCs within a LDPC. 
> 
> Now, you might ask: how do I start? That is currently left undefined. It is assumed that somehow you can get a hold of a first container. 


Well, If there isn't a container around to POST to, then Cody's initial PUT would work to bootstrap the cascade of creation processes. 


What about the following (related) scenario ::

For a resource <Bob> there is an LDPC called <Bob>:<likes>. The triples inside this LDPC are the things that <Bob> likes. So, that's all good. But, what if I then need a <Bob>:<friends> LDPC to make a record of <Bob>s friends. Currently <Bob> doesn't have any <friends> triples, and therefore this LDPC doesn't exist ? 

Somehow we need to create this a new LDPC (with type ldp:container, ldp:membershippredicate of <friends>, ldp:membershipsubject of <Bob>). So, either the creation of the <Bob>:<friends> is processed by <Bob> using POST. Or, this new <Bob>:<friends> resource has to be PUT to the server directly ... 

(??) 

Roger



> --
> Arnaud  Le Hors - Software Standards Architect - IBM Software Group
> 
> 
> Cody Burleson <cody.burleson@base22.com> wrote on 04/17/2013 07:00:33 AM:
> 
> > From: Cody Burleson <cody.burleson@base22.com> 
> > To: "Eric Prud'hommeaux" <eric@w3.org>, 
> > Cc: Linked Data Platform WG <public-ldp-wg@w3.org> 
> > Date: 04/17/2013 07:09 AM 
> > Subject: Re: Question regarding POST versus PUT for creating an LDPC 
> > 
> > First of all, thanks for your feedback.
> > 
> > I understand the case of creating a resource within a container and 
> > using the container as a factory for that. I think I understand the 
> > case of creating a container.
> > 
> > In the case that I am creating a named container, I am considering 
> > the following:
> > 
> > HTTP PUT (of type text/turtle) TO URI: http://base22.com/carbon/ourco
> > 
> > @base <http://base22.com/carbon> .
> > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
> > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
> > @prefix dcterms: <http://purl.org/dc/terms/>.
> > @prefix ldp: <http://www.w3.org/ns/ldp#>.
> > 
> > <>
> >     a ldp:Container;
> >     dcterms:description "A domain root container for OurCo resources.";
> >     rdfs:comment "In a multitenant environment, Carbon LDP typically
> > uses a root container after the servlet context to represent the 
> > concept of the tenant (e.g. a site, application, or particular 
> > domain of knowledge.";
> >     rdfs:label "ourco".
> > 
> > My thought is because I am PUTting to "/ourco" and an LDPC/LDPR does
> > not yet exist at that URI, then the server can accept creation of 
> > the container, which would henceforth be accessible at that URI.
> > 
> > Does that sound about right?
> > 
> > - Cody
> > 
> > 
> 
> > On Wed, Apr 17, 2013 at 5:38 AM, Eric Prud'hommeaux <eric@w3.org> wrote: 
> > * Cody Burleson <cody.burleson@base22.com> [2013-04-16 23:37-0500] 
> > > Team,
> > >
> > > I'm curious of your opinion.
> > >
> > > I have been feverishly trying to catch up, where time permits, by trying my
> > > hand at implementing what is specified thus far (in Java, as a layer atop
> > > Tomcat).
> > >
> > > One area where I'm having doubts is on what might be the more logical HTTP
> > > method for the creation of an LDPC. POST or PUT?
> > >
> > > I kind of get the feeling that the spec, as it stands, seems to imply that
> > > PUT is the better method. But I'm not so sure.
> > >
> > > In your experience, is there a convention for CREATE? It just doesn't seem
> > > clear to me that one is intended over the other. I suppose both could be
> > > supported, but what would be the majority expectation?
> > >
> > > Or does it matter?
> > >
> > > Sorry - I know I'm not really contributing yet, but rather - just asking
> > > more questions. But I think, perhaps, that once I get my code up to a point
> > > where it's starting to have good coverage, it may start to reveal some real
> > > questions and issues that could add value. So, bear with me (and be gentle).
> 
> > If the client knows or has control over the name of the resource to be
> > created, it should PUT the contents to the new location. There are
> > several problems with this caveat:
> > 
> > 1 PUTting a resource names that aren't cryptographically unique means
> >   it's likely that some client has already created that resource,
> >   e.g. all clients try all the time to create container/item1.
> > 
> > 2 The server implementation might constrain the names of the resources
> >   it can store and serve, e.g. one backed by a database which stores
> >   only an integer which it concatonates unto "container/item".
> > 
> > For these reasons, LDP also supports the common web convention of
> > POSTing to a factory to create new resources. In LDP's case, that
> > factory is called a container and there is a prescribed protocol and
> > media language for talking to it.
> > 
> > Hope I answered the right question.
> > 
> > 
> > > --
> > > Cody Burleson
> > 
> > --
> > -ericP 
> > 
> > 
> > 
> > -- 
> > Cody Burleson
> > Enterprise Web Architect, Base22
> > Mobile: +1 (214) 702-6338
> > Skype: codyburleson
> > Email: cody@base22.com
> > Blog: codyburleson.com 
> > 
> > [image removed] 
> > 
> > Check my free/busy time.

Received on Wednesday, 17 April 2013 16:08:59 UTC