<NME> DatasetXSLTWriter.java
<BEF> /**
 *  Copyright 2012 Martynas Jusevičius <martynas@atomgraph.com>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package com.atomgraph.client.writer;

import com.atomgraph.client.util.DataManager;
import org.apache.jena.ontology.OntModelSpec;
import java.io.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.Produces;
import javax.ws.rs.core.*;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import javax.inject.Singleton;
import net.sf.saxon.s9api.XsltExecutable;
import org.apache.jena.query.Dataset;

/**
 * Transforms RDF with XSLT stylesheet and writes (X)HTML result to response.
 * Needs to be registered in the JAX-RS application.
 * 
 * @author Martynas Jusevičius {@literal <martynas@atomgraph.com>}
 * @see org.apache.jena.query.Dataset
 * @see javax.ws.rs.ext.MessageBodyWriter
 */
@Provider
@Singleton
@Produces({MediaType.TEXT_HTML + ";charset=UTF-8", MediaType.APPLICATION_XHTML_XML + ";charset=UTF-8"})
public class DatasetXSLTWriter extends ModelXSLTWriterBase implements MessageBodyWriter<Dataset>
{
    
    /**
     * Constructs dataset writer from XSLT executable and ontology model specification.
     * 
     * @param xsltExec compiled XSLT stylesheet
     * @param ontModelSpec ontology model specification
     * @param dataManager RDF data manager
     */
    public DatasetXSLTWriter(XsltExecutable xsltExec, OntModelSpec ontModelSpec, DataManager dataManager)
    {
        super(xsltExec, ontModelSpec, dataManager);
    }
    
    @Override
    public void writeTo(Dataset dataset, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headerMap, OutputStream entityStream) throws IOException
    {
        super.writeTo(dataset.getDefaultModel(), type, genericType, annotations, mediaType, headerMap, entityStream);
    }
    
    @Override
    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
    {
        return Dataset.class.isAssignableFrom(type);
    }

}
<MSG> SNAPSHOT bump
Core version bump
Responses based on Model again, not Dataset

<DFF> @@ -40,6 +40,7 @@ import org.apache.jena.query.Dataset;
 @Provider
 @Singleton
 @Produces({MediaType.TEXT_HTML + ";charset=UTF-8", MediaType.APPLICATION_XHTML_XML + ";charset=UTF-8"})
