incubator-any23-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject svn commit: r1380399 - in /incubator/any23/trunk: core/src/main/java/org/apache/any23/extractor/html/ core/src/main/java/org/apache/any23/extractor/rdf/ core/src/main/java/org/apache/any23/vocab/ core/src/main/java/org/apache/any23/writer/ core/src/tes...
Date Mon, 03 Sep 2012 23:14:32 GMT
Author: ansell
Date: Mon Sep  3 23:14:31 2012
New Revision: 1380399

URL: http://svn.apache.org/viewvc?rev=1380399&view=rev
Log:
ANY23-83 : Remove some more hardcoded formats and mime-types

Modified:
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/NTriplesExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFXMLExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TriXExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TurtleExtractor.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/vocab/RDFSchemaUtils.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java
    incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java
    incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
    incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
    incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/Servlet.java
    incubator/any23/trunk/service/src/test/java/org/apache/any23/servlet/ServletTest.java

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
Mon Sep  3 23:14:31 2012
@@ -30,6 +30,7 @@ import org.apache.any23.extractor.rdf.RD
 import org.apache.any23.rdf.PopularPrefixes;
 import org.openrdf.model.URI;
 import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.RDFParser;
 import org.openrdf.rio.turtle.TurtleParser;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -60,7 +61,7 @@ public class TurtleHTMLExtractor impleme
                     TurtleHTMLExtractor.class
             );
 
