[Mulgara-svn] r1866 - in branches/distinct_queries: . jxdata/iTQL jxdata/iTQL/distinct lib src/jar/content-rdfxml/java/org/mulgara/content/rdfxml src/jar/querylang/java/org/mulgara/protocol/http src/jar/querylang/java/org/mulgara/store/jxunit src/jar/resolver-store/java/org/mulgara/store/statement/xa11
pag at mulgara.org
pag at mulgara.org
Tue Dec 8 18:39:04 UTC 2009
Author: pag
Date: 2009-12-08 10:39:03 -0800 (Tue, 08 Dec 2009)
New Revision: 1866
Added:
branches/distinct_queries/jxdata/iTQL/distinct/
branches/distinct_queries/jxdata/iTQL/distinct/queryResult1.txt
branches/distinct_queries/jxdata/iTQL/distinct/queryResult2.txt
branches/distinct_queries/jxdata/iTQL/distinct/result1.txt
branches/distinct_queries/jxdata/iTQL/distinct/test.jxu
branches/distinct_queries/jxdata/iTQL/people.rdf
branches/distinct_queries/lib/apache-mime4j-0.5.jar
branches/distinct_queries/lib/commons-logging-1.1.1.jar
branches/distinct_queries/lib/httpclient-4.0-beta2.jar
branches/distinct_queries/lib/httpcore-4.0-beta3.jar
branches/distinct_queries/lib/httpmime-4.0-beta2.jar
branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/PartialFailureException.java
branches/distinct_queries/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java
Removed:
branches/distinct_queries/lib/commons-logging-1.0.3.jar
Modified:
branches/distinct_queries/.classpath
branches/distinct_queries/build.properties
branches/distinct_queries/common.xml
branches/distinct_queries/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java
branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java
Log:
Merged 1836:1865 from trunk
Modified: branches/distinct_queries/.classpath
===================================================================
--- branches/distinct_queries/.classpath 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/.classpath 2009-12-08 18:39:03 UTC (rev 1866)
@@ -78,8 +78,6 @@
<classpathentry kind="lib" path="lib/castor-1.2-xml.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-discovery-1.2.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-logging-1.0.3.jar"/>
<classpathentry kind="lib" path="lib/concurrent-1.3.4.jar"/>
<classpathentry kind="lib" path="lib/connector-1_5.jar"/>
<classpathentry kind="lib" path="lib/derby.jar"/>
@@ -127,5 +125,11 @@
<classpathentry kind="lib" path="lib/xml-apis-2.9.1.jar"/>
<classpathentry kind="lib" path="dist/ideSupport.jar" sourcepath="obj/jar/config/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/apache-mime4j-0.5.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.0-beta2.jar"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.0-beta3.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.0-beta2.jar"/>
<classpathentry kind="output" path="obj/jar"/>
</classpath>
Modified: branches/distinct_queries/build.properties
===================================================================
--- branches/distinct_queries/build.properties 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/build.properties 2009-12-08 18:39:03 UTC (rev 1866)
@@ -93,6 +93,7 @@
# Lib jars
activation.jar =activation-1.1.1.jar
antlr.jar =antlr.jar
+apache-mime4j.jar =apache-mime4j-0.5.jar
apache.soap.jar =apache-soap-2.2.jar
aspectjrt.jar =aspectjrt-1.2.jar
axis.jar =axis-1.4.jar
@@ -103,12 +104,15 @@
velocity.jar =velocity-1.5.jar
commons-discovery.jar =commons-discovery-1.2.jar
commons-httpclient.jar =commons-httpclient-3.1.jar
-commons-logging.jar =commons-logging-1.0.3.jar
+commons-logging.jar =commons-logging-1.1.1.jar
commons-codec.jar =commons-codec-1.3.jar
concurrent.jar =concurrent-1.3.4.jar
d2r.jar =d2rmap-V02.jar
emory-util.jar =emory-util-2.1-remote.jar
httpclient.jar =${commons-httpclient.jar}
+http-client.jar =httpclient-4.0-beta2.jar
+http-core.jar =httpcore-4.0-beta3.jar
+http-mime.jar =httpmime-4.0-beta2.jar
icu4j.jar =icu4j_3_4.jar
jargs.jar =jargs-0.2.jar
jasper.compiler.jar =jasper-compiler-4.2.29.jar
Modified: branches/distinct_queries/common.xml
===================================================================
--- branches/distinct_queries/common.xml 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/common.xml 2009-12-08 18:39:03 UTC (rev 1866)
@@ -59,7 +59,7 @@
<fileset dir="${lib.dir}" includes="**/axis-ant-1.4.jar"/>
<fileset dir="${lib.dir}" includes="**/wsdl4j-1.5.1.jar"/>
<fileset dir="${lib.dir}" includes="**/log4j-1.2.15.jar"/>
- <fileset dir="${lib.dir}" includes="**/commons-logging-1.0.3.jar"/>
+ <fileset dir="${lib.dir}" includes="**/commons-logging-1.1.1.jar"/>
<fileset dir="${lib.dir}" includes="**/commons-discovery-1.2.jar"/>
<fileset dir="${lib.dir}" includes="**/jaxrpc-1.4.jar"/>
<fileset dir="${lib.dir}" includes="**/saaj-1.4.jar"/>
@@ -147,6 +147,7 @@
jotm*.jar, commons-logging-*.jar, Quick4rt.jar,
commons-discovery-*.jar, commons-httpclient-*.jar,
commons-codec-*.jar, connector-*.jar, jaxrpc-*.jar,
+ ${apache-mime4j.jar}, ${http-client.jar}, ${http-core.jar}, ${http-mime.jar},
carol*.jar, howl-logger*.jar, javax.servlet*.jar, servlet-api*.jar,
${joda-time.jar}, mulgara-sparql*.jar, sesame-model-*.jar"
excludes="jboss-j2ee.jar"/>
Added: branches/distinct_queries/jxdata/iTQL/distinct/queryResult1.txt
===================================================================
--- branches/distinct_queries/jxdata/iTQL/distinct/queryResult1.txt (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/distinct/queryResult1.txt 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sparql xmlns="http://www.w3.org/2005/sparql-results#">
+ <head>
+ <variable name="person"/>
+ <variable name="email"/>
+ </head>
+ <results>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Barney</uri>
+ </binding>
+ <binding name="email">
+ <literal>barney at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Brian</uri>
+ </binding>
+ <binding name="email">
+ <literal>brian at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#David</uri>
+ </binding>
+ <binding name="email">
+ <literal>david at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Fred</uri>
+ </binding>
+ <binding name="email">
+ <literal>fred at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Janelle</uri>
+ </binding>
+ <binding name="email">
+ <literal>janelle at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Peter</uri>
+ </binding>
+ <binding name="email">
+ <literal>peter at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Theresa</uri>
+ </binding>
+ <binding name="email">
+ <literal>theresa at test.com</literal>
+ </binding>
+ </result>
+ </results>
+</sparql>
Added: branches/distinct_queries/jxdata/iTQL/distinct/queryResult2.txt
===================================================================
--- branches/distinct_queries/jxdata/iTQL/distinct/queryResult2.txt (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/distinct/queryResult2.txt 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sparql xmlns="http://www.w3.org/2005/sparql-results#">
+ <head>
+ <variable name="person"/>
+ <variable name="email"/>
+ </head>
+ <results>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Barney</uri>
+ </binding>
+ <binding name="email">
+ <literal>barney at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Brian</uri>
+ </binding>
+ <binding name="email">
+ <literal>brian at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#David</uri>
+ </binding>
+ <binding name="email">
+ <literal>david at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Fred</uri>
+ </binding>
+ <binding name="email">
+ <literal>fred at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Janelle</uri>
+ </binding>
+ <binding name="email">
+ <literal>janelle at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Peter</uri>
+ </binding>
+ <binding name="email">
+ <literal>peter at test.com</literal>
+ </binding>
+ </result>
+ <result>
+ <binding name="person">
+ <uri>http://test.com/test#Theresa</uri>
+ </binding>
+ <binding name="email">
+ <literal>theresa at test.com</literal>
+ </binding>
+ </result>
+ </results>
+</sparql>
Added: branches/distinct_queries/jxdata/iTQL/distinct/result1.txt
===================================================================
--- branches/distinct_queries/jxdata/iTQL/distinct/result1.txt (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/distinct/result1.txt 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 96 statements from @baseuri@/jxdata/iTQL/people.rdf into @server@#people</message></query></answer>
Added: branches/distinct_queries/jxdata/iTQL/distinct/test.jxu
===================================================================
--- branches/distinct_queries/jxdata/iTQL/distinct/test.jxu (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/distinct/test.jxu 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,118 @@
+<jxu>
+ <set name="debug" value="false" />
+
+ <set name="modelName" value="@server@#people" />
+ <set name="loadCommand" value="load <@baseuri@/jxdata/iTQL/people.rdf> into <@server@#people> ;" />
+ <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+ <ifEqual converse="true" file="result1.txt" name="loadResult">
+ <save name="loadResult" file="badLoadResult.xml"/>
+ <fail>Output failed. Check badLoadResult.xml for output.</fail>
+ </ifEqual>
+
+ <!-- now query the graphs -->
+
+ <set name="query" value="prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+ prefix mulgara: <http://mulgara.org/mulgara#>
+ prefix foaf: <http://xmlns.com/foaf/0.1/>
+ prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#>
+
+ select ?person ?email
+ from <@server@#people>
+ where {
+ ?person a foaf:Person .
+ ?person foaf:mbox ?email .
+ {
+ { ?person foaf:firstName 'Fred' }
+ UNION
+ { ?person foaf:firstName 'Barney' }
+ UNION
+ {
+ { ?person contact:home [ contact:address [ contact:city 'London' ] ] }
+ UNION
+ { ?person contact:home [ contact:address [ contact:city 'NY' ] ] }
+ UNION
+ {
+ ?person foaf:birthday ?bd .
+ GRAPH <sys:xsd> {
+ ?bd mulgara:after '1970-07-01'^^xsd:date .
+ ?bd mulgara:before '1971-06-30'^^xsd:date
+ }
+ }
+ UNION
+ {
+ ?person foaf:birthday ?bd .
+ GRAPH <sys:xsd> { ?bd mulgara:after '1975-01-01'^^xsd:date . ?bd mulgara:before '1975-12-31'^^xsd:date } .
+ {
+ { ?person contact:home [ contact:address [ contact:city 'Chicago' ] ] }
+ UNION
+ { ?person contact:home [ contact:address [ contact:city 'Fredericksburg' ] ] }
+ }
+ }
+ }
+ }
+ }
+ order by ?person"/>
+
+ <eval stepClass="org.mulgara.store.jxunit.SparqlQueryJX" />
+ <ifEqual converse="true" file="queryResult1.txt" name="queryResult">
+ <save name="queryResult" file="badQuery1Result.xml"/>
+ <fail>Output failed. Check badQuery1Result.xml for output.</fail>
+ </ifEqual>
+
+
+ <set name="query" value="prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+ prefix mulgara: <http://mulgara.org/mulgara#>
+ prefix foaf: <http://xmlns.com/foaf/0.1/>
+ prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#>
+
+ select distinct ?person ?email
+ from <@server@#people>
+ where {
+ ?person a foaf:Person .
+ ?person foaf:mbox ?email .
+ {
+ { ?person foaf:firstName 'Fred' }
+ UNION
+ { ?person foaf:firstName 'Barney' }
+ UNION
+ {
+ { ?person contact:home [ contact:address [ contact:city 'London' ] ] }
+ UNION
+ { ?person contact:home [ contact:address [ contact:city 'NY' ] ] }
+ UNION
+ {
+ ?person foaf:birthday ?bd .
+ GRAPH <sys:xsd> {
+ ?bd mulgara:after '1970-07-01'^^xsd:date .
+ ?bd mulgara:before '1971-06-30'^^xsd:date
+ }
+ }
+ UNION
+ {
+ ?person foaf:birthday ?bd .
+ GRAPH <sys:xsd> { ?bd mulgara:after '1975-01-01'^^xsd:date . ?bd mulgara:before '1975-12-31'^^xsd:date } .
+ {
+ { ?person contact:home [ contact:address [ contact:city 'Chicago' ] ] }
+ UNION
+ { ?person contact:home [ contact:address [ contact:city 'Fredericksburg' ] ] }
+ }
+ }
+ }
+ }
+ }
+ order by ?person"/>
+
+ <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+ <ifEqual converse="true" file="queryResult2.txt" name="queryResult">
+ <save name="queryResult" file="badQuery2Result.xml"/>
+ <fail>Output failed. Check badQuery2Result.xml for output.</fail>
+ </ifEqual>
+
+
+ <!-- now drop the graphs -->
+ <set name="query" value="drop <@server@#people>;"/>
+ <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+
+</jxu>
+
Added: branches/distinct_queries/jxdata/iTQL/people.rdf
===================================================================
--- branches/distinct_queries/jxdata/iTQL/people.rdf (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/people.rdf 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,164 @@
+<?xml version="1.0"?>
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"
+ xmlns:test="http://test.com/">
+
+ <!-- included: First name is Fred -->
+ <foaf:Person rdf:about="http://test.com/test#Fred">
+ <foaf:firstName>Fred</foaf:firstName>
+ <foaf:mbox>fred at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1980-02-11</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Bedrock</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- excluded: not a person -->
+ <test:Dog rdf:about="http://test.com/test#FredTheDog">
+ <foaf:firstName>Fred</foaf:firstName>
+ <foaf:mbox>fredthedog at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1980-02-11</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Bedrock</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </test:Dog>
+
+ <!-- included: First name is Barney -->
+ <foaf:Person rdf:about="http://test.com/test#Barney">
+ <foaf:firstName>Barney</foaf:firstName>
+ <foaf:mbox>barney at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1978-11-11</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Bedrock</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- excluded: not a first name we want, not the right place, not the right date -->
+ <foaf:Person rdf:about="http://test.com/test#Bruce">
+ <foaf:firstName>Bruce</foaf:firstName>
+ <foaf:mbox>bruce at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1939-05-01</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Gotham</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- included: in London -->
+ <foaf:Person rdf:about="http://test.com/test#Brian">
+ <foaf:firstName>Brian</foaf:firstName>
+ <foaf:mbox>brian at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1976-10-13</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>London</contact:city>
+ <contact:country>UK</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- included: in NY -->
+ <foaf:Person rdf:about="http://test.com/test#Peter">
+ <foaf:firstName>Peter</foaf:firstName>
+ <foaf:mbox>peter at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1962-08-01</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>NY</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- included: birthday in 70-71 -->
+ <foaf:Person rdf:about="http://test.com/test#Janelle">
+ <foaf:firstName>Janelle</foaf:firstName>
+ <foaf:mbox>janelle at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1971-02-21</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Brisbane</contact:city>
+ <contact:country>Australia</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- excluded: birthday in 75, but not in required city -->
+ <foaf:Person rdf:about="http://test.com/test#Rowan">
+ <foaf:firstName>Rowan</foaf:firstName>
+ <foaf:mbox>rowan at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1975-07-10</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Houston</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- included: birthday in 75 and in Chicago -->
+ <foaf:Person rdf:about="http://test.com/test#Theresa">
+ <foaf:firstName>Theresa</foaf:firstName>
+ <foaf:mbox>theresa at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1975-03-10</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Chicago</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- included: birthday in 75 and in Fredericksburg -->
+ <foaf:Person rdf:about="http://test.com/test#David">
+ <foaf:firstName>David</foaf:firstName>
+ <foaf:mbox>david at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1975-08-18</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Fredericksburg</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- excluded: in Chicago, but birthday not in 75 -->
+ <foaf:Person rdf:about="http://test.com/test#Alan">
+ <foaf:firstName>Alan</foaf:firstName>
+ <foaf:mbox>alan at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1974-04-04</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Chicago</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </foaf:Person>
+
+ <!-- excluded: required birthday, in Chicago, but not a person -->
+ <test:Dog rdf:about="http://test.com/test#Fido">
+ <foaf:firstName>Fido</foaf:firstName>
+ <foaf:mbox>fido at test.com</foaf:mbox>
+ <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1975-09-13</foaf:birthday>
+ <contact:home rdf:parseType="Resource">
+ <contact:address rdf:parseType="Resource">
+ <contact:city>Chicago</contact:city>
+ <contact:country>USA</contact:country>
+ </contact:address>
+ </contact:home>
+ </test:Dog>
+
+</rdf:RDF>
Copied: branches/distinct_queries/lib/apache-mime4j-0.5.jar (from rev 1865, trunk/lib/apache-mime4j-0.5.jar)
===================================================================
(Binary files differ)
Deleted: branches/distinct_queries/lib/commons-logging-1.0.3.jar
===================================================================
(Binary files differ)
Copied: branches/distinct_queries/lib/commons-logging-1.1.1.jar (from rev 1865, trunk/lib/commons-logging-1.1.1.jar)
===================================================================
(Binary files differ)
Copied: branches/distinct_queries/lib/httpclient-4.0-beta2.jar (from rev 1865, trunk/lib/httpclient-4.0-beta2.jar)
===================================================================
(Binary files differ)
Copied: branches/distinct_queries/lib/httpcore-4.0-beta3.jar (from rev 1865, trunk/lib/httpcore-4.0-beta3.jar)
===================================================================
(Binary files differ)
Copied: branches/distinct_queries/lib/httpmime-4.0-beta2.jar (from rev 1865, trunk/lib/httpmime-4.0-beta2.jar)
===================================================================
(Binary files differ)
Modified: branches/distinct_queries/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java
===================================================================
--- branches/distinct_queries/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java 2009-12-08 18:39:03 UTC (rev 1866)
@@ -483,7 +483,7 @@
assert resource.getURI() != null;
return resolverSession.localize(new URIReferenceImpl(new URI(resource.getURI())));
} catch (URISyntaxException e) {
- throw new Error("ARP generated a malformed URI", e);
+ throw new Error("ARP generated a malformed URI: '" + resource.getURI() + "'", e);
}
}
}
Copied: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/PartialFailureException.java (from rev 1865, trunk/src/jar/querylang/java/org/mulgara/protocol/http/PartialFailureException.java)
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/PartialFailureException.java (rev 0)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/PartialFailureException.java 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009 Duraspace.
+ *
+ * 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 org.mulgara.protocol.http;
+
+import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
+
+/**
+ * Encodes the condition of a bad HTTP servlet request.
+ *
+ * @created Sep 8, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="http://www.fedora-commons.org/">Fedora Commons</a>
+ */
+public class PartialFailureException extends ServletException {
+
+ /** The serialization ID */
+ private static final long serialVersionUID = 3953416493075214645L;
+
+ /** An default constructor to indicate a problem. */
+ public PartialFailureException() {
+ super(SC_NO_CONTENT);
+ }
+
+ /**
+ * @param message The message to send with a bad request code.
+ */
+ public PartialFailureException(String message) {
+ super(SC_NO_CONTENT, message);
+ }
+
+}
Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2009-12-08 18:39:03 UTC (rev 1866)
@@ -443,15 +443,27 @@
}
// upload the data
+ int attempts = 0;
+ int failed = 0;
+ StringBuilder errorBuffer = new StringBuilder();
for (int partNr = 0; partNr < mime.getCount(); partNr++) {
BodyPart part = mime.getBodyPart(partNr);
String partName = mime.getPartName(partNr);
try {
- if (!knownParam(partName)) resp.addHeader(HDR_STMT_COUNT, Long.toString(loadData(destGraph, part, conn)));
+ if (!knownParam(partName)) {
+ attempts++;
+ resp.addHeader(HDR_STMT_COUNT, Long.toString(loadData(destGraph, part, conn)));
+ }
} catch (QueryException e) {
resp.addHeader(HDR_CANNOT_LOAD, partName);
+ errorBuffer.append("\n").append(partName).append(": ").append(e.getMessage());
+ failed++;
}
}
+ if (failed == attempts) {
+ throw new BadRequestException("Unable to load data from " + failed + " file" + (failed == 1 ? "" : "s") + errorBuffer);
+ }
+ if (failed > 0) throw new PartialFailureException("Failed to load " + failed + "/" + attempts + " files" + errorBuffer);
} catch (MessagingException e) {
throw new BadRequestException("Unable to process received MIME data: " + e.getMessage());
}
Copied: branches/distinct_queries/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java (from rev 1865, trunk/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java)
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java (rev 0)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java 2009-12-08 18:39:03 UTC (rev 1866)
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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 org.mulgara.store.jxunit;
+
+// 3rd party package
+import net.sourceforge.jxunit.JXTestCase;
+import net.sourceforge.jxunit.JXTestStep;
+import net.sourceforge.jxunit.JXProperties;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.CoreProtocolPNames;
+
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+
+
+/**
+ * Test frame for SPARQL queries.
+ *
+ * @created 2009-09-17
+ * @author Paul Gearon
+ */
+public class SparqlQueryJX implements JXTestStep {
+
+ /** Line separator. */
+ private static final String EOL = System.getProperty("line.separator");
+
+ /** Name of the query command parameter */
+ public final static String QUERY = "query";
+
+ /** Parameter name of the results of the command */
+ public final static String RESULT = "queryResult";
+
+ /** Parameter name of the time flag */
+ public final static String TIME_NAME = "time";
+
+ /** Parameter name of the endpoint parameter */
+ public final static String ENDPOINT_NAME = "endpoint";
+
+ /** Parameter name of the default graph */
+ public final static String DEFAULT_GRAPH_NAME = "default-graph-uri";
+
+ /** The default endpoint to connect to */
+ private final static String DEFAULT_ENDPOINT = "http://localhost:8080/sparql/";
+
+ /** The character encoding to use for the request URL */
+ private static final String UTF8 = "UTF-8";
+
+ /** Internal record of the URL used */
+ private String requestUrl = "-";
+
+ /** Size for internal read buffer */
+ private final static int BUFFER_SIZE = 1024;
+
+ /**
+ * Execute this object. Retrieves a string from the testCase properties and
+ * executes it as a SPARQL query, returning the results in the testCase object.
+ *
+ * @param testCase The map object containing the properties.
+ * @throws Exception propagated exception from the query framework.
+ */
+ @SuppressWarnings("unchecked") // JXProperties does not use Generics
+ public void eval(JXTestCase testCase) throws Exception {
+
+ JXProperties props = testCase.getProperties();
+
+ // get the query to execute
+ String query = (String)props.get(QUERY);
+
+ // get the default graph URI
+ String defGraphStr = props.getString(DEFAULT_GRAPH_NAME);
+ URI defGraph = (defGraphStr != null) ? new URI(defGraphStr) : null;
+
+ // retrieve the endpoint to use
+ String confEndpoint = props.getString(ENDPOINT_NAME);
+ String endpoint = (confEndpoint != null && !confEndpoint.equals("")) ? confEndpoint : DEFAULT_ENDPOINT;
+
+ // retrieve flag asking if the query should be timed
+ String timeStr = props.getString(TIME_NAME);
+ boolean time = (timeStr != null) && Boolean.valueOf(timeStr).booleanValue();
+
+ long start = System.currentTimeMillis();
+ String queryResult = "";
+
+ try {
+ queryResult = executeQuery(endpoint, query, defGraph);
+ } catch (Exception ex) {
+ queryResult = "URL = <" + requestUrl + ">";
+ queryResult += "Exception: " + org.mulgara.util.StackTrace.throwableToString(ex);
+ } finally {
+ }
+
+ if (time) {
+ System.out.println(EOL + "query: \"" + query + "\" query has taken " +
+ (System.currentTimeMillis() - start) + " milliseconds to execute." + EOL);
+ }
+
+ props.put(RESULT, queryResult + EOL);
+ }
+
+
+ /**
+ * Execute a query against a SPARQL endpoint.
+ * @param endpoint The URL of the endpoint.
+ * @param query The query to execute.
+ * @param defGraph The default graph to execute the query against,
+ * or <code>null</code> if not set.
+ * @return A string representation of the result from the server.
+ * @throws IOException If there was an error communicating with the server.
+ * @throws UnsupportedEncodingException The SPARQL endpoint used an encoding not understood by this system.
+ * @throws HttpClientException An unexpected response was returned from the SPARQL endpoint.
+ */
+ String executeQuery(String endpoint, String query, URI defGraph)
+ throws IOException, UnsupportedEncodingException, HttpClientException {
+ String request = endpoint + "?";
+ if (defGraph != null && (0 != defGraph.toString().length())) request += "default-graph-uri=" + defGraph.toString() + "&";
+ request += "query=" + URLEncoder.encode(query, UTF8);
+ requestUrl = request;
+
+ HttpClient client = new DefaultHttpClient();
+ client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
+
+ HttpGet get = new HttpGet(request);
+ get.setHeader("Accept", "application/rdf+xml");
+
+ StringBuilder result = new StringBuilder();
+ try {
+ HttpResponse response = client.execute(get);
+ StatusLine status = response.getStatusLine();
+ if (status.getStatusCode() != HttpStatus.SC_OK) {
+ String msg = "Bad result from SPARQL endpoint: " + status;
+ System.err.println(msg);
+ throw new HttpClientException(msg);
+ }
+
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ InputStreamReader resultStream = new InputStreamReader(entity.getContent());
+ char[] buffer = new char[BUFFER_SIZE];
+ int len;
+ while ((len = resultStream.read(buffer)) >= 0) result.append(buffer, 0, len);
+ resultStream.close();
+ } else {
+ String msg = "No data in response from SPARQL endpoint";
+ System.out.println(msg);
+ throw new HttpClientException(msg);
+ }
+ } catch (UnsupportedEncodingException e) {
+ System.err.println("Unsupported encoding returned from SPARQL endpoint: " + e.getMessage());
+ throw e;
+ } catch (IOException ioe) {
+ System.err.println("Error communicating with SPARQL endpoint: " + ioe.getMessage());
+ throw ioe;
+ }
+ return result.toString();
+ }
+
+
+ public static class HttpClientException extends Exception {
+ /** Serialization ID */
+ private static final long serialVersionUID = -7563267824587372995L;
+ public HttpClientException() {}
+ public HttpClientException(String msg) {
+ super(msg);
+ }
+ public HttpClientException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ public HttpClientException(Throwable cause) {
+ super(cause);
+ }
+ }
+}
Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java 2009-12-08 08:23:30 UTC (rev 1865)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java 2009-12-08 18:39:03 UTC (rev 1866)
@@ -197,9 +197,6 @@
/** A reference token for keeping the recording phase available until we no longer need it */
private Phase.Token recordingPhaseToken = null;
- /** The list of graphs known to this statement store. */
- private LinkedHashSet<Long> committedGraphNodes = null;
-
/**
* This flag indicates that the current object has been fully written, and may be considered
* as committed when the rest of the system is ready.
@@ -327,7 +324,7 @@
if (!dirty && currentPhase.isInUse()) {
try {
- new Phase();
+ new Phase(true);
} catch (IOException ex) {
throw new StatementStoreException("I/O error", ex);
}
@@ -350,7 +347,7 @@
if (node0 != NONE && node1 != NONE && node2 != NONE && node3 != NONE) {
if (!dirty && currentPhase.isInUse()) {
try {
- new Phase();
+ new Phase(true);
} catch (IOException ex) {
throw new StatementStoreException("I/O error", ex);
}
@@ -367,7 +364,7 @@
// There is at least one triple to remove so protect the
// Tuples as we make changes to the triplestore.
try {
- new Phase();
+ new Phase(true);
} catch (IOException ex) {
throw new StatementStoreException("I/O error", ex);
}
@@ -625,13 +622,13 @@
openMetarootFile(true);
synchronized (committedPhaseLock) {
- committedPhaseToken = new Phase().use();
+ committedPhaseToken = new Phase(true).use();
}
this.phaseNumber = phaseNumber;
phaseIndex = 1;
for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFiles[i].clear();
- new Phase();
+ new Phase(true);
}
@@ -667,9 +664,9 @@
recordingPhaseToken = currentPhase.use();
Phase recordingPhase = currentPhase;
// new Phase() has a side effect of setting the current phase, but we'll keep a local copy anyway
- newCurrent = new Phase();
+ newCurrent = new Phase(false);
// could not set up the committed graphs yet, so send them in after the fact
- newCurrent.graphNodes = recordingPhase.graphNodes;
+ newCurrent.graphNodes = new LinkedHashSet<Long>(recordingPhase.graphNodes);
// Ensure that all data associated with the phase is on disk.
for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFiles[i].force();
@@ -735,7 +732,6 @@
synchronized (committedPhaseLock) {
if (committedPhaseToken != null) committedPhaseToken.release();
committedPhaseToken = recordingPhaseToken;
- committedGraphNodes = currentPhase.graphNodes;
}
recordingPhaseToken = null;
} catch (IOException ex) {
@@ -830,7 +826,7 @@
} catch (IllegalStateException ex) {
throw new SimpleXAResourceException("Cannot construct initial phase.", ex);
}
- new Phase();
+ new Phase(true);
// Invalidate the on-disk metaroot that the new phase will be saved to.
Block block = metarootBlocks[1 - phaseIndex];
@@ -1206,16 +1202,19 @@
/**
* Creates a new phase based on the current state of the database.
* This sets the latest phase on the outer statement store.
+ * @param initializeGraphs scan for graphs to initialize the graphs list.
* @throws IOException Error on the filesystem.
*/
- Phase() throws IOException {
+ Phase(boolean initializeGraphs) throws IOException {
for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFilePhases[i] = tripleAVLFiles[i].new Phase();
currentPhase = this;
dirty = true;
- try {
- graphNodes = committedGraphNodes == null ? scanForGraphs() : new LinkedHashSet<Long>(committedGraphNodes);
- } catch (StatementStoreException e) {
- throw new IOException("Unable to get metadata for phase: " + e.getMessage());
+ if (initializeGraphs) {
+ try {
+ graphNodes = scanForGraphs();
+ } catch (StatementStoreException e) {
+ throw new IOException("Unable to get metadata for phase: " + e.getMessage());
+ }
}
}
More information about the Mulgara-svn
mailing list