Re: Question regarding POST versus PUT for creating an LDPC

That is very helpful. Thank you.

Do you think we should be thinking of something to say about this first
container? In a Java Content Repository, for example, there is always a
notion of a root node and as such, the JCR API has some standard functions
around operating on the root node. Or, do you think this is just something
we leave up to the implementers?

In my case, I am implementing atop of Tomcat, so it's really a server on a
server (that is to say, a servlet mapped to a context). Supposing the LDP
Server application is called "ACME LDP", for example, I at least need a
servlet context. So it would be a URI like:

http://localhost:8080/acme

So I suppose it seems logical to me to program the main front controller
servlet that's responding to all of the HTTP methods to treat "acme" or
perhaps the "/" that follows as a root container. That is to say - hitting
http://localhost:8080/acme/ in my browser would be a GET on the root
container and and POST or PUT to  http://localhost:8080/acme/ would be
effectively saying "post or put to the root". In other words, the root
container is assumed to exist but is not identified by any specific label
(part) in the URI. It is just -> /. In a little bit of a different case,
one might configure an HTTP Server that fronts the app server in such that
by using URL rewriting or something, the servlet mapping (/acme) is not
necessary to be part of the URI. In that case a URL like http://host:port/
would GET the assumed root container.

I guess that's how I will proceed. Likely I'll find some kind of flub in
that plan soon enough. But then - that's the purpose; I am trying to test
the efficacy of our spec in how well it guides the implementer.

Let me know if you have any additional thoughts based on what I added.
Otherwise, I think I have enough to progress on now.

- Cody


On Wed, Apr 17, 2013 at 10:11 AM, Arnaud Le Hors <lehors@us.ibm.com> wrote:

> 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.
> --
> 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.




-- 
Cody Burleson
Enterprise Web Architect, Base22
Mobile: +1 (214) 702-6338
Skype: codyburleson
Email: cody@base22.com
Blog: codyburleson.com

* <http://base22.com>*
*
*
*Check my free/busy
time.<http://www.google.com/calendar/embed?src=cody.burleson%40base22.com&ctz=America/Chicago%20>
*

Received on Wednesday, 17 April 2013 16:05:38 UTC