+@Deprecated
 public class DatasetXSLTWriter extends ModelXSLTWriterBase implements MessageBodyWriter<Dataset>
 {
     

{'commit': 'diff --git a/pom.xml b/pom.xml\nindex f06bc077..e9e7e2e6 100644\n--- a/pom.xml\n+++ b/pom.xml\n@@ -3,7 +3,7 @@\n \n     <groupId>com.atomgraph</groupId>\n     <artifactId>client</artifactId>\n-    <version>3.0.49-SNAPSHOT</version>\n+    <version>3.0.50-SNAPSHOT</version>\n     <packaging>${packaging.type}</packaging>\n \n     <name>AtomGraph Web-Client</name>\n@@ -97,7 +97,7 @@\n         <dependency>\n             <groupId>${project.groupId}</groupId>\n             <artifactId>core</artifactId>\n-            <version>3.0.10</version>\n+            <version>3.0.13-SNAPSHOT</version>\n         </dependency>\n <!--        <dependency>\n             <groupId>org.glassfish.jersey.connectors</groupId>\ndiff --git a/src/main/java/com/atomgraph/client/mapper/ClientErrorExceptionMapper.java b/src/main/java/com/atomgraph/client/mapper/ClientErrorExceptionMapper.java\nindex 72d338f7..98c8ede2 100644\n--- a/src/main/java/com/atomgraph/client/mapper/ClientErrorExceptionMapper.java\n+++ b/src/main/java/com/atomgraph/client/mapper/ClientErrorExceptionMapper.java\n@@ -20,7 +20,6 @@ import javax.ws.rs.core.Response;\n import javax.ws.rs.ext.ExceptionMapper;\n import javax.ws.rs.ext.Provider;\n import javax.ws.rs.ClientErrorException;\n-import org.apache.jena.query.DatasetFactory;\n import org.apache.jena.rdf.model.Resource;\n \n /**\n@@ -36,7 +35,7 @@ public class ClientErrorExceptionMapper extends ExceptionMapperBase implements E\n     {\n         Resource exRes = toResource(ex, Response.Status.fromStatusCode(ex.getResponse().getStatus()), null);\n         \n-        return getResponseBuilder(DatasetFactory.create(exRes.getModel())).\n+        return getResponseBuilder(exRes.getModel()).\n             status(ex.getResponse().getStatus()).\n             build();\n     }\ndiff --git a/src/main/java/com/atomgraph/client/mapper/ExceptionMapperBase.java b/src/main/java/com/atomgraph/client/mapper/ExceptionMapperBase.java\nindex d4f10479..ce23166d 100644\n--- a/src/main/java/com/atomgraph/client/mapper/ExceptionMapperBase.java\n+++ b/src/main/java/com/atomgraph/client/mapper/ExceptionMapperBase.java\n@@ -36,7 +36,6 @@ import com.atomgraph.core.util.ModelUtils;\n import javax.inject.Inject;\n import javax.ws.rs.core.EntityTag;\n import javax.ws.rs.core.MediaType;\n-import org.apache.jena.query.Dataset;\n \n /**\n  * Abstract base class for ExceptionMappers that build responses with exceptions as RDF resources.\n@@ -69,19 +68,6 @@ abstract public class ExceptionMapperBase\n         return resource;\n     }\n     \n-    public Response.ResponseBuilder getResponseBuilder(Dataset dataset)\n-    {\n-        Variant variant = getRequest().selectVariant(getVariants(Dataset.class));\n-        if (variant == null) return getResponseBuilder(dataset.getDefaultModel()); // if quads are not acceptable, fallback to responding with the default graph\n-        \n-        return new com.atomgraph.core.model.impl.Response(getRequest(),\n-                dataset,\n-                null,\n-                new EntityTag(Long.toHexString(com.atomgraph.core.model.impl.Response.hashDataset(dataset))),\n-                getVariants(Dataset.class)).\n-            getResponseBuilder();\n-    }\n-    \n     public Response.ResponseBuilder getResponseBuilder(Model model)\n     {\n         return new com.atomgraph.core.model.impl.Response(getRequest(),\ndiff --git a/src/main/java/com/atomgraph/client/mapper/NotFoundExceptionMapper.java b/src/main/java/com/atomgraph/client/mapper/NotFoundExceptionMapper.java\nindex 2b0e2355..b84fce0c 100644\n--- a/src/main/java/com/atomgraph/client/mapper/NotFoundExceptionMapper.java\n+++ b/src/main/java/com/atomgraph/client/mapper/NotFoundExceptionMapper.java\n@@ -21,7 +21,6 @@ import org.apache.jena.rdf.model.ResourceFactory;\n import javax.ws.rs.core.Response;\n import javax.ws.rs.ext.ExceptionMapper;\n import javax.ws.rs.ext.Provider;\n-import org.apache.jena.query.DatasetFactory;\n \n /**\n  * Maps one of Jena\'s remote loading 404 Not Found exceptions.\n@@ -35,9 +34,9 @@ public class NotFoundExceptionMapper extends ExceptionMapperBase implements Exce\n     @Override\n     public Response toResponse(NotFoundException ex)\n     {\n-        return getResponseBuilder(DatasetFactory.create(DatasetFactory.create(toResource(ex, Response.Status.NOT_FOUND,\n+        return getResponseBuilder(toResource(ex, Response.Status.NOT_FOUND,\n                         ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#NotFound")).\n-                    getModel()))).\n+                    getModel()).\n                 status(Response.Status.NOT_FOUND).\n                 build();\n     }\ndiff --git a/src/main/java/com/atomgraph/client/mapper/RiotExceptionMapper.java b/src/main/java/com/atomgraph/client/mapper/RiotExceptionMapper.java\nindex d794506a..26d62327 100644\n--- a/src/main/java/com/atomgraph/client/mapper/RiotExceptionMapper.java\n+++ b/src/main/java/com/atomgraph/client/mapper/RiotExceptionMapper.java\n@@ -17,7 +17,6 @@ package com.atomgraph.client.mapper;\n \n import javax.ws.rs.core.Response;\n import javax.ws.rs.ext.ExceptionMapper;\n-import org.apache.jena.query.DatasetFactory;\n import org.apache.jena.rdf.model.ResourceFactory;\n import org.apache.jena.riot.RiotException;\n \n@@ -31,9 +30,9 @@ public class RiotExceptionMapper extends ExceptionMapperBase implements Exceptio\n     @Override\n     public Response toResponse(RiotException ex)\n     {\n-        return getResponseBuilder(DatasetFactory.create(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,\n+        return getResponseBuilder(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,\n                         ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).\n-                    getModel())).\n+                    getModel()).\n                 status(Response.Status.INTERNAL_SERVER_ERROR).\n                 build();\n     }\ndiff --git a/src/main/java/com/atomgraph/client/model/impl/ProxyResourceBase.java b/src/main/java/com/atomgraph/client/model/impl/ProxyResourceBase.java\nindex 1e82f161..ae5d3430 100644\n--- a/src/main/java/com/atomgraph/client/model/impl/ProxyResourceBase.java\n+++ b/src/main/java/com/atomgraph/client/model/impl/ProxyResourceBase.java\n@@ -51,8 +51,6 @@ import javax.ws.rs.client.WebTarget;\n import javax.ws.rs.core.EntityTag;\n import javax.ws.rs.core.Link;\n import javax.ws.rs.core.Variant;\n-import org.apache.jena.query.Dataset;\n-import org.apache.jena.query.DatasetFactory;\n import org.apache.jena.rdf.model.Model;\n import org.slf4j.Logger;\n import org.slf4j.LoggerFactory;\n@@ -100,7 +98,6 @@ public class ProxyResourceBase implements Resource\n         this.mediaTypes = mediaTypes;\n         this.accept = accept;\n         List<javax.ws.rs.core.MediaType> readableMediaTypesList = new ArrayList<>();\n-        //readableMediaTypesList.addAll(mediaTypes.getReadable(Dataset.class));\n         readableMediaTypesList.addAll(mediaTypes.getReadable(Model.class));\n         this.readableMediaTypes = readableMediaTypesList.toArray(new MediaType[readableMediaTypesList.size()]);\n         \n@@ -196,36 +193,10 @@ public class ProxyResourceBase implements Resource\n \n             Model description = cr.readEntity(Model.class);\n             \n-            return getResponse(DatasetFactory.create(description));\n+            return getResponse(description);\n         }\n     }\n \n-    /**\n-     * Returns response for the given RDF dataset.\n-     * \n-     * @param dataset RDF dataset\n-     * @return response object\n-     */\n-    public Response getResponse(Dataset dataset)\n-    {\n-        List<Variant> variants = com.atomgraph.core.model.impl.Response.getVariantListBuilder(getWritableMediaTypes(Dataset.class),\n-                new ArrayList(),\n-                new ArrayList()).\n-            add().\n-            build();\n-\n-        Variant variant = getRequest().selectVariant(variants);\n-        if (variant == null || MediaTypes.isTriples(variant.getMediaType())) return getResponse(dataset.getDefaultModel()); // fallback to Model\n-\n-        return new com.atomgraph.core.model.impl.Response(getRequest(),\n-                dataset,\n-                null,\n-                new EntityTag(Long.toHexString(com.atomgraph.core.model.impl.Response.hashDataset(dataset))),\n-                variants).\n-            getResponseBuilder().\n-                build();\n-    }\n-    \n     /**\n      * Returns response for the given RDF model.\n      * \n@@ -276,45 +247,37 @@ public class ProxyResourceBase implements Resource\n     /**\n      * Forwards POST request with RDF dataset body and returns RDF response from remote resource.\n      * \n-     * @param dataset\n+     * @param model\n      * @return response\n      */\n     @POST\n     @Override\n-    public Response post(Dataset dataset)\n+    public Response post(Model model)\n     {\n         if (getWebTarget() == null) throw new NotFoundException("Resource URI not supplied"); // cannot throw Exception in constructor: https://github.com/eclipse-ee4j/jersey/issues/4436\n         \n         if (log.isDebugEnabled()) log.debug("POSTing Dataset to URI: {}", getWebTarget().getUri());\n         return getWebTarget().request().\n-                accept(getMediaTypes().getReadable(Dataset.class).toArray(new javax.ws.rs.core.MediaType[0])).\n-                post(Entity.entity(dataset, com.atomgraph.core.MediaType.APPLICATION_NTRIPLES_TYPE));\n-        \n-//        Response.ResponseBuilder rb = Response.status(cr.getStatusInfo());\n-//        if (cr.hasEntity()) rb.entity(cr.readEntity(Dataset.class)); // cr.getEntityInputStream()\n-//        return rb.build();\n+            accept(getMediaTypes().getReadable(Model.class).toArray(new javax.ws.rs.core.MediaType[0])).\n+            post(Entity.entity(model, com.atomgraph.core.MediaType.APPLICATION_NTRIPLES_TYPE));\n     }\n \n     /**\n      * Forwards PUT request with RDF dataset body and returns response from remote resource.\n      * \n-     * @param dataset RDF payload\n+     * @param model RDF payload\n      * @return response\n      */\n     @PUT\n     @Override\n-    public Response put(Dataset dataset)\n+    public Response put(Model model)\n     {\n         if (getWebTarget() == null) throw new NotFoundException("Resource URI not supplied"); // cannot throw Exception in constructor: https://github.com/eclipse-ee4j/jersey/issues/4436\n         \n         if (log.isDebugEnabled()) log.debug("PUTting Dataset to URI: {}", getWebTarget().getUri());\n         return getWebTarget().request().\n-                accept(getMediaTypes().getReadable(Dataset.class).toArray(new javax.ws.rs.core.MediaType[0])).\n-                put(Entity.entity(dataset, com.atomgraph.core.MediaType.APPLICATION_NTRIPLES_TYPE));\n-        \n-//        ResponseBuilder rb = Response.status(cr.getStatusInfo());\n-//        if (cr.hasEntity()) rb.entity(cr.getEntity(Dataset.class)); // cr.getEntityInputStream()\n-//        return rb.build();\n+            accept(getMediaTypes().getReadable(Model.class).toArray(new javax.ws.rs.core.MediaType[0])).\n+            put(Entity.entity(model, com.atomgraph.core.MediaType.APPLICATION_NTRIPLES_TYPE));\n     }\n     \n     /**\n@@ -329,12 +292,8 @@ public class ProxyResourceBase implements Resource\n         \n         if (log.isDebugEnabled()) log.debug("DELETEing Dataset from URI: {}", getWebTarget().getUri());\n         return getWebTarget().request().\n-                accept(getMediaTypes().getReadable(Dataset.class).toArray(new javax.ws.rs.core.MediaType[0])).\n-                delete(Response.class);\n-        \n-//        ResponseBuilder rb = Response.status(cr.getStatusInfo());\n-//        if (cr.hasEntity()) rb.entity(cr.getEntity(Dataset.class)); // cr.getEntityInputStream()\n-//        return rb.build();\n+            accept(getMediaTypes().getReadable(Model.class).toArray(new javax.ws.rs.core.MediaType[0])).\n+            delete(Response.class);\n     }\n     \n     public HttpHeaders getHttpHeaders()\ndiff --git a/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java b/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java\nindex f57d355e..f59119a1 100644\n--- a/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java\n+++ b/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java\n@@ -40,6 +40,7 @@ import org.apache.jena.query.Dataset;\n @Provider\n @Singleton\n @Produces({MediaType.TEXT_HTML + ";charset=UTF-8", MediaType.APPLICATION_XHTML_XML + ";charset=UTF-8"})\n+@Deprecated\n public class DatasetXSLTWriter extends ModelXSLTWriterBase implements MessageBodyWriter<Dataset>\n {\n     \n', 'commit_subject': 'SNAPSHOT bump Core version bump Responses based on Model again, not Dataset', 'repo_name': 'AtomGraph/Web-Client', 'committer': {'name': 'Martynas', 'email': 'b14a8f953b021d09d1aafdca53cb27d7d9cede0c@graphity.org', 'time_sec': '1621969415', 'tz_offset': '120', 'date': {'seconds': '1621969415'}}, 'commit_tree': 'e69b4833d1649efd581ab7837ff2eb6a350d0a4a', 'commit_message': 'SNAPSHOT bump\nCore version bump\nResponses based on Model again, not Dataset\n', 'language_name': 'Java', 'license': 'apache-2.0', 'hunks': '@@ -40,6 +40,7 @@ import org.apache.jena.query.Dataset;\n @Provider\n @Singleton\n @Produces({MediaType.TEXT_HTML + ";charset=UTF-8", MediaType.APPLICATION_XHTML_XML + ";charset=UTF-8"})\n+@Deprecated\n public class DatasetXSLTWriter extends ModelXSLTWriterBase implements MessageBodyWriter<Dataset>\n {\n     \n', 'addition_count': 1, 'deletion_count': 0, 'src_file': 'a/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java', 'tgt_file': 'b/src/main/java/com/atomgraph/client/writer/DatasetXSLTWriter.java', 'file_extension': '.java', 'before_file': '/**\n *  Copyright 2012 Martynas Jusevičius <martynas@atomgraph.com>\n *\n *  Licensed under the Apache License, Version 2.0 (the "License");\n *  you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software\n *  distributed under the License is distributed on an "AS IS" BASIS,\n *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  See the License for the specific language governing permissions and\n *  limitations under the License.\n *\n */\npackage com.atomgraph.client.writer;\n\nimport com.atomgraph.client.util.DataManager;\nimport org.apache.jena.ontology.OntModelSpec;\nimport java.io.*;\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Type;\nimport javax.ws.rs.Produces;\nimport javax.ws.rs.core.*;\nimport javax.ws.rs.ext.MessageBodyWriter;\nimport javax.ws.rs.ext.Provider;\nimport javax.inject.Singleton;\nimport net.sf.saxon.s9api.XsltExecutable;\nimport org.apache.jena.query.Dataset;\n\n/**\n * Transforms RDF with XSLT stylesheet and writes (X)HTML result to response.\n * Needs to be registered in the JAX-RS application.\n * \n * @author Martynas Jusevičius {@literal <martynas@atomgraph.com>}\n * @see org.apache.jena.query.Dataset\n * @see javax.ws.rs.ext.MessageBodyWriter\n */\n@Provider\n@Singleton\n@Produces({MediaType.TEXT_HTML + ";charset=UTF-8", MediaType.APPLICATION_XHTML_XML + ";charset=UTF-8"})\npublic class DatasetXSLTWriter extends ModelXSLTWriterBase implements MessageBodyWriter<Dataset>\n{\n    \n    /**\n     * Constructs dataset writer from XSLT executable and ontology model specification.\n     * \n     * @param xsltExec compiled XSLT stylesheet\n     * @param ontModelSpec ontology model specification\n     * @param dataManager RDF data manager\n     */\n    public DatasetXSLTWriter(XsltExecutable xsltExec, OntModelSpec ontModelSpec, DataManager dataManager)\n    {\n        super(xsltExec, ontModelSpec, dataManager);\n    }\n    \n    @Override\n    public void writeTo(Dataset dataset, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headerMap, OutputStream entityStream) throws IOException\n    {\n        super.writeTo(dataset.getDefaultModel(), type, genericType, annotations, mediaType, headerMap, entityStream);\n    }\n    \n    @Override\n    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)\n    {\n        return Dataset.class.isAssignableFrom(type);\n    }\n\n}', 'message': 'SNAPSHOT bump\nCore version bump\nResponses based on Model again, not Dataset\n', 'author_name': 'Martynas', 'lang': 'java'}