You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
(57) |
Apr
(103) |
May
(164) |
Jun
(139) |
Jul
(173) |
Aug
(196) |
Sep
(221) |
Oct
(333) |
Nov
(214) |
Dec
(88) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(163) |
Feb
(165) |
Mar
(98) |
Apr
(93) |
May
(199) |
Jun
(118) |
Jul
(200) |
Aug
(212) |
Sep
(185) |
Oct
(297) |
Nov
(437) |
Dec
(272) |
| 2006 |
Jan
(542) |
Feb
(329) |
Mar
(267) |
Apr
(332) |
May
(267) |
Jun
(130) |
Jul
(161) |
Aug
(348) |
Sep
(166) |
Oct
(305) |
Nov
(173) |
Dec
(173) |
| 2007 |
Jan
(199) |
Feb
(118) |
Mar
(133) |
Apr
(200) |
May
(208) |
Jun
(146) |
Jul
(198) |
Aug
(146) |
Sep
(187) |
Oct
(182) |
Nov
(181) |
Dec
(83) |
| 2008 |
Jan
(252) |
Feb
(124) |
Mar
(124) |
Apr
(101) |
May
(143) |
Jun
(122) |
Jul
(129) |
Aug
(60) |
Sep
(80) |
Oct
(89) |
Nov
(54) |
Dec
(112) |
| 2009 |
Jan
(88) |
Feb
(145) |
Mar
(105) |
Apr
(164) |
May
(123) |
Jun
(154) |
Jul
(374) |
Aug
(341) |
Sep
(219) |
Oct
(137) |
Nov
(373) |
Dec
(240) |
| 2010 |
Jan
(197) |
Feb
(270) |
Mar
(253) |
Apr
(150) |
May
(102) |
Jun
(51) |
Jul
(300) |
Aug
(512) |
Sep
(254) |
Oct
(258) |
Nov
(288) |
Dec
(143) |
| 2011 |
Jan
(238) |
Feb
(179) |
Mar
(253) |
Apr
(332) |
May
(248) |
Jun
(255) |
Jul
(216) |
Aug
(282) |
Sep
(146) |
Oct
(77) |
Nov
(86) |
Dec
(69) |
| 2012 |
Jan
(172) |
Feb
(234) |
Mar
(229) |
Apr
(101) |
May
(212) |
Jun
(267) |
Jul
(129) |
Aug
(210) |
Sep
(239) |
Oct
(271) |
Nov
(368) |
Dec
(220) |
| 2013 |
Jan
(179) |
Feb
(155) |
Mar
(59) |
Apr
(47) |
May
(99) |
Jun
(158) |
Jul
(185) |
Aug
(16) |
Sep
(16) |
Oct
(7) |
Nov
(20) |
Dec
(12) |
| 2014 |
Jan
(21) |
Feb
(17) |
Mar
(18) |
Apr
(13) |
May
(27) |
Jun
(15) |
Jul
(19) |
Aug
(22) |
Sep
(30) |
Oct
(16) |
Nov
(19) |
Dec
(16) |
| 2015 |
Jan
(14) |
Feb
(24) |
Mar
(33) |
Apr
(41) |
May
(14) |
Jun
(80) |
Jul
(53) |
Aug
(8) |
Sep
(7) |
Oct
(15) |
Nov
(13) |
Dec
(2) |
| 2016 |
Jan
(22) |
Feb
(12) |
Mar
(30) |
Apr
(6) |
May
(33) |
Jun
(16) |
Jul
(8) |
Aug
(20) |
Sep
(12) |
Oct
(18) |
Nov
(12) |
Dec
(11) |
| 2017 |
Jan
(24) |
Feb
(26) |
Mar
(47) |
Apr
(23) |
May
(19) |
Jun
(14) |
Jul
(28) |
Aug
(30) |
Sep
(17) |
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
(73) |
Mar
(90) |
Apr
(42) |
May
(116) |
Jun
(90) |
Jul
(127) |
Aug
(103) |
Sep
(56) |
Oct
(42) |
Nov
(95) |
Dec
(58) |
| 2020 |
Jan
(102) |
Feb
(31) |
Mar
(93) |
Apr
(60) |
May
(57) |
Jun
(45) |
Jul
(29) |
Aug
(32) |
Sep
(44) |
Oct
(86) |
Nov
(51) |
Dec
(71) |
| 2021 |
Jan
(44) |
Feb
(25) |
Mar
(78) |
Apr
(130) |
May
(64) |
Jun
(74) |
Jul
(21) |
Aug
(64) |
Sep
(40) |
Oct
(43) |
Nov
(21) |
Dec
(99) |
| 2022 |
Jan
(154) |
Feb
(64) |
Mar
(45) |
Apr
(95) |
May
(62) |
Jun
(48) |
Jul
(73) |
Aug
(37) |
Sep
(71) |
Oct
(27) |
Nov
(40) |
Dec
(65) |
| 2023 |
Jan
(89) |
Feb
(130) |
Mar
(124) |
Apr
(50) |
May
(93) |
Jun
(46) |
Jul
(45) |
Aug
(68) |
Sep
(62) |
Oct
(71) |
Nov
(108) |
Dec
(82) |
| 2024 |
Jan
(53) |
Feb
(76) |
Mar
(64) |
Apr
(75) |
May
(36) |
Jun
(54) |
Jul
(98) |
Aug
(137) |
Sep
(58) |
Oct
(177) |
Nov
(84) |
Dec
(52) |
| 2025 |
Jan
(70) |
Feb
(53) |
Mar
(72) |
Apr
(47) |
May
(88) |
Jun
(49) |
Jul
(86) |
Aug
(51) |
Sep
(65) |
Oct
(91) |
Nov
(18) |
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
(17) |
2
(10) |
3
(1) |
4
(5) |
5
(16) |
6
(28) |
|
7
(13) |
8
(21) |
9
(9) |
10
(12) |
11
(7) |
12
(5) |
13
(20) |
|
14
|
15
(5) |
16
(12) |
17
(6) |
18
(5) |
19
(7) |
20
(6) |
|
21
(8) |
22
(3) |
23
(3) |
24
(3) |
25
(10) |
26
|
27
(15) |
|
28
(6) |
29
|
30
(3) |
31
(11) |
|
|
|
|
From: <br...@us...> - 2006-05-31 21:35:25
|
Revision: 3639 Author: brihaye Date: 2006-05-31 14:35:11 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3639&view=rev Log Message: ----------- Stupid provisional constraint to skip tests that are known to carsh the XQTS. To be refined and externalized in a file. Modified Paths: -------------- trunk/eXist-1.0/webapp/xqts/xqts.xql Modified: trunk/eXist-1.0/webapp/xqts/xqts.xql =================================================================== --- trunk/eXist-1.0/webapp/xqts/xqts.xql 2006-05-31 20:23:08 UTC (rev 3638) +++ trunk/eXist-1.0/webapp/xqts/xqts.xql 2006-05-31 21:35:11 UTC (rev 3639) @@ -262,7 +262,7 @@ (: Create the collection hierarchy for this group and get the results.xml doc to append to. :) let $resultsDoc := xqts:create-collections($group) - let $tests := $group/catalog:test-case + let $tests := $group/catalog:test-case[not(starts-with(@name, 'Constr-inscope-1'))] return ( (: Execute the test cases :) for $test in $tests This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 20:23:18
|
Revision: 3638 Author: wolfgang_m Date: 2006-05-31 13:23:08 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3638&view=rev Log Message: ----------- changed run.sh to use start.jar and pass profiler settings Modified Paths: -------------- trunk/eXist-1.0/bin/run.sh Modified: trunk/eXist-1.0/bin/run.sh =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 20:12:48
|
Revision: 3637 Author: wolfgang_m Date: 2006-05-31 13:12:39 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3637&view=rev Log Message: ----------- WebDAV GET did now return truncated documents. Removing the Content-Length seems to fix this. For XML resources, the "real" content length depends on serialization parameters and is impossible to calculate in advance. Modified Paths: -------------- trunk/eXist-1.0/src/org/exist/http/webdav/methods/Get.java Modified: trunk/eXist-1.0/src/org/exist/http/webdav/methods/Get.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/webdav/methods/Get.java 2006-05-31 16:42:43 UTC (rev 3636) +++ trunk/eXist-1.0/src/org/exist/http/webdav/methods/Get.java 2006-05-31 20:12:39 UTC (rev 3637) @@ -117,7 +117,7 @@ response.setContentType(metadata.getMimeType()); response.addDateHeader("Last-Modified", metadata.getLastModified()); - response.setContentLength(resource.getContentLength()); +// response.setContentLength(resource.getContentLength()); ServletOutputStream os = response.getOutputStream(); if(resource.getResourceType() == DocumentImpl.XML_FILE) { @@ -141,7 +141,7 @@ os.flush(); } - os.flush(); +// os.flush(); } catch (EXistException e) { throw new ServletException(SERIALIZE_ERROR + e.getMessage(), e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 16:43:54
|
Revision: 3636 Author: wolfgang_m Date: 2006-05-31 09:42:43 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3636&view=rev Log Message: ----------- Set svn:eol-style property to LF to avoid trouble with mixed CRLF and LF in generated files. Property Changed: ---------------- branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryLexer.java branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryParser.java branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryTreeParser.java Property changes on: branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryLexer.java ___________________________________________________________________ Name: svn:eol-style - native + LF Property changes on: branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryParser.java ___________________________________________________________________ Name: svn:eol-style - native + LF Property changes on: branches/DLN/eXist-1.0/src/org/exist/xquery/parser/XQueryTreeParser.java ___________________________________________________________________ Name: svn:eol-style - native + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 16:06:19
|
Revision: 3635 Author: wolfgang_m Date: 2006-05-31 09:05:50 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3635&view=rev Log Message: ----------- DLN: the improved ancestor-descendant join algorithms should finally work now (well, all tests are running through at least). Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/xquery/LocationStep.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/AllTests.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java Modified: branches/DLN/eXist-1.0/src/org/exist/xquery/LocationStep.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xquery/LocationStep.java 2006-05-31 16:05:09 UTC (rev 3634) +++ branches/DLN/eXist-1.0/src/org/exist/xquery/LocationStep.java 2006-05-31 16:05:50 UTC (rev 3635) @@ -25,10 +25,8 @@ import org.exist.dom.DocumentImpl; import org.exist.dom.DocumentSet; import org.exist.dom.ExtArrayNodeSet; -import org.exist.dom.NodeImpl; import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; -import org.exist.dom.NodeSetHelper; import org.exist.dom.NodeVisitor; import org.exist.dom.StoredNode; import org.exist.dom.VirtualNodeSet; @@ -525,7 +523,7 @@ NodeId parentId = current.getNodeId().getParentId(); if(parentId.getTreeLevel() == 1 && current.getDocument().getCollection().isTempCollection()) continue; - StoredNode parentNode = (StoredNode) context.getBroker().objectWith(current.getOwnerDocument(), parentId); + StoredNode parentNode = context.getBroker().objectWith(current.getOwnerDocument(), parentId); visitor.setContext(current); parentNode.accept(visitor); } Modified: branches/DLN/eXist-1.0/src/org/exist/xquery/test/AllTests.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xquery/test/AllTests.java 2006-05-31 16:05:09 UTC (rev 3634) +++ branches/DLN/eXist-1.0/src/org/exist/xquery/test/AllTests.java 2006-05-31 16:05:50 UTC (rev 3635) @@ -41,7 +41,7 @@ TestSuite suite = new TestSuite("Test for org.exist.xquery.test"); //$JUnit-BEGIN$ XPathQueryTest.setURI("xmldb:exist://" + DBBroker.ROOT_COLLECTION); - suite.addTestSuite(XQueryUpdateTest.class); +// suite.addTestSuite(XQueryUpdateTest.class); suite.addTestSuite(XQueryFunctionsTest.class); suite.addTestSuite(JavaFunctionsTest.class); suite.addTestSuite(XPathQueryTest.class); Modified: branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java 2006-05-31 16:05:09 UTC (rev 3634) +++ branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java 2006-05-31 16:05:50 UTC (rev 3635) @@ -1507,6 +1507,7 @@ fail(e.getMessage()); } } + /** * @return * @throws XMLDBException Modified: branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java 2006-05-31 16:05:09 UTC (rev 3634) +++ branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java 2006-05-31 16:05:50 UTC (rev 3635) @@ -43,381 +43,381 @@ protected static String UPDATE_XML = "<progress total=\"100\" done=\"0\" failed=\"0\" passed=\"0\"/>"; - protected final static int ITEMS_TO_APPEND = 2000; + protected final static int ITEMS_TO_APPEND = 1000; private BrokerPool pool; -// public void testAppend() { -// DBBroker broker = null; -// try { -// System.out.println("testAppend() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// String query = -// " declare variable $i external;\n" + -// " update insert\n" + -// " <product id='id{$i}' num='{$i}'>\n" + -// " <description>Description {$i}</description>\n" + -// " <price>{$i + 1.0}</price>\n" + -// " <stock>{$i * 10}</stock>\n" + -// " </product>\n" + -// " into /products"; -// XQueryContext context = xquery.newContext(AccessContext.TEST); -// CompiledXQuery compiled = xquery.compile(context, query); -// for (int i = 0; i < ITEMS_TO_APPEND; i++) { -// context.declareVariable("i", new Integer(i)); -// xquery.execute(compiled, null); -// } -// -// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// Serializer serializer = broker.getSerializer(); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// seq = xquery.execute("//product", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND, seq.getLength()); -// -// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND, seq.getLength()); -// System.out.println("testAppend: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testAppendAttributes() { -// testAppend(); -// DBBroker broker = null; -// try { -// System.out.println("testAppendAttributes() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// String query = -// " declare variable $i external;\n" + -// " update insert\n" + -// " attribute name { concat('n', $i) }\n" + -// " into //product[@num = $i]"; -// XQueryContext context = xquery.newContext(AccessContext.TEST); -// CompiledXQuery compiled = xquery.compile(context, query); -// for (int i = 0; i < ITEMS_TO_APPEND; i++) { -// context.declareVariable("i", new Integer(i)); -// xquery.execute(compiled, null); -// } -// -// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// Serializer serializer = broker.getSerializer(); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// seq = xquery.execute("//product", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND, seq.getLength()); -// -// seq = xquery.execute("//product[@name = 'n20']", null, AccessContext.TEST); -// assertEquals(1, seq.getLength()); -// -// store(broker, "attribs.xml", "<test attr1='aaa' attr2='bbb'>ccc</test>"); -// query = "update insert attribute attr1 { 'eee' } into /test"; -// -// System.out.println("testing duplicate attribute ..."); -// xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("/test[@attr1 = 'eee']", null, AccessContext.TEST); -// assertEquals(1, seq.getLength()); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// System.out.println("testAppendAttributes: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testInsertBefore() { -// DBBroker broker = null; -// try { -// System.out.println("testInsertBefore() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// String query = -// " update insert\n" + -// " <product id='original'>\n" + -// " <description>Description</description>\n" + -// " <price>0</price>\n" + -// " <stock>10</stock>\n" + -// " </product>\n" + -// " into /products"; -// -// XQuery xquery = broker.getXQueryService(); -// xquery.execute(query, null, AccessContext.TEST); -// -// query = -// " declare variable $i external;\n" + -// " update insert\n" + -// " <product id='id{$i}'>\n" + -// " <description>Description {$i}</description>\n" + -// " <price>{$i + 1.0}</price>\n" + -// " <stock>{$i * 10}</stock>\n" + -// " </product>\n" + -// " preceding /products/product[1]"; -// XQueryContext context = xquery.newContext(AccessContext.TEST); -// CompiledXQuery compiled = xquery.compile(context, query); -// for (int i = 0; i < ITEMS_TO_APPEND; i++) { -// context.declareVariable("i", new Integer(i)); -// xquery.execute(compiled, null); -// } -// -// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// Serializer serializer = broker.getSerializer(); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// seq = xquery.execute("//product", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); -// -// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND, seq.getLength()); -// System.out.println("testInsertBefore: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testInsertAfter() { -// DBBroker broker = null; -// try { -// System.out.println("testInsertAfter() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// String query = -// " update insert\n" + -// " <product id='original'>\n" + -// " <description>Description</description>\n" + -// " <price>0</price>\n" + -// " <stock>10</stock>\n" + -// " </product>\n" + -// " into /products"; -// -// XQuery xquery = broker.getXQueryService(); -// xquery.execute(query, null, AccessContext.TEST); -// -// query = -// " declare variable $i external;\n" + -// " update insert\n" + -// " <product id='id{$i}'>\n" + -// " <description>Description {$i}</description>\n" + -// " <price>{$i + 1.0}</price>\n" + -// " <stock>{$i * 10}</stock>\n" + -// " </product>\n" + -// " following /products/product[1]"; -// XQueryContext context = xquery.newContext(AccessContext.TEST); -// CompiledXQuery compiled = xquery.compile(context, query); -// for (int i = 0; i < ITEMS_TO_APPEND; i++) { -// context.declareVariable("i", new Integer(i)); -// xquery.execute(compiled, null); -// } -// -// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// Serializer serializer = broker.getSerializer(); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// seq = xquery.execute("//product", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); -// -// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); -// assertEquals(ITEMS_TO_APPEND, seq.getLength()); -// System.out.println("testInsertAfter: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testUpdate() { -// testAppend(); -// DBBroker broker = null; -// try { -// System.out.println("testUpdate() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// -// String query = -// "for $prod in //product return\n" + -// " update value $prod/description\n" + -// " with 'Updated Description'"; -// Sequence seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product[starts-with(description, 'Updated')]", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// Serializer serializer = broker.getSerializer(); -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// query = -// "for $prod in //product return\n" + -// " update value $prod/stock/text()\n" + -// " with 400"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product[stock = 400]", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// query = -// "for $prod in //product return\n" + -// " update value $prod/@num\n" + -// " with xs:int($prod/@num) * 3"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// seq = xquery.execute("//product[@num = 3]", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); -// -// query = -// "for $prod in //product return\n" + -// " update value $prod/stock\n" + -// " with (<local>10</local>,<external>1</external>)"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("/products", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 1); -// -// seq = xquery.execute("//product/stock/external[. = 1]", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// System.out.println("testUpdate: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testRemove() { -// testAppend(); -// -// DBBroker broker = null; -// try { -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// -// String query = -// "for $prod in //product return\n" + -// " update delete $prod\n"; -// Sequence seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product", null, AccessContext.TEST); -// assertEquals(seq.getLength(), 0); -// -// System.out.println("testRemove: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testRename() { -// testAppend(); -// DBBroker broker = null; -// try { -// System.out.println("testUpdate() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// -// String query = -// "for $prod in //product return\n" + -// " update rename $prod/description as 'desc'\n"; -// Sequence seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product/desc", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// query = -// "for $prod in //product return\n" + -// " update rename $prod/@num as 'count'\n"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product/@count", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// System.out.println("testUpdate: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } -// -// public void testReplace() { -// testAppend(); -// DBBroker broker = null; -// try { -// System.out.println("testReplace() ...\n"); -// broker = pool.get(SecurityManager.SYSTEM_USER); -// -// XQuery xquery = broker.getXQueryService(); -// -// String query = -// "for $prod in //product return\n" + -// " update replace $prod/description with <desc>An updated description.</desc>\n"; -// Sequence seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product/desc", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// query = -// "for $prod in //product return\n" + -// " update replace $prod/@num with '1'\n"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product/@num", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// query = -// "for $prod in //product return\n" + -// " update replace $prod/desc/text() with 'A new update'\n"; -// seq = xquery.execute(query, null, AccessContext.TEST); -// -// seq = xquery.execute("//product[starts-with(desc, 'A new')]", null, AccessContext.TEST); -// assertEquals(seq.getLength(), ITEMS_TO_APPEND); -// -// System.out.println("testUpdate: PASS"); -// } catch (Exception e) { -// e.printStackTrace(); -// fail(e.getMessage()); -// } finally { -// pool.release(broker); -// } -// } + public void testAppend() { + DBBroker broker = null; + try { + System.out.println("testAppend() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + String query = + " declare variable $i external;\n" + + " update insert\n" + + " <product id='id{$i}' num='{$i}'>\n" + + " <description>Description {$i}</description>\n" + + " <price>{$i + 1.0}</price>\n" + + " <stock>{$i * 10}</stock>\n" + + " </product>\n" + + " into /products"; + XQueryContext context = xquery.newContext(AccessContext.TEST); + CompiledXQuery compiled = xquery.compile(context, query); + for (int i = 0; i < ITEMS_TO_APPEND; i++) { + context.declareVariable("i", new Integer(i)); + xquery.execute(compiled, null); + } + + Sequence seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + Serializer serializer = broker.getSerializer(); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + seq = xquery.execute("//product", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND, seq.getLength()); + + seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND, seq.getLength()); + System.out.println("testAppend: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + public void testAppendAttributes() { + testAppend(); + DBBroker broker = null; + try { + System.out.println("testAppendAttributes() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + String query = + " declare variable $i external;\n" + + " update insert\n" + + " attribute name { concat('n', $i) }\n" + + " into //product[@num = $i]"; + XQueryContext context = xquery.newContext(AccessContext.TEST); + CompiledXQuery compiled = xquery.compile(context, query); + for (int i = 0; i < ITEMS_TO_APPEND; i++) { + context.declareVariable("i", new Integer(i)); + xquery.execute(compiled, null); + } + + Sequence seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + Serializer serializer = broker.getSerializer(); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + seq = xquery.execute("//product", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND, seq.getLength()); + + seq = xquery.execute("//product[@name = 'n20']", null, AccessContext.TEST); + assertEquals(1, seq.getLength()); + + store(broker, "attribs.xml", "<test attr1='aaa' attr2='bbb'>ccc</test>"); + query = "update insert attribute attr1 { 'eee' } into /test"; + + System.out.println("testing duplicate attribute ..."); + xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("/test[@attr1 = 'eee']", null, AccessContext.TEST); + assertEquals(1, seq.getLength()); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + System.out.println("testAppendAttributes: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testInsertBefore() { + DBBroker broker = null; + try { + System.out.println("testInsertBefore() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + String query = + " update insert\n" + + " <product id='original'>\n" + + " <description>Description</description>\n" + + " <price>0</price>\n" + + " <stock>10</stock>\n" + + " </product>\n" + + " into /products"; + + XQuery xquery = broker.getXQueryService(); + xquery.execute(query, null, AccessContext.TEST); + + query = + " declare variable $i external;\n" + + " update insert\n" + + " <product id='id{$i}'>\n" + + " <description>Description {$i}</description>\n" + + " <price>{$i + 1.0}</price>\n" + + " <stock>{$i * 10}</stock>\n" + + " </product>\n" + + " preceding /products/product[1]"; + XQueryContext context = xquery.newContext(AccessContext.TEST); + CompiledXQuery compiled = xquery.compile(context, query); + for (int i = 0; i < ITEMS_TO_APPEND; i++) { + context.declareVariable("i", new Integer(i)); + xquery.execute(compiled, null); + } + + Sequence seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + Serializer serializer = broker.getSerializer(); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + seq = xquery.execute("//product", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); + + seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND, seq.getLength()); + System.out.println("testInsertBefore: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testInsertAfter() { + DBBroker broker = null; + try { + System.out.println("testInsertAfter() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + String query = + " update insert\n" + + " <product id='original'>\n" + + " <description>Description</description>\n" + + " <price>0</price>\n" + + " <stock>10</stock>\n" + + " </product>\n" + + " into /products"; + + XQuery xquery = broker.getXQueryService(); + xquery.execute(query, null, AccessContext.TEST); + + query = + " declare variable $i external;\n" + + " update insert\n" + + " <product id='id{$i}'>\n" + + " <description>Description {$i}</description>\n" + + " <price>{$i + 1.0}</price>\n" + + " <stock>{$i * 10}</stock>\n" + + " </product>\n" + + " following /products/product[1]"; + XQueryContext context = xquery.newContext(AccessContext.TEST); + CompiledXQuery compiled = xquery.compile(context, query); + for (int i = 0; i < ITEMS_TO_APPEND; i++) { + context.declareVariable("i", new Integer(i)); + xquery.execute(compiled, null); + } + + Sequence seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + Serializer serializer = broker.getSerializer(); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + seq = xquery.execute("//product", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); + + seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); + assertEquals(ITEMS_TO_APPEND, seq.getLength()); + System.out.println("testInsertAfter: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testUpdate() { + testAppend(); + DBBroker broker = null; + try { + System.out.println("testUpdate() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + + String query = + "for $prod in //product return\n" + + " update value $prod/description\n" + + " with 'Updated Description'"; + Sequence seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product[starts-with(description, 'Updated')]", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + Serializer serializer = broker.getSerializer(); + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + query = + "for $prod in //product return\n" + + " update value $prod/stock/text()\n" + + " with 400"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product[stock = 400]", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + query = + "for $prod in //product return\n" + + " update value $prod/@num\n" + + " with xs:int($prod/@num) * 3"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + seq = xquery.execute("//product[@num = 3]", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); + + query = + "for $prod in //product return\n" + + " update value $prod/stock\n" + + " with (<local>10</local>,<external>1</external>)"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("/products", null, AccessContext.TEST); + assertEquals(seq.getLength(), 1); + + seq = xquery.execute("//product/stock/external[. = 1]", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + System.out.println("testUpdate: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testRemove() { + testAppend(); + + DBBroker broker = null; + try { + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + + String query = + "for $prod in //product return\n" + + " update delete $prod\n"; + Sequence seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product", null, AccessContext.TEST); + assertEquals(seq.getLength(), 0); + + System.out.println("testRemove: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testRename() { + testAppend(); + DBBroker broker = null; + try { + System.out.println("testUpdate() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + + String query = + "for $prod in //product return\n" + + " update rename $prod/description as 'desc'\n"; + Sequence seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product/desc", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + query = + "for $prod in //product return\n" + + " update rename $prod/@num as 'count'\n"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product/@count", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + System.out.println("testUpdate: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + public void testReplace() { + testAppend(); + DBBroker broker = null; + try { + System.out.println("testReplace() ...\n"); + broker = pool.get(SecurityManager.SYSTEM_USER); + + XQuery xquery = broker.getXQueryService(); + + String query = + "for $prod in //product return\n" + + " update replace $prod/description with <desc>An updated description.</desc>\n"; + Sequence seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product/desc", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + query = + "for $prod in //product return\n" + + " update replace $prod/@num with '1'\n"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product/@num", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + query = + "for $prod in //product return\n" + + " update replace $prod/desc/text() with 'A new update'\n"; + seq = xquery.execute(query, null, AccessContext.TEST); + + seq = xquery.execute("//product[starts-with(desc, 'A new')]", null, AccessContext.TEST); + assertEquals(seq.getLength(), ITEMS_TO_APPEND); + + System.out.println("testUpdate: PASS"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + public void testAttrUpdate() { DBBroker broker = null; try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 16:05:18
|
Revision: 3634 Author: wolfgang_m Date: 2006-05-31 09:05:09 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3634&view=rev Log Message: ----------- DLN: the improved ancestor-descendant join algorithms should finally work now (well, all tests are running through at least). Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/dom/ByDocumentIterator.java branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java Modified: branches/DLN/eXist-1.0/src/org/exist/dom/ByDocumentIterator.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/ByDocumentIterator.java 2006-05-31 16:04:22 UTC (rev 3633) +++ branches/DLN/eXist-1.0/src/org/exist/dom/ByDocumentIterator.java 2006-05-31 16:05:09 UTC (rev 3634) @@ -7,4 +7,6 @@ public boolean hasNextNode(); public NodeProxy nextNode(); + + public NodeProxy peekNode(); } Modified: branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-31 16:04:22 UTC (rev 3633) +++ branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-31 16:05:09 UTC (rev 3634) @@ -966,7 +966,7 @@ public boolean hasNextNode() { return next != null; } - + public NodeProxy nextNode() { if (next == null) return null; @@ -976,5 +976,9 @@ next = currentPart.get(pos); return n; } + + public NodeProxy peekNode() { + return next; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 16:04:34
|
Revision: 3633 Author: wolfgang_m Date: 2006-05-31 09:04:22 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3633&view=rev Log Message: ----------- DLN: the improved ancestor-descendant join algorithms should finally work now (well, all tests are running through at least). Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java branches/DLN/eXist-1.0/src/org/exist/storage/NativeElementIndex.java branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java Modified: branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java 2006-05-31 16:03:32 UTC (rev 3632) +++ branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java 2006-05-31 16:04:22 UTC (rev 3633) @@ -462,11 +462,6 @@ if (qnameValueIndex != null) qnameValueIndex.endElement((ElementImpl) node, currentPath, content); } - - // TODO move_to NativeElementIndex; name change (See ContentLoadingObserver ): addRow() --> endElement() - // save element by calling ElementIndex - elementIndex.setDocument(doc); - elementIndex.addNode(node.getQName(), p); } /** Takes care of actually remove entries from the indices; @@ -2896,6 +2891,10 @@ // qnameValueIndex.startElement((ElementImpl)node, currentPath, index); notifyStartElement((ElementImpl)node, currentPath, index); + NodeProxy p = new NodeProxy(node); + p.setIndexType(indexType); + elementIndex.setDocument(doc); + elementIndex.addNode(node.getQName(), p); break; case Node.ATTRIBUTE_NODE : Modified: branches/DLN/eXist-1.0/src/org/exist/storage/NativeElementIndex.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/NativeElementIndex.java 2006-05-31 16:03:32 UTC (rev 3632) +++ branches/DLN/eXist-1.0/src/org/exist/storage/NativeElementIndex.java 2006-05-31 16:04:22 UTC (rev 3633) @@ -166,7 +166,8 @@ LOG.warn("IO error while writing structural index: " + e.getMessage(), e); } StorageAddress.write(storedNode.getInternalAddress(), os); - } + } + broker.getBrokerPool().getNodeFactory().writeEndOfDocument(os); os.writeFixedInt(lenOffset, os.position() - lenOffset - 4); //Compute a key for the node ElementValue ref; @@ -271,6 +272,7 @@ newGIDList.add(new NodeProxy(doc, nodeId, address)); } } + broker.getBrokerPool().getNodeFactory().createFromStream(is); } } } catch (EOFException e) { @@ -296,7 +298,8 @@ LOG.warn("IO error while writing structural index: " + e.getMessage(), e); } StorageAddress.write(storedNode.getInternalAddress(), os); - } + } + broker.getBrokerPool().getNodeFactory().writeEndOfDocument(os); os.writeFixedInt(lenOffset, os.position() - lenOffset - 4); } } @@ -459,7 +462,7 @@ } while (is.available() > 0) { int storedDocId = is.readInt(); - is.readByte(); + byte ordered = is.readByte(); int gidsCount = is.readInt(); //TOUNDERSTAND -pb int size = is.readFixedInt(); @@ -488,6 +491,8 @@ sameDocSet = false; } } + nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); + result.setSorted(storedDocument, ordered == ENTRIES_ORDERED); } } catch (EOFException e) { //EOFExceptions are expected here @@ -521,6 +526,7 @@ */ public NodeSet findDescendantsByTagName(byte type, QName qname, int axis, DocumentSet docs, ExtArrayNodeSet contextSet, int contextId) { +// LOG.debug(contextSet.toString()); short nodeType = getIndexType(type); ByDocumentIterator citer = contextSet.iterateByDocument(); final ExtArrayNodeSet result = new ExtArrayNodeSet(docs.getLength(), 256); @@ -575,13 +581,14 @@ continue; } NodeId ancestorId = ancestor.getNodeId(); - ((BFile.PageInputStream)is).mark(); - + long prevPosition = ((BFile.PageInputStream)is).position(); + long markedPosition = prevPosition; + NodeId lastMarked = ancestorId; + //Process the nodes for the current document NodeId nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); long address = StorageAddress.read(is); - int k = 0, marked = 0; - int found = 0; + while (true) { int relation = nodeId.computeRelation(ancestorId); // LOG.debug(ancestorId + " -> " + nodeId + ": " + relation); @@ -602,39 +609,40 @@ storedNode.deepCopyContext(ancestor, contextId); } else storedNode.copyContext(ancestor); - found++; } - if (k + 1 < gidsCount) { + prevPosition = ((BFile.PageInputStream)is).position(); + NodeId next = broker.getBrokerPool().getNodeFactory().createFromStream(is); + if (next != DLN.END_OF_DOCUMENT) { // retrieve the next descendant from the stream - k++; - nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); + nodeId = next; address = StorageAddress.read(is); } else { // no more descendants. check if there are more ancestors if (citer.hasNextNode()) { - ancestor = citer.nextNode(); + NodeProxy nextNode = citer.peekNode(); // reached the end of the input stream: // if the ancestor set has more nodes and the following ancestor // is a descendant of the previous one, we have to rescan the input stream // for further matches - if (ancestor.getNodeId().isDescendantOf(ancestorId)) { - ((BFile.PageInputStream)is).rewind(); - k = marked; + if (nextNode.getNodeId().isDescendantOf(ancestorId)) { + prevPosition = markedPosition; + ((BFile.PageInputStream)is).seek(markedPosition); nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); address = StorageAddress.read(is); + ancestor = citer.nextNode(); ancestorId = ancestor.getNodeId(); } else { - ancestorId = ancestor.getNodeId(); +// ancestorId = ancestor.getNodeId(); break; } - } else + } else { break; + } } } else { // current node is not a descendant of the ancestor node. Compare the // node ids and proceed with next descendant or ancestor. int cmp = ancestorId.compareTo(nodeId); -// LOG.debug("cmp: " + ancestor.getNodeId() + " -> " + nodeId + ": " + cmp); if (cmp < 0) { // check if we have more ancestors if (citer.hasNextNode()) { @@ -645,32 +653,56 @@ if (next.getNodeId().isDescendantOf(ancestorId)) { // rewind the input stream to the position from where we started // for the previous ancestor node - ((BFile.PageInputStream)is).rewind(); - k = marked; + ((BFile.PageInputStream)is).seek(markedPosition); nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); address = StorageAddress.read(is); } else { // mark the current position in the input stream - ((BFile.PageInputStream)is).mark(); - marked = k; + if (!next.getNodeId().isDescendantOf(lastMarked)) { + lastMarked = next.getNodeId(); + markedPosition = prevPosition; + } } ancestor = next; ancestorId = ancestor.getNodeId(); } else { // no more ancestors: skip the remaining descendants for this document - while (++k < gidsCount) { - broker.getBrokerPool().getNodeFactory().createFromStream(is); + while (broker.getBrokerPool().getNodeFactory().createFromStream(is) + != DLN.END_OF_DOCUMENT) { StorageAddress.read(is); } break; } } else { // load the next descendant from the input stream - if (++k < gidsCount) { - nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); + prevPosition = ((BFile.PageInputStream)is).position(); + NodeId nextId = broker.getBrokerPool().getNodeFactory().createFromStream(is); + if (nextId != DLN.END_OF_DOCUMENT) { + nodeId = nextId; address = StorageAddress.read(is); - } else - break; + } else { + // check if we have more ancestors + if (citer.hasNextNode()) { + ancestor = citer.nextNode(); + // if the ancestor set has more nodes and the following ancestor + // is a descendant of the previous one, we have to rescan the input stream + // for further matches + if (ancestor.getNodeId().isDescendantOf(ancestorId)) { + // rewind the input stream to the position from where we started + // for the previous ancestor node + prevPosition = markedPosition; + ((BFile.PageInputStream)is).seek(markedPosition); + nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is); + address = StorageAddress.read(is); + ancestorId = ancestor.getNodeId(); + } else { + ancestorId = ancestor.getNodeId(); + break; + } + } else { + break; + } + } } } } Modified: branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-31 16:03:32 UTC (rev 3632) +++ branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-31 16:04:22 UTC (rev 3633) @@ -2192,9 +2192,9 @@ public long getAddress(); - public void mark(); + public long position(); - public void rewind() throws IOException; + public void seek(long position) throws IOException; } /** @@ -2206,8 +2206,6 @@ implements PageInputStream { private long address = 0L; - - private int mark = 0; public SimplePageInput() { } @@ -2221,13 +2219,12 @@ return address; } - public void mark() { - mark = position; + public long position() { + return position; } - public void rewind() { - LOG.debug("REWIND to " + mark); - position = mark; + public void seek(long pos) throws IOException { + this.position = (int) pos; } } @@ -2242,12 +2239,9 @@ private int pageLen; - private int offset = 0; + private short offset = 0; private long address = 0L; - - private int markedOffset; - private long markedPage; public MultiPageInput() { } @@ -2260,9 +2254,6 @@ pageLen = fileHeader.getWorkSize(); dataCache.add(first, 3); this.address = address; - - markedOffset = offset; - markedPage = first.getPageNum(); } public long getAddress() { @@ -2491,19 +2482,20 @@ } } - public void mark() { - markedOffset = offset; - markedPage = nextPage.getPageNum(); + public long position() { + return StorageAddress.createPointer((int) nextPage.getPageNum(), offset); } - public void rewind() throws IOException { + public void seek(long position) throws IOException { + int newPage = StorageAddress.pageFromPointer(position); + short newOffset = StorageAddress.tidFromPointer(position); try { lock.acquire(Lock.READ_LOCK); - nextPage = getSinglePage(markedPage); + nextPage = getSinglePage(newPage); pageLen = nextPage.ph.getDataLength(); if (pageLen > fileHeader.getWorkSize()) pageLen = fileHeader.getWorkSize(); - offset = markedOffset; + offset = newOffset; dataCache.add(nextPage); } catch (LockException e) { throw new IOException("failed to acquire a read lock on " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 16:03:44
|
Revision: 3632 Author: wolfgang_m Date: 2006-05-31 09:03:32 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3632&view=rev Log Message: ----------- DLN: the improved ancestor-descendant join algorithms should finally work now (well, all tests are running through at least). Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/numbering/DLN.java branches/DLN/eXist-1.0/src/org/exist/numbering/DLNBase.java branches/DLN/eXist-1.0/src/org/exist/numbering/DLNFactory.java branches/DLN/eXist-1.0/src/org/exist/numbering/NodeId.java branches/DLN/eXist-1.0/src/org/exist/numbering/NodeIdFactory.java Modified: branches/DLN/eXist-1.0/src/org/exist/numbering/DLN.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/numbering/DLN.java 2006-05-31 08:28:12 UTC (rev 3631) +++ branches/DLN/eXist-1.0/src/org/exist/numbering/DLN.java 2006-05-31 16:03:32 UTC (rev 3632) @@ -113,8 +113,8 @@ * @param is * @throws IOException */ - public DLN(VariableByteInput is) throws IOException { - super(is); + public DLN(short bitCnt, VariableByteInput is) throws IOException { + super(bitCnt, is); } /** @@ -326,5 +326,8 @@ id0 = new DLN("1.1/1"); System.out.println("Descendant:\n" + id1.toBitString() + "\n" + id0.toBitString() + "\n: " + id1.isDescendantOf(id0)); + + System.out.println("Doc node: " + DOCUMENT_NODE.toString() + " - " + + ((DLN)DOCUMENT_NODE).bitIndex); } } Modified: branches/DLN/eXist-1.0/src/org/exist/numbering/DLNBase.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/numbering/DLNBase.java 2006-05-31 08:28:12 UTC (rev 3631) +++ branches/DLN/eXist-1.0/src/org/exist/numbering/DLNBase.java 2006-05-31 16:03:32 UTC (rev 3632) @@ -136,8 +136,7 @@ bitIndex = nbits - 1; } - public DLNBase(VariableByteInput is) throws IOException { - final int bitCnt = is.readShort(); + public DLNBase(short bitCnt, VariableByteInput is) throws IOException { int blen = bitCnt / 8; if (bitCnt % 8 > 0) ++blen; @@ -211,6 +210,9 @@ int units = unitsUsed(startBit, bits); startBit += units; int numBits = bitWidth(units); +// System.err.println("startBit: " + startBit + "; bitIndex: " + bitIndex + +// "; units: " + units + ": numBits: " + numBits + " " + toBitString() + +// "; bits: " + bits.length); int id = 0; for (int i = numBits - 1; i >= 0; i--) { if ((bits[startBit >> UNIT_SHIFT] & (1 << ((7 - startBit++) & 7))) != 0) { Modified: branches/DLN/eXist-1.0/src/org/exist/numbering/DLNFactory.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/numbering/DLNFactory.java 2006-05-31 08:28:12 UTC (rev 3631) +++ branches/DLN/eXist-1.0/src/org/exist/numbering/DLNFactory.java 2006-05-31 16:03:32 UTC (rev 3632) @@ -22,6 +22,7 @@ package org.exist.numbering; import org.exist.storage.io.VariableByteInput; +import org.exist.storage.io.VariableByteOutputStream; import java.io.IOException; @@ -40,7 +41,8 @@ } public NodeId createFromStream(VariableByteInput is) throws IOException { - return new DLN(is); + short bitCnt = is.readShort(); + return bitCnt == 0 ? DLN.END_OF_DOCUMENT : new DLN(bitCnt, is); } public NodeId createFromData(int sizeHint, byte[] data, int startOffset) { @@ -58,4 +60,8 @@ public int lengthInBytes(int units, byte[] data, int startOffset) { return DLN.getLengthInBytes(units, data, startOffset); } + + public void writeEndOfDocument(VariableByteOutputStream os) { + os.writeShort(0); + } } Modified: branches/DLN/eXist-1.0/src/org/exist/numbering/NodeId.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/numbering/NodeId.java 2006-05-31 08:28:12 UTC (rev 3631) +++ branches/DLN/eXist-1.0/src/org/exist/numbering/NodeId.java 2006-05-31 16:03:32 UTC (rev 3632) @@ -39,6 +39,8 @@ */ public final static NodeId DOCUMENT_NODE = new DLN(0); + public final static NodeId END_OF_DOCUMENT = new DLN(0); + public final static int IS_CHILD = 1; public final static int IS_DESCENDANT = 2; public final static int IS_SELF = 3; Modified: branches/DLN/eXist-1.0/src/org/exist/numbering/NodeIdFactory.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/numbering/NodeIdFactory.java 2006-05-31 08:28:12 UTC (rev 3631) +++ branches/DLN/eXist-1.0/src/org/exist/numbering/NodeIdFactory.java 2006-05-31 16:03:32 UTC (rev 3632) @@ -22,6 +22,7 @@ package org.exist.numbering; import org.exist.storage.io.VariableByteInput; +import org.exist.storage.io.VariableByteOutputStream; import java.io.IOException; @@ -103,4 +104,6 @@ * @return the document node id. */ NodeId documentNodeId(); -} + + void writeEndOfDocument(VariableByteOutputStream os); +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 08:28:19
|
Revision: 3631 Author: wolfgang_m Date: 2006-05-31 01:28:12 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3631&view=rev Log Message: ----------- Binary format has changed. Modified Paths: -------------- trunk/eXist-1.0/src/org/exist/storage/index/BFile.java Modified: trunk/eXist-1.0/src/org/exist/storage/index/BFile.java =================================================================== --- trunk/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-31 08:16:10 UTC (rev 3630) +++ trunk/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-31 08:28:12 UTC (rev 3631) @@ -81,7 +81,7 @@ */ public class BFile extends BTree { - public final static short FILE_FORMAT_VERSION_ID = 3; + public final static short FILE_FORMAT_VERSION_ID = 4; public final static long UNKNOWN_ADDRESS = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 08:16:21
|
Revision: 3630 Author: wolfgang_m Date: 2006-05-31 01:16:10 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3630&view=rev Log Message: ----------- Store the "real" size of the data when storing a binary resource. Some WebDAV clients seem to be offended by the estimated size eXist used to return for content length. Modified Paths: -------------- trunk/eXist-1.0/src/org/exist/collections/Collection.java trunk/eXist-1.0/src/org/exist/dom/BinaryDocument.java trunk/eXist-1.0/src/org/exist/http/RESTServer.java trunk/eXist-1.0/src/org/exist/http/webdav/methods/Put.java Modified: trunk/eXist-1.0/src/org/exist/collections/Collection.java =================================================================== --- trunk/eXist-1.0/src/org/exist/collections/Collection.java 2006-05-31 08:14:27 UTC (rev 3629) +++ trunk/eXist-1.0/src/org/exist/collections/Collection.java 2006-05-31 08:16:10 UTC (rev 3630) @@ -1107,19 +1107,19 @@ XmldbURI docUri, byte[] data, String mimeType, Date created, Date modified) throws EXistException, PermissionDeniedException, LockException, TriggerException { return addBinaryResource(transaction, broker, docUri, - new ByteArrayInputStream(data), mimeType, created, modified); + new ByteArrayInputStream(data), mimeType, data.length, created, modified); } // Streaming public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, - XmldbURI docUri, InputStream is, String mimeType) + XmldbURI docUri, InputStream is, String mimeType, int size) throws EXistException, PermissionDeniedException, LockException, TriggerException { - return addBinaryResource(transaction, broker, docUri, is, mimeType, null, null); + return addBinaryResource(transaction, broker, docUri, is, mimeType, size, null, null); } // Streaming public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, - XmldbURI docUri, InputStream is, String mimeType, Date created, Date modified) + XmldbURI docUri, InputStream is, String mimeType, int size, Date created, Date modified) throws EXistException, PermissionDeniedException, LockException, TriggerException { if (broker.isReadOnly()) throw new PermissionDeniedException("Database is read-only"); @@ -1161,7 +1161,7 @@ if(modified != null) metadata.setLastModified(modified.getTime()); - + blob.setContentLength(size); broker.storeBinaryResource(transaction, blob, is); addDocument(transaction, broker, blob); Modified: trunk/eXist-1.0/src/org/exist/dom/BinaryDocument.java =================================================================== --- trunk/eXist-1.0/src/org/exist/dom/BinaryDocument.java 2006-05-31 08:14:27 UTC (rev 3629) +++ trunk/eXist-1.0/src/org/exist/dom/BinaryDocument.java 2006-05-31 08:16:10 UTC (rev 3630) @@ -47,6 +47,8 @@ private long pageNr = Page.NO_PAGE; + private int realSize = 0; + public BinaryDocument(DBBroker broker) { super(broker, null, null); } @@ -78,6 +80,14 @@ return pageNr; } + public int getContentLength() { + return realSize; + } + + public void setContentLength(int length) { + this.realSize = length; + } + public void write(VariableByteOutputStream ostream) throws IOException { ostream.writeInt(getDocId()); ostream.writeUTF(getFileURI().toString()); @@ -93,7 +103,8 @@ ostream.writeInt(user.getUID()); ostream.writeInt(group.getId()); } - ostream.writeByte((byte) permissions.getPermissions()); + ostream.writeByte((byte) permissions.getPermissions()); + ostream.writeInt(realSize); getMetadata().write(ostream); } @@ -117,7 +128,8 @@ permissions.setGroup(group.getName()); } permissions.setPermissions(perm); - + realSize = istream.readInt(); + DocumentMetadata metadata = new DocumentMetadata(); metadata.read(istream); setMetadata(metadata); Modified: trunk/eXist-1.0/src/org/exist/http/RESTServer.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/RESTServer.java 2006-05-31 08:14:27 UTC (rev 3629) +++ trunk/eXist-1.0/src/org/exist/http/RESTServer.java 2006-05-31 08:16:10 UTC (rev 3630) @@ -768,7 +768,7 @@ } else { FileInputStream is = new FileInputStream(tempFile); - collection.addBinaryResource(transaction, broker, docUri, is, contentType); + collection.addBinaryResource(transaction, broker, docUri, is, contentType, (int) tempFile.length()); is.close(); response.sendError(HttpServletResponse.SC_OK, "Document " + docUri + " stored as binary resource."); } Modified: trunk/eXist-1.0/src/org/exist/http/webdav/methods/Put.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/webdav/methods/Put.java 2006-05-31 08:14:27 UTC (rev 3629) +++ trunk/eXist-1.0/src/org/exist/http/webdav/methods/Put.java 2006-05-31 08:16:10 UTC (rev 3630) @@ -142,7 +142,7 @@ } else { LOG.debug("storing Binary resource"); FileInputStream is = new FileInputStream(tempFile); - doc = collection.addBinaryResource(txn, broker, pathUri, is, contentType); + doc = collection.addBinaryResource(txn, broker, pathUri, is, contentType, (int) tempFile.length()); is.close(); LOG.debug("done"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-31 08:14:34
|
Revision: 3629 Author: wolfgang_m Date: 2006-05-31 01:14:27 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3629&view=rev Log Message: ----------- SVN did not compile: XmlLibraryChecker does not seem to be up to date. Commented out the offending lines. Adam: please fix. Modified Paths: -------------- trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java Modified: trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-30 21:03:57 UTC (rev 3628) +++ trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-31 08:14:27 UTC (rev 3629) @@ -172,17 +172,17 @@ +"of the JRE."); } - if( XmlLibraryChecker.isSaxonVersionOK() ){ - LOG.info("Detected "+ XmlLibraryChecker.SAXONVERSION+ ", OK."); - - } else { - LOG.warn("eXist requires '"+ XmlLibraryChecker.SAXONVERSION - + "' but detected '"+ XmlLibraryChecker.getSaxonVersion() - +"'. Please add the correct version to the " - +"class-path, e.g. in the 'endorsed' folder of " - +"the servlet container or in the 'endorsed' folder " - +"of the JRE."); - } +// if( XmlLibraryChecker.isSaxonVersionOK() ){ +// LOG.info("Detected "+ XmlLibraryChecker.SAXONVERSION+ ", OK."); +// +// } else { +// LOG.warn("eXist requires '"+ XmlLibraryChecker.SAXONVERSION +// + "' but detected '"+ XmlLibraryChecker.getSaxonVersion() +// +"'. Please add the correct version to the " +// +"class-path, e.g. in the 'endorsed' folder of " +// +"the servlet container or in the 'endorsed' folder " +// +"of the JRE."); +// } } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <del...@us...> - 2006-05-30 21:04:10
|
Revision: 3628 Author: deliriumsky Date: 2006-05-30 14:03:57 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3628&view=rev Log Message: ----------- WSDL files for generating the Human Readable module and function descriptions and WSDL for the SOAPServer. Work in progress... Added Paths: ----------- trunk/eXist-1.0/tools/SOAPServer/ trunk/eXist-1.0/tools/SOAPServer/description.xslt trunk/eXist-1.0/tools/SOAPServer/function.xslt trunk/eXist-1.0/tools/SOAPServer/wsdl.xslt Added: trunk/eXist-1.0/tools/SOAPServer/description.xslt =================================================================== --- trunk/eXist-1.0/tools/SOAPServer/description.xslt (rev 0) +++ trunk/eXist-1.0/tools/SOAPServer/description.xslt 2006-05-30 21:03:57 UTC (rev 3628) @@ -0,0 +1,67 @@ +<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" media-type="text/xhtml" omit-xml-declaration="no"/> + <xsl:template match="/webservice"> + <xsl:variable name="webserviceName" select="name" as="xs:string"/> + <xsl:variable name="webserviceURL" select="URL" as="xs:string"/> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <style type="text/css"> + BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } + #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } + A:link { color: #336699; font-weight: bold; text-decoration: underline; } + A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } + A:active { color: #336699; font-weight: bold; text-decoration: underline; } + A:hover { color: cc3300; font-weight: bold; text-decoration: underline; } + P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; } + pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; } + td { color: #000000; font-family: Verdana; font-size: .7em; } + h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; } + h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; } + ul { margin-top: 10px; margin-left: 20px; } + ol { margin-top: 10px; margin-left: 20px; } + li { margin-top: 10px; color: #000000; } + font.value { color: darkblue; font: bold; } + font.key { color: darkgreen; font: bold; } + .heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; } + .button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; } + .frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; } + .frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; } + .frmInput { font-family: Verdana; font-size: 1em; } + .intro { margin-left: -15px; } + </style> + <title>eXist Web Service - <xsl:value-of select="$webserviceName"/> + </title> + </head> + <body> + <div id="content"> + <p class="heading1"> + <xsl:value-of select="$webserviceName"/> + </p> + <br/> + <span> + <p class="intro"> + <xsl:value-of select="description"/> + </p> + </span> + <span> + <p class="intro">The following operations are supported. For a formal definition, please review the <a href="{$webserviceURL}?WSDL">Service Description</a>.</p> + <ul> + <xsl:for-each select="functions/function"> + <li> + <xsl:variable name="funName" select="name"/> + <a href="{$webserviceURL}?function={$funName}"> + <xsl:value-of select="$funName"/> + </a> + <span> + <br/> + <xsl:value-of select="description"/> + </span> + </li> + </xsl:for-each> + </ul> + </span> + </div> + </body> + </html> + </xsl:template> +</xsl:stylesheet> \ No newline at end of file Added: trunk/eXist-1.0/tools/SOAPServer/function.xslt =================================================================== --- trunk/eXist-1.0/tools/SOAPServer/function.xslt (rev 0) +++ trunk/eXist-1.0/tools/SOAPServer/function.xslt 2006-05-30 21:03:57 UTC (rev 3628) @@ -0,0 +1,79 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"> + <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" media-type="text/xhtml" omit-xml-declaration="no"/> + <xsl:template match="/webservice"> + <xsl:variable name="webserviceName" select="name" as="xs:string"/> + <xsl:variable name="webserviceURL" select="URL" as="xs:string"/> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <style type="text/css"> + BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } + #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } + A:link { color: #336699; font-weight: bold; text-decoration: underline; } + A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } + A:active { color: #336699; font-weight: bold; text-decoration: underline; } + A:hover { color: cc3300; font-weight: bold; text-decoration: underline; } + P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; } + pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; } + td { color: #000000; font-family: Verdana; font-size: .7em; } + h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; } + h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; } + ul { margin-top: 10px; margin-left: 20px; } + ol { margin-top: 10px; margin-left: 20px; } + li { margin-top: 10px; color: #000000; } + font.value { color: darkblue; font: bold; } + font.key { color: darkgreen; font: bold; } + .heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; } + .button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; } + .frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; } + .frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; } + .frmInput { font-family: Verdana; font-size: 1em; } + .intro { margin-left: -15px; } + </style> + <title>eXist Web Service - <xsl:value-of select="$webserviceName"/> + </title> + </head> + <body> + <div id="content"> + <p class="heading1"> + <xsl:value-of select="$webserviceName"/> + </p> + <br/> + <span> + <p class="intro">Click <a href="{$webserviceURL}">here</a> for a complete list of operations.</p> + <h2> + <xsl:value-of select="functions/function/name"/> + </h2> + <p class="intro"> + <xsl:value-of select="function/function/description"/> + </p> + <p>The following is a sample SOAP request and response. The <font class="value">placeholders</font> shown need to be replaced with actual values.</p> + <pre>POST <xsl:value-of select="path"/> HTTP/1.1 +Host: <xsl:value-of select="host"/> +Content-Type: text/xml; charset=utf-8 +Content-Length: <font class="value">length</font> +SOAPAction: "" + +<?xml version="1.0" encoding="utf-8"?> +<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <<xsl:value-of select="functions/function/name"/> xmlns="<xsl:value-of select="$webserviceURL"/>"> + </<xsl:value-of select="functions/function/name"/>> + </soap:Body> +</soap:Envelope></pre> + <pre>HTTP/1.1 200 OK +Content-Type: text/xml; charset=utf-8 +Content-Length: <font class="value">length</font> + +<?xml version="1.0" encoding="utf-8"?> +<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <<xsl:value-of select="functions/function/name"/>Response xmlns="<xsl:value-of select="$webserviceURL"/>"> + </<xsl:value-of select="functions/function/name"/>Response> + </soap:Body> +</soap:Envelope></pre> + </span> + </div> + </body> + </html> + </xsl:template> +</xsl:stylesheet> \ No newline at end of file Added: trunk/eXist-1.0/tools/SOAPServer/wsdl.xslt =================================================================== --- trunk/eXist-1.0/tools/SOAPServer/wsdl.xslt (rev 0) +++ trunk/eXist-1.0/tools/SOAPServer/wsdl.xslt 2006-05-30 21:03:57 UTC (rev 3628) @@ -0,0 +1,90 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" version="2.0"> + <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" media-type="text/xml" omit-xml-declaration="no"/> + <xsl:template match="/webservice"> + <xsl:variable name="webserviceName" select="name" as="xs:string"/> + <xsl:variable name="webserviceURL" select="URL" as="xs:string"/> + <definitions name="{$webserviceName}" targetNamespace="{$webserviceURL}"> + <types> + <xs:schema elementFormDefault="qualified" targetNamespace="{$webserviceURL}"> + <xsl:for-each select="functions/function"> + <xsl:variable name="funName" select="name" as="xs:string"/> + <xs:element name="{$funName}"> + <xs:complexType> + <xs:sequence> + <xsl:for-each select="parameters/parameter"> + <xsl:variable name="type" select="type"/> + <xsl:variable name="cardinality" select="cardinality"/> + <xsl:choose> + <xsl:when test="$cardinality > 2"><!-- need array of type --></xsl:when> + <xsl:otherwise> + <xs:element name="{concat('arg', position())}" type="{$type}"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="{concat($funName, 'Response')}"> + <xs:complexType> + <xs:sequence> + <xsl:variable name="type" select="return/type"/> + <xsl:variable name="cardinality" select="return/cardinality"/> + <xsl:choose> + <xsl:when test="$cardinality > 2"><!-- need array of type --></xsl:when> + <xsl:otherwise> + <xs:element name="{concat($funName, 'Result')}" type="{$type}"/> + </xsl:otherwise> + </xsl:choose> + </xs:sequence> + </xs:complexType> + </xs:element> + </xsl:for-each> + </xs:schema> + </types> + <xsl:for-each select="functions/function"> + <xsl:variable name="funName" select="name" as="xs:string"/> + <message name="{concat($funName, 'SoapRequest')}"> + <part name="parameters" element="{concat('tns:',$funName)}"/> + </message> + <message name="{concat($funName, 'SoapResponse')}"> + <part name="parameters" element="{concat('tns:',$funName,'Response')}"/> + </message> + </xsl:for-each> + <portType name="{concat($webserviceName, 'SoapType')}"> + <xsl:for-each select="functions/function"> + <xsl:variable name="funName" select="name" as="xs:string"/> + <operation name="{$funName}"> + <documentation> + <xsl:value-of select="description"/> + </documentation> + <input message="{concat('tns:', $funName ,'SoapRequest')}"/> + <output message="{concat('tns:', $funName ,'SoapResponse')}"/> + </operation> + </xsl:for-each> + </portType> + <binding name="{concat($webserviceName, 'SoapBinding')}" type="{concat('tns:', $webserviceName, 'SoapType')}"> + <soap:binding style="document" transport="" rel="nofollow">http://schemas.xmlsoap.org/soap/http"/> + <xsl:for-each select="functions/function"> + <xsl:variable name="funName" select="name" as="xs:string"/> + <operation name="{$funName}"> + <soap:operation soapAction="" style="document"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + </xsl:for-each> + </binding> + <service name="{$webserviceName}"> + <documentation> + <xsl:value-of select="description"/> + </documentation> + <port name="{concat($webserviceName, 'Soap')}" binding="tns:{concat($webserviceName, 'SoapBinding')}"> + <soap:address location="{$webserviceURL}"/> + </port> + </service> + </definitions> + </xsl:template> +</xsl:stylesheet> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <del...@us...> - 2006-05-30 20:53:10
|
Revision: 3627 Author: deliriumsky Date: 2006-05-30 13:52:59 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3627&view=rev Log Message: ----------- Added the XQuery type .xqws to represent a XQuery Web Service for the SOAPServer Modified Paths: -------------- trunk/eXist-1.0/mime-types.xml trunk/eXist-1.0/src/org/exist/util/mime-types.xml Modified: trunk/eXist-1.0/mime-types.xml =================================================================== --- trunk/eXist-1.0/mime-types.xml 2006-05-30 20:50:22 UTC (rev 3626) +++ trunk/eXist-1.0/mime-types.xml 2006-05-30 20:52:59 UTC (rev 3627) @@ -45,7 +45,7 @@ <mime-type name="application/xquery" type="binary"> <description>XQuery script</description> - <extensions>.xq,.xql,.xqm,.xquery,.xqy</extensions> + <extensions>.xq,.xql,.xqm,.xquery,.xqy,.xqws</extensions> </mime-type> <mime-type name="application/octet-stream" type="binary"> <description>Generic binary stream</description> Modified: trunk/eXist-1.0/src/org/exist/util/mime-types.xml =================================================================== --- trunk/eXist-1.0/src/org/exist/util/mime-types.xml 2006-05-30 20:50:22 UTC (rev 3626) +++ trunk/eXist-1.0/src/org/exist/util/mime-types.xml 2006-05-30 20:52:59 UTC (rev 3627) @@ -45,7 +45,7 @@ <mime-type name="application/xquery" type="binary"> <description>XQuery script</description> - <extensions>.xq,.xql,.xqm,.xquery,.xqy</extensions> + <extensions>.xq,.xql,.xqm,.xquery,.xqy,.xqws</extensions> </mime-type> <mime-type name="application/octet-stream" type="binary"> <description>Generic binary stream</description> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <del...@us...> - 2006-05-30 20:50:37
|
Revision: 3626 Author: deliriumsky Date: 2006-05-30 13:50:22 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3626&view=rev Log Message: ----------- Work in progress of SOAPServer for eXist. Currently generates human readable module description and function description (needs a little more work) and WSDL for simple functions. Requires function.xslt, description.xslt and wsdl.xslt to be loaded into /db/system/webservice from $EXIST_HOME/tools/SOAPServer. Wont currently process incoming SOAP requests. To be continued... Modified Paths: -------------- trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java Added Paths: ----------- trunk/eXist-1.0/src/org/exist/http/SOAPServer.java trunk/eXist-1.0/src/org/exist/storage/serializers/WSDLFilter.java Added: trunk/eXist-1.0/src/org/exist/http/SOAPServer.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/SOAPServer.java (rev 0) +++ trunk/eXist-1.0/src/org/exist/http/SOAPServer.java 2006-05-30 20:50:22 UTC (rev 3626) @@ -0,0 +1,504 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 Wolfgang M. Meier + * wol...@ex... + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: RESTServer.java 3567 2006-05-19 13:37:34 +0000 (Fri, 19 May 2006) wolfgang_m $ + */ +package org.exist.http; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.StringWriter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TemplatesHandler; +import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; + +import org.exist.dom.BinaryDocument; +import org.exist.dom.DocumentImpl; +import org.exist.dom.QName; +import org.exist.http.servlets.HttpRequestWrapper; +import org.exist.http.servlets.HttpResponseWrapper; +import org.exist.http.servlets.RequestWrapper; +import org.exist.http.servlets.ResponseWrapper; +import org.exist.memtree.MemTreeBuilder; +import org.exist.security.PermissionDeniedException; +import org.exist.security.xacml.AccessContext; +import org.exist.source.Source; +import org.exist.source.StringSource; +import org.exist.storage.DBBroker; +import org.exist.storage.XQueryPool; +import org.exist.storage.lock.Lock; +import org.exist.storage.serializers.Serializer; +import org.exist.storage.serializers.WSDLFilter; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.CompiledXQuery; +import org.exist.xquery.Constants; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Module; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQuery; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.functions.request.RequestModule; +import org.exist.xquery.functions.response.ResponseModule; +import org.exist.xquery.functions.session.SessionModule; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * + * @author Adam Retter (ada...@de...) + */ +public class SOAPServer +{ + private String formEncoding; //TODO: we may be able to remove this eventually, in favour of HttpServletRequestWrapper being setup in EXistServlet, currently used for doPost() but perhaps could be used for other Request Methods? - deliriumsky + private String containerEncoding; + + private final static String ENCODING = "UTF-8"; + private final static String SEPERATOR = System.getProperty("line.separator"); + private final static String XSLT_WEBSERVICE_WSDL = "/db/system/webservice/wsdl.xslt"; + private final static String XSLT_WEBSERVICE_DESCRIPTION = "/db/system/webservice/description.xslt"; + private final static String XSLT_WEBSERVICE_FUNCTION = "/db/system/webservice/function.xslt"; + public final static String WEBSERVICE_MODULE_EXTENSION = ".xqws"; + + + //TODO: SHARE THIS FUNCTION WITH RESTServer (copied at the moment) + private final static String QUERY_ERROR_HEAD = + "<html>" + + "<head>" + + "<title>Query Error</title>" + + "<style type=\"text/css\">" + + ".errmsg {" + + " border: 1px solid black;" + + " padding: 15px;" + + " margin-left: 20px;" + + " margin-right: 20px;" + + "}" + + "h1 { color: #C0C0C0; }" + + ".path {" + + " padding-bottom: 10px;" + + "}" + + ".high { " + + " color: #666699; " + + " font-weight: bold;" + + "}" + + "</style>" + + "</head>" + + "<body>" + + "<h1>XQuery Error</h1>"; + + //Constructor + public SOAPServer(String formEncoding, String containerEncoding) + { + this.formEncoding = formEncoding; + this.containerEncoding = containerEncoding; + } + + //proceses requests for description documents (WSDL, human readable, human readable specific function) + public void doGet(DBBroker broker, HttpServletRequest request, HttpServletResponse response, String path) throws BadRequestException, PermissionDeniedException, NotFoundException, IOException + { + //set the encoding + if (request.getCharacterEncoding() == null) + request.setCharacterEncoding(formEncoding); + + /* Process the request */ + + /* + * TODO: I think simple webservices can also be called using GET, so we may need to cater for that as well + * but first it would be best to write the doPost() method, split the code out into functions and also use it for this. + */ + + // 1) Get the xqws + DocumentImpl docXQWS = null; + XmldbURI pathUri = XmldbURI.create(path); + docXQWS = (DocumentImpl) broker.getXMLResource(pathUri, Lock.READ_LOCK); + BinaryDocument bin = (BinaryDocument)docXQWS; + byte[] xqwsData = broker.getBinaryResource(bin); + + // 2) move through the xqws char by char checking if a line contains the module namespace declaration + StringBuffer sbNamespace = new StringBuffer(); + ByteArrayInputStream bis = new ByteArrayInputStream(xqwsData); + while(bis.available() > 0) + { + char c = (char)bis.read(); //TODO: do we need encoding here? + sbNamespace.append(c); + if(c == SEPERATOR.charAt(SEPERATOR.length() -1)) + { + if(sbNamespace.toString().startsWith("module namespace")) + { + //break out of the while loop, sbNamespace should now contain our namespace + break; + } + else + { + //empty the namespace buffer + sbNamespace.delete(0, sbNamespace.length()); + } + } + } + + //close the XQWS Document and release the read lock + docXQWS.getUpdateLock().release(); + + // 3): create an XQuery wrapper to access the module + String query = "xquery version \"1.0\";" + SEPERATOR; + query += SEPERATOR; + query += "import " + sbNamespace.toString().substring(0, sbNamespace.length() - 2) + " at \"" + docXQWS.getFileURI().toString() + "\";" + SEPERATOR; + query += SEPERATOR; + query += "()"; + Source source = new StringSource(query); + + // 4) Compile the XQuery + XQuery xquery = broker.getXQueryService(); + XQueryPool pool = xquery.getXQueryPool(); + XQueryContext context; + + //try and get pre-compiled XQuery + CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source); + + //Create the context and set a header to indicate cache status + if(compiled == null) + { + context = xquery.newContext(AccessContext.REST); + response.setHeader("X-XQuery-Cached", "false"); + } + else + { + context = compiled.getContext(); + response.setHeader("X-XQuery-Cached", "true"); + } + + try + { + //Setup the context + declareVariables(context, request, response); + context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(docXQWS.getCollection().getURI()).toString()); + context.setStaticallyKnownDocuments(new XmldbURI[] { docXQWS.getCollection().getURI() }); + + //no pre-compiled XQuery so compile, it + if(compiled == null) + { + try + { + compiled = xquery.compile(context, source); + } + catch (IOException e) + { + throw new BadRequestException("Failed to read query from " + docXQWS.getURI(), e); + } + } + } + catch (XPathException e) + { + response.setContentType("text/html"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + writeResponse(response, formatXPathException(null, path, e), ENCODING); + } + + //store the compiled xqws for use later + pool.returnCompiledXQuery(source, compiled); + + // 5) Inspect the xqws function signatures and create a small xml doc to represent them + Module xqws = compiled.getContext().getModule(sbNamespace.substring(sbNamespace.indexOf("\"")+1, sbNamespace.lastIndexOf("\""))); + FunctionSignature[] xqwsFunctions = xqws.listFunctions(); + MemTreeBuilder builderWebserviceDoc = new MemTreeBuilder(); + builderWebserviceDoc.startDocument(); + builderWebserviceDoc.startElement(new QName("webservice", null, null), null); + builderWebserviceDoc.startElement(new QName("name", null, null), null); + builderWebserviceDoc.characters(docXQWS.getFileURI().toString().substring(0, docXQWS.getFileURI().toString().indexOf(WEBSERVICE_MODULE_EXTENSION))); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.startElement(new QName("description", null, null), null); + builderWebserviceDoc.characters(xqws.getDescription()); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.startElement(new QName("host", null, null), null); + builderWebserviceDoc.characters(request.getServerName() + ":" + request.getServerPort()); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.startElement(new QName("path", null, null), null); + builderWebserviceDoc.characters(path); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.startElement(new QName("URL", null, null), null); + builderWebserviceDoc.characters(request.getRequestURL()); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.startElement(new QName("functions", null, null), null); + for(int f = 0; f < xqwsFunctions.length; f++) + { + if(request.getParameter("function") != null) + { + //Specific Function Description + if(xqwsFunctions[f].getName().getLocalName().equals(request.getParameter("function"))) + { + ConstructFunctionNode(xqwsFunctions[f], builderWebserviceDoc); + break; + } + } + else + { + //All Function Descriptions + ConstructFunctionNode(xqwsFunctions[f], builderWebserviceDoc); + } + } + builderWebserviceDoc.endElement(); + builderWebserviceDoc.endElement(); + builderWebserviceDoc.endDocument(); + org.exist.memtree.DocumentImpl docWebservice = builderWebserviceDoc.getDocument(); + + // 6) Transform the XML document to either a human readable description, description of a specific function or WSDL + DocumentImpl docStylesheet = null; + + //get the appropraite stylesheet + if(request.getParameter("WSDL") != null || request.getParameter("wsdl") != null) + { + //WSDL + docStylesheet = broker.getXMLResource(XmldbURI.create(XSLT_WEBSERVICE_WSDL), Lock.READ_LOCK); + + //set output content type for wsdl + response.setContentType("text/xml"); + } + else if(request.getParameter("function") != null) + { + //Specific Function Description + docStylesheet = broker.getXMLResource(XmldbURI.create(XSLT_WEBSERVICE_FUNCTION), Lock.READ_LOCK); + } + else + { + //Human Readable Description + docStylesheet = broker.getXMLResource(XmldbURI.create(XSLT_WEBSERVICE_DESCRIPTION), Lock.READ_LOCK); + } + + + //Transform docWebservice with the stylesheet + MemTreeBuilder outputBuilder = new MemTreeBuilder(); + outputBuilder.startDocument(); + try + { + /* + * TODO: the code in this try statement (apart from the WSDLFilter use) was mostly extracted from + * transform:stream-transform(), it would be better to be able to share that code somehow + */ + + SAXTransformerFactory factory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); + TemplatesHandler templatesHandler = factory.newTemplatesHandler(); + templatesHandler.startDocument(); + Serializer serializer = broker.getSerializer(); + serializer.reset(); + WSDLFilter wsdlfilter = new WSDLFilter(templatesHandler, request.getRequestURL().toString()); + serializer.setSAXHandlers(wsdlfilter, null); + serializer.toSAX(docStylesheet); + templatesHandler.endDocument(); + + TransformerHandler handler = factory.newTransformerHandler(templatesHandler.getTemplates()); + + //START send result of transformation directly to response + OutputStream os = new BufferedOutputStream(response.getOutputStream()); + StreamResult result = new StreamResult(os); + handler.setResult(result); + //END + + handler.startDocument(); + docWebservice.toSAX(broker, handler); + handler.endDocument(); + } + catch(TransformerConfigurationException tce) + { + response.setContentType("text/html"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + writeResponse(response, formatXPathException(null, path, new XPathException(null, "SAX exception while transforming node: " + tce.getMessage(), tce)), ENCODING); + } + catch (SAXException e) + { + response.setContentType("text/html"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + writeResponse(response, formatXPathException(null, path, new XPathException(null, "SAX exception while transforming node: " + e.getMessage(), e)), ENCODING); + } + + //close the Stylesheet Document and release the read lock + docStylesheet.getUpdateLock().release(); + } + + //returns the node with the name "definitions" from the NodeList or its children (recursively) + public Node getDefinitionsNode(NodeList nl) + { + Node result = null; + + for(int i = 0; i < nl.getLength(); i ++) + { + Node n = nl.item(i); + + if(n.getNodeType() == Type.ELEMENT) + { + if(n.getNodeName().equals("definitions")) + { + //found node + result = n; + break; + } + + if(n.hasChildNodes()) + { + result = getDefinitionsNode(n.getChildNodes()); + } + } + } + + return result; + } + + //TODO: process incomoing SOAP documents + public void doPost(DBBroker broker, HttpServletRequest request, HttpServletResponse response, String path) throws BadRequestException, PermissionDeniedException, IOException + { + + } + + //builds an XML node called function + /* + * <function> + * <name/> + * <description/> + * <parameters> + * <parameter> + * <name/> + * <type/> + * <cardinality/> + * </parameter> + * </parameters> + * <return> + * <type/> + * <cardinality/> + * </return> + * </function> + */ + private void ConstructFunctionNode(FunctionSignature signature, MemTreeBuilder builderFunction) + { + //Generate an XML snippet for each function + builderFunction.startElement(new QName("function", null, null), null); + builderFunction.startElement(new QName("name", null, null), null); + builderFunction.characters(signature.getName().getLocalName()); + builderFunction.endElement(); + if(signature.getDescription() != null) + { + builderFunction.startElement(new QName("description", null, null), null); + builderFunction.characters(signature.getDescription()); + builderFunction.endElement(); + } + SequenceType[] xqwsArguments = signature.getArgumentTypes(); + builderFunction.startElement(new QName("parameters", null, null), null); + for(int a = 0; a < xqwsArguments.length; a++) + { + builderFunction.startElement(new QName("parameter",null, null), null); + builderFunction.startElement(new QName("name",null, null), null); + //builderFunction.characters(xqwsArguments[a].getNodeName().getLocalName()); //TODO: how to get parameter name? + builderFunction.endElement(); + builderFunction.startElement(new QName("type",null, null), null); + builderFunction.characters(Type.getTypeName(xqwsArguments[a].getPrimaryType())); + builderFunction.endElement(); + builderFunction.startElement(new QName("cardinality",null, null), null); + builderFunction.characters(Integer.toString(xqwsArguments[a].getCardinality())); + builderFunction.endElement(); + builderFunction.endElement(); + } + builderFunction.endElement(); + builderFunction.startElement(new QName("return",null, null), null); + builderFunction.startElement(new QName("type",null, null), null); + builderFunction.characters(Type.getTypeName(signature.getReturnType().getPrimaryType())); + builderFunction.endElement(); + builderFunction.startElement(new QName("cardinality",null, null), null); + builderFunction.characters(Integer.toString(signature.getReturnType().getCardinality())); + builderFunction.endElement(); + builderFunction.endElement(); + builderFunction.endElement(); + } + + //TODO: SHARE THIS FUNCTION WITH RESTServer (copied at the moment) + /** + * Pass the request, response and session objects to the XQuery + * context. + * + * @param context + * @param request + * @param response + * @throws XPathException + */ + private void declareVariables(XQueryContext context, HttpServletRequest request, HttpServletResponse response) throws XPathException + { + RequestWrapper reqw = new HttpRequestWrapper(request, formEncoding, containerEncoding); + ResponseWrapper respw = new HttpResponseWrapper(response); + //context.declareNamespace(RequestModule.PREFIX, RequestModule.NAMESPACE_URI); + context.declareVariable(RequestModule.PREFIX + ":request", reqw); + context.declareVariable(ResponseModule.PREFIX + ":response", respw); + context.declareVariable(SessionModule.PREFIX + ":session", reqw.getSession()); + } + + //TODO: SHARE THIS FUNCTION WITH RESTServer (copied at the moment) + /** + * @param query + * @param e + */ + private String formatXPathException(String query, String path, XPathException e) { + StringWriter writer = new StringWriter(); + writer.write(QUERY_ERROR_HEAD); + writer.write("<p class=\"path\"><span class=\"high\">Path</span>: "); + writer.write("<a href=\""); + writer.write(path); + writer.write("\">"); + writer.write(path); + writer.write("</a></p>"); + + writer.write("<p class=\"errmsg\">"); + writer.write(e.getMessage()); + writer.write("</p>"); + if(query != null) { + writer.write("<p><span class=\"high\">Query</span>:</p><pre>"); + writer.write(query); + writer.write("</pre>"); + } + writer.write("</body></html>"); + return writer.toString(); + } + + //TODO: SHARE THIS FUNCTION WITH RESTServer (copied at the moment) + private void writeResponse(HttpServletResponse response, String data, String encoding) throws IOException + { +// response.setCharacterEncoding(encoding); + + // possible format contentType: text/xml; charset=UTF-8 + String contentType = response.getContentType(); + if ( contentType != null && !response.isCommitted() ) { + + int semicolon = contentType.indexOf(';'); + if (semicolon != Constants.STRING_NOT_FOUND) { + contentType = contentType.substring(0,semicolon); + } + + response.setContentType(contentType + "; charset=" + encoding); + } + + OutputStream is = response.getOutputStream(); + is.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes()); + is.write(data.getBytes(encoding)); + } +} Modified: trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java =================================================================== --- trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-28 19:02:55 UTC (rev 3625) +++ trunk/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-30 20:50:22 UTC (rev 3626) @@ -41,6 +41,7 @@ import org.exist.http.Descriptor; import org.exist.http.NotFoundException; import org.exist.http.RESTServer; +import org.exist.http.SOAPServer; import org.exist.security.PermissionDeniedException; import org.exist.security.SecurityManager; import org.exist.security.User; @@ -68,16 +69,17 @@ private String formEncoding = null; public final static String DEFAULT_ENCODING = "UTF-8"; - protected final static Logger LOG = Logger.getLogger(EXistServlet.class); + protected final static Logger LOG = Logger.getLogger(EXistServlet.class); private BrokerPool pool = null; private String defaultUsername = SecurityManager.GUEST_USER; private String defaultPassword = SecurityManager.GUEST_USER; - private RESTServer server; + private RESTServer srvREST; + private SOAPServer srvSOAP; - private Authenticator authenticator; + private Authenticator authenticator; - private User defaultUser; + private User defaultUser; /* (non-Javadoc) * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) @@ -141,15 +143,22 @@ throw new ServletException("Unable to configure database instance: " + e.getMessage(), e); } - // Instantiate REST server + + //get form and container encoding's formEncoding = config.getInitParameter("form-encoding"); if(formEncoding == null) formEncoding = DEFAULT_ENCODING; String containerEncoding = config.getInitParameter("container-encoding"); if(containerEncoding == null) containerEncoding = DEFAULT_ENCODING; - server = new RESTServer(formEncoding, containerEncoding); + + //Instantiate REST Server + srvREST = new RESTServer(formEncoding, containerEncoding); + //Instantiate SOAP Server + srvSOAP = new SOAPServer(formEncoding, containerEncoding); + + // XML lib checks.... if( XmlLibraryChecker.isXercesVersionOK() ){ LOG.info("Detected "+ XmlLibraryChecker.XERCESVERSION + ", OK."); @@ -163,12 +172,12 @@ +"of the JRE."); } - if( XmlLibraryChecker.isXalanVersionOK() ){ - LOG.info("Detected "+ XmlLibraryChecker.XALANVERSION+ ", OK."); + if( XmlLibraryChecker.isSaxonVersionOK() ){ + LOG.info("Detected "+ XmlLibraryChecker.SAXONVERSION+ ", OK."); } else { - LOG.warn("eXist requires '"+ XmlLibraryChecker.XALANVERSION - + "' but detected '"+ XmlLibraryChecker.getXalanVersion() + LOG.warn("eXist requires '"+ XmlLibraryChecker.SAXONVERSION + + "' but detected '"+ XmlLibraryChecker.getSaxonVersion() +"'. Please add the correct version to the " +"class-path, e.g. in the 'endorsed' folder of " +"the servlet container or in the 'endorsed' folder " @@ -223,7 +232,7 @@ DBBroker broker = null; try { broker = pool.get(user); - server.doPut(broker, tempFile, XmldbURI.create(path), request, response); + srvREST.doPut(broker, tempFile, XmldbURI.create(path), request, response); } catch (BadRequestException e) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } catch (PermissionDeniedException e) { @@ -279,9 +288,21 @@ //fouth, process the request DBBroker broker = null; - try { + try + { broker = pool.get(user); - server.doGet(broker, request, response, path); + + //Route the request + if(path.indexOf(SOAPServer.WEBSERVICE_MODULE_EXTENSION) > -1) + { + //SOAP Server + srvSOAP.doGet(broker, request, response, path); + } + else + { + //REST Server + srvREST.doGet(broker, request, response, path); + } } catch (BadRequestException e) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, e .getMessage()); @@ -328,7 +349,7 @@ DBBroker broker = null; try { broker = pool.get(user); - server.doHead(broker, request, response, path); + srvREST.doHead(broker, request, response, path); } catch (BadRequestException e) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, e .getMessage()); @@ -375,7 +396,7 @@ DBBroker broker = null; try { broker = pool.get(user); - server.doDelete(broker, XmldbURI.create(path), response); + srvREST.doDelete(broker, XmldbURI.create(path), response); } catch (PermissionDeniedException e) { response .sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); @@ -450,7 +471,18 @@ DBBroker broker = null; try { broker = pool.get(user); - server.doPost(broker, request, response, path); + + //Route the request + if(path.indexOf(SOAPServer.WEBSERVICE_MODULE_EXTENSION) > -1) + { + //SOAP Server + srvSOAP.doPost(broker, request, response, path); + } + else + { + //REST Server + srvREST.doPost(broker, request, response, path); + } } catch (PermissionDeniedException e) { response .sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); Added: trunk/eXist-1.0/src/org/exist/storage/serializers/WSDLFilter.java =================================================================== --- trunk/eXist-1.0/src/org/exist/storage/serializers/WSDLFilter.java (rev 0) +++ trunk/eXist-1.0/src/org/exist/storage/serializers/WSDLFilter.java 2006-05-30 20:50:22 UTC (rev 3626) @@ -0,0 +1,138 @@ +/** + * + */ +package org.exist.storage.serializers; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; + +/** + * Add the xmlns:tns namespace to the definitions element of the WSDL stylesheet + * we do this here as a workaround for Xalan, Xalan has no easy + * way to declare additional dynamic namespaces. + * There are two possible known Xalan hacks to do this - + * + * 1) declare a dummy attribute with the namespace. + * This seems to break WSDL compatibilty though! + * 2) declare a variable containing an element with namespace and copy the + * namespace using xsl:copy-of and xalan:nodeset() but this doesnt seem to work! + * + * http://sources.redhat.com/ml/xsl-list/2001-09/msg01204.html + * + * If we were using Saxon instead of Xalan then the workaround is easy as XSLT 2.0 + * supports xsl:namespace for declaring dynamic namespaces + * + * + * @author Adam Retter (ada...@de...) + */ +public class WSDLFilter implements ContentHandler +{ + protected ContentHandler outputHandler = null; + protected String tnsNamespaceUri = null; + + public WSDLFilter(ContentHandler outputHandler, String tnsNamespaceUri) + { + this.outputHandler = outputHandler; + this.tnsNamespaceUri = tnsNamespaceUri; + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator) + */ + public void setDocumentLocator(Locator locator) + { + outputHandler.setDocumentLocator(locator); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#startDocument() + */ + public void startDocument() throws SAXException + { + outputHandler.startDocument(); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#endDocument() + */ + public void endDocument() throws SAXException + { + outputHandler.endDocument(); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) + */ + public void startPrefixMapping(String prefix, String uri) throws SAXException + { + outputHandler.startPrefixMapping(prefix, uri); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String) + */ + public void endPrefixMapping(String prefix) throws SAXException + { + outputHandler.endPrefixMapping(prefix); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + */ + public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException + { + if(qName.equals("definitions")) + { + outputHandler.startPrefixMapping("tns", tnsNamespaceUri); + } + outputHandler.startElement(uri, localName, qName, atts); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + */ + public void endElement(String uri, String localName, String qName) throws SAXException + { + if(qName.equals("definitions")) + { + outputHandler.endPrefixMapping("tns"); + } + outputHandler.endElement(uri, localName, qName); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#characters(char[], int, int) + */ + public void characters(char[] ch, int start, int length) throws SAXException + { + outputHandler.characters(ch, start, length); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) + */ + public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException + { + outputHandler.ignorableWhitespace(ch, start, length); + } + + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String) + */ + public void processingInstruction(String target, String data) throws SAXException + { + outputHandler.processingInstruction(target, data); + } + + /* (non-Javadoc) + * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) + */ + public void skippedEntity(String name) throws SAXException + { + outputHandler.skippedEntity(name); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <di...@us...> - 2006-05-28 19:03:04
|
Revision: 3625 Author: dizzzz Date: 2006-05-28 12:02:55 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3625&view=rev Log Message: ----------- Fixed: Wrong NS in doc ; should be http://exist-db.org/transformer/1.0 Modified Paths: -------------- trunk/eXist-1.0/webapp/devguide.xml Modified: trunk/eXist-1.0/webapp/devguide.xml =================================================================== --- trunk/eXist-1.0/webapp/devguide.xml 2006-05-28 18:58:19 UTC (rev 3624) +++ trunk/eXist-1.0/webapp/devguide.xml 2006-05-28 19:02:55 UTC (rev 3625) @@ -948,7 +948,7 @@ using Transformers and about their basic concepts.</para> <para>As with other transformers, the XMLDBTransformer listens for a limited set of tags that belong to the namespace <filename moreinfo="none" - >http://exist-db/transformer/1.0</filename>. These are + >." rel="nofollow">http://exist-db.org/transformer/1.0</filename>. These are <sgmltag>collection</sgmltag>, <sgmltag>for-each</sgmltag>, <sgmltag>select-node</sgmltag>, <sgmltag>current-node</sgmltag>. To examine how they are used, let's consider the following example (Note that the complete version of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-28 18:58:27
|
Revision: 3624 Author: wolfgang_m Date: 2006-05-28 11:58:19 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3624&view=rev Log Message: ----------- Fixed wrong namespace in XMLDB transformer example. Modified Paths: -------------- trunk/eXist-1.0/webapp/devguide.xml Modified: trunk/eXist-1.0/webapp/devguide.xml =================================================================== --- trunk/eXist-1.0/webapp/devguide.xml 2006-05-28 14:52:10 UTC (rev 3623) +++ trunk/eXist-1.0/webapp/devguide.xml 2006-05-28 18:58:19 UTC (rev 3624) @@ -957,7 +957,7 @@ <example> <title>XMLDBTransformer Example</title> <screen format="linespecific"><![CDATA[ -<xdb:collection xmlns:xdb="http://exist-db/transformer/1.0" +<xdb:collection xmlns:xdb="http://exist-db.org/transformer/1.0" uri="xdb:exist:///db"> <!-- iterate through all rdf:Description elements containing the term "computer" --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-28 14:52:18
|
Revision: 3623 Author: wolfgang_m Date: 2006-05-28 07:52:10 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3623&view=rev Log Message: ----------- DLN: added fallback to DOMFile.getNodeValue: if a node value could not be located due to a wrong storage address (e.g. after a node update), try to find the correct address via the index. Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java Modified: branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java 2006-05-28 14:50:19 UTC (rev 3622) +++ branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryUpdateTest.java 2006-05-28 14:52:10 UTC (rev 3623) @@ -23,6 +23,7 @@ import org.exist.xquery.CompiledXQuery; import org.exist.xquery.XQuery; import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.IntegerValue; import org.exist.xquery.value.NodeValue; import org.exist.xquery.value.Sequence; import org.xml.sax.SAXException; @@ -39,150 +40,403 @@ "<?xml version=\"1.0\"?>" + "<products/>"; + protected static String UPDATE_XML = + "<progress total=\"100\" done=\"0\" failed=\"0\" passed=\"0\"/>"; + protected final static int ITEMS_TO_APPEND = 2000; private BrokerPool pool; - public void testAppend() { - DBBroker broker = null; - try { - System.out.println("testAppend() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - XQuery xquery = broker.getXQueryService(); - String query = - " declare variable $i external;\n" + - " update insert\n" + - " <product id='id{$i}' num='{$i}'>\n" + - " <description>Description {$i}</description>\n" + - " <price>{$i + 1.0}</price>\n" + - " <stock>{$i * 10}</stock>\n" + - " </product>\n" + - " into /products"; - XQueryContext context = xquery.newContext(AccessContext.TEST); - CompiledXQuery compiled = xquery.compile(context, query); - for (int i = 0; i < ITEMS_TO_APPEND; i++) { - context.declareVariable("i", new Integer(i)); - xquery.execute(compiled, null); - } - - Sequence seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - Serializer serializer = broker.getSerializer(); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND, seq.getLength()); - - seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND, seq.getLength()); - System.out.println("testAppend: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } +// public void testAppend() { +// DBBroker broker = null; +// try { +// System.out.println("testAppend() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// String query = +// " declare variable $i external;\n" + +// " update insert\n" + +// " <product id='id{$i}' num='{$i}'>\n" + +// " <description>Description {$i}</description>\n" + +// " <price>{$i + 1.0}</price>\n" + +// " <stock>{$i * 10}</stock>\n" + +// " </product>\n" + +// " into /products"; +// XQueryContext context = xquery.newContext(AccessContext.TEST); +// CompiledXQuery compiled = xquery.compile(context, query); +// for (int i = 0; i < ITEMS_TO_APPEND; i++) { +// context.declareVariable("i", new Integer(i)); +// xquery.execute(compiled, null); +// } +// +// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// Serializer serializer = broker.getSerializer(); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// seq = xquery.execute("//product", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND, seq.getLength()); +// +// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND, seq.getLength()); +// System.out.println("testAppend: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testAppendAttributes() { +// testAppend(); +// DBBroker broker = null; +// try { +// System.out.println("testAppendAttributes() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// String query = +// " declare variable $i external;\n" + +// " update insert\n" + +// " attribute name { concat('n', $i) }\n" + +// " into //product[@num = $i]"; +// XQueryContext context = xquery.newContext(AccessContext.TEST); +// CompiledXQuery compiled = xquery.compile(context, query); +// for (int i = 0; i < ITEMS_TO_APPEND; i++) { +// context.declareVariable("i", new Integer(i)); +// xquery.execute(compiled, null); +// } +// +// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// Serializer serializer = broker.getSerializer(); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// seq = xquery.execute("//product", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND, seq.getLength()); +// +// seq = xquery.execute("//product[@name = 'n20']", null, AccessContext.TEST); +// assertEquals(1, seq.getLength()); +// +// store(broker, "attribs.xml", "<test attr1='aaa' attr2='bbb'>ccc</test>"); +// query = "update insert attribute attr1 { 'eee' } into /test"; +// +// System.out.println("testing duplicate attribute ..."); +// xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("/test[@attr1 = 'eee']", null, AccessContext.TEST); +// assertEquals(1, seq.getLength()); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// System.out.println("testAppendAttributes: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testInsertBefore() { +// DBBroker broker = null; +// try { +// System.out.println("testInsertBefore() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// String query = +// " update insert\n" + +// " <product id='original'>\n" + +// " <description>Description</description>\n" + +// " <price>0</price>\n" + +// " <stock>10</stock>\n" + +// " </product>\n" + +// " into /products"; +// +// XQuery xquery = broker.getXQueryService(); +// xquery.execute(query, null, AccessContext.TEST); +// +// query = +// " declare variable $i external;\n" + +// " update insert\n" + +// " <product id='id{$i}'>\n" + +// " <description>Description {$i}</description>\n" + +// " <price>{$i + 1.0}</price>\n" + +// " <stock>{$i * 10}</stock>\n" + +// " </product>\n" + +// " preceding /products/product[1]"; +// XQueryContext context = xquery.newContext(AccessContext.TEST); +// CompiledXQuery compiled = xquery.compile(context, query); +// for (int i = 0; i < ITEMS_TO_APPEND; i++) { +// context.declareVariable("i", new Integer(i)); +// xquery.execute(compiled, null); +// } +// +// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// Serializer serializer = broker.getSerializer(); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// seq = xquery.execute("//product", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); +// +// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND, seq.getLength()); +// System.out.println("testInsertBefore: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testInsertAfter() { +// DBBroker broker = null; +// try { +// System.out.println("testInsertAfter() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// String query = +// " update insert\n" + +// " <product id='original'>\n" + +// " <description>Description</description>\n" + +// " <price>0</price>\n" + +// " <stock>10</stock>\n" + +// " </product>\n" + +// " into /products"; +// +// XQuery xquery = broker.getXQueryService(); +// xquery.execute(query, null, AccessContext.TEST); +// +// query = +// " declare variable $i external;\n" + +// " update insert\n" + +// " <product id='id{$i}'>\n" + +// " <description>Description {$i}</description>\n" + +// " <price>{$i + 1.0}</price>\n" + +// " <stock>{$i * 10}</stock>\n" + +// " </product>\n" + +// " following /products/product[1]"; +// XQueryContext context = xquery.newContext(AccessContext.TEST); +// CompiledXQuery compiled = xquery.compile(context, query); +// for (int i = 0; i < ITEMS_TO_APPEND; i++) { +// context.declareVariable("i", new Integer(i)); +// xquery.execute(compiled, null); +// } +// +// Sequence seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// Serializer serializer = broker.getSerializer(); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// seq = xquery.execute("//product", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); +// +// seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); +// assertEquals(ITEMS_TO_APPEND, seq.getLength()); +// System.out.println("testInsertAfter: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testUpdate() { +// testAppend(); +// DBBroker broker = null; +// try { +// System.out.println("testUpdate() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// +// String query = +// "for $prod in //product return\n" + +// " update value $prod/description\n" + +// " with 'Updated Description'"; +// Sequence seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product[starts-with(description, 'Updated')]", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// Serializer serializer = broker.getSerializer(); +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// query = +// "for $prod in //product return\n" + +// " update value $prod/stock/text()\n" + +// " with 400"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product[stock = 400]", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// query = +// "for $prod in //product return\n" + +// " update value $prod/@num\n" + +// " with xs:int($prod/@num) * 3"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// seq = xquery.execute("//product[@num = 3]", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); +// +// query = +// "for $prod in //product return\n" + +// " update value $prod/stock\n" + +// " with (<local>10</local>,<external>1</external>)"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("/products", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 1); +// +// seq = xquery.execute("//product/stock/external[. = 1]", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// System.out.println("testUpdate: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testRemove() { +// testAppend(); +// +// DBBroker broker = null; +// try { +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// +// String query = +// "for $prod in //product return\n" + +// " update delete $prod\n"; +// Sequence seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product", null, AccessContext.TEST); +// assertEquals(seq.getLength(), 0); +// +// System.out.println("testRemove: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testRename() { +// testAppend(); +// DBBroker broker = null; +// try { +// System.out.println("testUpdate() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// +// String query = +// "for $prod in //product return\n" + +// " update rename $prod/description as 'desc'\n"; +// Sequence seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product/desc", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// query = +// "for $prod in //product return\n" + +// " update rename $prod/@num as 'count'\n"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product/@count", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// System.out.println("testUpdate: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } +// +// public void testReplace() { +// testAppend(); +// DBBroker broker = null; +// try { +// System.out.println("testReplace() ...\n"); +// broker = pool.get(SecurityManager.SYSTEM_USER); +// +// XQuery xquery = broker.getXQueryService(); +// +// String query = +// "for $prod in //product return\n" + +// " update replace $prod/description with <desc>An updated description.</desc>\n"; +// Sequence seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product/desc", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// query = +// "for $prod in //product return\n" + +// " update replace $prod/@num with '1'\n"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product/@num", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// query = +// "for $prod in //product return\n" + +// " update replace $prod/desc/text() with 'A new update'\n"; +// seq = xquery.execute(query, null, AccessContext.TEST); +// +// seq = xquery.execute("//product[starts-with(desc, 'A new')]", null, AccessContext.TEST); +// assertEquals(seq.getLength(), ITEMS_TO_APPEND); +// +// System.out.println("testUpdate: PASS"); +// } catch (Exception e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } finally { +// pool.release(broker); +// } +// } - public void testAppendAttributes() { - testAppend(); + public void testAttrUpdate() { DBBroker broker = null; try { - System.out.println("testAppendAttributes() ...\n"); + System.out.println("testAttrUpdate() ...\n"); broker = pool.get(SecurityManager.SYSTEM_USER); + store(broker, "test.xml", UPDATE_XML); - XQuery xquery = broker.getXQueryService(); String query = - " declare variable $i external;\n" + - " update insert\n" + - " attribute name { concat('n', $i) }\n" + - " into //product[@num = $i]"; - XQueryContext context = xquery.newContext(AccessContext.TEST); - CompiledXQuery compiled = xquery.compile(context, query); - for (int i = 0; i < ITEMS_TO_APPEND; i++) { - context.declareVariable("i", new Integer(i)); - xquery.execute(compiled, null); - } - - Sequence seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - Serializer serializer = broker.getSerializer(); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND, seq.getLength()); - - seq = xquery.execute("//product[@name = 'n20']", null, AccessContext.TEST); - assertEquals(1, seq.getLength()); - - store(broker, "<test attr1='aaa' attr2='bbb'>ccc</test>"); - query = "update insert attribute attr1 { 'eee' } into /test"; - - System.out.println("testing duplicate attribute ..."); - xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("/test[@attr1 = 'eee']", null, AccessContext.TEST); - assertEquals(1, seq.getLength()); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - System.out.println("testAppendAttributes: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - - public void testInsertBefore() { - DBBroker broker = null; - try { - System.out.println("testInsertBefore() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - String query = - " update insert\n" + - " <product id='original'>\n" + - " <description>Description</description>\n" + - " <price>0</price>\n" + - " <stock>10</stock>\n" + - " </product>\n" + - " into /products"; - + "let $progress := /progress\n" + + "for $i in 1 to 100\n" + + "let $done := $progress/@done\n" + + "return (\n" + + " update value $done with xs:int($done + 1),\n" + + " xs:int(/progress/@done)\n" + + ")"; XQuery xquery = broker.getXQueryService(); - xquery.execute(query, null, AccessContext.TEST); - - query = - " declare variable $i external;\n" + - " update insert\n" + - " <product id='id{$i}'>\n" + - " <description>Description {$i}</description>\n" + - " <price>{$i + 1.0}</price>\n" + - " <stock>{$i * 10}</stock>\n" + - " </product>\n" + - " preceding /products/product[1]"; - XQueryContext context = xquery.newContext(AccessContext.TEST); - CompiledXQuery compiled = xquery.compile(context, query); - for (int i = 0; i < ITEMS_TO_APPEND; i++) { - context.declareVariable("i", new Integer(i)); - xquery.execute(compiled, null); - } - - Sequence seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - Serializer serializer = broker.getSerializer(); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); + Sequence result = xquery.execute(query, null, AccessContext.TEST); - seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND, seq.getLength()); - System.out.println("testInsertBefore: PASS"); + System.out.println("testAttrUpdate(): PASSED\n"); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); @@ -191,235 +445,12 @@ } } - public void testInsertAfter() { - DBBroker broker = null; - try { - System.out.println("testInsertAfter() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - String query = - " update insert\n" + - " <product id='original'>\n" + - " <description>Description</description>\n" + - " <price>0</price>\n" + - " <stock>10</stock>\n" + - " </product>\n" + - " into /products"; - - XQuery xquery = broker.getXQueryService(); - xquery.execute(query, null, AccessContext.TEST); - - query = - " declare variable $i external;\n" + - " update insert\n" + - " <product id='id{$i}'>\n" + - " <description>Description {$i}</description>\n" + - " <price>{$i + 1.0}</price>\n" + - " <stock>{$i * 10}</stock>\n" + - " </product>\n" + - " following /products/product[1]"; - XQueryContext context = xquery.newContext(AccessContext.TEST); - CompiledXQuery compiled = xquery.compile(context, query); - for (int i = 0; i < ITEMS_TO_APPEND; i++) { - context.declareVariable("i", new Integer(i)); - xquery.execute(compiled, null); - } - - Sequence seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - Serializer serializer = broker.getSerializer(); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND + 1, seq.getLength()); - - seq = xquery.execute("//product[price > 0.0]", null, AccessContext.TEST); - assertEquals(ITEMS_TO_APPEND, seq.getLength()); - System.out.println("testInsertAfter: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - - public void testUpdate() { - testAppend(); - DBBroker broker = null; - try { - System.out.println("testUpdate() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - XQuery xquery = broker.getXQueryService(); - - String query = - "for $prod in //product return\n" + - " update value $prod/description\n" + - " with 'Updated Description'"; - Sequence seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product[starts-with(description, 'Updated')]", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - Serializer serializer = broker.getSerializer(); - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - query = - "for $prod in //product return\n" + - " update value $prod/stock/text()\n" + - " with 400"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product[stock = 400]", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - query = - "for $prod in //product return\n" + - " update value $prod/@num\n" + - " with xs:int($prod/@num) * 3"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - seq = xquery.execute("//product[@num = 3]", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - System.out.println(serializer.serialize((NodeValue) seq.itemAt(0))); - - query = - "for $prod in //product return\n" + - " update value $prod/stock\n" + - " with (<local>10</local>,<external>1</external>)"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("/products", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - - seq = xquery.execute("//product/stock/external[. = 1]", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - System.out.println("testUpdate: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - - public void testRemove() { - testAppend(); - - DBBroker broker = null; - try { - broker = pool.get(SecurityManager.SYSTEM_USER); - - XQuery xquery = broker.getXQueryService(); - - String query = - "for $prod in //product return\n" + - " update delete $prod\n"; - Sequence seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(seq.getLength(), 0); - - System.out.println("testRemove: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - - public void testRename() { - testAppend(); - DBBroker broker = null; - try { - System.out.println("testUpdate() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - XQuery xquery = broker.getXQueryService(); - - String query = - "for $prod in //product return\n" + - " update rename $prod/description as 'desc'\n"; - Sequence seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product/desc", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - query = - "for $prod in //product return\n" + - " update rename $prod/@num as 'count'\n"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product/@count", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - System.out.println("testUpdate: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - - public void testReplace() { - testAppend(); - DBBroker broker = null; - try { - System.out.println("testReplace() ...\n"); - broker = pool.get(SecurityManager.SYSTEM_USER); - - XQuery xquery = broker.getXQueryService(); - - String query = - "for $prod in //product return\n" + - " update replace $prod/description with <desc>An updated description.</desc>\n"; - Sequence seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product/desc", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - query = - "for $prod in //product return\n" + - " update replace $prod/@num with '1'\n"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product/@num", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - query = - "for $prod in //product return\n" + - " update replace $prod/desc/text() with 'A new update'\n"; - seq = xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product[starts-with(desc, 'A new')]", null, AccessContext.TEST); - assertEquals(seq.getLength(), ITEMS_TO_APPEND); - - System.out.println("testUpdate: PASS"); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - pool.release(broker); - } - } - protected void setUp() throws Exception { this.pool = startDB(); DBBroker broker = null; try { broker = pool.get(SecurityManager.SYSTEM_USER); - store(broker, TEST_XML); + store(broker, "test.xml", TEST_XML); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); @@ -428,7 +459,7 @@ } } - private void store(DBBroker broker, String data) throws PermissionDeniedException, EXistException, TriggerException, SAXException, LockException, TransactionException { + private void store(DBBroker broker, String docName, String data) throws PermissionDeniedException, EXistException, TriggerException, SAXException, LockException, TransactionException { TransactionManager mgr = pool.getTransactionManager(); Txn transaction = mgr.beginTransaction(); System.out.println("Transaction started ..."); @@ -436,12 +467,12 @@ Collection root = broker.getOrCreateCollection(transaction, TEST_COLLECTION); broker.saveCollection(transaction, root); - IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("test.xml"), data); + IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(docName), data); root.store(transaction, broker, info, data, false); mgr.commit(transaction); - DocumentImpl doc = root.getDocument(broker, XmldbURI.create("test.xml")); + DocumentImpl doc = root.getDocument(broker, XmldbURI.create(docName)); broker.getSerializer().serialize(doc); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-28 14:50:30
|
Revision: 3622 Author: wolfgang_m Date: 2006-05-28 07:50:19 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3622&view=rev Log Message: ----------- DLN: added fallback to DOMFile.getNodeValue: if a node value could not be located due to a wrong storage address (e.g. after a node update), try to find the correct address via the index. Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java Modified: branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java 2006-05-28 10:00:42 UTC (rev 3621) +++ branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java 2006-05-28 14:50:19 UTC (rev 3622) @@ -1753,12 +1753,20 @@ address = findValue(this, new NodeProxy(node)); if (address == BTree.KEY_NOT_FOUND) return null; - final RecordPos rec = findRecord(address); - SanityCheck.THROW_ASSERT(rec != null, - "Node data could not be found! Page: " - + StorageAddress.pageFromPointer(address) - + "; tid: " - + StorageAddress.tidFromPointer(address)); + RecordPos rec = findRecord(address); + if (rec == null) { + address = findValue(this, new NodeProxy(node)); + if (address != BTree.KEY_NOT_FOUND) + rec = findRecord(address); + if (address == BTree.KEY_NOT_FOUND || rec == null) + throw new RuntimeException( + "Node data could not be found for node: " + node.getNodeId() + "; " + + ((DocumentImpl)node.getOwnerDocument()).getURI() + + "; Page: " + + StorageAddress.pageFromPointer(address) + + "; tid: " + + StorageAddress.tidFromPointer(address)); + } final ByteArrayOutputStream os = new ByteArrayOutputStream(); getNodeValue((DocumentImpl)node.getOwnerDocument(), os, rec, true, addWhitespace); final byte[] data = os.toByteArray(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-28 10:00:48
|
Revision: 3621 Author: wolfgang_m Date: 2006-05-28 03:00:42 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3621&view=rev Log Message: ----------- DLN: removed test. It was moved to org.exist.xquery.test.XQueryUpdateTest. Removed Paths: ------------- branches/DLN/eXist-1.0/src/org/exist/storage/test/XQueryUpdateTest.java Deleted: branches/DLN/eXist-1.0/src/org/exist/storage/test/XQueryUpdateTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/test/XQueryUpdateTest.java 2006-05-28 09:56:56 UTC (rev 3620) +++ branches/DLN/eXist-1.0/src/org/exist/storage/test/XQueryUpdateTest.java 2006-05-28 10:00:42 UTC (rev 3621) @@ -1,62 +0,0 @@ -package org.exist.storage.test; - -import junit.textui.TestRunner; - -import org.exist.security.SecurityManager; -import org.exist.security.xacml.AccessContext; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.txn.TransactionManager; -import org.exist.xquery.XQuery; -import org.exist.xquery.value.Sequence; - -public class XQueryUpdateTest extends AbstractUpdateTest { - - public static void main(String[] args) { - TestRunner.run(XQueryUpdateTest.class); - } - - public void testAppend() { - BrokerPool pool = null; - DBBroker broker = null; - try { - System.out.println("testRead() ...\n"); - - pool = startDB(); - TransactionManager mgr = pool.getTransactionManager(); - broker = pool.get(SecurityManager.SYSTEM_USER); - - init(broker, mgr); - - XQuery xquery = broker.getXQueryService(); - String query = - "for $i in 1 to 5 return (\n" + - " util:log('DEBUG', ('Update No.: ', $i)),\n" + - " update insert\n" + - " <product id='id{$i}'>\n" + - " <description>Description {$i}</description>\n" + - " <price>{$i * 2.5}</price>\n" + - " <stock>{$i * 10}</stock>\n" + - " </product>\n" + - " into /products\n" + - ")"; - xquery.execute(query, null, AccessContext.TEST); - - Sequence seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(seq.getLength(), 2000); - -// query = -// "for $i in 1 to 1000 return\n" + -// " update delete /products/product[last()]"; -// xquery.execute(query, null, AccessContext.TEST); - - seq = xquery.execute("//product", null, AccessContext.TEST); - assertEquals(seq.getLength(), 1); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (pool != null) pool.release(broker); - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-28 09:57:12
|
Revision: 3620 Author: wolfgang_m Date: 2006-05-28 02:56:56 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3620&view=rev Log Message: ----------- DLN: Fixed ExtArrayNodeSet.selectParentChild: returned empty sequence for /rootNode. Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java Modified: branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-27 21:32:55 UTC (rev 3619) +++ branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-28 09:56:56 UTC (rev 3620) @@ -590,9 +590,9 @@ // same document NodeId pa = na.getNodeId(); NodeId pb = nb.getNodeId(); - - if (pb.isDescendantOf(pa)) { - if (pb.isChildOf(pa)) { + int relation = pb.computeRelation(pa); + if (relation != -1) { + if (relation == NodeId.IS_CHILD) { if(mode == NodeSet.DESCENDANT) { if (Expression.NO_CONTEXT_ID != contextId) nb.addContextNode(contextId, na); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-27 21:33:08
|
Revision: 3619 Author: wolfgang_m Date: 2006-05-27 14:32:55 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3619&view=rev Log Message: ----------- DLN: Fixed ArrayIndexOutOfBounds exception. Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java Modified: branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-27 18:49:46 UTC (rev 3618) +++ branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-27 21:32:55 UTC (rev 3619) @@ -2494,15 +2494,15 @@ public void mark() { markedOffset = offset; markedPage = nextPage.getPageNum(); - LOG.debug("Marked: " + markedPage + ":" + markedOffset); } public void rewind() throws IOException { - LOG.debug("Rewind: " + markedPage + ":" + markedOffset); try { lock.acquire(Lock.READ_LOCK); nextPage = getSinglePage(markedPage); pageLen = nextPage.ph.getDataLength(); + if (pageLen > fileHeader.getWorkSize()) + pageLen = fileHeader.getWorkSize(); offset = markedOffset; dataCache.add(nextPage); } catch (LockException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-27 18:51:57
|
Revision: 3618 Author: wolfgang_m Date: 2006-05-27 11:49:46 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3618&view=rev Log Message: ----------- DLN: Updated branch with revisions r3479 to r3617 from trunk Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/JettyStart.java branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonRequestWrapper.java branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonResponseWrapper.java branches/DLN/eXist-1.0/src/org/exist/collections/Collection.java branches/DLN/eXist-1.0/src/org/exist/collections/CollectionCache.java branches/DLN/eXist-1.0/src/org/exist/dom/DocumentImpl.java branches/DLN/eXist-1.0/src/org/exist/dom/ElementImpl.java branches/DLN/eXist-1.0/src/org/exist/http/RESTServer.java branches/DLN/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpRequestWrapper.java branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpResponseWrapper.java branches/DLN/eXist-1.0/src/org/exist/http/servlets/RequestWrapper.java branches/DLN/eXist-1.0/src/org/exist/http/servlets/ResponseWrapper.java branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Get.java branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Put.java branches/DLN/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java branches/DLN/eXist-1.0/src/org/exist/security/LDAPSecurityManager.java branches/DLN/eXist-1.0/src/org/exist/start/start.config branches/DLN/eXist-1.0/src/org/exist/storage/DBBroker.java branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java branches/DLN/eXist-1.0/src/org/exist/util/serializer/SAXSerializer.java branches/DLN/eXist-1.0/src/org/exist/validation/Validator.java branches/DLN/eXist-1.0/src/org/exist/validation/test/ApacheXmlComponentsTest.java branches/DLN/eXist-1.0/src/org/exist/xmldb/FullXmldbURI.java branches/DLN/eXist-1.0/src/org/exist/xmldb/LocalCollection.java branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteCollection.java branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteXMLResource.java branches/DLN/eXist-1.0/src/org/exist/xmldb/XmldbURI.java branches/DLN/eXist-1.0/src/org/exist/xmldb/test/XmldbURITest.java branches/DLN/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java branches/DLN/eXist-1.0/src/org/exist/xquery/LocationStep.java branches/DLN/eXist-1.0/src/org/exist/xquery/Module.java branches/DLN/eXist-1.0/src/org/exist/xquery/Predicate.java branches/DLN/eXist-1.0/src/org/exist/xquery/RootNode.java branches/DLN/eXist-1.0/src/org/exist/xquery/SequenceConstructor.java branches/DLN/eXist-1.0/src/org/exist/xquery/XQueryContext.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/FunName.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/request/RequestModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/response/ResponseModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/SystemModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/transform/Transform.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/util/Eval.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/util/SystemProperty.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/util/UtilModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBCreated.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/AllTests.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/XPathQueryTest.java branches/DLN/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java branches/DLN/eXist-1.0/src/org/exist/xquery/util/DocUtils.java branches/DLN/eXist-1.0/src/org/exist/xquery/value/DayTimeDurationValue.java branches/DLN/eXist-1.0/src/org/exist/xquery/value/DurationValue.java branches/DLN/eXist-1.0/src/org/exist/xquery/value/StringValue.java branches/DLN/eXist-1.0/src/org/exist/xquery/value/UntypedAtomicValue.java branches/DLN/eXist-1.0/src/org/exist/xquery/value/YearMonthDurationValue.java Added Paths: ----------- branches/DLN/eXist-1.0/src/org/exist/validation/XmlLibraryChecker.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/exist/ branches/DLN/eXist-1.0/src/org/exist/xquery/functions/exist/ExistModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/request/GetCookieNames.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/request/GetCookieValue.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/response/SetCookie.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/CountInstances.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/GetBuild.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/GetMemory.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/GetVersion.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/system/Shutdown.java Removed Paths: ------------- branches/DLN/eXist-1.0/src/org/exist/xquery/functions/exist/ExistModule.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/response/SetDateHeader.java branches/DLN/eXist-1.0/src/org/exist/xquery/functions/util/ExistVersion.java Property Changed: ---------------- branches/DLN/eXist-1.0/src/org/exist/start/start.config Modified: branches/DLN/eXist-1.0/src/org/exist/JettyStart.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/JettyStart.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/JettyStart.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -29,6 +29,7 @@ import org.exist.util.Configuration; import org.exist.xmldb.DatabaseImpl; import org.exist.xmldb.ShutdownListener; +import org.exist.validation.XmlLibraryChecker; import org.mortbay.jetty.Server; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Database; @@ -47,8 +48,30 @@ start.run(args); } - public JettyStart() { - } + public JettyStart() { + // Additional checks XML libs @@@@ + if( XmlLibraryChecker.isXercesVersionOK() ){ + System.out.println("Detected "+ XmlLibraryChecker.XERCESVERSION + ", OK."); + + } else { + System.err.println("\nWARN: eXist requires '"+ XmlLibraryChecker.XERCESVERSION + + "' but detected '"+ XmlLibraryChecker.getXercesVersion() + +"'. Please add the correct version to the " + +"class-path, e.g. in the 'endorsed' folder of " + +"eXist or in the 'endorsed' folder of the JRE.\n"); + } + + if( XmlLibraryChecker.isXalanVersionOK() ){ + System.out.println("Detected "+ XmlLibraryChecker.XALANVERSION + ", OK."); + + } else { + System.err.println("\nWARN: eXist requires '"+ XmlLibraryChecker.XALANVERSION + + "' but detected '"+ XmlLibraryChecker.getXalanVersion() + +"'. Please add the correct version to the " + +"class-path, e.g. in the 'endorsed' folder of " + +"eXist or the 'endorsed' folder of the JRE.\n"); + } + } public void run(String[] args) { if (args.length == 0) { Modified: branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonRequestWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonRequestWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonRequestWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -33,6 +33,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.Cookie; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Session; @@ -66,6 +67,11 @@ this.servletRequest = servletRequest; } + public Cookie[] getCookies() + { + return servletRequest.getCookies(); + } + /** * @see javax.servlet.http.HttpServletRequest#getInputStream() */ Modified: branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonResponseWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonResponseWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/cocoon/CocoonResponseWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -30,6 +30,7 @@ import org.apache.cocoon.environment.Cookie; import org.apache.cocoon.environment.Response; +import org.apache.cocoon.environment.http.HttpCookie; import org.exist.http.servlets.ResponseWrapper; /** @@ -47,6 +48,15 @@ } /** + * @param name Name of the Cookie + * @param value Value of the Cookie + */ + public void addCookie(String name, String value) + { + response.addCookie(new HttpCookie(name, value)); + } + + /** * @param arg0 */ public void addCookie(Cookie arg0) { Modified: branches/DLN/eXist-1.0/src/org/exist/collections/Collection.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/collections/Collection.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/collections/Collection.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -21,6 +21,7 @@ */ package org.exist.collections; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -1092,15 +1093,32 @@ return trigger; } + // Blob public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, - XmldbURI docUri, byte[] data, String mimeType) + XmldbURI docUri, byte[] data, String mimeType) throws EXistException, PermissionDeniedException, LockException, TriggerException { return addBinaryResource(transaction, broker, docUri, data, mimeType, null, null); } + // Blob public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, XmldbURI docUri, byte[] data, String mimeType, Date created, Date modified) throws EXistException, PermissionDeniedException, LockException, TriggerException { + return addBinaryResource(transaction, broker, docUri, + new ByteArrayInputStream(data), mimeType, created, modified); + } + + // Streaming + public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, + XmldbURI docUri, InputStream is, String mimeType) + throws EXistException, PermissionDeniedException, LockException, TriggerException { + return addBinaryResource(transaction, broker, docUri, is, mimeType, null, null); + } + + // Streaming + public BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, + XmldbURI docUri, InputStream is, String mimeType, Date created, Date modified) + throws EXistException, PermissionDeniedException, LockException, TriggerException { if (broker.isReadOnly()) throw new PermissionDeniedException("Database is read-only"); BinaryDocument blob = null; @@ -1142,7 +1160,7 @@ if(modified != null) metadata.setLastModified(modified.getTime()); - broker.storeBinaryResource(transaction, blob, data); + broker.storeBinaryResource(transaction, blob, is); addDocument(transaction, broker, blob); broker.storeXMLResource(transaction, blob); Modified: branches/DLN/eXist-1.0/src/org/exist/collections/CollectionCache.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/collections/CollectionCache.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/collections/CollectionCache.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -33,7 +33,7 @@ public void add(Collection collection, int initialRefCount) { super.add(collection, initialRefCount); - names.put(collection.getURI(), collection.getKey()); + names.put(collection.getURI().toString(), collection.getKey()); } public Collection get(Collection collection) { @@ -41,7 +41,7 @@ } public Collection get(XmldbURI name) { - long key = names.get(name); + long key = names.get(name.toString()); if (key < 0) return null; return (Collection) get(key); @@ -82,7 +82,7 @@ if (old != null) { pool.getConfigurationManager().invalidate(old.getURI()); map.remove(old.getKey()); - names.remove(old.getURI()); + names.remove(old.getURI().toString()); old.sync(true); } items[bucket] = item; @@ -98,7 +98,7 @@ public void remove(Cacheable item) { final Collection col = (Collection) item; super.remove(item); - names.remove(col.getURI()); + names.remove(col.getURI().toString()); if(pool.getConfigurationManager() != null) // might be null during db initialization pool.getConfigurationManager().invalidate(col.getURI()); } @@ -115,7 +115,7 @@ for (int i = 0; i < count; i++) { newItems[i] = items[i]; newMap.put(items[i].getKey(), items[i]); - newNames.put(((Collection) items[i]).getURI(), items[i].getKey()); + newNames.put(((Collection) items[i]).getURI().toString(), items[i].getKey()); } this.size = newSize; this.map = newMap; Modified: branches/DLN/eXist-1.0/src/org/exist/dom/DocumentImpl.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/DocumentImpl.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/dom/DocumentImpl.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -269,7 +269,8 @@ * @return */ public int getContentLength() { - return getMetadata().getPageCount() * broker.getPageSize(); + int length = getMetadata().getPageCount() * broker.getPageSize(); + return (length<0) ? 0 : length; } public void triggerDefrag() { Modified: branches/DLN/eXist-1.0/src/org/exist/dom/ElementImpl.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/ElementImpl.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/dom/ElementImpl.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -759,8 +759,10 @@ /** * @see org.w3c.dom.Node#getNodeValue() */ - public String getNodeValue() throws DOMException { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "getNodeValue() not implemented on class " + getClass().getName()); + public String getNodeValue() /*throws DOMException*/ { + //TODO : parametrize the boolea value ? + return getBroker().getNodeValue(this, false); + //throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "getNodeValue() not implemented on class " + getClass().getName()); } /** Modified: branches/DLN/eXist-1.0/src/org/exist/http/RESTServer.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/RESTServer.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/RESTServer.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -29,10 +29,12 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.io.Writer; import java.net.URI; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -40,6 +42,7 @@ import java.util.Iterator; import java.util.Properties; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilder; @@ -379,7 +382,9 @@ { response.setContentType(resource.getMetadata().getMimeType()); } - writeResponse(response, broker.getBinaryResource((BinaryDocument) resource)); + OutputStream os = response.getOutputStream(); + broker.readBinaryResource((BinaryDocument) resource, os); + os.flush(); } else { @@ -397,23 +402,26 @@ try { serializer.setProperties(outputProperties); - String output = serializer.serialize(resource); if(asMimeType != null) //was a mime-type specified? { - response.setContentType(asMimeType); + response.setContentType(asMimeType+"; charset="+encoding); } else { if (serializer.isStylesheetApplied()) { - response.setContentType("text/html"); + response.setContentType("text/html; charset="+encoding); } else { - response.setContentType(resource.getMetadata().getMimeType()); + response.setContentType(resource.getMetadata().getMimeType()+"; charset="+encoding); } } - writeResponse(response, output, encoding); + OutputStream is = response.getOutputStream(); + Writer w = new OutputStreamWriter(is,encoding); + serializer.serialize(resource,w); + w.flush(); + w.close(); } catch (SAXException saxe) { @@ -758,17 +766,13 @@ collection.store(transaction, broker, info, createInputSource(charset,url), false); response.sendError(HttpServletResponse.SC_OK, "Document " + docUri + " stored."); } else { - byte[] chunk = new byte[4096]; - ByteArrayOutputStream os = new ByteArrayOutputStream(); + FileInputStream is = new FileInputStream(tempFile); - int l; - while ((l = is.read(chunk)) > -1) { - os.write(chunk, 0, l); - } - collection.addBinaryResource(transaction, broker, docUri, os - .toByteArray(), contentType); + collection.addBinaryResource(transaction, broker, docUri, is, contentType); + is.close(); response.sendError(HttpServletResponse.SC_OK, "Document " + docUri + " stored as binary resource."); } + transact.commit(transaction); } catch (SAXParseException e) { transact.abort(transaction); Modified: branches/DLN/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/servlets/EXistServlet.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -49,6 +49,7 @@ import org.exist.storage.DBBroker; import org.exist.util.Configuration; import org.exist.util.DatabaseConfigurationException; +import org.exist.validation.XmlLibraryChecker; import org.exist.xmldb.XmldbURI; import org.exist.xquery.Constants; import org.xmldb.api.DatabaseManager; @@ -148,6 +149,31 @@ if(containerEncoding == null) containerEncoding = DEFAULT_ENCODING; server = new RESTServer(formEncoding, containerEncoding); + + // XML lib checks.... + if( XmlLibraryChecker.isXercesVersionOK() ){ + LOG.info("Detected "+ XmlLibraryChecker.XERCESVERSION + ", OK."); + + } else { + LOG.warn("eXist requires '"+ XmlLibraryChecker.XERCESVERSION + + "' but detected '"+ XmlLibraryChecker.getXercesVersion() + +"'. Please add the correct version to the " + +"class-path, e.g. in the 'endorsed' folder of " + +"the servlet container or in the 'endorsed' folder " + +"of the JRE."); + } + + if( XmlLibraryChecker.isXalanVersionOK() ){ + LOG.info("Detected "+ XmlLibraryChecker.XALANVERSION+ ", OK."); + + } else { + LOG.warn("eXist requires '"+ XmlLibraryChecker.XALANVERSION + + "' but detected '"+ XmlLibraryChecker.getXalanVersion() + +"'. Please add the correct version to the " + +"class-path, e.g. in the 'endorsed' folder of " + +"the servlet container or in the 'endorsed' folder " + +"of the JRE."); + } } /* (non-Javadoc) Modified: branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpRequestWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpRequestWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpRequestWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -33,6 +33,7 @@ import java.util.Iterator; import java.util.List; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -72,6 +73,14 @@ } /** + * Returns an array of Cookies + */ + public Cookie[] getCookies() + { + return servletRequest.getCookies(); + } + + /** * Parses multi-part requests in order to set the parameters. */ private void parseMultipartContent() { Modified: branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpResponseWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpResponseWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/servlets/HttpResponseWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -28,6 +28,7 @@ import java.util.Locale; import java.util.Map; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; /** @@ -45,6 +46,15 @@ } /** + * @param name Name of the Cookie + * @param value Value of the Cookie + */ + public void addCookie(String name, String value) + { + response.addCookie(new Cookie(name, value)); + } + + /** * @param arg0 * @param arg1 */ Modified: branches/DLN/eXist-1.0/src/org/exist/http/servlets/RequestWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/servlets/RequestWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/servlets/RequestWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -29,6 +29,8 @@ import java.security.Principal; import java.util.Enumeration; +import javax.servlet.http.Cookie; + /** * @author Wolfgang Meier (wol...@ex...) */ @@ -40,6 +42,8 @@ public InputStream getInputStream() throws IOException; + public Cookie[] getCookies(); + public String getContentType(); public String getContextPath(); Modified: branches/DLN/eXist-1.0/src/org/exist/http/servlets/ResponseWrapper.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/servlets/ResponseWrapper.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/servlets/ResponseWrapper.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -30,7 +30,14 @@ * @author Wolfgang Meier (wol...@ex...) */ public interface ResponseWrapper { + /** + * @param name Name of the Cookie + * @param value Value of the Cookie + */ + public void addCookie(String name, String value); + + /** * @param arg0 * @param arg1 */ Modified: branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Get.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Get.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Get.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -23,6 +23,8 @@ package org.exist.http.webdav.methods; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; @@ -79,7 +81,6 @@ throws ServletException, IOException { DBBroker broker = null; - byte[] contentData = null; DocumentImpl resource = null; Collection collection = null; @@ -111,40 +112,35 @@ return; } + DocumentMetadata metadata = resource.getMetadata(); response.setContentType(metadata.getMimeType()); response.addDateHeader("Last-Modified", metadata.getLastModified()); + response.setContentLength(resource.getContentLength()); + ServletOutputStream os = response.getOutputStream(); + if(resource.getResourceType() == DocumentImpl.XML_FILE) { Serializer serializer = broker.getSerializer(); serializer.reset(); try { serializer.setProperties(WebDAV.OUTPUT_PROPERTIES); - String content = serializer.serialize(resource); - contentData = content.getBytes("UTF-8"); + Writer w = new OutputStreamWriter(os,"UTF-8"); + serializer.serialize(resource,w); + w.flush(); + w.close(); + } catch (SAXException e) { LOG.error(e); throw new ServletException(SERIALIZE_ERROR + e.getMessage(), e); } } else { - contentData = broker.getBinaryResource((BinaryDocument)resource); + broker.readBinaryResource((BinaryDocument) resource, os); + os.flush(); } - // TODO all data is serialized here to bytearray. for large files this - // is far from efficient. Implement streaming, XML content already supports - // this. - - // Serve out content - if(contentData == null) { - LOG.debug("content data is empty. No data could be retrieved."); - response.sendError(HttpServletResponse.SC_NOT_FOUND); // TODO is this correct Code? - return; - } - response.setContentLength(contentData.length); - ServletOutputStream os = response.getOutputStream(); - os.write(contentData); os.flush(); } catch (EXistException e) { Modified: branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Put.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Put.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/http/webdav/methods/Put.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -140,18 +140,10 @@ collection.store(txn, broker, info, is, false); LOG.debug("done"); } else { - LOG.debug("storing Binary resource"); - byte[] chunk = new byte[4096]; - ByteArrayOutputStream os = new ByteArrayOutputStream(); + LOG.debug("storing Binary resource"); FileInputStream is = new FileInputStream(tempFile); - int l; - while((l = is.read(chunk)) > -1) { - os.write(chunk, 0, l); - } - - doc = collection.addBinaryResource(txn, broker, - pathUri, os.toByteArray(), contentType); - + doc = collection.addBinaryResource(txn, broker, pathUri, is, contentType); + is.close(); LOG.debug("done"); } Modified: branches/DLN/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -159,12 +159,17 @@ public int addAttribute(QName qname, String value) { int lastNode = doc.getLastNode(); - if(0 < lastNode && doc.nodeKind[lastNode] != Node.ELEMENT_NODE) { - lastNode = characters(value); - } else { - lastNode = doc.addAttribute(lastNode, qname, value); - } - return lastNode; + //if(0 < lastNode && doc.nodeKind[lastNode] != Node.ELEMENT_NODE) { + //Definitely wrong ! + //lastNode = characters(value); + //} else { + //lastNode = doc.addAttribute(lastNode, qname, value); + //} + int nodeNr = doc.addAttribute(lastNode, qname, value); + //TODO : + //1) call linkNode(nodeNr); ? + //2) is there a relationship between lastNode and nodeNr ? + return nodeNr; } /** Modified: branches/DLN/eXist-1.0/src/org/exist/security/LDAPSecurityManager.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/security/LDAPSecurityManager.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/security/LDAPSecurityManager.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -280,6 +280,10 @@ SearchResult result = (SearchResult)groups.next(); mainGroup = getAttributeValue(groupNameAttr, result.getAttributes()); } + + if (mainGroup==null || mainGroup.length()==0) { + throw new IllegalStateException("Main group "+gid+" for user "+username+" is not able to be found in LDAP for group property "+gidNumberAttr); + } int uid = Integer.parseInt(getAttributeValue(uidNumberAttr, attrs)); LOG.info("Constructing user "+username+"/"+uid+" in group "+(mainGroup==null ? "<none>" : mainGroup)); @@ -309,6 +313,9 @@ while (groups.hasMore()) { SearchResult result = (SearchResult)groups.next(); String name = getAttributeValue(groupNameAttr, result.getAttributes()); + if (name==null || name.length()==0) { + throw new IllegalStateException("Group associated with "+username+" does not have a valid name for attribute "+groupNameAttr); + } if (!name.equals(mainGroup)) { LOG.info(" ...adding: "+name); user.addGroup(name); Modified: branches/DLN/eXist-1.0/src/org/exist/start/start.config =================================================================== (Binary files differ) Property changes on: branches/DLN/eXist-1.0/src/org/exist/start/start.config ___________________________________________________________________ Name: svn:mime-type - application/octet-stream Modified: branches/DLN/eXist-1.0/src/org/exist/storage/DBBroker.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/DBBroker.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/storage/DBBroker.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -28,6 +28,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.text.Collator; import java.util.Iterator; @@ -597,6 +598,15 @@ * @param data the document binary data */ public abstract void storeBinaryResource(Txn transaction, BinaryDocument blob, byte[] data); + + /** + * Stores the given data under the given binary resource descriptor + * (BinaryDocument). + * + * @param blob the binary document descriptor + * @param is the document binary data as input stream + */ + public abstract void storeBinaryResource(Txn transaction, BinaryDocument blob, InputStream is); public abstract void getCollectionResources(Collection collection); @@ -609,12 +619,10 @@ */ public abstract byte[] getBinaryResource(BinaryDocument blob); + public abstract void readBinaryResource(final BinaryDocument blob, final OutputStream os); + public abstract void getResourceMetadata(DocumentImpl doc); - - - - - + /** * Completely delete this binary document (descriptor and binary * data). Modified: branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/storage/NativeBroker.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -25,6 +25,8 @@ import java.io.EOFException; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.text.Collator; import java.util.ArrayList; @@ -1415,6 +1417,22 @@ .run(); } + public void storeBinaryResource(final Txn transaction, final BinaryDocument blob, final InputStream is) { + if (is == null) { + blob.setPage(-1); + return; + } + new DOMTransaction(this, domDb, Lock.WRITE_LOCK) { + public Object start() throws ReadOnlyException { + LOG.debug("Storing binary resource as a stream " + blob.getFileURI()); + blob.setPage(domDb.addBinary(transaction, blob, is)); + return null; + } + } + .run(); + } + + /** * get a document by its file name. The document's file name is used to * identify a document. @@ -1496,6 +1514,17 @@ return data; } + public void readBinaryResource(final BinaryDocument blob, final OutputStream os) { + if (blob.getPage() < 0) + return; + new DOMTransaction(this, domDb, Lock.WRITE_LOCK) { + public Object start() throws ReadOnlyException { + domDb.readBinary(blob.getPage(), os); + return null; + } + }.run(); + } + //TODO : consider a better cooperation with Collection -pb public void getCollectionResources(Collection collection) { Lock lock = collectionsDb.getLock(); Modified: branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/storage/dom/DOMFile.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -24,6 +24,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.text.NumberFormat; @@ -46,6 +48,8 @@ import org.exist.storage.btree.BTreeException; import org.exist.storage.btree.DBException; import org.exist.storage.btree.IndexQuery; +import org.exist.storage.btree.Paged.Page; +import org.exist.storage.btree.Paged.PageHeader; import org.exist.storage.btree.Value; import org.exist.storage.cache.Cache; import org.exist.storage.cache.Cacheable; @@ -318,15 +322,30 @@ * Store a raw binary resource into the file. The data will always be * written into an overflow page. * - * @param value + * @param value Binary resource as byte array * @return */ - public long addBinary(Txn transaction, DocumentImpl doc, byte[] value) { - OverflowDOMPage overflow = new OverflowDOMPage(transaction); - int pagesCount = overflow.write(transaction, value); - doc.getMetadata().setPageCount(pagesCount); - return overflow.getPageNum(); - } + public long addBinary(Txn transaction, DocumentImpl doc, byte[] value) { + OverflowDOMPage overflow = new OverflowDOMPage(transaction); + int pagesCount = overflow.write(transaction, value); + doc.getMetadata().setPageCount(pagesCount); + return overflow.getPageNum(); + } + + + /** + * Store a raw binary resource into the file. The data will always be + * written into an overflow page. + * + * @param is Binary resource as stream. + * @return + */ + public long addBinary(Txn transaction, DocumentImpl doc, InputStream is) { + OverflowDOMPage overflow = new OverflowDOMPage(transaction); + int pagesCount = overflow.write(transaction, is); + doc.getMetadata().setPageCount(pagesCount); + return overflow.getPageNum(); + } /** * Return binary data stored with {@link #addBinary(byte[])}. @@ -338,6 +357,15 @@ return getOverflowValue(pageNum); } + public void readBinary(long pageNum, OutputStream os) { + try { + OverflowDOMPage overflow = new OverflowDOMPage(pageNum); + overflow.streamTo(os); + } catch (IOException e) { + LOG.error("io error while loading overflow value", e); + } + } + /** * Insert a new node after the specified node. * @@ -1263,7 +1291,7 @@ return null; } } - + public void removeOverflowValue(Txn transaction, long pnum) { try { OverflowDOMPage overflow = new OverflowDOMPage(pnum); @@ -2948,62 +2976,126 @@ Page firstPage = null; public OverflowDOMPage(Txn transaction) { - LOG.debug("Creating overflow page"); firstPage = createNewPage(); - - // if (transaction != null) { - // Loggable loggable = new CreatePageLoggable(transaction, Page.NO_PAGE, - // firstPage.getPageNum()); - // writeToLog(loggable, firstPage); - // } + LOG.debug("Creating overflow page: " + firstPage.getPageNum()); } public OverflowDOMPage(long first) throws IOException { firstPage = getPage(first); } - public int write(Txn transaction, byte[] data) { - int pageCount = 0; - try { - int remaining = data.length; - int chunkSize = fileHeader.getWorkSize(); - Page page = firstPage, next = null; - int pos = 0; - Value value; - while (remaining > 0) { - chunkSize = remaining > fileHeader.getWorkSize() ? fileHeader - .getWorkSize() - : remaining; - value = new Value(data, pos, chunkSize); - remaining -= chunkSize; - if (remaining > 0) { - next = createNewPage(); +// Write binary resource from inputstream +public int write(Txn transaction, InputStream is) { - page.getPageHeader().setNextPage(next.getPageNum()); - } else - page.getPageHeader().setNextPage(Page.NO_PAGE); + int pageCount = 0; + int chunkSize = fileHeader.getWorkSize(); + Page page = firstPage, next = null; - if (isTransactional && transaction != null) { - Loggable loggable = new WriteOverflowPageLoggable( - transaction, page.getPageNum(), - remaining > 0 ? next.getPageNum() : Page.NO_PAGE, value); - writeToLog(loggable, page); - } + try { + // Transfer bytes from inputstream to db + byte[] buf = new byte[chunkSize]; + int len = is.read(buf); + + // Check if stream does contain any data + if(len<1){ + page.setPageNum(Page.NO_PAGE); + page.getPageHeader().setNextPage(Page.NO_PAGE); + return -1; + } + + // Read remaining stream + while ( len > -1 ) { + + // If there are bytes in stream, read + if(len>0){ + Value value = new Value(buf, 0, len); + + if (len == chunkSize) { + next = createNewPage(); + page.getPageHeader().setNextPage(next.getPageNum()); + + } else { // there are less then 'chuckSize' + page.getPageHeader().setNextPage(Page.NO_PAGE); + } + + // If no data is in input stream left, don't write + if (isTransactional && transaction != null) { + + + long nextPageNum = (len==chunkSize) ? next.getPageNum() + : Page.NO_PAGE; + + Loggable loggable = new WriteOverflowPageLoggable( + transaction, page.getPageNum(), + nextPageNum , value); + writeToLog(loggable, page); + } + + writeValue(page, value); + pageCount++; + page = next; + next = null; + + } + len = is.read(buf); + } + // TODO what if remaining length=0? - writeValue(page, value); - pos += chunkSize; - page = next; - next = null; - ++pageCount; - } - } catch (IOException e) { - LOG.error("io error while writing overflow page", e); - } - return pageCount; + } catch (IOException ex) { + LOG.error("io error while writing overflow page", ex); + } + + return pageCount; +} + + + public int write(Txn transaction, byte[] data) { + int pageCount = 0; + try { + int remaining = data.length; + int chunkSize = fileHeader.getWorkSize(); + Page page = firstPage, next = null; + int pos = 0; + Value value; + while (remaining > 0) { + chunkSize = remaining > fileHeader.getWorkSize() ? fileHeader + .getWorkSize() + : remaining; + value = new Value(data, pos, chunkSize); + remaining -= chunkSize; + if (remaining > 0) { + next = createNewPage(); + + page.getPageHeader().setNextPage(next.getPageNum()); + } else + page.getPageHeader().setNextPage(Page.NO_PAGE); + + if (isTransactional && transaction != null) { + Loggable loggable = new WriteOverflowPageLoggable( + transaction, page.getPageNum(), + remaining > 0 ? next.getPageNum() : Page.NO_PAGE, value); + writeToLog(loggable, page); + } + + writeValue(page, value); + pos += chunkSize; + page = next; + next = null; + ++pageCount; + } + } catch (IOException e) { + LOG.error("io error while writing overflow page", e); + } + return pageCount; } public byte[] read() { ByteArrayOutputStream os = new ByteArrayOutputStream(); + streamTo(os); + return os.toByteArray(); + } + + public void streamTo(OutputStream os) { Page page = firstPage; byte[] chunk; long np; @@ -3021,9 +3113,7 @@ } ++count; } - return os.toByteArray(); } - public void delete(Txn transaction) throws IOException { Page page = firstPage; long np; Modified: branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/storage/index/BFile.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -2262,7 +2262,7 @@ this.address = address; markedOffset = offset; - markedPage = nextPage.getPageNum(); + markedPage = first.getPageNum(); } public long getAddress() { @@ -2494,16 +2494,16 @@ public void mark() { markedOffset = offset; markedPage = nextPage.getPageNum(); + LOG.debug("Marked: " + markedPage + ":" + markedOffset); } public void rewind() throws IOException { - LOG.debug("REWIND"); - offset = markedOffset; + LOG.debug("Rewind: " + markedPage + ":" + markedOffset); try { lock.acquire(Lock.READ_LOCK); - nextPage = (SinglePage) getDataPage(markedPage, false); + nextPage = getSinglePage(markedPage); pageLen = nextPage.ph.getDataLength(); - offset = 0; + offset = markedOffset; dataCache.add(nextPage); } catch (LockException e) { throw new IOException("failed to acquire a read lock on " Modified: branches/DLN/eXist-1.0/src/org/exist/util/serializer/SAXSerializer.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/util/serializer/SAXSerializer.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/util/serializer/SAXSerializer.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -311,6 +311,9 @@ ) { nsEntry = (Map.Entry) i.next(); prefix = (String) nsEntry.getKey(); + if (prefix.equals("xmlns")) { + continue; + } uri = (String) nsEntry.getValue(); if(!optionalNamespaceDecls.containsKey(prefix)) { receiver.namespace(prefix, uri); Modified: branches/DLN/eXist-1.0/src/org/exist/validation/Validator.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/validation/Validator.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/validation/Validator.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -58,9 +58,6 @@ private static SAXParserFactory saxFactory = null; private static BrokerPool brokerPool ; - // Required Xerces version. - public final static String XERCESVERSION = "Xerces-J 2.8.0"; - // Xerces feature and property names final static String FEATURE_VALIDATION ="http://xml.org/sax/features/validation"; @@ -90,9 +87,10 @@ try{ String version = org.apache.xerces.impl.Version.getVersion(); - if(!XERCESVERSION.equals(version)){ + if( !XmlLibraryChecker.isXercesVersionOK() ){ logger.error("Xerces version mismatch! eXist requires '" - + XERCESVERSION+"' but found '"+version+"'. " + + XmlLibraryChecker.XERCESVERSION+"' but found '" + + XmlLibraryChecker.getXercesVersion()+"'. " + "Please add correct Xerces libraries to the " + "endorsed folder of your JRE or webcontainer."); } Copied: branches/DLN/eXist-1.0/src/org/exist/validation/XmlLibraryChecker.java (from rev 3617, trunk/eXist-1.0/src/org/exist/validation/XmlLibraryChecker.java) =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/validation/XmlLibraryChecker.java (rev 0) +++ branches/DLN/eXist-1.0/src/org/exist/validation/XmlLibraryChecker.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -0,0 +1,69 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.validation; + +/** + * Class for checking dependencies with XML libraries. + * + * @author dizzzz + */ +public class XmlLibraryChecker { + + // Required Xerces version. + public static final String XERCESVERSION = "Xerces-J 2.8.0"; + + // Required Xalan version. + public static final String XALANVERSION = "Xalan Java 2.7.0"; + + public static final String UNKNOWNVERSION = "<No version>"; + + public static String getXercesVersion(){ + + String version = "Xerces version could not be determined"; + try{ + version = org.apache.xerces.impl.Version.getVersion(); + } catch (Exception ex) { + System.out.println(version + "; '" + ex.getMessage() +"'"); + } + return version; + } + + public static String getXalanVersion(){ + String version = "Xalan version could not be determined"; + try{ + version = org.apache.xalan.Version.getVersion(); + } catch (Exception ex) { + System.out.println(version + "; '" + ex.getMessage() +"'"); + } + return version; + } + + public static boolean isXercesVersionOK(){ + return ( XERCESVERSION.equals(getXercesVersion()) ); + } + + public static boolean isXalanVersionOK(){ + return ( XALANVERSION.equals(getXalanVersion()) ); + } + +} Modified: branches/DLN/eXist-1.0/src/org/exist/validation/test/ApacheXmlComponentsTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/validation/test/ApacheXmlComponentsTest.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/validation/test/ApacheXmlComponentsTest.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -27,6 +27,7 @@ import junit.framework.TestSuite; import org.exist.validation.Validator; +import org.exist.validation.XmlLibraryChecker; /** * Class for testing xerces and xalan configuration. @@ -34,9 +35,7 @@ * @author dizzzz */ public class ApacheXmlComponentsTest extends TestCase { - - public static String XALANVERSION = "Xalan Java 2.7.0"; - + public ApacheXmlComponentsTest(String testName) { super(testName); } @@ -61,12 +60,12 @@ String version = org.apache.xerces.impl.Version.getVersion(); System.out.println("Xerces"); - System.out.println("Required version '"+Validator.XERCESVERSION+"'"); + System.out.println("Required version '"+XmlLibraryChecker.XERCESVERSION+"'"); System.out.println("Found version '"+version+"'"); - assertEquals("Incorrect Xerces version! "+ + assertTrue("Incorrect Xerces version! "+ "Please put correct jar in endorsed folder", - Validator.XERCESVERSION, version); + XmlLibraryChecker.isXercesVersionOK() ); } @@ -75,11 +74,11 @@ String version = org.apache.xalan.Version.getVersion(); System.out.println("Xalan"); - System.out.println("Required version '"+XALANVERSION+"'"); + System.out.println("Required version '"+ XmlLibraryChecker.XALANVERSION+"'"); System.out.println("Found version '"+version+"'"); - assertEquals("Incorrect Xalan version! "+ + assertTrue("Incorrect Xalan version! "+ "Please put correct jar in endorsed folder", - XALANVERSION, version); + XmlLibraryChecker.isXalanVersionOK() ); } } Modified: branches/DLN/eXist-1.0/src/org/exist/xmldb/FullXmldbURI.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xmldb/FullXmldbURI.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/xmldb/FullXmldbURI.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -7,7 +7,6 @@ //this will never have xmldb: private URI wrappedURI; - private String instanceName; private String context; private String apiName; @@ -23,40 +22,32 @@ /** Feeds private members * @throws URISyntaxException */ - protected void parseURI(URI xmldbURI) throws URISyntaxException { + protected void parseURI(URI xmldbURI, boolean hadXmldbPrefix) throws URISyntaxException { wrappedURI = xmldbURI; - //Reinitialise members - this.instanceName = null; - if (wrappedURI.getQuery() != null) - //Put the "right" URI in the message ;-) - throw new URISyntaxException(wrappedURI.toString(), "xmldb URI should not provide a query part"); - if (wrappedURI.getFragment() != null) - //Put the "right" URI in the message ;-) - throw new URISyntaxException(wrappedURI.toString(), "xmldb URI should not provide a fragment part"); - //Is an encoded scheme ever possible ? - instanceName = wrappedURI.getScheme(); - if (instanceName == null) - //Put the "right" URI in the message ;-) - throw new URISyntaxException(wrappedURI.toString(), "xmldb URI scheme has no instance name"); - String userInfo = wrappedURI.getUserInfo(); - //Very tricky : - if (wrappedURI.getHost() == null && wrappedURI.getAuthority() != null) { - userInfo = wrappedURI.getAuthority(); - if (userInfo.endsWith("@")) - userInfo = userInfo.substring(0, userInfo.length() - 1); + if(hadXmldbPrefix) { + if (wrappedURI.getScheme() == null) + //Put the "right" URI in the message ;-) + throw new URISyntaxException(XMLDB_URI_PREFIX+wrappedURI.toString(), "xmldb URI scheme has no instance name"); + String userInfo = wrappedURI.getUserInfo(); + //Very tricky : + if (wrappedURI.getHost() == null && wrappedURI.getAuthority() != null) { + userInfo = wrappedURI.getAuthority(); + if (userInfo.endsWith("@")) + userInfo = userInfo.substring(0, userInfo.length() - 1); + } + //Eventually rewrite wrappedURI *without* user info + if (userInfo != null) { + StringBuffer recomputed = new StringBuffer();//XMLDB_URI_PREFIX); + recomputed.append(wrappedURI.getScheme()); + recomputed.append("://"); + recomputed.append(wrappedURI.getHost()); + if (wrappedURI.getPort() != -1) + recomputed.append(":").append(wrappedURI.getPort()); + recomputed.append(wrappedURI.getRawPath()); + wrappedURI = new URI(recomputed.toString()); + } } - //Eventually rewrite wrappedURI *without* user info - if (userInfo != null) { - StringBuffer recomputed = new StringBuffer();//XMLDB_URI_PREFIX); - recomputed.append(wrappedURI.getScheme()); - recomputed.append("://"); - recomputed.append(wrappedURI.getHost()); - if (wrappedURI.getPort() != -1) - recomputed.append(":").append(wrappedURI.getPort()); - recomputed.append(wrappedURI.getRawPath()); - wrappedURI = new URI(recomputed.toString()); - } - super.parseURI(xmldbURI); + super.parseURI(xmldbURI,hadXmldbPrefix); } protected void splitPath(String path) throws URISyntaxException { @@ -70,7 +61,7 @@ if(host==null || EMBEDDED_SERVER_AUTHORITY.equals(host)) { if (getPort() != NO_PORT) //Put the "right" URI in the message ;-) - throw new URISyntaxException(wrappedURI.toString(), "Local xmldb URI should not provide a port"); + throw new URISyntaxException(XMLDB_URI_PREFIX+wrappedURI.toString(), "Local xmldb URI should not provide a port"); apiName = API_LOCAL; context = null; pathForSuper = path; @@ -112,8 +103,8 @@ protected void recomputeURI() throws URISyntaxException { URI oldWrappedURI = wrappedURI; StringBuffer buf = new StringBuffer(); - if (instanceName != null) - buf.append(instanceName).append("://"); + if (getInstanceName() != null) + buf.append(getInstanceName()).append("://"); //No userInfo if (getHost() != null) buf.append(getHost()); @@ -131,22 +122,7 @@ throw e; } } - - - /* - * It is an error for any of the following private members to throw an exception. - */ - private void setInstanceName(String instanceName) { - String oldInstanceName = this.instanceName; - try { - this.instanceName = instanceName; - recomputeURI(); - } catch (URISyntaxException e) { - this.instanceName = oldInstanceName; - throw new IllegalArgumentException("Invalid URI: "+e.getMessage()); - } - } - + private void setContext(String context) { String oldContext = this.context; try { @@ -173,7 +149,7 @@ } public String getInstanceName() { - return instanceName; + return wrappedURI.getScheme(); } Modified: branches/DLN/eXist-1.0/src/org/exist/xmldb/LocalCollection.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xmldb/LocalCollection.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/xmldb/LocalCollection.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -506,19 +506,22 @@ throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "Collection " + path + " not found"); if (!checkPermissions(collection, Permission.READ)) return new String[0]; - + List allresources = new ArrayList(); DocumentImpl doc; for (Iterator i = collection.iterator(broker); i.hasNext(); ) { doc = (DocumentImpl) i.next(); - // Only if Locktoken has Null resource flag set + // Include only when (1) locktoken is present or (2) + // locktoken indicates that it is not a null resource LockToken lock = doc.getMetadata().getLockToken(); - if(lock==null || lock.getResourceType()!=LockToken.RESOURCE_TYPE_NULL_RESOURCE){ + if(lock==null || (!lock.isNullResource()) ){ allresources.add( doc.getFileURI() ); } + } + // Copy content of list into String array. int j=0; String[] resources = new String[allresources.size()]; for(Iterator i = allresources.iterator(); i.hasNext(); j++){ Modified: branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java 2006-05-27 16:30:06 UTC (rev 3617) +++ branches/DLN/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java 2006-05-27 18:49:46 UTC (rev 3618) @@ -54,8 +54,8 @@ private Permission ... [truncated message content] |
|
From: <wol...@us...> - 2006-05-27 16:30:14
|
Revision: 3617 Author: wolfgang_m Date: 2006-05-27 09:30:06 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3617&view=rev Log Message: ----------- DLN: fixed ExtArrayNodeSet.selectParentChild Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/dom/test/BasicNodeSetTest.java Modified: branches/DLN/eXist-1.0/src/org/exist/dom/test/BasicNodeSetTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/test/BasicNodeSetTest.java 2006-05-27 16:29:27 UTC (rev 3616) +++ branches/DLN/eXist-1.0/src/org/exist/dom/test/BasicNodeSetTest.java 2006-05-27 16:30:06 UTC (rev 3617) @@ -246,13 +246,28 @@ result = ((AbstractNodeSet) speakers).selectPrecedingSiblings(largeSet.toNodeSet(), -1); assertEquals(160, result.getLength()); - Sequence nestedSet = executeQuery(broker, "//section[@n = '1.1.1']", 1, null); + System.out.println("Testing ExtArrayNodeSet.selectParentChild ..."); + Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1')]", 2, null); test = new NameTest(Type.ELEMENT, new QName("para", "")); NodeSet children = broker.getElementIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - result = ((AbstractNodeSet)children).hasChildrenInSet(nestedSet.toNodeSet(), NodeSet.DESCENDANT, -1); + result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); assertEquals(3, result.getLength()); + nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null); + result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(2, result.getLength()); + + nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.2')]", 3, null); + result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(4, result.getLength()); + + nestedSet = executeQuery(broker, "//para[@n = ('1.1.2.1')]", 1, null); + test = new NameTest(Type.ELEMENT, new QName("section", "")); + NodeSet sections = broker.getElementIndex().findElementsByTagName(ElementValue.ELEMENT, + docs, test.getName(), null); + result = ((NodeSet) nestedSet).selectParentChild(sections.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(1, result.getLength()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); @@ -479,7 +494,7 @@ root = broker.getOrCreateCollection(transaction, XmldbURI.create(DBBroker.ROOT_COLLECTION + "/test")); assertNotNull(root); - broker.removeCollection(transaction, root); +// broker.removeCollection(transaction, root); transact.commit(transaction); } catch (Exception e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-27 16:29:33
|
Revision: 3616 Author: wolfgang_m Date: 2006-05-27 09:29:27 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3616&view=rev Log Message: ----------- DLN: fixed ExtArrayNodeSet.selectParentChild Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java Modified: branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-27 10:38:12 UTC (rev 3615) +++ branches/DLN/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java 2006-05-27 16:29:27 UTC (rev 3616) @@ -609,8 +609,17 @@ } if (++pos < length) nb = array[pos]; - else - break; + else if (ia.hasNext()) { + NodeProxy next = (NodeProxy) ia.next(); + if (next.getNodeId().isDescendantOf(pa)) { + pos = startPos; + nb = array[pos]; + na = next; + startPos = pos; + } else + break; + } else + break; } else { int cmp = pa.compareTo(pb); if (cmp < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <wol...@us...> - 2006-05-27 10:39:03
|
Revision: 3615 Author: wolfgang_m Date: 2006-05-27 03:38:12 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/exist/?rev=3615&view=rev Log Message: ----------- Properly clear instance variables after each test run to avoid wasting memory. Modified Paths: -------------- branches/DLN/eXist-1.0/src/org/exist/storage/test/RecoverBinaryTest.java Modified: branches/DLN/eXist-1.0/src/org/exist/storage/test/RecoverBinaryTest.java =================================================================== --- branches/DLN/eXist-1.0/src/org/exist/storage/test/RecoverBinaryTest.java 2006-05-27 10:37:09 UTC (rev 3614) +++ branches/DLN/eXist-1.0/src/org/exist/storage/test/RecoverBinaryTest.java 2006-05-27 10:38:12 UTC (rev 3615) @@ -127,5 +127,6 @@ protected void tearDown() { BrokerPool.stopAll(false); + pool = null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |