read-write-web / rww-play

read write web Play
59 stars 19 forks source link

Example for creating an LDPC creates a file instead of a directory on the file system #142

Closed reederz closed 9 years ago

reederz commented 9 years ago

I'm talking about this example: https://github.com/read-write-web/rww-play/wiki/Curl-Interactions#creating-a-container .

Here's what I did:

[  2:47PM ]  [ justas@choedankal:~/Source/scala/workspace/jolocom/rww-play/test_www(dev✗) ]
curl -X POST -k -i -H "Content-Type: text/turtle; utf-8"  --cert ../eg/test-localhost.pem:test -H "Slug: XDir" -d @../eg/newContainer.ttl https://localhost:8443/2013/
HTTP/1.1 201 Created
Location: https://localhost:8443/2013/XDir
User: https://localhost:8443/2013/card#me
Content-Length: 0
[  2:48PM ]  [ justas@choedankal:~/Source/scala/workspace/jolocom/rww-play/test_www(dev✗) ]
 $ file XDir
XDir: symbolic link to XDir.ttl
[  2:49PM ]  [ justas@choedankal:~/Source/scala/workspace/jolocom/rww-play/test_www(dev✗) ]
 $ cat XDir.ttl 

<XDir> a <http://www.w3.org/ns/ldp#BasicContainer> ;
    <http://xmlns.com/foaf/0.1/topic> "A container for some type X of resources" ;
    <http://xmlns.com/foaf/0.1/maker> <https://localhost:8443/card#me> .

<> <http://www.w3.org/ns/ldp#contains> <XDir> .

After creation of this container, I trie to create a data resource in it using this example: https://github.com/read-write-web/rww-play/wiki/Curl-Interactions#creating-a-data-resource :

curl -X POST -k -i -H "Content-Type: text/turtle; utf-8"  \
>     --cert ../eg/test-localhost.pem:test  \
>     -H "Slug: couch" -d @../eg/couch.ttl https://localhost:8443/2013/XDir/
HTTP/1.1 417 Expectation Failed
Content-Type: text/plain; charset=utf-8
Content-Length: 1790

Cannot run class rww.ldp.CreateLDPR on an LDPR that is not an LDPC 
rww.ldp.LDPExceptions$RequestNotAcceptable: Cannot run class rww.ldp.CreateLDPR on an LDPR that is not an LDPC 
    at rww.ldp.actor.local.LDPRActor.runLocalCmd(LDPRActor.scala:305)
    at rww.ldp.actor.local.LDPRActor.adviceCmd(LDPRActor.scala:339)
    at rww.ldp.actor.local.LDPRActor$$anonfun$receive$1.applyOrElse(LDPRActor.scala:349)
    at scala.runtime.AbstractPartialFunction$mcVL$sp.apply$mcVL$sp(AbstractPartialFunction.scala:33)
    at scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:33)
    at scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:25)
    at rww.ldp.actor.common.RWWBaseActor$$anon$1.apply(RWWBaseActor.scala:26)
    at rww.ldp.actor.common.RWWBaseActor$$anon$1.apply(RWWBaseActor.scala:20)
    at scala.PartialFunction$class.applyOrElse(PartialFunction.scala:118)
    at rww.ldp.actor.common.RWWBaseActor$$anon$1.applyOrElse(RWWBaseActor.scala:20)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
    at rww.ldp.actor.local.LDPRActor.aroundReceive(LDPRActor.scala:29)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
    at akka.actor.ActorCell.invoke(ActorCell.scala:487)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)
    at akka.dispatch.Mailbox.run(Mailbox.scala:221)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
sylvainlb commented 9 years ago

Any update on this? I've been trying to create a LDPC, but I can't find any way to do it. Is it a known restriction?

bblfish commented 9 years ago

That looks like a bug to me.

bblfish commented 9 years ago

yes, the bug is with the example. To create a new LDPC you need to pass in the header the type of the resource you want to create, with the header

Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type",

I think that means you have to adapt the example to:

$ curl -X POST -k -i -H "Content-Type: text/turtle; utf-8"  -H "Link: Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type'" --cert ../eg/test-localhost.pem:test -H "Slug: XDir" -d @../eg/newContainer.ttl https://localhost:8443/2013/

Does that work?

reederz commented 9 years ago

I've tried creating a basic container with the adapted example:

[  9:17PM ]  [ justas@choedankal:~/Source/scala/RWW/rww-play/test_www(dev✔) ]
 $ curl -X POST -k -i -H "Content-Type: text/turtle; utf-8"  -H "Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type'" --cert ../eg/test-localhost.pem:test -H "Slug: XDir" -d @../eg/newContainer.ttl https://localhost:8443/2013/
HTTP/1.1 201 Created
Location: https://localhost:8443/2013/XDir
User: https://localhost:8443/2013/card#me
Content-Length: 0

Unfortunately, the end result is exactly the same as before I.e. the resulting XDir is a file (instead of directory) with the following content:

[  9:18PM ]  [ justas@choedankal:~/Source/scala/RWW/rww-play/test_www(dev✗) ]
 $ cat XDir

<XDir> a <http://www.w3.org/ns/ldp#BasicContainer> ;
    <http://xmlns.com/foaf/0.1/topic> "A container for some type X of resources" ;
    <http://xmlns.com/foaf/0.1/maker> <https://localhost:8443/card#me> .

<> <http://www.w3.org/ns/ldp#contains> <XDir> .
bblfish commented 9 years ago

ok, that looks like a bug then. Let me look at that.

bblfish commented 9 years ago

The following works:

curl -X POST -k -i -H "Content-Type: text/turtle; utf-8"  -H 'Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"' --cert ../eg/test-localhost.pem:test -H "Slug: XDir" -d @../eg/newContainer.ttl https://localhost:8443/2013/

If you can work out that my parser for link headers is incorrect, and that it should also allow quotation with single quotes ' then please open another issue.

I have fixed the curl description.

reederz commented 9 years ago

@bblfish I confirm- it works. Thanks

sylvainlb commented 8 years ago

Works for me too. Thanks !