Fix mime type for xhtml, upgraded to latest incubator of jena and added timeout for connection when fetching files. webid
authorHenry Story <henry.story@bblfish.net>
Fri, 06 Jan 2012 20:46:17 +0100
branchwebid
changeset 168 5be56759c8cf
parent 167 a38d404047ce
child 169 288d9317e2f7
Fix mime type for xhtml, upgraded to latest incubator of jena and added timeout for connection when fetching files.
project/build.scala
src/main/scala/GraphCache.scala
src/main/scala/Lang.scala
src/main/scala/ReadWriteWebMain.scala
src/main/scala/util/SpyInputStream.scala
src/test/scala/auth/CreateWebIDSpec.scala
--- a/project/build.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/project/build.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -26,10 +26,10 @@
   val slf4japi = "org.slf4j" % "slf4j-api" % "1.6.4"
   val slf4jlog = "org.slf4j" % "slf4j-log4j12" % "1.6.4"
   val antiXML = "com.codecommit" %% "anti-xml" % "0.4-SNAPSHOT" % "test"
-  val jena = "com.hp.hpl.jena" % "jena" % "2.6.4"
+  val jena = "org.apache.jena" % "jena-core" % "2.7.0-incubating"
+  val arq = "org.apache.jena" % "jena-arq" % "2.9.0-incubating"
   val rdfa = "net.rootdev" % "java-rdfa" % "0.4.2-RC2"
   val htmlparser = "nu.validator.htmlparser" % "htmlparser" % "1.2.1"
-  val arq = "com.hp.hpl.jena" % "arq" % "2.8.8"
   val grizzled = "org.clapper" %% "grizzled-scala" % "1.0.8" % "test"
   val scalaz = "org.scalaz" %% "scalaz-core" % "6.0.3"
   val argot =  "org.clapper" %% "argot" % "0.3.5"
--- a/src/main/scala/GraphCache.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/src/main/scala/GraphCache.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -30,7 +30,7 @@
 import scalaz.{Scalaz, Validation}
 import java.util.concurrent.TimeUnit
 import com.google.common.cache.{LoadingCache, CacheLoader, CacheBuilder, Cache}
-
+import java.io.{File, FileOutputStream}
 
 
 /**
@@ -45,6 +45,10 @@
   import dispatch._
   import Scalaz._
 
+  //use shellac's rdfa parser
+  new net.rootdev.javardfa.jena.RDFaReader  //import rdfa parser
+
+
   //this is a simple but quite stupid web cache so that graphs can stay in memory and be used a little
   // bit across sessions
   val cache: LoadingCache[URL,Validation[Throwable,Model]] =
@@ -56,7 +60,11 @@
          def load(url: URL) = getUrl(url)
        })
 
-  val http = new Http with thread.Safety
+  val http = new Http with thread.Safety {
+    import org.apache.http.params.CoreConnectionPNames
+    client.getParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000)
+    client.getParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, 15000)
+  }
   
   def basePath = null //should be cache dir?
 
@@ -65,7 +73,7 @@
   def resource(u : URL) = new org.w3.readwriteweb.Resource {
     import CacheControl._
     def name() = u
-    def get(cacheControl: CacheControl.Value = CacheControl.CacheOnly) = cacheControl match {
+    def get(cacheControl: CacheControl.Value) = cacheControl match {
       case CacheOnly => {
         val res = cache.getIfPresent(u)
         if (null==res) NoCachEntry.fail
--- a/src/main/scala/Lang.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/src/main/scala/Lang.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -59,7 +59,7 @@
       case "text/turtle" => Some(TURTLE)
       case "application/rdf+xml" => Some(RDFXML)
       case "text/html" => Some(HTML)
-      case "text/xhtml" => Some(XHTML)
+      case "application/xhtml+xml" => Some(XHTML)
       case _ => None
   }    
   
--- a/src/main/scala/ReadWriteWebMain.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/src/main/scala/ReadWriteWebMain.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -16,7 +16,6 @@
 
 trait ReadWriteWebArgs {
   val logger: Logger = LoggerFactory.getLogger(this.getClass)
-  new net.rootdev.javardfa.jena.RDFaReader  //import rdfa parser
 
   val postUsageMsg= Some("""
   |PROPERTIES
--- a/src/main/scala/util/SpyInputStream.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/src/main/scala/util/SpyInputStream.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -34,7 +34,7 @@
 
 class SpyInputStream(val in: InputStream, val out: OutputStream) extends InputStream {
   var stopOut = false
-  
+
   def read() ={
 
     val i = try {
--- a/src/test/scala/auth/CreateWebIDSpec.scala	Thu Jan 05 23:55:46 2012 +0100
+++ b/src/test/scala/auth/CreateWebIDSpec.scala	Fri Jan 06 20:46:17 2012 +0100
@@ -39,7 +39,7 @@
 
 /**
  * A key manager that can contain multiple keys, but where the client can take one of a number of identities
- * One at a time - so this is not sychronised. It also assumes that the server will accept all CAs, which in
+ * One at a time - so this is not synchronised. It also assumes that the server will accept all CAs, which in
  * these test cases it does.
  */
 class FlexiKeyManager extends X509ExtendedKeyManager {