diff --git a/webapp/lib/sesame-config-2.6.2.jar b/webapp/lib/sesame-config-2.6.6.jar similarity index 84% rename from webapp/lib/sesame-config-2.6.2.jar rename to webapp/lib/sesame-config-2.6.6.jar index 26cbc0963..ff3c892fd 100644 Binary files a/webapp/lib/sesame-config-2.6.2.jar and b/webapp/lib/sesame-config-2.6.6.jar differ diff --git a/webapp/lib/sesame-console-2.6.2.jar b/webapp/lib/sesame-console-2.6.2.jar deleted file mode 100644 index fe26b29b7..000000000 Binary files a/webapp/lib/sesame-console-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-console-2.6.6.jar b/webapp/lib/sesame-console-2.6.6.jar new file mode 100644 index 000000000..e1459d460 Binary files /dev/null and b/webapp/lib/sesame-console-2.6.6.jar differ diff --git a/webapp/lib/sesame-http-client-2.6.2.jar b/webapp/lib/sesame-http-client-2.6.2.jar deleted file mode 100644 index e97f4c373..000000000 Binary files a/webapp/lib/sesame-http-client-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-http-client-2.6.6.jar b/webapp/lib/sesame-http-client-2.6.6.jar new file mode 100644 index 000000000..f31173496 Binary files /dev/null and b/webapp/lib/sesame-http-client-2.6.6.jar differ diff --git a/webapp/lib/sesame-http-protocol-2.6.2.jar b/webapp/lib/sesame-http-protocol-2.6.6.jar similarity index 70% rename from webapp/lib/sesame-http-protocol-2.6.2.jar rename to webapp/lib/sesame-http-protocol-2.6.6.jar index eae330cc3..6191a830b 100644 Binary files a/webapp/lib/sesame-http-protocol-2.6.2.jar and b/webapp/lib/sesame-http-protocol-2.6.6.jar differ diff --git a/webapp/lib/sesame-http-server-spring-2.6.2.jar b/webapp/lib/sesame-http-server-spring-2.6.6.jar similarity index 63% rename from webapp/lib/sesame-http-server-spring-2.6.2.jar rename to webapp/lib/sesame-http-server-spring-2.6.6.jar index 5ef8a9be9..e4d84da9f 100644 Binary files a/webapp/lib/sesame-http-server-spring-2.6.2.jar and b/webapp/lib/sesame-http-server-spring-2.6.6.jar differ diff --git a/webapp/lib/sesame-model-2.6.2.jar b/webapp/lib/sesame-model-2.6.6.jar similarity index 88% rename from webapp/lib/sesame-model-2.6.2.jar rename to webapp/lib/sesame-model-2.6.6.jar index 441853df5..1584f6996 100644 Binary files a/webapp/lib/sesame-model-2.6.2.jar and b/webapp/lib/sesame-model-2.6.6.jar differ diff --git a/webapp/lib/sesame-query-2.6.2.jar b/webapp/lib/sesame-query-2.6.6.jar similarity index 78% rename from webapp/lib/sesame-query-2.6.2.jar rename to webapp/lib/sesame-query-2.6.6.jar index 9771e39aa..b2d6ca6bd 100644 Binary files a/webapp/lib/sesame-query-2.6.2.jar and b/webapp/lib/sesame-query-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryalgebra-evaluation-2.6.2.jar b/webapp/lib/sesame-queryalgebra-evaluation-2.6.2.jar deleted file mode 100644 index d8b06eb82..000000000 Binary files a/webapp/lib/sesame-queryalgebra-evaluation-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-queryalgebra-evaluation-2.6.6.jar b/webapp/lib/sesame-queryalgebra-evaluation-2.6.6.jar new file mode 100644 index 000000000..26bc2a4b9 Binary files /dev/null and b/webapp/lib/sesame-queryalgebra-evaluation-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryalgebra-model-2.6.2.jar b/webapp/lib/sesame-queryalgebra-model-2.6.6.jar similarity index 66% rename from webapp/lib/sesame-queryalgebra-model-2.6.2.jar rename to webapp/lib/sesame-queryalgebra-model-2.6.6.jar index 65ac7d5f6..219a00591 100644 Binary files a/webapp/lib/sesame-queryalgebra-model-2.6.2.jar and b/webapp/lib/sesame-queryalgebra-model-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryparser-api-2.6.2.jar b/webapp/lib/sesame-queryparser-api-2.6.2.jar deleted file mode 100644 index 4636125f9..000000000 Binary files a/webapp/lib/sesame-queryparser-api-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-queryparser-api-2.6.6.jar b/webapp/lib/sesame-queryparser-api-2.6.6.jar new file mode 100644 index 000000000..f95b27d96 Binary files /dev/null and b/webapp/lib/sesame-queryparser-api-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryparser-serql-2.6.2.jar b/webapp/lib/sesame-queryparser-serql-2.6.6.jar similarity index 89% rename from webapp/lib/sesame-queryparser-serql-2.6.2.jar rename to webapp/lib/sesame-queryparser-serql-2.6.6.jar index e2b7d9a64..5ad27c359 100644 Binary files a/webapp/lib/sesame-queryparser-serql-2.6.2.jar and b/webapp/lib/sesame-queryparser-serql-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryparser-sparql-2.6.2.jar b/webapp/lib/sesame-queryparser-sparql-2.6.2.jar deleted file mode 100644 index cd7463424..000000000 Binary files a/webapp/lib/sesame-queryparser-sparql-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-queryparser-sparql-2.6.6.jar b/webapp/lib/sesame-queryparser-sparql-2.6.6.jar new file mode 100644 index 000000000..bf7e68d59 Binary files /dev/null and b/webapp/lib/sesame-queryparser-sparql-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryresultio-api-2.6.2.jar b/webapp/lib/sesame-queryresultio-api-2.6.6.jar similarity index 72% rename from webapp/lib/sesame-queryresultio-api-2.6.2.jar rename to webapp/lib/sesame-queryresultio-api-2.6.6.jar index bd28e0202..690591e59 100644 Binary files a/webapp/lib/sesame-queryresultio-api-2.6.2.jar and b/webapp/lib/sesame-queryresultio-api-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryresultio-binary-2.6.2.jar b/webapp/lib/sesame-queryresultio-binary-2.6.6.jar similarity index 62% rename from webapp/lib/sesame-queryresultio-binary-2.6.2.jar rename to webapp/lib/sesame-queryresultio-binary-2.6.6.jar index bc9345185..1066601cc 100644 Binary files a/webapp/lib/sesame-queryresultio-binary-2.6.2.jar and b/webapp/lib/sesame-queryresultio-binary-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryresultio-sparqljson-2.6.2.jar b/webapp/lib/sesame-queryresultio-sparqljson-2.6.6.jar similarity index 59% rename from webapp/lib/sesame-queryresultio-sparqljson-2.6.2.jar rename to webapp/lib/sesame-queryresultio-sparqljson-2.6.6.jar index 97db0b69d..c9cc19e6c 100644 Binary files a/webapp/lib/sesame-queryresultio-sparqljson-2.6.2.jar and b/webapp/lib/sesame-queryresultio-sparqljson-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryresultio-sparqlxml-2.6.2.jar b/webapp/lib/sesame-queryresultio-sparqlxml-2.6.6.jar similarity index 73% rename from webapp/lib/sesame-queryresultio-sparqlxml-2.6.2.jar rename to webapp/lib/sesame-queryresultio-sparqlxml-2.6.6.jar index c3c45fd97..ce8f21b5f 100644 Binary files a/webapp/lib/sesame-queryresultio-sparqlxml-2.6.2.jar and b/webapp/lib/sesame-queryresultio-sparqlxml-2.6.6.jar differ diff --git a/webapp/lib/sesame-queryresultio-text-2.6.2.jar b/webapp/lib/sesame-queryresultio-text-2.6.2.jar deleted file mode 100644 index d3e195511..000000000 Binary files a/webapp/lib/sesame-queryresultio-text-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-queryresultio-text-2.6.6.jar b/webapp/lib/sesame-queryresultio-text-2.6.6.jar new file mode 100644 index 000000000..1841c2228 Binary files /dev/null and b/webapp/lib/sesame-queryresultio-text-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-api-2.6.2.jar b/webapp/lib/sesame-repository-api-2.6.6.jar similarity index 74% rename from webapp/lib/sesame-repository-api-2.6.2.jar rename to webapp/lib/sesame-repository-api-2.6.6.jar index 2b47de0a3..226e2a78c 100644 Binary files a/webapp/lib/sesame-repository-api-2.6.2.jar and b/webapp/lib/sesame-repository-api-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-contextaware-2.6.2.jar b/webapp/lib/sesame-repository-contextaware-2.6.2.jar deleted file mode 100644 index f69b04a5a..000000000 Binary files a/webapp/lib/sesame-repository-contextaware-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-repository-contextaware-2.6.6.jar b/webapp/lib/sesame-repository-contextaware-2.6.6.jar new file mode 100644 index 000000000..8360459bb Binary files /dev/null and b/webapp/lib/sesame-repository-contextaware-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-dataset-2.6.2.jar b/webapp/lib/sesame-repository-dataset-2.6.6.jar similarity index 70% rename from webapp/lib/sesame-repository-dataset-2.6.2.jar rename to webapp/lib/sesame-repository-dataset-2.6.6.jar index 36490be86..c1a960a1a 100644 Binary files a/webapp/lib/sesame-repository-dataset-2.6.2.jar and b/webapp/lib/sesame-repository-dataset-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-event-2.6.2.jar b/webapp/lib/sesame-repository-event-2.6.2.jar deleted file mode 100644 index 92ba79803..000000000 Binary files a/webapp/lib/sesame-repository-event-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-repository-event-2.6.6.jar b/webapp/lib/sesame-repository-event-2.6.6.jar new file mode 100644 index 000000000..f5f3e9200 Binary files /dev/null and b/webapp/lib/sesame-repository-event-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-http-2.6.2.jar b/webapp/lib/sesame-repository-http-2.6.6.jar similarity index 51% rename from webapp/lib/sesame-repository-http-2.6.2.jar rename to webapp/lib/sesame-repository-http-2.6.6.jar index 576f07c80..fb45ff7e9 100644 Binary files a/webapp/lib/sesame-repository-http-2.6.2.jar and b/webapp/lib/sesame-repository-http-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-manager-2.6.2.jar b/webapp/lib/sesame-repository-manager-2.6.6.jar similarity index 56% rename from webapp/lib/sesame-repository-manager-2.6.2.jar rename to webapp/lib/sesame-repository-manager-2.6.6.jar index 52cd8a834..047bfb784 100644 Binary files a/webapp/lib/sesame-repository-manager-2.6.2.jar and b/webapp/lib/sesame-repository-manager-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-sail-2.6.2.jar b/webapp/lib/sesame-repository-sail-2.6.6.jar similarity index 51% rename from webapp/lib/sesame-repository-sail-2.6.2.jar rename to webapp/lib/sesame-repository-sail-2.6.6.jar index 97b4406eb..71987104b 100644 Binary files a/webapp/lib/sesame-repository-sail-2.6.2.jar and b/webapp/lib/sesame-repository-sail-2.6.6.jar differ diff --git a/webapp/lib/sesame-repository-sparql-2.6.2.jar b/webapp/lib/sesame-repository-sparql-2.6.6.jar similarity index 74% rename from webapp/lib/sesame-repository-sparql-2.6.2.jar rename to webapp/lib/sesame-repository-sparql-2.6.6.jar index 8229628b1..9a43beb4e 100644 Binary files a/webapp/lib/sesame-repository-sparql-2.6.2.jar and b/webapp/lib/sesame-repository-sparql-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-api-2.6.2.jar b/webapp/lib/sesame-rio-api-2.6.6.jar similarity index 62% rename from webapp/lib/sesame-rio-api-2.6.2.jar rename to webapp/lib/sesame-rio-api-2.6.6.jar index 159f80184..3f60b67cb 100644 Binary files a/webapp/lib/sesame-rio-api-2.6.2.jar and b/webapp/lib/sesame-rio-api-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-binary-2.6.2.jar b/webapp/lib/sesame-rio-binary-2.6.2.jar deleted file mode 100644 index 0f4eeb4d7..000000000 Binary files a/webapp/lib/sesame-rio-binary-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-rio-binary-2.6.6.jar b/webapp/lib/sesame-rio-binary-2.6.6.jar new file mode 100644 index 000000000..8a0345b56 Binary files /dev/null and b/webapp/lib/sesame-rio-binary-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-n3-2.6.2.jar b/webapp/lib/sesame-rio-n3-2.6.2.jar deleted file mode 100644 index 156f688bc..000000000 Binary files a/webapp/lib/sesame-rio-n3-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-rio-n3-2.6.6.jar b/webapp/lib/sesame-rio-n3-2.6.6.jar new file mode 100644 index 000000000..b83d16f18 Binary files /dev/null and b/webapp/lib/sesame-rio-n3-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-ntriples-2.6.2.jar b/webapp/lib/sesame-rio-ntriples-2.6.6.jar similarity index 76% rename from webapp/lib/sesame-rio-ntriples-2.6.2.jar rename to webapp/lib/sesame-rio-ntriples-2.6.6.jar index 617183506..9ded9ccbb 100644 Binary files a/webapp/lib/sesame-rio-ntriples-2.6.2.jar and b/webapp/lib/sesame-rio-ntriples-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-rdfxml-2.6.2.jar b/webapp/lib/sesame-rio-rdfxml-2.6.6.jar similarity index 87% rename from webapp/lib/sesame-rio-rdfxml-2.6.2.jar rename to webapp/lib/sesame-rio-rdfxml-2.6.6.jar index 2d82b3435..e6d0c356c 100644 Binary files a/webapp/lib/sesame-rio-rdfxml-2.6.2.jar and b/webapp/lib/sesame-rio-rdfxml-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-trig-2.6.2.jar b/webapp/lib/sesame-rio-trig-2.6.6.jar similarity index 57% rename from webapp/lib/sesame-rio-trig-2.6.2.jar rename to webapp/lib/sesame-rio-trig-2.6.6.jar index da521398e..49c88a025 100644 Binary files a/webapp/lib/sesame-rio-trig-2.6.2.jar and b/webapp/lib/sesame-rio-trig-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-trix-2.6.2.jar b/webapp/lib/sesame-rio-trix-2.6.6.jar similarity index 70% rename from webapp/lib/sesame-rio-trix-2.6.2.jar rename to webapp/lib/sesame-rio-trix-2.6.6.jar index 0de2a4d6b..fa630c163 100644 Binary files a/webapp/lib/sesame-rio-trix-2.6.2.jar and b/webapp/lib/sesame-rio-trix-2.6.6.jar differ diff --git a/webapp/lib/sesame-rio-turtle-2.6.2.jar b/webapp/lib/sesame-rio-turtle-2.6.2.jar deleted file mode 100644 index fc69da302..000000000 Binary files a/webapp/lib/sesame-rio-turtle-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-rio-turtle-2.6.6.jar b/webapp/lib/sesame-rio-turtle-2.6.6.jar new file mode 100644 index 000000000..8a160084a Binary files /dev/null and b/webapp/lib/sesame-rio-turtle-2.6.6.jar differ diff --git a/webapp/lib/sesame-runtime-2.6.2.jar b/webapp/lib/sesame-runtime-2.6.2.jar deleted file mode 100644 index 3e8078917..000000000 Binary files a/webapp/lib/sesame-runtime-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-runtime-2.6.6.jar b/webapp/lib/sesame-runtime-2.6.6.jar new file mode 100644 index 000000000..a63e62223 Binary files /dev/null and b/webapp/lib/sesame-runtime-2.6.6.jar differ diff --git a/webapp/lib/sesame-sail-api-2.6.2.jar b/webapp/lib/sesame-sail-api-2.6.2.jar deleted file mode 100644 index c42382c13..000000000 Binary files a/webapp/lib/sesame-sail-api-2.6.2.jar and /dev/null differ diff --git a/webapp/lib/sesame-sail-api-2.6.6.jar b/webapp/lib/sesame-sail-api-2.6.6.jar new file mode 100644 index 000000000..a0343f984 Binary files /dev/null and b/webapp/lib/sesame-sail-api-2.6.6.jar differ diff --git a/webapp/lib/sesame-sail-inferencer-2.6.2.jar b/webapp/lib/sesame-sail-inferencer-2.6.6.jar similarity index 75% rename from webapp/lib/sesame-sail-inferencer-2.6.2.jar rename to webapp/lib/sesame-sail-inferencer-2.6.6.jar index 65b67c73d..dec735a2d 100644 Binary files a/webapp/lib/sesame-sail-inferencer-2.6.2.jar and b/webapp/lib/sesame-sail-inferencer-2.6.6.jar differ diff --git a/webapp/lib/sesame-sail-memory-2.6.2.jar b/webapp/lib/sesame-sail-memory-2.6.6.jar similarity index 72% rename from webapp/lib/sesame-sail-memory-2.6.2.jar rename to webapp/lib/sesame-sail-memory-2.6.6.jar index 6825d207b..0d7be35e5 100644 Binary files a/webapp/lib/sesame-sail-memory-2.6.2.jar and b/webapp/lib/sesame-sail-memory-2.6.6.jar differ diff --git a/webapp/lib/sesame-sail-nativerdf-2.6.2.jar b/webapp/lib/sesame-sail-nativerdf-2.6.6.jar similarity index 67% rename from webapp/lib/sesame-sail-nativerdf-2.6.2.jar rename to webapp/lib/sesame-sail-nativerdf-2.6.6.jar index 9ebaa81f9..91c90722c 100644 Binary files a/webapp/lib/sesame-sail-nativerdf-2.6.2.jar and b/webapp/lib/sesame-sail-nativerdf-2.6.6.jar differ diff --git a/webapp/lib/sesame-sail-rdbms-2.6.2.jar b/webapp/lib/sesame-sail-rdbms-2.6.6.jar similarity index 86% rename from webapp/lib/sesame-sail-rdbms-2.6.2.jar rename to webapp/lib/sesame-sail-rdbms-2.6.6.jar index a9a3f6e86..b88993585 100644 Binary files a/webapp/lib/sesame-sail-rdbms-2.6.2.jar and b/webapp/lib/sesame-sail-rdbms-2.6.6.jar differ diff --git a/webapp/lib/sesame-util-2.6.2.jar b/webapp/lib/sesame-util-2.6.6.jar similarity index 76% rename from webapp/lib/sesame-util-2.6.2.jar rename to webapp/lib/sesame-util-2.6.6.jar index b20b81b0e..cec6c51ee 100644 Binary files a/webapp/lib/sesame-util-2.6.2.jar and b/webapp/lib/sesame-util-2.6.6.jar differ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java index 149d64af5..5e8c60e73 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java @@ -180,6 +180,7 @@ public class JenaIngestController extends BaseEditController { processRenameResourceRequest(vreq, response, maker, modelType); } else if("mergeResult".equals(actionStr)){ processMergeResultRequest(vreq, response, maker, modelType); + return; } else { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java index f6f1c8e8b..4ad52cca1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java @@ -10,16 +10,15 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.methods.ByteArrayRequestEntity; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openrdf.model.Resource; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryLanguage; -import org.openrdf.query.Update; -import org.openrdf.query.UpdateExecutionException; -import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.RepositoryException; import org.openrdf.repository.RepositoryResult; @@ -32,6 +31,7 @@ import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -48,6 +48,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.ChangeSetImpl; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.ListeningGraph; +import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; /* * API to write, read, and update Vitro's RDF store, with support @@ -59,8 +60,9 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { private static final Log log = LogFactory.getLog(RDFServiceImpl.class); private String readEndpointURI; private String updateEndpointURI; - private Repository readRepository; - private Repository updateRepository; + private HTTPRepository readRepository; + private HTTPRepository updateRepository; + private boolean useSesameContextQuery = true; /** * Returns an RDFService for a remote repository @@ -78,7 +80,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { this.updateEndpointURI = updateEndpointURI; this.readRepository = new HTTPRepository(readEndpointURI); this.updateRepository = new HTTPRepository(updateEndpointURI); - + testConnection(); } @@ -332,25 +334,47 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { // graph update API @Override public List getGraphURIs() throws RDFServiceException { - - List graphNodeList = new ArrayList(); - - try { - RepositoryConnection conn = getWriteConnection(); + if (!this.useSesameContextQuery) { + return getGraphURIsFromSparqlQuery(); + } else { try { - RepositoryResult conResult = conn.getContextIDs(); - while (conResult.hasNext()) { - Resource res = conResult.next(); - graphNodeList.add(res.stringValue()); - } - } finally { - conn.close(); + return getGraphURIsFromSesameContexts(); + } catch (RepositoryException re) { + this.useSesameContextQuery = false; + return getGraphURIsFromSparqlQuery(); } - } catch (RepositoryException re) { - throw new RuntimeException(re); + } + } + + private List getGraphURIsFromSesameContexts() throws RepositoryException { + List graphURIs = new ArrayList(); + RepositoryConnection conn = getReadConnection(); + try { + RepositoryResult conResult = conn.getContextIDs(); + while (conResult.hasNext()) { + Resource res = conResult.next(); + graphURIs.add(res.stringValue()); + } + } finally { + conn.close(); } - - return graphNodeList; + return graphURIs; + } + + private List getGraphURIsFromSparqlQuery() throws RDFServiceException { + List graphURIs = new ArrayList(); + try { + String graphURIString = "SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } } ORDER BY ?g"; + ResultSet rs = ResultSetFactory.fromJSON( + sparqlSelectQuery(graphURIString, RDFService.ResultFormat.JSON)); + while (rs.hasNext()) { + QuerySolution qs = rs.nextSolution(); + graphURIs.add(qs.getResource("g").getURI()); + } + } catch (Exception e) { + throw new RDFServiceException("Unable to list graph URIs", e); + } + return graphURIs; } /** @@ -416,6 +440,14 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { return updateEndpointURI; } + protected RepositoryConnection getReadConnection() { + try { + return this.readRepository.getConnection(); + } catch (RepositoryException e) { + throw new RuntimeException(e); + } + } + protected RepositoryConnection getWriteConnection() { try { return this.updateRepository.getConnection(); @@ -424,35 +456,34 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { } } - protected void executeUpdate(String updateString) { + protected void executeUpdate(String updateString) throws RDFServiceException { try { - RepositoryConnection conn = getWriteConnection(); - try { - Update u = conn.prepareUpdate(QueryLanguage.SPARQL, updateString); - u.execute(); - } catch (MalformedQueryException e) { - throw new RuntimeException(e); - } catch (UpdateExecutionException e) { - log.error(e,e); - log.error("Update command: \n" + updateString); - throw new RuntimeException(e); - } finally { - conn.close(); + HttpClient httpClient = new HttpClient(); + PostMethod meth = new PostMethod(updateEndpointURI); + meth.addRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + NameValuePair[] body = new NameValuePair[1]; + body[0] = new NameValuePair("update", updateString); + meth.setRequestBody(body); + int response = httpClient.executeMethod(meth); + if (response > 399) { + log.error("response " + response + " to update. \n"); + log.debug("update string: \n" + updateString); + throw new RDFServiceException("Unable to perform SPARQL UPDATE"); } - } catch (RepositoryException re) { - throw new RuntimeException(re); - } + } catch (Exception e) { + throw new RDFServiceException("Unable to perform change set update", e); + } } - public void addModel(Model model, String graphURI) { + public void addModel(Model model, String graphURI) throws RDFServiceException { verbModel(model, graphURI, "INSERT"); } - public void deleteModel(Model model, String graphURI) { + public void deleteModel(Model model, String graphURI) throws RDFServiceException { verbModel(model, graphURI, "DELETE"); } - private void verbModel(Model model, String graphURI, String verb) { + private void verbModel(Model model, String graphURI, String verb) throws RDFServiceException { Model m = ModelFactory.createDefaultModel(); int testLimit = 1000; StmtIterator stmtIt = model.listStatements(); @@ -481,7 +512,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { } } - protected void addTriple(Triple t, String graphURI) { + protected void addTriple(Triple t, String graphURI) throws RDFServiceException { StringBuffer updateString = new StringBuffer(); updateString.append("INSERT DATA { "); @@ -498,7 +529,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { notifyListeners(t, ModelChange.Operation.ADD, graphURI); } - protected void removeTriple(Triple t, String graphURI) { + protected void removeTriple(Triple t, String graphURI) throws RDFServiceException { StringBuffer updateString = new StringBuffer(); updateString.append("DELETE DATA { "); @@ -551,7 +582,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { } } - private void performChange(ModelChange modelChange) { + private void performChange(ModelChange modelChange) throws RDFServiceException { Model model = parseModel(modelChange); if (modelChange.getOperation() == ModelChange.Operation.ADD) { addModel(model, modelChange.getGraphURI()); @@ -563,7 +594,8 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { } } - private void removeBlankNodesWithSparqlUpdate(Model model, String graphURI) { + private void removeBlankNodesWithSparqlUpdate(Model model, String graphURI) + throws RDFServiceException { List blankNodeStatements = new ArrayList(); StmtIterator stmtIt = model.listStatements(); while (stmtIt.hasNext()) { @@ -636,7 +668,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { } } - private void removeUsingSparqlUpdate(Model model, String graphURI) { + private void removeUsingSparqlUpdate(Model model, String graphURI) throws RDFServiceException { StmtIterator stmtIt = model.listStatements();