~ fix the relative URI issue (by using explicit RDFWriter)
authorAlexandre Bertails <bertails@gmail.com>
Sun, 28 Aug 2011 10:36:01 -0400
changeset 12 4fcf6502668c
parent 11 e323200c6ecc
child 13 dc0c44140125
~ fix the relative URI issue (by using explicit RDFWriter)
src/main/scala/Main.scala
--- a/src/main/scala/Main.scala	Sat Aug 27 20:13:23 2011 -0400
+++ b/src/main/scala/Main.scala	Sun Aug 28 10:36:01 2011 -0400
@@ -29,9 +29,8 @@
   
   val read = unfiltered.filter.Planify {
     case req @ Path(path) => {
-      val baseURI = req.underlying.getRequestURL.toString  
+      val baseURI = req.underlying.getRequestURL.toString
       val fileOnDisk = new File(base, path)
-       
       def foo():(OutputStream, Model) = {
         // get empty model if file not on disk
         val model = ModelFactory.createDefaultModel()
@@ -71,7 +70,8 @@
         case PUT(_) => {
           val bodyModel = modelFromInputStream(Body.stream(req), baseURI)
           val (fos, _) = foo()
-          bodyModel.write(fos, "RDF/XML-ABBREV", baseURI)
+          val writer = bodyModel.getWriter("RDF/XML-ABBREV")
+          writer.write(bodyModel, fos, baseURI)
           fos.close()
           Created
         }
@@ -81,14 +81,16 @@
             case PostUpdate(update) => {
               val (fos, model) = foo()
               UpdateAction.execute(update, model)
-              model.write(fos)
+              val writer = model.getWriter("RDF/XML-ABBREV")
+              writer.write(model, fos, baseURI)
               fos.close()
               Ok
             }
             case PostRDF(diffModel) => {
               val (fos, model) = foo()
               model.add(diffModel)
-              model.write(fos)
+              val writer = model.getWriter("RDF/XML-ABBREV")
+              writer.write(model, fos, baseURI)
               fos.close()
               Ok
             }