jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1612062 - in /jena/trunk/jena-arq/src/main/java: arq/qparse.java com/hp/hpl/jena/sparql/lang/ParserBase.java
Date Sun, 20 Jul 2014 08:59:09 GMT
Author: andy
Date: Sun Jul 20 08:59:09 2014
New Revision: 1612062

URL: http://svn.apache.org/r1612062
Log:
JENA-730 : (try to) accept all IRIs and print warnings on bad IRIs.  Used to cause parse errors.

Modified:
    jena/trunk/jena-arq/src/main/java/arq/qparse.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java

Modified: jena/trunk/jena-arq/src/main/java/arq/qparse.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/arq/qparse.java?rev=1612062&r1=1612061&r2=1612062&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/arq/qparse.java (original)
+++ jena/trunk/jena-arq/src/main/java/arq/qparse.java Sun Jul 20 08:59:09 2014
@@ -21,6 +21,7 @@ package arq;
 import java.io.PrintStream ;
 import java.util.Iterator ;
 
+import org.apache.jena.atlas.logging.LogCtl ;
 import arq.cmd.CmdException ;
 import arq.cmdline.ArgDecl ;
 import arq.cmdline.CmdARQ ;
@@ -37,6 +38,7 @@ import com.hp.hpl.jena.query.Syntax ;
 import com.hp.hpl.jena.shared.JenaException ;
 import com.hp.hpl.jena.sparql.ARQInternalErrorException ;
 import com.hp.hpl.jena.sparql.core.QueryCheckException ;
+import com.hp.hpl.jena.sparql.lang.ParserBase ;
 import com.hp.hpl.jena.sparql.resultset.ResultSetException ;
 import com.hp.hpl.jena.sparql.util.QueryOutputUtils ;
 import com.hp.hpl.jena.sparql.util.QueryUtils ;
@@ -165,6 +167,7 @@ public class qparse extends CmdARQ
         try{
             Query query = modQuery.getQuery() ;
             try {
+                LogCtl.disable(ParserBase.ParserLoggerName) ;
                 QueryUtils.checkQuery(query, true) ;
             } catch (QueryCheckException ex)
             {
@@ -173,6 +176,8 @@ public class qparse extends CmdARQ
                 if ( ex.getCause() != null )
                     ex.getCause().printStackTrace(System.err) ;
             }
+            finally { LogCtl.set(ParserBase.ParserLoggerName, "INFO") ; }
+
             
             // Print the query out in some syntax
             if ( printQuery )

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java?rev=1612062&r1=1612061&r2=1612062&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java Sun Jul
20 08:59:09 2014
@@ -23,7 +23,13 @@ import java.util.HashSet ;
 import java.util.Set ;
 
 import org.apache.jena.atlas.logging.Log ;
+import org.apache.jena.iri.IRI ;
+import org.apache.jena.riot.checker.CheckerIRI ;
+import org.apache.jena.riot.system.ErrorHandler ;
+import org.apache.jena.riot.system.ErrorHandlerFactory ;
 import org.apache.jena.riot.system.RiotLib ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
 
 import com.hp.hpl.jena.datatypes.RDFDatatype ;
 import com.hp.hpl.jena.datatypes.TypeMapper ;
@@ -234,14 +240,17 @@ public class ParserBase
     // See RiotLib re bNode IRIs.
     // Merge sometime.
     
-    protected String resolveQuotedIRI(String iriStr ,int line, int column)
+    protected String resolveQuotedIRI(String iriStr, int line, int column)
     {
         iriStr = stripQuotes(iriStr) ;
         return resolveIRI(iriStr, line, column) ;
     }
 
-    
-    protected String resolveIRI(String iriStr ,int line, int column)
+    public static final String ParserLoggerName = "SPARQL" ;
+    private static Logger parserLog = LoggerFactory.getLogger(ParserLoggerName) ;
+    private static ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(parserLog)
;
+
+    protected String resolveIRI(String iriStr, int line, int column)
     {
         if ( isBNodeIRI(iriStr) )
             return iriStr ;
@@ -250,7 +259,12 @@ public class ParserBase
         {
             if ( getPrologue().getResolver() != null )
                 try {
-                    iriStr = getPrologue().getResolver().resolveSilent(iriStr).toString()
;
+                    // Used to be errors (pre Jena 2.12.0)
+                    // .resolve(iriStr)
+                    IRI iri = getPrologue().getResolver().resolveSilent(iriStr) ;
+                    if ( true ) 
+                        CheckerIRI.iriViolations(iri, errorHandler, line, column) ;
+                    iriStr = iri.toString() ;
                 } catch (JenaURIException ex)
                 { throwParseException(ex.getMessage(), line, column) ; }
         }



Mime
View raw message