On 31/10/13 14:37, Altmann, Michael wrote:

Here are three tests that show that altEntries in the global FileManager are 
not honored by the StreamManager.
I have a file called myontology.ttl that looks like

Thanks - I've created JENA-580 for this.

A temporary workaround is to call "RIOT.init() ;" before anything else.

        Andy



# imports: http://www.mckesson.com/life/snomed-ct.ontology.owl

@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

@prefix sct:     <http://www.mckesson.com/life/snomed-ct.ontology.owl#> .
@prefix ex:        <http://www.example.com#> .

<http://www.example.com>
       rdf:type owl:Ontology ;
       owl:imports <http://www.mckesson.com/life/snomed-ct.ontology.owl> .



The SNOMED ontology is available on the classpath with the path 
FactRepository/Common/models/snomed-ct.ttl .


The three test methods are shown below.  The key observation is that in the 
third one the
StreamsManager does not honor the altEntry and tries to resolve over the 
internet.


     /**
      * Proves that setting an AltEntry in FileManager is honored by FileManager
      */
     public void testLoadWithFileManagerFromAltEntry()
     {
                FileManager  mgr = FileManager.get();
                mgr.getLocationMapper().addAltEntry
                ("http://www.mckesson.com/life/snomed-ct.ontology.owl";,
                "FactRepository/Common/models/snomed-ct.ttl");
                
                Model m = FileManager.get().loadModel(
                                
"http://www.mckesson.com/life/snomed-ct.ontology.owl";);
                assertNotNull("Model should be non null", m);
                assertTrue("Model should be non empty", m.size()>0);

     }

     /**
      * Shows that setting up an AltEntry in StreamManager does get honored by
      * the StreamManager
      */
     public void testLoadOntologyWithStreamManagerFromAltEntry()
     {
                FileManager  fileMgr = FileManager.get();
                fileMgr.getLocationMapper().addAltEntry
                ("http://www.mckesson.com/life/snomed-ct.ontology.owl";,
                "FactRepository/Common/models/snomed-ct.ttl");
                
                Model model = ModelFactory.createDefaultModel();

                InputStream stream = 
getClass().getResourceAsStream("myontology.ttl");
                model.read(stream, null, "TTL");

                StreamManager streamMgr = 
StreamManager.makeDefaultStreamManager();
                streamMgr.getLocationMapper().addAltEntry
                ("http://www.mckesson.com/life/snomed-ct.ontology.owl";,
                "FactRepository/Common/models/snomed-ct.ttl");
                StreamManager.setGlobal(streamMgr);
                
/*
  * No error is logged from OntDocumentManager
  */
                OntModel ont = 
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF, model);

     }

     /**
      * Shows that setting up an AltEntry in FileManager does not get honored by
      * the StreamManager
      */
     public void testLoadOntologyWithFileManagerFromAltEntry()
     {
                FileManager  fileMgr = FileManager.get();
                fileMgr.getLocationMapper().addAltEntry
                ("http://www.mckesson.com/life/snomed-ct.ontology.owl";,
                "FactRepository/Common/models/snomed-ct.ttl");
                
                Model model = ModelFactory.createDefaultModel();

                InputStream stream = 
getClass().getResourceAsStream("myontology.ttl");
                model.read(stream, null, "TTL");
/*
  Logs
  WARN OntDocumentManager:1077 - An error occurred while attempting to read 
from http://www.mckesson.com/life/snomed-ct.ontology.owl. Msg was '404 - not 
found'.
org.apache.jena.atlas.web.HttpException: 404 - not found
  */
                OntModel ont = 
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF, model);

     }





-----Original Message-----
From: Andy Seaborne [mailto:[email protected]]
Sent: Wednesday, October 30, 2013 4:11 PM
To: [email protected]
Subject: Re: Replacing FileManager (WAS use of recent features from httpclient)

On 24/10/13 15:59, Altmann, Michael wrote:
Thanks,  I was not aware of the change.  I have code that configures the global 
FileManager.  It sets the locators, locations and prefixes.  Should I change 
that code to only manipulate the global StreamManager or manipulate it in 
addition to the FileManager?  I looked around in the documentation a bit, but I 
still see this page 
http://jena.apache.org/documentation/notes/file-manager.html , which focuses on 
the FileManager.


At what point do you reconfigure the global FileManager? Before any read/write 
atall?  Maybe the reset is being doen after you changed it.
I've just looked at the code and I can believe the you can set the global 
FileManager configuration, then cause RIOT to kick in and so loose the 
configuration.

If you call:

    IO_Jena.wireIntoJena()

it explicitly forces the reconfiguration.  It starts:

    FileManager.setGlobalFileManager(AdapterFileManager.get()) ;

If that wortks, it'll confirm my suspicion and I can put in a automatic 
kickstart.

  > http://jena.apache.org/documentation/notes/file-manager.html

That could do with rewriting but it should be compatible.

        Andy


[This thread is probably evolving to something that ought to be on the
users list.  Should we move it? ]




-----Original Message-----
From: Rob Vesse [mailto:[email protected]]
Sent: Thursday, October 24, 2013 9:26 AM
To: [email protected]
Subject: Re: Replacing FileManager (WAS use of recent features from
httpclient)

Michael

The issue is that recent versions of Jena delegate IO to ARQs RIOT subsystem 
which has a separate StreamManager which manages how resources are opened.

You can replace this like so:

StreamManager mgr = StreamManager.makeDefaultStreamManager();
// Clear out default setup
mgr.clearLocators();
// Add back ability to read from files mgr.addLocator(new
LocatorFile(null)); // Optionally add back ability to read from class
path mgr.addLocator(new 
LocatorClassLoader(StreamManager.getClass().getClassLoader()));
                StreamManager.setGlobal(mgr);

Hope this helps,

Rob



On 24/10/2013 14:45, "Altmann, Michael" <[email protected]>
wrote:

[Altmann, Michael] ...






Reply via email to