Revision: 14449
          http://gate.svn.sourceforge.net/gate/?rev=14449&view=rev
Author:   valyt
Date:     2011-10-28 10:35:30 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
Some ontology web sources use content negotiation to return the correct data 
according to who's looking at it (e.g. a browser would get the HTML describing 
the ontology, rather than the OWL XMl data).

Patch: added the appropriate Accept HTTP header when loading imports to 
indicate we prefer RDF/XML.

Modified Paths:
--------------
    
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/AbstractOntologyImpl.java

Modified: 
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/AbstractOntologyImpl.java
===================================================================
--- 
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/AbstractOntologyImpl.java
 2011-10-28 01:27:55 UTC (rev 14448)
+++ 
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/AbstractOntologyImpl.java
 2011-10-28 10:35:30 UTC (rev 14449)
@@ -19,8 +19,10 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -1888,7 +1890,13 @@
           }
           InputStream is;
           try {
-            is = location.openStream();
+            if(location.getProtocol().equals("http")) {
+              HttpURLConnection conn = 
(HttpURLConnection)location.openConnection();
+              conn.addRequestProperty("accept", 
"application/rdf+xml,application/xml;q=0.5,*/*;q=0.1");
+              is = conn.getInputStream();
+            } else {
+              is = location.openStream();  
+            }
           } catch (IOException ex) {
             throw new GateOntologyException(
                 "Problem opening the URL " + location +

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to