--- a/src/main/scala/Post.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/main/scala/Post.scala Sat Oct 15 10:28:08 2011 -0400
@@ -45,8 +45,9 @@
case qpe: QueryParseException => qpe.fail
}
+ // TODO
def postRDF =
- modelFromString(s, baseURI) flatMap { model => PostRDF(model).success }
+ modelFromString(s, baseURI, RDFXML) flatMap { model => PostRDF(model).success }
def postQuery =
try {
--- a/src/main/scala/plan.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/main/scala/plan.scala Sat Oct 15 10:28:08 2011 -0400
@@ -74,7 +74,7 @@
}
case PUT(_) & Lang(lang) =>
for {
- bodyModel <- modelFromInputStream(Body.stream(req), baseURI) failMap { t => BadRequest ~> ResponseString(t.getStackTraceString) }
+ bodyModel <- modelFromInputStream(Body.stream(req), baseURI, lang) failMap { t => BadRequest ~> ResponseString(t.getStackTraceString) }
_ <- r.save(bodyModel) failMap { t => InternalServerError ~> ResponseString(t.getStackTraceString) }
} yield Created
case PUT(_) =>
--- a/src/main/scala/util/package.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/main/scala/util/package.scala Sat Oct 15 10:28:08 2011 -0400
@@ -37,10 +37,10 @@
def modelFromInputStream(
is: InputStream,
base: String,
- lang: String = "RDF/XML-ABBREV"): Validation[Throwable, Model] =
+ lang: Lang): Validation[Throwable, Model] =
try {
val m = ModelFactory.createDefaultModel()
- m.read(is, base, lang)
+ m.getReader(lang.jenaLang).read(m, is, base)
m.success
} catch {
case t => t.fail
@@ -49,11 +49,11 @@
def modelFromString(
s: String,
base: String,
- lang: String = "RDF/XML-ABBREV"): Validation[Throwable, Model] =
+ lang: Lang): Validation[Throwable, Model] =
try {
val reader = new StringReader(s)
val m = ModelFactory.createDefaultModel()
- m.read(reader, base, lang)
+ m.getReader(lang.jenaLang).read(m, reader, base)
m.success
} catch {
case t => t.fail
--- a/src/test/scala/AccessContentSpecs.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/AccessContentSpecs.scala Sat Oct 15 10:28:08 2011 -0400
@@ -24,7 +24,7 @@
"return a 200 and an empty model" in {
val (statusCode, model) = Http(uri >+ {
req => (req.get_statusCode,
- req as_model(uriBase))
+ req as_model(uriBase, RDFXML))
} )
statusCode must_== 200
model must beIsomorphicWith (emptyModel)
@@ -37,8 +37,8 @@
"a GET on Joe's URI" should {
"deliver TURTLE and RDF/XML graphs that are isomorphic to each other" in {
- val rdfxml = Http(uri as_model(uriBase))
- val turtle = Http(uri <:< Map("Accept" -> "text/turtle") as_model(uriBase, lang="TURTLE"))
+ val rdfxml = Http(uri as_model(uriBase, RDFXML))
+ val turtle = Http(uri <:< Map("Accept" -> "text/turtle") as_model(uriBase, TURTLE))
rdfxml must beIsomorphicWith(turtle)
}
}
--- a/src/test/scala/CreateContentSpecs.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/CreateContentSpecs.scala Sat Oct 15 10:28:08 2011 -0400
@@ -21,7 +21,7 @@
"now exist and be isomorphic with the original document" in {
val (statusCode, via, model) = Http(uri >++ { req => (req.get_statusCode,
req.get_header("MS-Author-Via"),
- req as_model(uriBase))
+ req as_model(uriBase, RDFXML))
} )
statusCode must_== 200
via must_== "SPARQL"
@@ -56,7 +56,7 @@
</rdf:RDF>
"""
- val expectedFinalModel = modelFromString(finalRDF, uriBase).toOption.get
+ val expectedFinalModel = modelFromString(finalRDF, uriBase, RDFXML).toOption.get
"POSTing an RDF document to Joe's URI" should {
"succeed" in {
@@ -64,7 +64,7 @@
httpCode must_== 200
}
"append the diff graph to the initial graph" in {
- val model = Http(uri as_model(uriBase))
+ val model = Http(uri as_model(uriBase, RDFXML))
model must beIsomorphicWith (expectedFinalModel)
}
}
--- a/src/test/scala/SparqlQuerySpecs.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/SparqlQuerySpecs.scala Sat Oct 15 10:28:08 2011 -0400
@@ -57,7 +57,7 @@
"""POSTing "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }" to Joe's URI""" should {
"return an isomorphic RDF graph" in {
- val model = Http(uri as_model(uriBase))
+ val model = Http(uri as_model(uriBase, RDFXML))
model must beIsomorphicWith (referenceModel)
}
}
--- a/src/test/scala/SparqlUpdateSpecs.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/SparqlUpdateSpecs.scala Sat Oct 15 10:28:08 2011 -0400
@@ -19,7 +19,7 @@
httpCode must_== 200
}
"produce a graph with one more triple than the original one" in {
- val model = Http(uri as_model(uriBase))
+ val model = Http(uri as_model(uriBase, RDFXML))
model.size must_== (referenceModel.size + 1)
}
}
--- a/src/test/scala/util/specs.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/util/specs.scala Sat Oct 15 10:28:08 2011 -0400
@@ -62,7 +62,7 @@
"""
"""
- val referenceModel = modelFromString(rdfxml, uriBase).toOption.get
+ val referenceModel = modelFromString(rdfxml, uriBase, RDFXML).toOption.get
}
--- a/src/test/scala/util/utiltest.scala Sat Oct 15 10:12:34 2011 -0400
+++ b/src/test/scala/util/utiltest.scala Sat Oct 15 10:28:08 2011 -0400
@@ -39,7 +39,7 @@
class RequestW(req: Request) {
- def as_model(base: String, lang: String = "RDF/XML-ABBREV"): Handler[Model] =
+ def as_model(base: String, lang: Lang): Handler[Model] =
req >> { is => modelFromInputStream(is, base, lang).toOption.get }
def post(body: String): Request =