-    private TurtleParser turtleParser;
+    private RDFParser turtleParser;
 
     public void run(
             ExtractionParameters extractionParameters,
@@ -110,7 +111,7 @@ public class TurtleHTMLExtractor impleme
      * @param n the script node.
      * @param er the extraction result used to store triples.
      */
-    private void processScriptNode(TurtleParser turtleParser, URI documentURI, Node n, ExtractionResult
er) {
+    private void processScriptNode(RDFParser turtleParser, URI documentURI, Node n, ExtractionResult
er) {
         final Node idAttribute = n.getAttributes().getNamedItem("id");
         final String graphName =
                 documentURI.stringValue() +

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
Mon Sep  3 23:14:31 2012
@@ -57,7 +57,7 @@ public abstract class BaseRDFExtractor i
 
     public abstract ExtractorDescription getDescription();
 
-    protected abstract RDFParserBase getParser(
+    protected abstract RDFParser getParser(
             ExtractionContext extractionContext,
             ExtractionResult extractionResult
     );

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/NTriplesExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/NTriplesExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/NTriplesExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/NTriplesExtractor.java
Mon Sep  3 23:14:31 2012
@@ -22,6 +22,7 @@ import org.apache.any23.extractor.Extrac
 import org.apache.any23.extractor.ExtractorDescription;
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.SimpleExtractorFactory;
+import org.openrdf.rio.RDFParser;
 import org.openrdf.rio.helpers.RDFParserBase;
 
 import java.util.Arrays;
@@ -61,7 +62,7 @@ public class NTriplesExtractor extends B
     }
 
     @Override
-    protected RDFParserBase getParser(ExtractionContext extractionContext, ExtractionResult
extractionResult) {
+    protected RDFParser getParser(ExtractionContext extractionContext, ExtractionResult extractionResult)
{
         return RDFParserFactory.getInstance().getNTriplesParser(
                 isVerifyDataType(), isStopAtFirstError(), extractionContext, extractionResult
         );

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
Mon Sep  3 23:14:31 2012
@@ -20,16 +20,14 @@ package org.apache.any23.extractor.rdf;
 import org.apache.any23.extractor.IssueReport;
 import org.apache.any23.extractor.ExtractionContext;
 import org.apache.any23.extractor.ExtractionResult;
-import org.apache.any23.io.nquads.NQuadsParser;
 import org.apache.any23.rdf.Any23ValueFactoryWrapper;
 import org.openrdf.model.impl.ValueFactoryImpl;
 import org.openrdf.rio.ParseErrorListener;
+import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
 import org.openrdf.rio.RDFParser;
-import org.openrdf.rio.ntriples.NTriplesParser;
-import org.openrdf.rio.rdfxml.RDFXMLParser;
-import org.openrdf.rio.trix.TriXParser;
+import org.openrdf.rio.Rio;
 import org.openrdf.rio.turtle.TurtleParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,7 +64,7 @@ public class RDFParserFactory {
      * @param extractionResult the output extraction result.
      * @return a new instance of a configured Turtle parser.
      */
-    public TurtleParser getTurtleParserInstance(
+    public RDFParser getTurtleParserInstance(
             final boolean verifyDataType,
             final boolean stopAtFirstError,
             final ExtractionContext extractionContext,
@@ -89,13 +87,13 @@ public class RDFParserFactory {
      * @param extractionResult the output extraction result.
      * @return a new instance of a configured RDFXML parser.
      */
-    public RDFXMLParser getRDFXMLParser(
+    public RDFParser getRDFXMLParser(
             final boolean verifyDataType,
             final boolean stopAtFirstError,
             final ExtractionContext extractionContext,
             final ExtractionResult extractionResult
     ) {
-        final RDFXMLParser parser = new RDFXMLParser();
+        final RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
         configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
         return parser;
     }
@@ -109,13 +107,13 @@ public class RDFParserFactory {
      * @param extractionResult the output extraction result.
      * @return a new instance of a configured NTriples parser.
      */
-    public NTriplesParser getNTriplesParser(
+    public RDFParser getNTriplesParser(
             final boolean verifyDataType,
             final boolean stopAtFirstError,
             final ExtractionContext extractionContext,
             final ExtractionResult extractionResult
     ) {
-        final NTriplesParser parser = new NTriplesParser();
+        final RDFParser parser = Rio.createParser(RDFFormat.NTRIPLES);
         configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
         return parser;
     }
@@ -129,13 +127,13 @@ public class RDFParserFactory {
      * @param extractionResult the output extraction result.
      * @return a new instance of a configured NQuads parser.
      */
-    public NQuadsParser getNQuadsParser(
+    public RDFParser getNQuadsParser(
             final boolean verifyDataType,
             final boolean stopAtFirstError,
             final ExtractionContext extractionContext,
             final ExtractionResult extractionResult
     ) {
-        final NQuadsParser parser = new NQuadsParser();
+        final RDFParser parser = Rio.createParser(RDFFormat.NQUADS);
         configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
         return parser;
     }
@@ -149,13 +147,13 @@ public class RDFParserFactory {
      * @param extractionResult the output extraction result.
      * @return a new instance of a configured TriX parser.
      */
-    public TriXParser getTriXParser(
+    public RDFParser getTriXParser(
             final boolean verifyDataType,
             final boolean stopAtFirstError,
             final ExtractionContext extractionContext,
             final ExtractionResult extractionResult
     ) {
-        final TriXParser parser = new TriXParser();
+        final RDFParser parser = Rio.createParser(RDFFormat.TRIX);
         configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
         return parser;
     }

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFXMLExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFXMLExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFXMLExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFXMLExtractor.java
Mon Sep  3 23:14:31 2012
@@ -22,6 +22,7 @@ import org.apache.any23.extractor.Extrac
 import org.apache.any23.extractor.ExtractorDescription;
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.SimpleExtractorFactory;
+import org.openrdf.rio.RDFParser;
 import org.openrdf.rio.helpers.RDFParserBase;
 
 import java.util.Arrays;
@@ -73,7 +74,7 @@ public class RDFXMLExtractor extends Bas
     }
 
     @Override
-    protected RDFParserBase getParser(ExtractionContext extractionContext, ExtractionResult
extractionResult) {
+    protected RDFParser getParser(ExtractionContext extractionContext, ExtractionResult extractionResult)
{
         return RDFParserFactory.getInstance().getRDFXMLParser(
                 isVerifyDataType(), isStopAtFirstError(), extractionContext, extractionResult
         );

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TriXExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TriXExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TriXExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TriXExtractor.java
Mon Sep  3 23:14:31 2012
@@ -22,6 +22,7 @@ import org.apache.any23.extractor.Extrac
 import org.apache.any23.extractor.ExtractorDescription;
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.SimpleExtractorFactory;
+import org.openrdf.rio.RDFParser;
 import org.openrdf.rio.helpers.RDFParserBase;
 
 import java.util.Arrays;
@@ -69,7 +70,7 @@ public class TriXExtractor extends BaseR
     }
 
     @Override
-    protected RDFParserBase getParser(ExtractionContext extractionContext, ExtractionResult
extractionResult) {
+    protected RDFParser getParser(ExtractionContext extractionContext, ExtractionResult extractionResult)
{
         return RDFParserFactory.getInstance().getTriXParser(
                 isVerifyDataType(), isStopAtFirstError(), extractionContext, extractionResult
         );

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TurtleExtractor.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TurtleExtractor.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TurtleExtractor.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/TurtleExtractor.java
Mon Sep  3 23:14:31 2012
@@ -22,6 +22,7 @@ import org.apache.any23.extractor.Extrac
 import org.apache.any23.extractor.ExtractorDescription;
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.SimpleExtractorFactory;
+import org.openrdf.rio.RDFParser;
 import org.openrdf.rio.helpers.RDFParserBase;
 
 import java.util.Arrays;
@@ -74,7 +75,7 @@ public class TurtleExtractor extends Bas
     }
 
     @Override
-    protected RDFParserBase getParser(ExtractionContext extractionContext, ExtractionResult
extractionResult) {
+    protected RDFParser getParser(ExtractionContext extractionContext, ExtractionResult extractionResult)
{
         return RDFParserFactory.getInstance().getTurtleParserInstance(
                 isVerifyDataType(), isStopAtFirstError(), extractionContext, extractionResult
         );

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/vocab/RDFSchemaUtils.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/vocab/RDFSchemaUtils.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/vocab/RDFSchemaUtils.java (original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/vocab/RDFSchemaUtils.java Mon
Sep  3 23:14:31 2012
@@ -17,17 +17,16 @@
 
 package org.apache.any23.vocab;
 
-import org.apache.any23.io.nquads.NQuadsWriter;
 import org.apache.any23.rdf.RDFUtils;
 import org.apache.any23.util.DiscoveryUtils;
 import org.apache.any23.util.StringUtils;
 import org.openrdf.model.URI;
 import org.openrdf.model.vocabulary.RDF;
 import org.openrdf.model.vocabulary.RDFS;
+import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFWriter;
-import org.openrdf.rio.ntriples.NTriplesWriter;
-import org.openrdf.rio.rdfxml.RDFXMLWriter;
+import org.openrdf.rio.Rio;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
@@ -124,16 +123,17 @@ public class RDFSchemaUtils {
             PrintStream ps
     ) throws RDFHandlerException {
         final RDFWriter rdfWriter;
+        // FIXME: Remove hardcoding for format translation
         if(format == VocabularyFormat.RDFXML) {
-            rdfWriter = new RDFXMLWriter(ps);
+            rdfWriter = Rio.createWriter(RDFFormat.RDFXML, ps);
             if(willFollowAnother)
                 ps.print("\n");
                 ps.print(RDF_XML_SEPARATOR);
                 ps.print("\n");
         } else if(format == VocabularyFormat.NTriples) {
-            rdfWriter = new NTriplesWriter(ps);
+            rdfWriter = Rio.createWriter(RDFFormat.NTRIPLES, ps);
         } else if(format == VocabularyFormat.NQuads) {
-            rdfWriter = new NQuadsWriter(ps);
+            rdfWriter = Rio.createWriter(RDFFormat.NQUADS, ps);
         }
         else {
             throw new IllegalArgumentException("Unsupported format " + format);

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java
Mon Sep  3 23:14:31 2012
@@ -29,7 +29,7 @@ import org.openrdf.rio.RDFFormat;
 @MetaInfServices
 public class NTriplesWriterFactory implements WriterFactory {
 
-    public static final String MIME_TYPE = "text/plain";
+    public static final String MIME_TYPE = RDFFormat.NTRIPLES.getDefaultMIMEType();
     public static final String IDENTIFIER = "ntriples";
 
     /**

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java
Mon Sep  3 23:14:31 2012
@@ -29,7 +29,7 @@ import org.openrdf.rio.RDFFormat;
 @MetaInfServices
 public class RDFXMLWriterFactory implements WriterFactory {
 
-    public static final String MIME_TYPE = "application/rdf+xml";
+    public static final String MIME_TYPE = RDFFormat.RDFXML.getDefaultMIMEType();
     public static final String IDENTIFIER = "rdfxml";
 
     /**

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java
Mon Sep  3 23:14:31 2012
@@ -29,7 +29,7 @@ import org.openrdf.rio.RDFFormat;
 @MetaInfServices
 public class TriXWriterFactory implements WriterFactory {
 
-    public static final String MIME_TYPE = "application/trix";
+    public static final String MIME_TYPE = RDFFormat.TRIX.getDefaultMIMEType();
     public static final String IDENTIFIER = "trix";
 
     /**

Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java
Mon Sep  3 23:14:31 2012
@@ -29,7 +29,7 @@ import org.openrdf.rio.RDFFormat;
 @MetaInfServices
 public class TurtleWriterFactory implements WriterFactory {
 
-    public static final String MIME_TYPE = "text/turtle";
+    public static final String MIME_TYPE = RDFFormat.TURTLE.getDefaultMIMEType();
     public static final String IDENTIFIER = "turtle";
 
     /**

Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
(original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
Mon Sep  3 23:14:31 2012
@@ -23,7 +23,6 @@ import org.apache.any23.extractor.Extrac
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.SingleDocumentExtraction;
 import org.apache.any23.extractor.SingleDocumentExtractionReport;
-import org.apache.any23.io.nquads.NQuadsWriter;
 import org.apache.any23.rdf.RDFUtils;
 import org.apache.any23.vocab.SINDICE;
 import org.apache.any23.writer.RepositoryWriter;
@@ -40,10 +39,10 @@ import org.openrdf.repository.Repository
 import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.RepositoryResult;
 import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
-import org.openrdf.rio.rdfxml.RDFXMLWriter;
-import org.openrdf.rio.turtle.TurtleWriter;
+import org.openrdf.rio.Rio;
 import org.openrdf.sail.Sail;
 import org.openrdf.sail.memory.MemoryStore;
 
@@ -572,7 +571,7 @@ public abstract class AbstractExtractorT
     protected String dumpModelToTurtle() throws RepositoryException {
         StringWriter w = new StringWriter();
         try {
-            conn.export(new TurtleWriter(w));
+            conn.export(Rio.createWriter(RDFFormat.TURTLE, w));
             return w.toString();
         } catch (RDFHandlerException ex) {
             throw new RuntimeException(ex);
@@ -588,7 +587,7 @@ public abstract class AbstractExtractorT
     protected String dumpModelToNQuads() throws RepositoryException {
         StringWriter w = new StringWriter();
         try {
-            conn.export(new NQuadsWriter(w));
+            conn.export(Rio.createWriter(RDFFormat.NQUADS, w));
             return w.toString();
         } catch (RDFHandlerException ex) {
             throw new RuntimeException(ex);
@@ -604,7 +603,7 @@ public abstract class AbstractExtractorT
     protected String dumpModelToRDFXML() throws RepositoryException {
         StringWriter w = new StringWriter();
         try {
-            conn.export(new RDFXMLWriter(w));
+            conn.export(Rio.createWriter(RDFFormat.RDFXML, w));
             return w.toString();
         } catch (RDFHandlerException ex) {
             throw new RuntimeException(ex);

Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
(original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
Mon Sep  3 23:14:31 2012
@@ -20,7 +20,6 @@ package org.apache.any23.extractor.micro
 import org.apache.any23.extractor.ExtractionException;
 import org.apache.any23.extractor.ExtractorFactory;
 import org.apache.any23.extractor.html.AbstractExtractorTestCase;
-import org.apache.any23.io.nquads.NQuadsParser;
 import org.apache.any23.vocab.SINDICE;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,9 +28,12 @@ import org.junit.Test;
 import org.openrdf.model.BNode;
 import org.openrdf.model.Statement;
 import org.openrdf.repository.RepositoryException;
+import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandler;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.Rio;
 
 import java.io.File;
 import java.io.FileReader;
@@ -182,7 +184,7 @@ public class MicrodataExtractorTest exte
 
     private List<Statement> loadResultStatement(String resultFilePath)
             throws RDFHandlerException, IOException, RDFParseException {
-        NQuadsParser nQuadsParser = new NQuadsParser();
+        RDFParser nQuadsParser = Rio.createParser(RDFFormat.NQUADS);
         TestRDFHandler rdfHandler = new TestRDFHandler();
         nQuadsParser.setRDFHandler(rdfHandler);
         File file = copyResourceToTempFile(resultFilePath);

Modified: incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/Servlet.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/Servlet.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/Servlet.java (original)
+++ incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/Servlet.java Mon
Sep  3 23:14:31 2012
@@ -26,6 +26,7 @@ import org.apache.any23.source.ByteArray
 import org.apache.any23.source.DocumentSource;
 import org.apache.any23.source.HTTPDocumentSource;
 import org.apache.any23.source.StringDocumentSource;
+import org.openrdf.rio.RDFFormat;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -135,22 +136,24 @@ public class Servlet extends HttpServlet
         if (result == null) {
             return null;
         }
-        if ("text/turtle".equals(result.getMediaType())) {
+        else if (RDFFormat.TURTLE.hasMIMEType(result.getMediaType())) {
             return "turtle";
         }
-        if ("text/rdf+n3".equals(result.getMediaType())) {
+        else if (RDFFormat.N3.hasMIMEType(result.getMediaType())) {
             return "n3";
         }
-        if ("text/rdf+nq".equals(result.getMediaType())) {
+        else if (RDFFormat.NQUADS.hasMIMEType(result.getMediaType())) {
             return "nq";
         }
-        if ("application/rdf+xml".equals(result.getMediaType())) {
+        else if (RDFFormat.RDFXML.hasMIMEType(result.getMediaType())) {
             return "rdf";
         }
-        if ("text/plain".equals(result.getMediaType())) {
+        else if (RDFFormat.NTRIPLES.hasMIMEType(result.getMediaType())) {
             return "nt";
         }
-        return "turtle";    // shouldn't happen
+        else {
+            return "turtle";    // shouldn't happen
+        }
     }
 
     private String getFormatFromRequest(HttpServletRequest request) {

Modified: incubator/any23/trunk/service/src/test/java/org/apache/any23/servlet/ServletTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/service/src/test/java/org/apache/any23/servlet/ServletTest.java?rev=1380399&r1=1380398&r2=1380399&view=diff
==============================================================================
--- incubator/any23/trunk/service/src/test/java/org/apache/any23/servlet/ServletTest.java
(original)
+++ incubator/any23/trunk/service/src/test/java/org/apache/any23/servlet/ServletTest.java
Mon Sep  3 23:14:31 2012
@@ -398,7 +398,7 @@ public class ServletTest {
     @Test
     public void testJSONResponseFormat() throws Exception {
         String body = "<http://sub/1> <http://pred/1> \"123\"^^<http://datatype>
<http://graph/1>.";
-        HttpTester response = doPostRequest("/json", body, "text/n-quads");
+        HttpTester response = doPostRequest("/json", body, "text/x-nquads");
         Assert.assertEquals(200, response.getStatus());
         final String EXPECTED_JSON =
                 "[" +
@@ -413,7 +413,7 @@ public class ServletTest {
     @Test
     public void testTriXResponseFormat() throws Exception {
         String body = "<http://sub/1> <http://pred/1> \"123\"^^<http://datatype>
<http://graph/1>.";
-        HttpTester response = doPostRequest("/trix", body, "text/n-quads");
+        HttpTester response = doPostRequest("/trix", body, "text/x-nquads");
         Assert.assertEquals(200, response.getStatus());
         final String content = response.getContent();
         assertContainsTag("graph" , false, 1, content);



Mime
View raw message