narrowing down the differences, before a merge webid
authorHenry Story <henry.story@bblfish.net>
Wed, 12 Oct 2011 14:09:33 +0200
branchwebid
changeset 55 0a97b1a3c435
parent 54 e027110a59e0
child 56 1ef59b9dab9b
narrowing down the differences, before a merge
src/main/scala/Resource.scala
--- a/src/main/scala/Resource.scala	Wed Oct 12 13:36:31 2011 +0200
+++ b/src/main/scala/Resource.scala	Wed Oct 12 14:09:33 2011 +0200
@@ -8,6 +8,8 @@
 import com.hp.hpl.jena.rdf.model._
 import com.hp.hpl.jena.shared.JenaException
 
+import org.w3.readwriteweb.util._
+
 import scalaz._
 import Scalaz._
 
@@ -24,7 +26,10 @@
   def save(model:Model):Validation[Throwable, Unit]
 }
 
-class Filesystem(baseDirectory:File, val basePath:String, val lang:String = "RDF/XML-ABBREV")(implicit mode:RWWMode) extends ResourceManager {
+class Filesystem(
+  baseDirectory: File,
+  val basePath: String,
+  val lang: String = "RDF/XML-ABBREV")(mode: RWWMode) extends ResourceManager {
   
   val logger:Logger = LoggerFactory.getLogger(this.getClass)
   
@@ -43,19 +48,20 @@
     }
     
     def get():Validation[Throwable, Model] = {
-      val m = ModelFactory.createDefaultModel()
+      val model = ModelFactory.createDefaultModel()
       if (fileOnDisk.exists()) {
         val fis = new FileInputStream(fileOnDisk)
         try {
-          m.read(fis, url.toString)
+          val reader = model.getReader(lang)
+          reader.read(model, fis, url.toString)
         } catch {
-          case je:JenaException => error("File %s was either empty or corrupted: considered as empty graph" format fileOnDisk.getAbsolutePath)
+          case je:JenaException => error("@@@")
         }
         fis.close()
-        m.success
+        model.success
       } else {
         mode match {
-          case AllResourcesAlreadyExist => m.success
+          case AllResourcesAlreadyExist => model.success
           case ResourcesDontExistByDefault => new FileNotFoundException().fail
       }
       }
@@ -65,7 +71,7 @@
       try {
         createFileOnDisk()
         val fos = new FileOutputStream(fileOnDisk)
-        val writer = model.getWriter("RDF/XML-ABBREV")
+        val writer = model.getWriter(lang)
         writer.write(model, fos, url.toString)
         fos.close().success
       } catch {