marklogic / marklogic-jena

Adapter for using MarkLogic with the Jena RDF Framework
Other
5 stars 11 forks source link

Fix handling of lang literals (in Jena 3 they have both type and lang) #42

Closed MichalWozniakSmartlogic closed 8 years ago

MichalWozniakSmartlogic commented 8 years ago

This is a fix for incorrect handling of literals with language tags.

Without the fix, when invoking MarklogicDatasetGraph.find(g, s, p, o) with an object that is a literal with language, the following error was thrown:

com.marklogic.client.FailedRequestException: Local message: failed to apply resource at /graphs/sparql: Bad Request. Server Message: REST-INVALIDPARAM: (err:FOER0000) Invalid parameter: Bind variable type parameter requires XSD type at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4646) at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3526) at com.marklogic.client.impl.JerseyServices.executeSparql(JerseyServices.java:5653) at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeQueryImpl(SPARQLQueryManagerImpl.java:107) at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeQueryImpl(SPARQLQueryManagerImpl.java:100) at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeSelect(SPARQLQueryManagerImpl.java:66) at com.marklogic.semantics.jena.client.JenaDatabaseClient.executeSelect(JenaDatabaseClient.java:141) at com.marklogic.semantics.jena.client.JenaDatabaseClient.executeSelect(JenaDatabaseClient.java:148) at com.marklogic.semantics.jena.MarkLogicDatasetGraph.selectTriplesInGraph(MarkLogicDatasetGraph.java:274) at com.marklogic.semantics.jena.MarkLogicDatasetGraph.findInSpecificNamedGraph(MarkLogicDatasetGraph.java:298) at org.apache.jena.sparql.core.DatasetGraphBaseFind.findNG(DatasetGraphBaseFind.java:64) at org.apache.jena.sparql.core.DatasetGraphBaseFind.find(DatasetGraphBaseFind.java:49)

In Jena 2 such literals did not have any type, so that the original code worked properly (in master branch).

In Jena 3 they have both the xsd:langString type AND the language tag, so the code needs to be fixed to take that into account. This fix is only need for Jena 3 version of this library (develop branch).

A related pull request was made to java-client-api, see: https://github.com/marklogic/java-client-api/pull/430

grechaw commented 8 years ago

Hi @pit3k , @MichalWozniakSmartlogic , I'm getting this merged into develop momentarily.

grechaw commented 8 years ago

I'll keep this issue in test for a bit to verify that I've covered cases from here through to REST API.