You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/08/12 15:13:02 UTC

svn commit: r1513131 - in /jena/trunk/jena-arq/src: main/java/org/apache/jena/riot/adapters/ main/java/org/apache/jena/riot/stream/ test/java/com/hp/hpl/jena/sparql/junit/ test/java/riotcmd/

Author: andy
Date: Mon Aug 12 13:13:02 2013
New Revision: 1513131

URL: http://svn.apache.org/r1513131
Log:
JENA-509
Incorrect path for seeking out the location mapping.
Need to use the style expected of the new locators
(file: forces real file).

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/adapters/AdapterFileManager.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/stream/JenaIOEnvironment.java
    jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/junit/EarlReport.java
    jena/trunk/jena-arq/src/test/java/riotcmd/rdflangtest.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/adapters/AdapterFileManager.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/adapters/AdapterFileManager.java?rev=1513131&r1=1513130&r2=1513131&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/adapters/AdapterFileManager.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/adapters/AdapterFileManager.java Mon Aug 12 13:13:02 2013
@@ -154,7 +154,7 @@ public class AdapterFileManager extends 
     /** Create a "standard" FileManager. */
     public static AdapterFileManager makeGlobal()
     {
-        AdapterFileManager fMgr = new AdapterFileManager(StreamManager.get(), (LocationMapper)null) ;
+        AdapterFileManager fMgr = new AdapterFileManager(StreamManager.get(), JenaIOEnvironment.getLocationMapper()) ;
         return fMgr ;
     }
     

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/stream/JenaIOEnvironment.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/stream/JenaIOEnvironment.java?rev=1513131&r1=1513130&r2=1513131&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/stream/JenaIOEnvironment.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/stream/JenaIOEnvironment.java Mon Aug 12 13:13:02 2013
@@ -34,28 +34,31 @@ import com.hp.hpl.jena.vocabulary.Locati
 /** Code for using the general facilities of the location mapper/ filemanager subsystem
  *  and set up for Jena usage. e.g. find a location mapper with RDf description. 
  */
