read-write-web / rww-play

read write web Play
59 stars 19 forks source link

Missing reader and writer for application/n-triples in readerSelector and writerSelector #134

Closed reederz closed 9 years ago

reederz commented 9 years ago

We're using Sesame readerSelector, which does not include NTriplesReader: https://github.com/read-write-web/banana-rdf/blob/master/sesame/src/main/scala/org/w3/banana/sesame/SesameModule.scala#L75-78 . We could solve this by exchange the following in ./app/controllers/package.scala:

val webClient: WebClient[Rdf] = new WSClient(Sesame.readerSelector, Sesame.turtleWriter)

for

  implicit val readerSelector: ReaderSelector[Sesame, Try] =
    ReaderSelector[Sesame, Try, Turtle] combineWith
      ReaderSelector[Sesame, Try, RDFXML] combineWith
      ReaderSelector[Sesame, Try, JsonLd] combineWith
      ReaderSelector[Sesame, Try, NTriples]

  val webClient: WebClient[Rdf] = new WSClient(readerSelector, Sesame.turtleWriter)

Also, we're using this writerSelector https://github.com/read-write-web/rww-play/blob/dev/app/controllers/package.scala#L181-187 which does not include one for application/n-triples. I'm not sure how to solve this problem since Sesame doesn't seem to support ntriples syntax.

bblfish commented 9 years ago

yep, that looks like the patch. I'll be glad to merge it.

reederz commented 9 years ago

and I'd be glad to make a PR :) but I've only the solution for "missing reader problem". The writer would still be missing. application/n-triples writer doesn't seem to exist in Sesame (https://github.com/read-write-web/banana-rdf/blob/master/sesame/src/main/scala/org/w3/banana/sesame/io/SesameRDFWriter.scala#L45-50 ). Does it mean that it has to be written? or can we somehow use the one from Plantain?

bblfish commented 9 years ago

I don't think you need an NTriples Writer do you? It looks like my client only ever writes one very specific type of output - which is a limitation, but not for LDP as Turtle is a requirement.

reederz commented 9 years ago

It seems like I do need a writer. If try to get application/n-triples with client, I get 415 response like this.

 curl -i --insecure  -H "Accept: application/n-triples" 'https://localhost:8443/srv/cors?url=http%3A%2F%2Flocalhost%3A8080%2Freederz.nt'
HTTP/1.1 415 Unsupported Media Type
Content-Type: text/plain; charset=utf-8
Content-Length: 82

could not find RDF type of resource at remote location Some(application/n-triples)%

The error comes from here and happens because appropriate writer cannot be found by writerSelector: https://github.com/read-write-web/rww-play/blob/dev/app/rww/play/CORSProxy.scala#L107-115 (

reederz commented 9 years ago

Alternatively, we could get some other reader/writer into plantain implementation for client apps. It is because currently, rww-scala-js with plantain can only speak "application/n-triples"

bblfish commented 9 years ago

Ah, yes, I see. There is in banana-rdf a writer here: https://github.com/read-write-web/banana-rdf/blob/master/io/ntriples/common/src/main/scala/org/w3/banana/io/NTriplesWriter.scala You just have to add it to the defaults in the controllers/package.scala I think.

reederz commented 9 years ago

Oh cool- it did work. I'll make a PR shortly.