-class JenaIOEnvironment
+public class JenaIOEnvironment
 {
     static LocationMapper theMapper = null ;
+    private final static Object lock = new Object() ;
     /** Get the global LocationMapper */
     public static LocationMapper getLocationMapper()
     {
-        if ( theMapper == null )
-        {
-            theMapper = new LocationMapper() ;
-            if ( getGlobalConfigPath() != null )
-                JenaIOEnvironment.createLocationMapper(getGlobalConfigPath()) ;
+        synchronized (lock) {
+            if ( theMapper == null ) {
+                String path = getGlobalConfigPath() ;
+                if ( path != null )
+                    theMapper = JenaIOEnvironment.createLocationMapper(path) ;
+                if ( theMapper == null )
+                    theMapper = new LocationMapper() ;
+            }
+            return theMapper ;
         }
-        return theMapper ;
     }
     
     static Logger log = LoggerFactory.getLogger(JenaIOEnvironment.class)  ;
     
     /** The default path for searching for the location mapper */
     public static final String DEFAULT_PATH =
-        "file:location-mapping.rdf;file:location-mapping.n3;file:location-mapping.ttl;"+
-        "file:etc/location-mapping.rdf;file:etc/location-mapping.n3;"+
-        "file:etc/location-mapping.ttl" ;
+        "location-mapping.ttl;location-mapping.rdf;location-mapping.n3;"+
+        "etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl" ;
     public static final String GlobalMapperSystemProperty1 = "http://jena.hpl.hp.com/2004/08/LocationMap" ;
     public static final String GlobalMapperSystemProperty2 = "LocationMap" ;
 
@@ -146,54 +149,45 @@ class JenaIOEnvironment
      *  to find a description of a LocationMapper, then create and return a
      *  LocationMapper based on the description.
      */
-    public static LocationMapper createLocationMapper(String configPath)
-    {
-        // Old code : maintenance: use Webreader to open the model. 
-        
-        LocationMapper locMap = new LocationMapper() ;
-        if ( configPath == null || configPath.length() == 0 )
-        {
+    public static LocationMapper createLocationMapper(String configPath) {
+        if ( configPath == null || configPath.length() == 0 ) {
             log.warn("Null configuration") ;
             return null ;
         }
-        
+
         // Make a file manager to look for the location mapping file
         StreamManager smgr = new StreamManager() ;
         smgr.addLocator(new LocatorFile()) ;
         smgr.addLocator(new LocatorClassLoader(smgr.getClass().getClassLoader())) ;
-        
+
         try {
-            String uriConfig = null ; 
+            String uriConfig = null ;
             TypedInputStream in = null ;
-            
-            StringTokenizer pathElems = new StringTokenizer( configPath, AdapterFileManager.PATH_DELIMITER );
+
+            StringTokenizer pathElems = new StringTokenizer(configPath, AdapterFileManager.PATH_DELIMITER) ;
             while (pathElems.hasMoreTokens()) {
-                String uri = pathElems.nextToken();
+                String uri = pathElems.nextToken() ;
                 if ( uri == null || uri.length() == 0 )
                     break ;
-                
+
                 in = smgr.openNoMapOrNull(uri) ;
-                if ( in != null )
-                {
+                if ( in != null ) {
                     uriConfig = uri ;
                     break ;
                 }
             }
-    
-            if ( in == null )
-            {
-                log.debug("Failed to find configuration: "+configPath) ;
+
+            if ( in == null ) {
+                log.debug("Failed to find configuration: " + configPath) ;
                 return null ;
             }
             String syntax = FileUtils.guessLang(uriConfig) ;
             Model model = ModelFactory.createDefaultModel() ;
             model.read(in, uriConfig, syntax) ;
-            processConfig(model) ;
-        } catch (JenaException ex)
-        {
-            LoggerFactory.getLogger(LocationMapper.class).warn("Error in configuration file: "+ex.getMessage()) ;
+            return processConfig(model) ;
+        } catch (JenaException ex) {
+            LoggerFactory.getLogger(LocationMapper.class).warn("Error in configuration file: " + ex.getMessage()) ;
+            return new LocationMapper() ;
         }
-        return locMap ;
     }
-
 }

Modified: jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/junit/EarlReport.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/junit/EarlReport.java?rev=1513131&r1=1513130&r2=1513131&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/junit/EarlReport.java (original)
+++ jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/junit/EarlReport.java Mon Aug 12 13:13:02 2013
@@ -25,11 +25,13 @@ import com.hp.hpl.jena.rdf.model.ModelFa
 import com.hp.hpl.jena.rdf.model.Resource ;
 import com.hp.hpl.jena.rdf.model.ResourceFactory ;
 import com.hp.hpl.jena.sparql.util.Utils ;
+import com.hp.hpl.jena.sparql.vocabulary.DOAP ;
 import com.hp.hpl.jena.sparql.vocabulary.EARL ;
 import com.hp.hpl.jena.sparql.vocabulary.FOAF ;
 import com.hp.hpl.jena.vocabulary.DC ;
 import com.hp.hpl.jena.vocabulary.DCTerms ;
 import com.hp.hpl.jena.vocabulary.RDF ;
+import com.hp.hpl.jena.vocabulary.XSD ;
 
 public class EarlReport
 {
@@ -64,14 +66,8 @@ public class EarlReport
         earl.setNsPrefix("rdf", RDF.getURI()) ;
         earl.setNsPrefix("dc", DC.getURI()) ;
         earl.setNsPrefix("dct", DCTerms.getURI()) ;
-        /*
-        <earl:Software rdf:about="#tool">
-          <dc:title xml:lang="en">Cool Tool</dc:title>
-          <dc:description xml:lang="en">My favorite tool!</dc:description>
-          <foaf:homepage rdf:resource="http://example.org/tools/#cool"/>
-          <dct:hasVersion>1.0.3</dct:hasVersion>
-        </earl:Software>
-        */
+        earl.setNsPrefix("doap", DOAP.getURI()) ; 
+        earl.setNsPrefix("xsd", XSD.getURI()) ;
         
         // Utils.
         system = (systemURI == null ) ? 

Modified: jena/trunk/jena-arq/src/test/java/riotcmd/rdflangtest.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/riotcmd/rdflangtest.java?rev=1513131&r1=1513130&r2=1513131&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/riotcmd/rdflangtest.java (original)
+++ jena/trunk/jena-arq/src/test/java/riotcmd/rdflangtest.java Mon Aug 12 13:13:02 2013
@@ -20,6 +20,8 @@ package riotcmd;
 
 import junit.framework.TestSuite ;
 import org.apache.jena.atlas.junit.BaseTest ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
 import org.apache.jena.riot.RIOT ;
 import org.apache.jena.riot.langsuite.FactoryTestRiot ;
 import org.apache.jena.riot.langsuite.VocabLangRDF ;
@@ -46,7 +48,6 @@ import com.hp.hpl.jena.sparql.vocabulary
 import com.hp.hpl.jena.vocabulary.DC ;
 import com.hp.hpl.jena.vocabulary.DCTerms ;
 import com.hp.hpl.jena.vocabulary.RDF ;
-import com.hp.hpl.jena.vocabulary.XSD ;
 
 /** A program to execute RDF language test suites
  * 
@@ -144,22 +145,40 @@ public class rdflangtest extends CmdGene
         SimpleTestRunner.runAndReport(suite) ;
     }
     
+    static String name =  "Apache Jena RIOT" ;
+    static String releaseName =  "RIOT" ;
+    //static String version = RIOT.getVersion() ;  // Can be "development"
+    static String version = null ;
+    static String homepage = "http://jena.apache.org/" ;
+    static String systemURI = "http://jena.apache.org/#riot" ;  // Null for bNode.
+
     static void oneManifestEarl(String testManifest)
     {
-        String name =  "Apache Jena RIOT" ;
-        String releaseName =  "RIOT" ;
-        String version = RIOT.getVersion() ;
-        String homepage = "http://jena.apache.org/" ;
-        String systemURI = "http://jena.apache.org/#riot" ;  // Null for bNode.
-        
-        // Include information later.
         EarlReport report = new EarlReport(systemURI, name, version, homepage) ;
         FactoryTestRiot.report = report ;
-        
+        TestSuite suite = FactoryTestRiot.make(testManifest, null, null) ;
+        SimpleTestRunner.runSilent(suite) ;
+
         Model model = report.getModel() ;
         model.setNsPrefix("rdft", VocabLangRDF.getURI()) ;
         model.setNsPrefix("turtletest", "http://www.w3.org/2013/TurtleTests/manifest.ttl#") ;
-        // Other tests ...
+        insertMetaOld(report) ;
+        RDFDataMgr.write(System.out, model, Lang.TURTLE) ;
+    }
+    
+    static void insertMeta(EarlReport report) {
+        Model model = report.getModel() ;
+        // We add the meta by hand separatly for better layout later 
+    }
+    
+    //OLD meta.
+    static void insertMetaOld(EarlReport report) {
+        Model model = report.getModel() ;
+        /*
+        <> foaf:primaryTopic <http://jena.apache.org/#riot> ;
+            dc:issued "..."^^xsd:dateTime;
+            foaf:maker who.
+        */
         
         // Update the EARL report. 
         Resource jena = model.createResource()
@@ -178,10 +197,6 @@ public class rdflangtest extends CmdGene
         Resource reporter = report.getReporter() ;
         reporter.addProperty(DC.creator, who) ;
 
-        model.setNsPrefix("doap", DOAP.getURI()) ; 
-        model.setNsPrefix("xsd", XSD.getURI()) ;
-        
-        // DAWG specific stuff.
         Resource system = report.getSystem() ;
         system.addProperty(RDF.type, DOAP.Project) ;
         system.addProperty(DOAP.name, name) ;
@@ -195,11 +210,5 @@ public class rdflangtest extends CmdGene
         Literal today = model.createTypedLiteral(today_node.getLiteralLexicalForm(), today_node.getLiteralDatatype()) ;
         release.addProperty(DOAP.created, today) ;
         release.addProperty(DOAP.name, releaseName) ;      // Again
-        
-        TestSuite suite = FactoryTestRiot.make(testManifest, null, null) ;
-        SimpleTestRunner.runSilent(suite) ;
-        
-        FactoryTestRiot.report.getModel().write(System.out, "TTL") ;
-        
     }
  }