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
(30) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Jean-Marc V. <jm...@us...> - 2004-08-07 16:48:13
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18278/src/org/exist/xmldb/test Modified Files: DOMTest.java Log Message: JUnit test: Update of an existing document through DOM: currently **FAILS** Index: DOMTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/DOMTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DOMTest.java 7 Aug 2004 15:38:44 -0000 1.3 --- DOMTest.java 7 Aug 2004 16:48:03 -0000 1.4 *************** *** 14,17 **** --- 14,20 ---- import org.w3c.dom.*; + /** + * @author jmv + */ public class DOMTest { *************** *** 33,36 **** --- 36,45 ---- } + /** + * - Storing XML resource from XML string + * - simple XQuery + * - removing resource + * - shutdown with the DatabaseInstanceManager + */ public void runTest1() { try { *************** *** 88,92 **** } } ! public void runTest2() { try { --- 97,105 ---- } } ! /** ! * - create and fill a simple document via DOM and JAXP ! * - store it with setContentAsDOM() ! * - simple access via getContentAsDOM() ! * */ public void runTest2() { try { *************** *** 161,165 **** } } ! public void runTest3() { try { --- 174,179 ---- } } ! ! /** like test 2 but add attribute and text as well */ public void runTest3() { try { *************** *** 215,218 **** --- 229,233 ---- } + /** like test 3 but uses the DOM as input to an (identity) XSLT transform */ public void runTest4(boolean getContentAsDOM) { Database database = null; |
From: Wolfgang M. M. <wol...@us...> - 2004-08-07 16:28:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14978/src/org/exist/xquery/parser Modified Files: XQueryLexer.java XQueryParser.java XQueryTreeParser.java XQuery.g Log Message: Namespace declarations in direct or computed element constructors were only copied to the output if they were referenced by a element or attribute qname following the declaration. This made it difficult to write - for example - an XSLT fragment that used the namespace in an xsl:template. Namespace declarations are now preserved. They are attached to the element node in which they were declared. Index: XQueryTreeParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryTreeParser.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** XQueryTreeParser.java 4 Aug 2004 19:00:06 -0000 1.17 --- XQueryTreeParser.java 7 Aug 2004 16:28:03 -0000 1.18 *************** *** 114,118 **** case XPOINTER: { ! AST __t268 = _t; org.exist.xquery.parser.XQueryAST tmp1_AST_in = (org.exist.xquery.parser.XQueryAST)_t; match(_t,XPOINTER); --- 114,118 ---- case XPOINTER: { ! AST __t277 = _t; org.exist.xquery.parser.XQueryAST tmp1_AST_in = (org.exist.xquery.parser.XQueryAST)_t; [...3276 lines suppressed...] private static final long[] mk_tokenSet_0() { ! long[] data = { 1442919852509134736L, -5765733423243055566L, 201850867L, 0L, 0L, 0L}; return data; } public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); private static final long[] mk_tokenSet_1() { ! long[] data = { 1152930163263537152L, 0L, 134217731L, 0L, 0L, 0L}; return data; } --- 5413,5422 ---- private static final long[] mk_tokenSet_0() { ! long[] data = { 1442915454462623632L, -5765733423243055566L, 201850867L, 0L, 0L, 0L}; return data; } public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); private static final long[] mk_tokenSet_1() { ! long[] data = { 1152925765217026048L, 0L, 134217731L, 0L, 0L, 0L}; return data; } Index: XQueryLexer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryLexer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** XQueryLexer.java 29 Jun 2004 14:23:24 -0000 1.11 --- XQueryLexer.java 7 Aug 2004 16:28:02 -0000 1.12 *************** *** 2165,2170 **** { ! int _cnt491=0; ! _loop491: do { if ((_tokenSet_3.member(LA(1)))) { --- 2165,2170 ---- { ! int _cnt502=0; ! _loop502: do { if ((_tokenSet_3.member(LA(1)))) { *************** *** 2172,2179 **** } else { ! if ( _cnt491>=1 ) { break _loop491; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } ! _cnt491++; } while (true); } --- 2172,2179 ---- } else { ! if ( _cnt502>=1 ) { break _loop502; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } ! _cnt502++; } while (true); } *************** *** 2316,2321 **** { ! int _cnt494=0; ! _loop494: do { switch ( LA(1)) { --- 2316,2321 ---- { ! int _cnt505=0; ! _loop505: do { switch ( LA(1)) { *************** *** 2341,2348 **** default: { ! if ( _cnt494>=1 ) { break _loop494; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt494++; } while (true); } --- 2341,2348 ---- default: { ! if ( _cnt505>=1 ) { break _loop505; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt505++; } while (true); } *************** *** 3068,3072 **** mNMSTART(false); { ! _loop501: do { if ((_tokenSet_6.member(LA(1)))) { --- 3068,3072 ---- mNMSTART(false); { ! _loop512: do { if ((_tokenSet_6.member(LA(1)))) { *************** *** 3074,3078 **** } else { ! break _loop501; } --- 3074,3078 ---- } else { ! break _loop512; } *************** *** 3093,3098 **** { ! int _cnt504=0; ! _loop504: do { switch ( LA(1)) { --- 3093,3098 ---- { ! int _cnt515=0; ! _loop515: do { switch ( LA(1)) { *************** *** 3122,3129 **** default: { ! if ( _cnt504>=1 ) { break _loop504; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt504++; } while (true); } --- 3122,3129 ---- default: { ! if ( _cnt515>=1 ) { break _loop515; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt515++; } while (true); } *************** *** 3142,3151 **** match("(:"); { ! _loop510: do { ! boolean synPredMatched509 = false; if (((LA(1)==':') && (_tokenSet_7.member(LA(2))) && (_tokenSet_7.member(LA(3))))) { ! int _m509 = mark(); ! synPredMatched509 = true; inputState.guessing++; try { --- 3142,3151 ---- match("(:"); { ! _loop521: do { ! boolean synPredMatched520 = false; if (((LA(1)==':') && (_tokenSet_7.member(LA(2))) && (_tokenSet_7.member(LA(3))))) { ! int _m520 = mark(); ! synPredMatched520 = true; inputState.guessing++; try { *************** *** 3158,3167 **** } catch (RecognitionException pe) { ! synPredMatched509 = false; } ! rewind(_m509); inputState.guessing--; } ! if ( synPredMatched509 ) { match(':'); } --- 3158,3167 ---- } catch (RecognitionException pe) { ! synPredMatched520 = false; } ! rewind(_m520); inputState.guessing--; } ! if ( synPredMatched520 ) { match(':'); } *************** *** 3170,3174 **** } else { ! break _loop510; } --- 3170,3174 ---- } else { ! break _loop521; } *************** *** 3273,3277 **** match('.'); { ! _loop518: do { if ((_tokenSet_3.member(LA(1)))) { --- 3273,3277 ---- match('.'); { ! _loop529: do { if ((_tokenSet_3.member(LA(1)))) { *************** *** 3279,3283 **** } else { ! break _loop518; } --- 3279,3283 ---- } else { ! break _loop529; } *************** *** 3367,3371 **** match('.'); { ! _loop526: do { if ((_tokenSet_3.member(LA(1)))) { --- 3367,3371 ---- match('.'); { ! _loop537: do { if ((_tokenSet_3.member(LA(1)))) { *************** *** 3373,3377 **** } else { ! break _loop526; } --- 3373,3377 ---- } else { ! break _loop537; } *************** *** 3481,3485 **** text.setLength(_saveIndex); { ! _loop536: do { if ((LA(1)=='&') && (LA(2)=='a'||LA(2)=='g'||LA(2)=='l'||LA(2)=='q')) { --- 3481,3485 ---- text.setLength(_saveIndex); { ! _loop547: do { if ((LA(1)=='&') && (LA(2)=='a'||LA(2)=='g'||LA(2)=='l'||LA(2)=='q')) { *************** *** 3503,3507 **** } else { ! break _loop536; } --- 3503,3507 ---- } else { ! break _loop547; } *************** *** 3519,3523 **** text.setLength(_saveIndex); { ! _loop540: do { if ((LA(1)=='&') && (LA(2)=='a'||LA(2)=='g'||LA(2)=='l'||LA(2)=='q')) { --- 3519,3523 ---- text.setLength(_saveIndex); { ! _loop551: do { if ((LA(1)=='&') && (LA(2)=='a'||LA(2)=='g'||LA(2)=='l'||LA(2)=='q')) { *************** *** 3541,3545 **** } else { ! break _loop540; } --- 3541,3545 ---- } else { ! break _loop551; } *************** *** 3569,3574 **** { ! int _cnt543=0; ! _loop543: do { switch ( LA(1)) { --- 3569,3574 ---- { ! int _cnt554=0; ! _loop554: do { switch ( LA(1)) { *************** *** 3642,3649 **** } else { ! if ( _cnt543>=1 ) { break _loop543; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt543++; } while (true); } --- 3642,3649 ---- } else { ! if ( _cnt554>=1 ) { break _loop554; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt554++; } while (true); } *************** *** 3661,3666 **** { ! int _cnt546=0; ! _loop546: do { switch ( LA(1)) { --- 3661,3666 ---- { ! int _cnt557=0; ! _loop557: do { switch ( LA(1)) { *************** *** 3724,3731 **** } else { ! if ( _cnt546>=1 ) { break _loop546; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt546++; } while (true); } --- 3724,3731 ---- } else { ! if ( _cnt557>=1 ) { break _loop557; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt557++; } while (true); } *************** *** 3746,3751 **** text.setLength(_saveIndex); { ! int _cnt553=0; ! _loop553: do { if ((_tokenSet_12.member(LA(1)))) { --- 3746,3751 ---- text.setLength(_saveIndex); { ! int _cnt564=0; ! _loop564: do { if ((_tokenSet_12.member(LA(1)))) { *************** *** 3755,3762 **** } else { ! boolean synPredMatched552 = false; if (((LA(1)=='-'))) { ! int _m552 = mark(); ! synPredMatched552 = true; inputState.guessing++; try { --- 3755,3762 ---- } else { ! boolean synPredMatched563 = false; if (((LA(1)=='-'))) { ! int _m563 = mark(); ! synPredMatched563 = true; inputState.guessing++; try { *************** *** 3769,3785 **** } catch (RecognitionException pe) { ! synPredMatched552 = false; } ! rewind(_m552); inputState.guessing--; } ! if ( synPredMatched552 ) { match('-'); } else { ! if ( _cnt553>=1 ) { break _loop553; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt553++; } while (true); } --- 3769,3785 ---- } catch (RecognitionException pe) { ! synPredMatched563 = false; } ! rewind(_m563); inputState.guessing--; } ! if ( synPredMatched563 ) { match('-'); } else { ! if ( _cnt564>=1 ) { break _loop564; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt564++; } while (true); } *************** *** 3802,3807 **** match(' '); { ! int _cnt560=0; ! _loop560: do { if ((_tokenSet_13.member(LA(1)))) { --- 3802,3807 ---- match(' '); { ! int _cnt571=0; ! _loop571: do { if ((_tokenSet_13.member(LA(1)))) { *************** *** 3811,3818 **** } else { ! boolean synPredMatched559 = false; if (((LA(1)=='?'))) { ! int _m559 = mark(); ! synPredMatched559 = true; inputState.guessing++; try { --- 3811,3818 ---- } else { ! boolean synPredMatched570 = false; if (((LA(1)=='?'))) { ! int _m570 = mark(); ! synPredMatched570 = true; inputState.guessing++; try { *************** *** 3825,3841 **** } catch (RecognitionException pe) { ! synPredMatched559 = false; } ! rewind(_m559); inputState.guessing--; } ! if ( synPredMatched559 ) { match('?'); } else { ! if ( _cnt560>=1 ) { break _loop560; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt560++; } while (true); } --- 3825,3841 ---- } catch (RecognitionException pe) { ! synPredMatched570 = false; } ! rewind(_m570); inputState.guessing--; } ! if ( synPredMatched570 ) { match('?'); } else { ! if ( _cnt571>=1 ) { break _loop571; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } ! _cnt571++; } while (true); } *************** *** 3882,3889 **** } else { ! boolean synPredMatched577 = false; if (((_tokenSet_15.member(LA(1))) && (_tokenSet_16.member(LA(2))) && (_tokenSet_17.member(LA(3))))) { ! int _m577 = mark(); ! synPredMatched577 = true; inputState.guessing++; try { --- 3882,3889 ---- } else { ! boolean synPredMatched588 = false; if (((_tokenSet_15.member(LA(1))) && (_tokenSet_16.member(LA(2))) && (_tokenSet_17.member(LA(3))))) { ! int _m588 = mark(); ! synPredMatched588 = true; inputState.guessing++; try { *************** *** 3939,3948 **** } catch (RecognitionException pe) { ! synPredMatched577 = false; } ! rewind(_m577); inputState.guessing--; } ! if ( synPredMatched577 ) { mDOUBLE_LITERAL(false); if ( inputState.guessing==0 ) { --- 3939,3948 ---- } catch (RecognitionException pe) { ! synPredMatched588 = false; } ! rewind(_m588); inputState.guessing--; } ! if ( synPredMatched588 ) { mDOUBLE_LITERAL(false); if ( inputState.guessing==0 ) { *************** *** 3963,3970 **** } else { ! boolean synPredMatched563 = false; if (((LA(1)=='<') && (LA(2)=='?'))) { ! int _m563 = mark(); ! synPredMatched563 = true; inputState.guessing++; try { --- 3963,3970 ---- } else { ! boolean synPredMatched574 = false; if (((LA(1)=='<') && (LA(2)=='?'))) { ! int _m574 = mark(); ! synPredMatched574 = true; inputState.guessing++; try { *************** *** 3974,3983 **** } catch (RecognitionException pe) { ! synPredMatched563 = false; } ! rewind(_m563); inputState.guessing--; } ! if ( synPredMatched563 ) { mXML_PI(false); if ( inputState.guessing==0 ) { --- 3974,3983 ---- } catch (RecognitionException pe) { ! synPredMatched574 = false; } ! rewind(_m574); inputState.guessing--; } ! if ( synPredMatched574 ) { mXML_PI(false); if ( inputState.guessing==0 ) { *************** *** 4008,4015 **** } else { ! boolean synPredMatched565 = false; if (((LA(1)=='.') && (LA(2)=='.') && (true))) { ! int _m565 = mark(); ! synPredMatched565 = true; inputState.guessing++; try { --- 4008,4015 ---- } else { ! boolean synPredMatched576 = false; if (((LA(1)=='.') && (LA(2)=='.') && (true))) { ! int _m576 = mark(); ! synPredMatched576 = true; inputState.guessing++; try { *************** *** 4020,4029 **** } catch (RecognitionException pe) { ! synPredMatched565 = false; } ! rewind(_m565); inputState.guessing--; } ! if ( synPredMatched565 ) { mPARENT(false); if ( inputState.guessing==0 ) { --- 4020,4029 ---- } catch (RecognitionException pe) { ! synPredMatched576 = false; } ! rewind(_m576); inputState.guessing--; } ! if ( synPredMatched576 ) { mPARENT(false); if ( inputState.guessing==0 ) { *************** *** 4115,4122 **** } else { ! boolean synPredMatched568 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m568 = mark(); ! synPredMatched568 = true; inputState.guessing++; try { --- 4115,4122 ---- } else { ! boolean synPredMatched579 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m579 = mark(); ! synPredMatched579 = true; inputState.guessing++; try { *************** *** 4145,4154 **** } catch (RecognitionException pe) { ! synPredMatched568 = false; } ! rewind(_m568); inputState.guessing--; } ! if ( synPredMatched568 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { --- 4145,4154 ---- } catch (RecognitionException pe) { ! synPredMatched579 = false; } ! rewind(_m579); inputState.guessing--; } ! if ( synPredMatched579 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { *************** *** 4157,4164 **** } else { ! boolean synPredMatched570 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m570 = mark(); ! synPredMatched570 = true; inputState.guessing++; try { --- 4157,4164 ---- } else { ! boolean synPredMatched581 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m581 = mark(); ! synPredMatched581 = true; inputState.guessing++; try { *************** *** 4169,4178 **** } catch (RecognitionException pe) { ! synPredMatched570 = false; } ! rewind(_m570); inputState.guessing--; } ! if ( synPredMatched570 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { --- 4169,4178 ---- } catch (RecognitionException pe) { ! synPredMatched581 = false; } ! rewind(_m581); inputState.guessing--; } ! if ( synPredMatched581 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { *************** *** 4181,4188 **** } else { ! boolean synPredMatched572 = false; if (((LA(1)=='.') && (true) && (true))) { ! int _m572 = mark(); ! synPredMatched572 = true; inputState.guessing++; try { --- 4181,4188 ---- } else { ! boolean synPredMatched583 = false; if (((LA(1)=='.') && (true) && (true))) { ! int _m583 = mark(); ! synPredMatched583 = true; inputState.guessing++; try { *************** *** 4192,4201 **** } catch (RecognitionException pe) { ! synPredMatched572 = false; } ! rewind(_m572); inputState.guessing--; } ! if ( synPredMatched572 ) { mSELF(false); if ( inputState.guessing==0 ) { --- 4192,4201 ---- } catch (RecognitionException pe) { ! synPredMatched583 = false; } ! rewind(_m583); inputState.guessing--; } ! if ( synPredMatched583 ) { mSELF(false); if ( inputState.guessing==0 ) { *************** *** 4204,4211 **** } else { ! boolean synPredMatched579 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m579 = mark(); ! synPredMatched579 = true; inputState.guessing++; try { --- 4204,4211 ---- } else { ! boolean synPredMatched590 = false; if (((_tokenSet_15.member(LA(1))) && (true) && (true))) { ! int _m590 = mark(); ! synPredMatched590 = true; inputState.guessing++; try { *************** *** 4216,4225 **** } catch (RecognitionException pe) { ! synPredMatched579 = false; } ! rewind(_m579); inputState.guessing--; } ! if ( synPredMatched579 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { --- 4216,4225 ---- } catch (RecognitionException pe) { ! synPredMatched590 = false; } ! rewind(_m590); inputState.guessing--; } ! if ( synPredMatched590 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { Index: XQueryParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParser.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** XQueryParser.java 4 Aug 2004 19:00:06 -0000 1.17 --- XQueryParser.java 7 Aug 2004 16:28:03 -0000 1.18 *************** *** 4727,4737 **** break; } - case LITERAL_namespace: - { - compNSConstructor(); - astFactory.addASTChild(currentAST, returnAST); - computedConstructor_AST = (org.exist.xquery.parser.XQueryAST)currentAST.root; - break; - } default: [...1416 lines suppressed...] case LITERAL_declare: { ! org.exist.xquery.parser.XQueryAST tmp422_AST = null; ! tmp422_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1)); ! astFactory.addASTChild(currentAST, tmp422_AST); match(LITERAL_declare); if ( inputState.guessing==0 ) { *************** *** 7005,7009 **** public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10()); private static final long[] mk_tokenSet_11() { ! long[] data = { 288511851128422400L, 6701356245527298048L, 0L, 0L}; return data; } --- 7079,7083 ---- public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10()); private static final long[] mk_tokenSet_11() { ! long[] data = { 288230376151711744L, 6701356245527298048L, 0L, 0L}; return data; } Index: XQuery.g =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQuery.g,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** XQuery.g 4 Aug 2004 19:00:06 -0000 1.21 --- XQuery.g 7 Aug 2004 16:28:03 -0000 1.22 *************** *** 663,668 **** | compXmlComment - | - compNSConstructor ; --- 663,666 ---- *************** *** 673,683 **** : ( "element" LCURLY ) => ! "element"! LCURLY! e1:expr RCURLY! LCURLY! e2:expr RCURLY! { #compElemConstructor = #(#[COMP_ELEM_CONSTRUCTOR], #compElemConstructor); } | ! "element"! qn=qName LCURLY! e3:expr RCURLY! { #compElemConstructor = #(#[COMP_ELEM_CONSTRUCTOR, qn], #[STRING_LITERAL, qn], #e3); } ; compAttrConstructor { --- 671,695 ---- : ( "element" LCURLY ) => ! "element"! LCURLY! expr RCURLY! LCURLY! compElemBody RCURLY! { #compElemConstructor = #(#[COMP_ELEM_CONSTRUCTOR], #compElemConstructor); } | ! "element"! qn=qName LCURLY! e3:compElemBody RCURLY! { #compElemConstructor = #(#[COMP_ELEM_CONSTRUCTOR, qn], #[STRING_LITERAL, qn], #e3); } ; + compElemBody + : + ( + ( "namespace" ncnameOrKeyword LCURLY ) => localNamespaceDecl + | + exprSingle + ) + ( COMMA! ( + ( "namespace" ncnameOrKeyword LCURLY ) => localNamespaceDecl + | + exprSingle ) + )* + ; + compAttrConstructor { *************** *** 724,734 **** ; ! compNSConstructor { ! String qn = null; } : ! "namespace" qn=qName LCURLY! e:expr RCURLY! ! { #compNSConstructor = #(#[COMP_NS_CONSTRUCTOR, qn], #e); } ; --- 736,746 ---- ; ! localNamespaceDecl { ! String nc = null; } : ! "namespace"! nc=ncnameOrKeyword LCURLY! l:STRING_LITERAL RCURLY! ! { #localNamespaceDecl = #(#[COMP_NS_CONSTRUCTOR, nc], #l); } ; *************** *** 2411,2415 **** { ElementConstructor c= new ElementConstructor(context); ! c.setASTNode(qn); step= c; elementContent = new EnclosedExpr(context); --- 2423,2427 ---- { ElementConstructor c= new ElementConstructor(context); ! c.setASTNode(qn); step= c; elementContent = new EnclosedExpr(context); *************** *** 2420,2424 **** qnameExpr=expr [qnamePathExpr] ! contentExpr=expr [elementContent] ) | --- 2432,2443 ---- qnameExpr=expr [qnamePathExpr] ! ( ! #( prefix:COMP_NS_CONSTRUCTOR uri:STRING_LITERAL ) ! { ! c.addNamespaceDecl(prefix.getText(), uri.getText()); ! } ! | ! contentExpr=expr[elementContent] ! )* ) | *************** *** 2458,2462 **** { ElementConstructor c= new ElementConstructor(context, e.getText()); ! c.setASTNode(e); step= c; } --- 2477,2481 ---- { ElementConstructor c= new ElementConstructor(context, e.getText()); ! c.setASTNode(e); step= c; } *************** *** 2467,2471 **** AttributeConstructor attrib= new AttributeConstructor(context, attrName.getText()); attrib.setASTNode(attrName); - c.addAttribute(attrib); } ( --- 2486,2489 ---- *************** *** 2479,2482 **** --- 2497,2501 ---- ) )+ + { c.addAttribute(attrib); } ) )* *************** *** 2525,2540 **** | #( - prefix:COMP_NS_CONSTRUCTOR - { - elementContent = new PathExpr(context); - NamespaceConstructor ns = new NamespaceConstructor(context, prefix.getText()); - ns.setURIExpression(elementContent); - ns.setASTNode(t); - step= ns; - } - contentExpr=expr [elementContent] - ) - | - #( d:COMP_DOC_CONSTRUCTOR { --- 2544,2547 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-08-07 16:28:12
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/memtree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14978/src/org/exist/memtree Modified Files: DocumentImpl.java NodeImpl.java NamespaceNode.java ElementImpl.java Receiver.java MemTreeBuilder.java Log Message: Namespace declarations in direct or computed element constructors were only copied to the output if they were referenced by a element or attribute qname following the declaration. This made it difficult to write - for example - an XSLT fragment that used the namespace in an xsl:template. Namespace declarations are now preserved. They are attached to the element node in which they were declared. Index: NodeImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/NodeImpl.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NodeImpl.java 29 Jun 2004 14:25:12 -0000 1.16 --- NodeImpl.java 7 Aug 2004 16:28:02 -0000 1.17 *************** *** 93,97 **** case Node.DOCUMENT_NODE : return "#document"; - case Node.ATTRIBUTE_NODE : case Node.ELEMENT_NODE : case Node.PROCESSING_INSTRUCTION_NODE : --- 93,96 ---- *************** *** 99,102 **** --- 98,105 ---- document.namePool.get(document.nodeName[nodeNumber]); return qn.toString(); + case Node.ATTRIBUTE_NODE: + return document.namePool.get(document.attrName[nodeNumber]).toString(); + case NodeImpl.NAMESPACE_NODE: + return document.namePool.get(document.namespaceCode[nodeNumber]).toString(); case Node.TEXT_NODE : return "#text"; Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/DocumentImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DocumentImpl.java 29 Jun 2004 14:25:12 -0000 1.11 --- DocumentImpl.java 7 Aug 2004 16:28:02 -0000 1.12 *************** *** 23,32 **** import java.util.Arrays; - import org.apache.xerces.dom.AttrNSImpl; import org.exist.dom.NodeProxy; import org.exist.dom.QName; import org.exist.util.hashtable.NamePool; import org.exist.xquery.XQueryContext; - import org.exist.xquery.value.Type; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; --- 23,30 ---- *************** *** 60,69 **** --- 58,71 ---- protected NamePool namePool = new NamePool(); + // holds the node type of a node protected short[] nodeKind = null; + // the tree level of a node protected short[] treeLevel; + // the node number of the next sibling protected int[] next; + // pointer into the namePool protected int[] nodeName; *************** *** 76,79 **** --- 78,82 ---- protected int nextChar = 0; + // attributes protected int[] attrName; *************** *** 84,91 **** --- 87,103 ---- protected int nextAttr = 0; + // namespaces + protected int[] namespaceParent; + + protected int[] namespaceCode; + + protected int nextNamespace = 0; + + // the current number of nodes in the doc protected int size = 1; protected int documentRootNode = -1; + // reference nodes (link to an external, persistent document fragment) protected NodeProxy references[]; *************** *** 116,119 **** --- 128,134 ---- attrValue = new String[ATTR_SIZE]; + namespaceCode = new int[5]; + namespaceParent = new int[5]; + references = new NodeProxy[REF_SIZE]; *************** *** 195,198 **** --- 210,222 ---- } + public int addNamespace(int nodeNr, QName qname) { + if(nodeKind == null) init(); + if(nextNamespace == namespaceCode.length) growNamespaces(); + namespaceCode[nextNamespace] = namePool.add(qname); + namespaceParent[nextNamespace] = nodeNr; + if(alphaLen[nodeNr] < 0) alphaLen[nodeNr] = nextNamespace; + return nextNamespace++; + } + public int getLastNode() { return size - 1; *************** *** 254,261 **** --- 278,302 ---- } + private void growNamespaces() { + int size = namespaceCode.length; + int newSize = (size * 3) / 2; + + int[] newCodes = new int[newSize]; + System.arraycopy(namespaceCode, 0, newCodes, 0, size); + namespaceCode = newCodes; + + int[] newParents = new int[newSize]; + System.arraycopy(namespaceParent, 0, newParents, 0, size); + namespaceParent = newParents; + } + public NodeImpl getAttribute(int nodeNr) throws DOMException { return new AttributeImpl(this, nodeNr); } + public NodeImpl getNamespaceNode(int nodeNr) throws DOMException { + return new NamespaceNode(this, nodeNr); + } + public NodeImpl getNode(int nodeNr) throws DOMException { if (nodeNr == 0) return this; *************** *** 280,286 **** node = new ReferenceNode(this, nodeNr); break; - case NodeImpl.NAMESPACE_NODE: - node = new NamespaceNode(this, nodeNr); - break; default: throw new DOMException(DOMException.NOT_FOUND_ERR, --- 321,324 ---- *************** *** 549,552 **** --- 587,603 ---- } } + int ns = document.alphaLen[nr]; + if (-1 < ns) { + XQueryContext context = receiver.getContext(); + while (ns < document.nextNamespace + && document.namespaceParent[ns] == nr) { + QName nsQName = (QName) document.namePool + .get(document.namespaceCode[ns]); + System.out.println("copying namespace node " + nsQName); + receiver.addNamespaceNode(nsQName); + context.declareInScopeNamespace(nsQName.getLocalName(), nsQName.getNamespaceURI()); + ++ns; + } + } break; case Node.TEXT_NODE: *************** *** 572,582 **** .addReferenceNode(document.references[document.alpha[nr]]); break; - case NodeImpl.NAMESPACE_NODE: - XQueryContext context = receiver.getContext(); - QName prefix = (QName) document.namePool.get(document.nodeName[nr]); - String uri = new String(document.characters, - document.alpha[nr], document.alphaLen[nr]); - context.declareInScopeNamespace(prefix.getLocalName(), uri); - break; } } --- 623,626 ---- Index: Receiver.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/Receiver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Receiver.java 29 Jun 2004 14:25:12 -0000 1.5 --- Receiver.java 7 Aug 2004 16:28:02 -0000 1.6 *************** *** 127,130 **** --- 127,134 ---- } + public void addNamespaceNode(QName qname) throws SAXException { + builder.namespaceNode(qname); + } + public void characters(CharSequence seq) throws SAXException { builder.characters(seq); Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/ElementImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ElementImpl.java 3 May 2004 13:08:43 -0000 1.4 --- ElementImpl.java 7 Aug 2004 16:28:02 -0000 1.5 *************** *** 137,146 **** NamedNodeMapImpl map = new NamedNodeMapImpl(); int attr = document.alpha[nodeNumber]; ! if (attr < 0) return map; ! while (attr < document.nextAttr ! && document.attrParent[attr] == nodeNumber) { ! map.add(new AttributeImpl(document, attr)); ! ++attr; } return map; --- 137,155 ---- NamedNodeMapImpl map = new NamedNodeMapImpl(); int attr = document.alpha[nodeNumber]; ! if(-1 < attr) { ! while (attr < document.nextAttr ! && document.attrParent[attr] == nodeNumber) { ! map.add(new AttributeImpl(document, attr)); ! ++attr; ! } ! } ! // add namespace declarations attached to this element ! int ns = document.alphaLen[nodeNumber]; ! if (ns < 0) return map; ! while (ns < document.nextNamespace ! && document.namespaceParent[ns] == nodeNumber) { ! map.add(new NamespaceNode(document, ns)); ! ++ns; } return map; Index: MemTreeBuilder.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MemTreeBuilder.java 29 Jun 2004 14:25:12 -0000 1.12 --- MemTreeBuilder.java 7 Aug 2004 16:28:02 -0000 1.13 *************** *** 28,32 **** import org.exist.dom.QName; import org.exist.xquery.XQueryContext; - import org.exist.xquery.value.Type; import org.w3c.dom.Node; import org.xml.sax.Attributes; --- 28,31 ---- *************** *** 249,260 **** public int namespaceNode(String prefix, String uri) { ! QName qn = new QName(prefix, null, null); ! int nodeNr = doc.addNode(NodeImpl.NAMESPACE_NODE, level, qn); ! doc.addChars(nodeNr, uri); ! int prevNr = prevNodeInLevel[level]; ! if (prevNr > -1) ! doc.next[prevNr] = nodeNr; ! doc.next[nodeNr] = prevNodeInLevel[level - 1]; ! prevNodeInLevel[level] = nodeNr; return nodeNr; } --- 248,257 ---- public int namespaceNode(String prefix, String uri) { ! return namespaceNode(new QName(prefix, uri, "xmlns")); ! } ! ! public int namespaceNode(QName qn) { ! int lastNode = doc.getLastNode(); ! int nodeNr = doc.addNamespace(lastNode, qn); return nodeNr; } Index: NamespaceNode.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/NamespaceNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NamespaceNode.java 29 Jun 2004 14:25:12 -0000 1.1 --- NamespaceNode.java 7 Aug 2004 16:28:02 -0000 1.2 *************** *** 25,36 **** import org.exist.dom.QName; import org.exist.xquery.value.Type; /** ! * A dynamically constructed namespace node. * * @author wolf */ ! public class NamespaceNode extends NodeImpl { /** --- 25,41 ---- import org.exist.dom.QName; import org.exist.xquery.value.Type; + import org.w3c.dom.Attr; + import org.w3c.dom.DOMException; + import org.w3c.dom.Element; /** ! * A dynamically constructed namespace node. Used to track namespace ! * declarations in elements. Implements Attr, so it can be treated as a normal ! * attribute. * * @author wolf */ ! public class NamespaceNode extends NodeImpl implements Attr { /** *************** *** 57,67 **** public String getPrefix() { ! QName qn = (QName)document.namePool.get(document.nodeName[nodeNumber]); return qn != null ? qn.getLocalName() : null; } public String getNamespaceURI() { ! return new String(document.characters, document.alpha[nodeNumber], ! document.alphaLen[nodeNumber]); } } --- 62,104 ---- public String getPrefix() { ! QName qn = getQName(); return qn != null ? qn.getLocalName() : null; } public String getNamespaceURI() { ! QName qn = getQName(); ! return qn != null ? qn.getNamespaceURI() : null; } + + public boolean getSpecified() { + return true; + } + + public QName getQName() { + return (QName)document.namePool.get(document.namespaceCode[nodeNumber]); + } + + public String getName() { + return getQName().toString(); + } + + /* (non-Javadoc) + * @see org.w3c.dom.Attr#getValue() + */ + public String getValue() { + return getQName().getNamespaceURI(); + } + + /* (non-Javadoc) + * @see org.w3c.dom.Attr#setValue(java.lang.String) + */ + public void setValue(String value) throws DOMException { + } + + /* (non-Javadoc) + * @see org.w3c.dom.Attr#getOwnerElement() + */ + public Element getOwnerElement() { + return (Element)document.getNode(document.namespaceParent[nodeNumber]); + } } |
From: Wolfgang M. M. <wol...@us...> - 2004-08-07 16:28:12
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14978/src/org/exist/xquery Modified Files: NamespaceConstructor.java XQuery.java ElementConstructor.java Log Message: Namespace declarations in direct or computed element constructors were only copied to the output if they were referenced by a element or attribute qname following the declaration. This made it difficult to write - for example - an XSLT fragment that used the namespace in an xsl:template. Namespace declarations are now preserved. They are attached to the element node in which they were declared. Index: XQuery.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQuery.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XQuery.java 23 Jun 2004 12:46:35 -0000 1.2 --- XQuery.java 7 Aug 2004 16:28:02 -0000 1.3 *************** *** 84,88 **** AST ast = parser.getAST(); ! // LOG.debug("Generated AST: " + ast.toStringTree()); PathExpr expr = new PathExpr(context); treeParser.xpath(ast, expr); --- 84,88 ---- AST ast = parser.getAST(); ! LOG.debug("Generated AST: " + ast.toStringTree()); PathExpr expr = new PathExpr(context); treeParser.xpath(ast, expr); Index: NamespaceConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/NamespaceConstructor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NamespaceConstructor.java 29 Jun 2004 14:23:24 -0000 1.1 --- NamespaceConstructor.java 7 Aug 2004 16:28:02 -0000 1.2 *************** *** 76,80 **** context.declareInScopeNamespace(prefix, value); int nodeNr = builder.namespaceNode(prefix, value); ! return ((DocumentImpl)builder.getDocument()).getNode(nodeNr); } --- 76,80 ---- context.declareInScopeNamespace(prefix, value); int nodeNr = builder.namespaceNode(prefix, value); ! return ((DocumentImpl)builder.getDocument()).getNamespaceNode(nodeNr); } Index: ElementConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/ElementConstructor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ElementConstructor.java 27 Jun 2004 21:10:06 -0000 1.5 --- ElementConstructor.java 7 Aug 2004 16:28:02 -0000 1.6 *************** *** 43,46 **** --- 43,47 ---- private PathExpr content = null; private AttributeConstructor attributes[] = null; + private QName namespaceDecls[] = null; public ElementConstructor(XQueryContext context) { *************** *** 62,66 **** public void addAttribute(AttributeConstructor attr) { ! if(attributes == null) { attributes = new AttributeConstructor[1]; attributes[0] = attr; --- 63,69 ---- public void addAttribute(AttributeConstructor attr) { ! if(attr.isNamespaceDeclaration()) { ! addNamespaceDecl(QName.extractLocalName(attr.getQName()), attr.getLiteralValue()); ! } else if(attributes == null) { attributes = new AttributeConstructor[1]; attributes[0] = attr; *************** *** 73,76 **** --- 76,91 ---- } + public void addNamespaceDecl(String prefix, String uri) { + if(namespaceDecls == null) { + namespaceDecls = new QName[1]; + namespaceDecls[0] = new QName(prefix, uri, "xmlns"); + } else { + QName decls[] = new QName[namespaceDecls.length + 1]; + System.arraycopy(namespaceDecls, 0, decls, 0, namespaceDecls.length); + decls[namespaceDecls.length] = new QName(prefix, uri, "xmlns"); + namespaceDecls = decls; + } + } + /* (non-Javadoc) * @see org.exist.xquery.Expression#eval(org.exist.xquery.StaticContext, org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) *************** *** 82,85 **** --- 97,106 ---- context.pushNamespaceContext(); MemTreeBuilder builder = context.getDocumentBuilder(); + // declare namespaces + if(namespaceDecls != null) { + for(int i = 0; i < namespaceDecls.length; i++) { + context.declareInScopeNamespace(namespaceDecls[i].getLocalName(), namespaceDecls[i].getNamespaceURI()); + } + } // process attributes AttributesImpl attrs = new AttributesImpl(); *************** *** 105,114 **** context.proceed(this, builder); constructor = (AttributeConstructor)attributes[i]; ! if(!constructor.isNamespaceDeclaration()) { ! attrValues = constructor.eval(contextSequence, contextItem); ! attrQName = QName.parse(context, constructor.getQName()); ! attrs.addAttribute(attrQName.getNamespaceURI(), attrQName.getLocalName(), attrQName.toString(), "CDATA", attrValues.getStringValue()); - } } } --- 126,133 ---- context.proceed(this, builder); constructor = (AttributeConstructor)attributes[i]; ! attrValues = constructor.eval(contextSequence, contextItem); ! attrQName = QName.parse(context, constructor.getQName()); ! attrs.addAttribute(attrQName.getNamespaceURI(), attrQName.getLocalName(), attrQName.toString(), "CDATA", attrValues.getStringValue()); } } *************** *** 122,125 **** --- 141,149 ---- int nodeNr = builder.startElement(qn, attrs); + if(namespaceDecls != null) { + for(int i = 0; i < namespaceDecls.length; i++) { + builder.namespaceNode(namespaceDecls[i]); + } + } // process element contents if(content != null) { *************** *** 131,135 **** return node; } ! /* (non-Javadoc) * @see org.exist.xquery.Expression#pprint() --- 155,159 ---- return node; } ! /* (non-Javadoc) * @see org.exist.xquery.Expression#pprint() |
From: Wolfgang M. M. <wol...@us...> - 2004-08-07 16:28:12
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14978/src/org/exist/util/serializer Modified Files: DOMStreamer.java Log Message: Namespace declarations in direct or computed element constructors were only copied to the output if they were referenced by a element or attribute qname following the declaration. This made it difficult to write - for example - an XSLT fragment that used the namespace in an xsl:template. Namespace declarations are now preserved. They are attached to the element node in which they were declared. Index: DOMStreamer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/DOMStreamer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DOMStreamer.java 28 Jul 2004 18:54:53 -0000 1.5 --- DOMStreamer.java 7 Aug 2004 16:28:02 -0000 1.6 *************** *** 42,45 **** --- 42,47 ---- /** + * General purpose class to stream a DOM node to SAX. + * * @author Wolfgang Meier (wol...@ex...) */ *************** *** 69,72 **** --- 71,79 ---- } + /** + * Reset internal state for reuse. Registered handlers will be set + * to null. + * + */ public void reset() { nsSupport.reset(); *************** *** 77,84 **** --- 84,106 ---- } + /** + * Serialize the given node and all its descendants to SAX. + * + * @param node + * @throws SAXException + */ public void serialize(Node node) throws SAXException { serialize(node, false); } + /** + * Serialize the given node and all its descendants to SAX. If + * callDocumentEvents is set to false, startDocument/endDocument + * events will not be fired. + * + * @param node + * @param callDocumentEvents + * @throws SAXException + */ public void serialize(Node node, boolean callDocumentEvents) throws SAXException { if(callDocumentEvents) *************** *** 133,136 **** --- 155,159 ---- for (int i = 0; i < attrs.getLength(); i++) { nextAttr = (Attr) attrs.item(i); + System.out.println("attr = " + nextAttr.getName()); attrName = nextAttr.getName(); if (attrName.equals("xmlns")) { *************** *** 141,144 **** --- 164,168 ---- } } else if (attrName.startsWith("xmlns:")) { + System.out.println("Found " + attrName); prefix = attrName.substring(6); if (nsSupport.getURI(prefix) == null) { |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 15:38:54
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6996/src/org/exist/xmldb/test Modified Files: DOMTest.java Log Message: error in test causing failure Index: DOMTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/DOMTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DOMTest.java 15 Dec 2003 13:15:10 -0000 1.2 --- DOMTest.java 7 Aug 2004 15:38:44 -0000 1.3 *************** *** 45,48 **** --- 45,49 ---- "CollectionManagementService", "1.0"); + cms.createCollection("A"); // jmv cms.removeCollection("A"); cms.createCollection("A"); *************** *** 83,87 **** System.out.println("test 1: PASSED"); } catch (Exception e) { ! System.out.println("test 1: FAILED"); e.printStackTrace(); } --- 84,88 ---- System.out.println("test 1: PASSED"); } catch (Exception e) { ! System.err.println("test 1: FAILED"); e.printStackTrace(); } |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 15:04:17
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1869/src/org/exist/client Modified Files: InteractiveClient.java Log Message: add XML Schema validation (commands putschema and validate) - test in progress Index: InteractiveClient.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/InteractiveClient.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** InteractiveClient.java 6 Aug 2004 15:34:30 -0000 1.34 --- InteractiveClient.java 7 Aug 2004 15:04:08 -0000 1.35 *************** *** 39,42 **** --- 39,43 ---- import java.io.StreamTokenizer; import java.io.StringReader; + import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; *************** *** 66,70 **** --- 67,75 ---- import org.apache.avalon.excalibur.cli.CLUtil; import org.apache.oro.io.GlobFilenameFilter; + import org.apache.xerces.parsers.DOMParser; + import org.apache.xml.serialize.OutputFormat; + import org.apache.xml.serialize.XMLSerializer; import org.exist.dom.XMLUtil; + import org.exist.schema.SchemaService; import org.exist.security.Permission; import org.exist.security.User; *************** *** 1039,1042 **** --- 1044,1068 ---- else if (args[0].equalsIgnoreCase("quit")) { return false; + + } else if (args[0].equalsIgnoreCase("validate")) { + if (args.length < 2) + messageln("missing document name."); + else { + SchemaService schemaService = (SchemaService) current.getService("SchemaService", "1.0"); + if (schemaService.validateResource(args[1])) + messageln("validated ok."); + else + messageln("there were errors."); + } + + } else if (args[0].equalsIgnoreCase("putschema")) { + if (args.length < 2) { + messageln("missing schema file name."); + } else { + importSchema(args[1]); + getResources(); + } + return true; + } else { messageln("unknown command"); *************** *** 1054,1057 **** --- 1080,1110 ---- } + /** + * @param String filename of the file that contains the schema + */ + private void importSchema(String filename) throws XMLDBException { + SchemaService schemaService = (SchemaService) current.getService("SchemaService", "1.0"); + if (schemaService != null) { + String schemaContents = null; + try { + DOMParser parser = new DOMParser(); + parser.parse(filename); + Document document = parser.getDocument(); + StringWriter sw = new StringWriter(); + XMLSerializer serializer = new XMLSerializer(sw, new OutputFormat(document, "UTF-8", true)); + serializer.serialize(document); + schemaContents = sw.toString(); + + schemaService.putSchema(schemaContents); + messageln("imported schema in file \"" + filename + "\"."); + + } catch (SAXException saxEx) { + messageln("Unable to parse schema in " + filename + ": " + saxEx.getMessage()); + } catch (IOException ioEx) { + messageln("Uable to parse schema in " + filename + ": " + ioEx.getMessage()); + } + } + } + private final ResourceSet find(String xpath) throws XMLDBException { if (xpath.charAt(xpath.length() - 1) == '\n') *************** *** 1301,1304 **** --- 1354,1362 ---- } + /** stores given Resource + * @param fileName simple file or directory + * @return + * @throws XMLDBException + */ protected synchronized boolean parse(String fileName) throws XMLDBException { fileName = fileName.replace('/', File.separatorChar).replace('\\', *************** *** 2118,2125 **** --- 2176,2187 ---- } catch (IOException ioe) { System.err.println(ioe); + } catch (Exception e) { + // TODO: handle exception + System.err.println(e); } try { Readline.writeHistoryFile(historyFile.getAbsolutePath()); } catch (Exception e) { + System.err.println("Could not write history File to " + historyFile.getAbsolutePath() ); } Readline.cleanup(); |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:56:08
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv464/src/org/exist/xmldb Modified Files: LocalCollection.java RemoteCollection.java Log Message: add XML Schema validation (commands putschema and validate) - test in progress Index: LocalCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollection.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** LocalCollection.java 4 Aug 2004 14:48:05 -0000 1.39 --- LocalCollection.java 7 Aug 2004 14:55:59 -0000 1.40 *************** *** 43,46 **** --- 43,47 ---- import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; + import org.exist.schema.LocalSchemaService; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; *************** *** 401,409 **** return new LocalIndexQueryService(user, brokerPool, this); throw new XMLDBException(ErrorCodes.NO_SUCH_SERVICE); } public Service[] getServices() throws XMLDBException { ! Service[] services = new Service[6]; services[0] = new LocalXPathQueryService(user, brokerPool, this); services[1] = new LocalCollectionManagementService(user, brokerPool, this); --- 402,413 ---- return new LocalIndexQueryService(user, brokerPool, this); + if (name.equals("SchemaService")) + return new LocalSchemaService(user, brokerPool, this); + throw new XMLDBException(ErrorCodes.NO_SUCH_SERVICE); } public Service[] getServices() throws XMLDBException { ! Service[] services = new Service[7]; services[0] = new LocalXPathQueryService(user, brokerPool, this); services[1] = new LocalCollectionManagementService(user, brokerPool, this); *************** *** 412,415 **** --- 416,420 ---- services[4] = new LocalXUpdateQueryService(user, brokerPool, this); services[5] = new LocalIndexQueryService(user, brokerPool, this); + services[6] = new LocalSchemaService(user, brokerPool, this); return services; // jmv null; } Index: RemoteCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteCollection.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** RemoteCollection.java 8 Jun 2004 08:16:08 -0000 1.14 --- RemoteCollection.java 7 Aug 2004 14:55:59 -0000 1.15 *************** *** 40,43 **** --- 40,44 ---- import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; + import org.exist.schema.RemoteSchemaService; import org.exist.security.Permission; import org.exist.xmlrpc.RpcServer; *************** *** 203,211 **** if (name.equals("XUpdateQueryService")) return new RemoteXUpdateQueryService(this); throw new XMLDBException(ErrorCodes.NO_SUCH_SERVICE); } public Service[] getServices() throws XMLDBException { ! Service[] services = new Service[6]; services[0] = new RemoteXPathQueryService(this); services[1] = new RemoteCollectionManagementService(this, rpcClient); --- 204,214 ---- if (name.equals("XUpdateQueryService")) return new RemoteXUpdateQueryService(this); + if (name.equals("SchemaService")) + return new RemoteSchemaService(this); throw new XMLDBException(ErrorCodes.NO_SUCH_SERVICE); } public Service[] getServices() throws XMLDBException { ! Service[] services = new Service[7]; services[0] = new RemoteXPathQueryService(this); services[1] = new RemoteCollectionManagementService(this, rpcClient); *************** *** 214,217 **** --- 217,221 ---- services[4] = new RemoteIndexQueryService(rpcClient, this); services[5] = new RemoteXUpdateQueryService(this); + services[6] = new RemoteSchemaService(this); return services; } |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:52:37
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/schema/internalaccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32415/src/org/exist/schema/internalaccess Added Files: InternalSchemaAccess.java Log Message: add XML Schema validation (commands putschema and validate) - test in progress --- NEW FILE: InternalSchemaAccess.java --- /* * Created on May 25, 2004 * */ package org.exist.schema.internalaccess; import java.io.IOException; import java.io.StringReader; import java.util.Hashtable; import javax.xml.namespace.QName; import org.exist.EXistException; import org.exist.dom.DocumentImpl; import org.exist.schema.SchemaAccess; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; import org.exolab.castor.xml.schema.AttributeDecl; import org.exolab.castor.xml.schema.ElementDecl; import org.exolab.castor.xml.schema.Schema; import org.exolab.castor.xml.schema.XMLType; import org.exolab.castor.xml.schema.reader.SchemaReader; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xmldb.api.base.ErrorCodes; import org.xmldb.api.base.XMLDBException; /** * Provides server-internal access to the schema store. This has the advantage of being a lot faster than * taking the detour via the SchemaService. In addition to that you can also access schema definitions from * places where you have lost track of the context collection. * * @author seb * */ public class InternalSchemaAccess implements SchemaAccess { /** * singleton instance: */ private static InternalSchemaAccess singleInstance = null; private BrokerPool brokerPool = null; /** * Key: String targetNamespace */ private Hashtable schemaCache = new Hashtable(); /** * Key: QName of type */ private Hashtable typeCache = new Hashtable(); /** * Key: QName of element */ private Hashtable elementCache = new Hashtable(); /** * Key QName of attribute */ private Hashtable attributeCache = new Hashtable(); /** * */ private InternalSchemaAccess() throws EXistException { super(); brokerPool = BrokerPool.getInstance(); } public static InternalSchemaAccess getSingleInstance() throws EXistException { if (singleInstance == null) { singleInstance = new InternalSchemaAccess(); } return singleInstance; } /** * Retrieve a document by name and serialize it into a string. * @param docName the full path to the document * @return the serialization of the XML document referred to by <code>docuName</code> * @throws XMLDBException if there is a database error in the process */ private String getDocumentAsString(String docName) throws XMLDBException { DBBroker broker = null; try { broker = brokerPool.get(); Serializer serializer = broker.getSerializer(); serializer.reset(); DocumentImpl doc = (DocumentImpl) getDocumentAsDOM(docName); if (doc != null) return serializer.serialize(doc); else return null; } catch (Exception e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error getting document " + docName, e); } finally { if (broker != null) brokerPool.release(broker); } } /** * Retrieve a document by name and return it as a Document. * @param docName the full path to the document * @return * @throws XMLDBException */ private Document getDocumentAsDOM(String docName) throws XMLDBException { DBBroker broker = null; try { broker = brokerPool.get(); DocumentImpl doc; return (DocumentImpl) broker.getDocument(docName); } catch (Exception e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error getting document " + docName, e); } finally { if (broker != null) brokerPool.release(broker); } } /** Collection in which the schemas are stored */ private static final String SCHEMA_COLLECTION_PATH = "/db/system/schema"; /** Index file mapping targetNamespace to resource name */ private static final String INDEX_NAME = SCHEMA_COLLECTION_PATH + "/.index"; /** * Determines the filename (resource name) of the resource that stores the schema defining target namespace. * @param targetNamespace * @return the resource name without path * @throws XMLDBException */ private String getSchemaFilename(String targetNamespace) throws XMLDBException { //FIXME almost duplicate code with GenericSchemaService#getSchemaFilename! if (targetNamespace == null) throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "null is not a valid namespace!"); Node root = getDocumentAsDOM(INDEX_NAME).getDocumentElement(); if ("schema-index".equals(root.getNodeName())) { NodeList schemas = root.getChildNodes(); for (int i = 0; i < schemas.getLength(); i++) { Node schema = schemas.item(i); if ("schema".equals(schema.getNodeName())) { Node targetNamespaceAttr = schema.getAttributes().getNamedItem("targetNamespace"); if ((targetNamespaceAttr != null) && (targetNamespace.equals(targetNamespaceAttr.getNodeValue()))) return schema.getAttributes().getNamedItem("resourceName").getNodeValue(); } } } else { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "invalid schema index. Unexpected root element " + root.getNodeName(), null); } return null; } /** * Retrieve a Castor representation of the schema * @param targetNamespace * @return Schema (as per the Castor implementation), null if the schema corresponding to NS targetNamespace is not known) * @throws XMLDBException */ public Schema getCastorSchema(String targetNamespace) throws XMLDBException { Schema castorSchema = (Schema) schemaCache.get(targetNamespace); if (castorSchema == null) { String schemaFilename = getSchemaFilename(targetNamespace); if (schemaFilename != null) { try { String schema = getDocumentAsString(SCHEMA_COLLECTION_PATH + "/" + schemaFilename); if (schema != null) { castorSchema = (new SchemaReader(new InputSource(new StringReader(schema)))).read(); if (castorSchema != null) schemaCache.put(targetNamespace, castorSchema); } else throw new XMLDBException( ErrorCodes.VENDOR_ERROR, "Schema document for target namespace " + targetNamespace + " not found even though it is in the index.", null); } catch (IOException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error parsing schema " + targetNamespace, e); } } } return castorSchema; } public void putSchema(String schemaContents) throws XMLDBException { throw new UnsupportedOperationException("InternalSchemaAccess does not support storing of schemas."); } public boolean validate(String id) throws XMLDBException { return false; } /** * Find the (globally declared) type refered to by qname */ public XMLType getType(QName qname) throws XMLDBException { if ((qname.getNamespaceURI() == null) || ("".equals(qname.getNamespaceURI()))) throw new IllegalArgumentException("QName " + qname.toString() + " is not fully qualified."); XMLType type = (XMLType) typeCache.get(qname); if (type == null) { Schema schema = getCastorSchema(qname.getNamespaceURI()); type = schema.getType(qname.getLocalPart()); typeCache.put(qname, type); } return type; } /** * @return ElementDecl The element declaration (Castor) or null if the element qname is not known. */ public ElementDecl getElement(QName qname) throws XMLDBException { if ((qname.getNamespaceURI() == null) || ("".equals(qname.getNamespaceURI()))) throw new IllegalArgumentException("QName " + qname.toString() + " is not fully qualified."); ElementDecl element = (ElementDecl) elementCache.get(qname); if (element == null) { Schema schema = getCastorSchema(qname.getNamespaceURI()); if (schema != null) { element = schema.getElementDecl(qname.getLocalPart()); if (element != null) elementCache.put(qname, element); else return null; } else { return null; } } return element; } public AttributeDecl getAttribute(QName qname) throws XMLDBException { if ((qname.getNamespaceURI() == null) || ("".equals(qname.getNamespaceURI()))) throw new IllegalArgumentException("QName " + qname.toString() + " is not fully qualified."); AttributeDecl attribute = (AttributeDecl) attributeCache.get(qname); if (attribute == null) { Schema schema = getCastorSchema(qname.getNamespaceURI()); attribute = schema.getAttribute(qname.getLocalPart()); attributeCache.put(qname, attribute); } return attribute; } public boolean isKnownNamespace(String namespaceURI) throws XMLDBException { return getCastorSchema(namespaceURI) != null; } } |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:52:37
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32415/src/org/exist/schema Added Files: LocalSchemaService.java SchemaAccess.java SchemaService.java RemoteSchemaService.java GenericSchemaService.java Log Message: add XML Schema validation (commands putschema and validate) - test in progress --- NEW FILE: LocalSchemaService.java --- /* * Created on Apr 10, 2004 * */ package org.exist.schema; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.xmldb.LocalCollection; /** * @author seb */ public class LocalSchemaService extends GenericSchemaService { public LocalSchemaService(User user, BrokerPool pool, LocalCollection collection) { super(collection); } } --- NEW FILE: SchemaService.java --- /* * Created on Apr 10, 2004 */ package org.exist.schema; import org.xmldb.api.base.Service; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.XMLResource; /** * @author seb */ public interface SchemaService extends Service, SchemaAccess { /** find the whole schema as an XMLResource */ XMLResource getSchema(String targetNamespace) throws XMLDBException; /** Stores a new schema given its contents */ void putSchema(String schemaContents) throws XMLDBException; /** Validates a resource in the current collection */ boolean validateResource(String id) throws XMLDBException; /** Validates a resource given its contents */ boolean validateContents(String contents) throws XMLDBException; /** Add a schema on-the-fly. This schema will not be made persistent. This is usefull to validate * documents where one knows that a schema is not in the schema store. * @param schema * @throws XMLDBException */ void registerTransientSchema(String schema) throws XMLDBException; } --- NEW FILE: GenericSchemaService.java --- /* * Created on Apr 10, 2004 * */ package org.exist.schema; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.log4j.Logger; import org.apache.tools.ant.filters.StringInputStream; import org.apache.xerces.parsers.DOMParser; import org.exist.xmldb.XQueryService; import org.exolab.castor.xml.schema.AttributeDecl; import org.exolab.castor.xml.schema.ElementDecl; import org.exolab.castor.xml.schema.Schema; import org.exolab.castor.xml.schema.XMLType; import org.exolab.castor.xml.schema.reader.SchemaReader; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xmldb.api.base.Collection; import org.xmldb.api.base.ErrorCodes; import org.xmldb.api.base.Resource; import org.xmldb.api.base.ResourceSet; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; import org.xmldb.api.modules.XMLResource; /** * @author seb */ public abstract class GenericSchemaService implements SchemaService { private class ValidationErrorHandler implements ErrorHandler { private ArrayList warnings = new ArrayList(); private ArrayList errors = new ArrayList(); public void error(SAXParseException exception) throws SAXException { addError(exception); } public void fatalError(SAXParseException exception) throws SAXException { addError(exception); } public void warning(SAXParseException exception) throws SAXException { addWarning(exception); } /** * @return */ public ArrayList getErrors() { return errors; } private void addError(SAXParseException e) { getErrors().add("Error: (" + e.getLineNumber() + ", " + e.getColumnNumber() + "): " + e.getMessage()); } /** * @return */ public ArrayList getWarnings() { return warnings; } private void addWarning(SAXParseException e) { getWarnings().add("Warning: (" + e.getLineNumber() + ", " + e.getColumnNumber() + "): " + e.getMessage()); } public XMLDBException toException() { String errors = ""; for (Iterator i = getErrors().iterator(); i.hasNext();) errors += (String) i.next() + "\n"; return new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error validating: \n" + errors, null); } } protected Logger LOG = Logger.getLogger(GenericSchemaService.class); private final static String INDEX_RESOURCE_NAME = ".index"; private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; private Collection parentCollection; private Collection schemasCollection; private ArrayList transientSchemas = null; public GenericSchemaService(Collection collection) { setParentCollection(collection); } public String getName() throws XMLDBException { return "SchemaService"; } public String getVersion() throws XMLDBException { return "1.0"; } public void setCollection(Collection arg0) throws XMLDBException { } public String getProperty(String arg0) throws XMLDBException { return null; } public void setProperty(String arg0, String arg1) throws XMLDBException { } private XMLResource getIndexResource() throws XMLDBException { XMLResource index = null; try { index = (XMLResource) getSchemasCollection().getResource(INDEX_RESOURCE_NAME); } catch (XMLDBException e) { } if (index == null) { index = (XMLResource) schemasCollection.createResource(INDEX_RESOURCE_NAME, "XMLResource"); index.setContent("<?xml version=\"1.0\" encoding=\"UTF-8\"?><schema-index/>"); getSchemasCollection().storeResource(index); } return index; } private String getSchemaFilename(String targetNamespace) throws XMLDBException { if (targetNamespace == null) throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "null is not a valid namespace!"); XMLResource index = getIndexResource(); String filename = null; Node root = index.getContentAsDOM(); if ("schema-index".equals(root.getNodeName())) { NodeList schemas = root.getChildNodes(); for (int i = 0; i < schemas.getLength(); i++) { Node schema = schemas.item(i); if ("schema".equals(schema.getNodeName())) { Node targetNamespaceAttr = schema.getAttributes().getNamedItem("targetNamespace"); if ((targetNamespaceAttr != null) && (targetNamespace.equals(targetNamespaceAttr.getNodeValue()))) return schema.getAttributes().getNamedItem("resourceName").getNodeValue(); } } } else { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "invalid schema index. Unexpected root element " + root.getNodeName(), null); } return filename; } private Collection getSchemasCollection() throws XMLDBException { if (schemasCollection == null) { Collection parent = getParentCollection(); while (parent.getParentCollection() != null) parent = parent.getParentCollection(); schemasCollection = parent.getChildCollection("system").getChildCollection("schema"); if (schemasCollection == null) { CollectionManagementService cms = (CollectionManagementService) getParentCollection().getService("CollectionManagementService", "1.0"); if (cms != null) { cms.setCollection(parent.getChildCollection("system")); schemasCollection = cms.createCollection("schema"); } else { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Could not get CollectionManagementService.", null); } } } return schemasCollection; } private String findTargetNamespace(String schemaContents) throws XMLDBException { String targetNamespace = null; DOMParser parser = new DOMParser(); try { parser.parse(new InputSource(new StringReader(schemaContents))); Node rootNode = parser.getDocument().getDocumentElement(); Node targetNamespaceAttr = rootNode.getAttributes().getNamedItem("targetNamespace"); if (targetNamespaceAttr != null) targetNamespace = targetNamespaceAttr.getNodeValue(); } catch (SAXException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error parsing schema: " + e.getMessage(), e); } catch (IOException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error parsing schema: " + e.getMessage(), e); } return targetNamespace; } public void putSchema(String schemaContents) throws XMLDBException { Collection schemasCollection = getSchemasCollection(); String targetNamespace = findTargetNamespace(schemaContents); String filename = getSchemaFilename(targetNamespace); Resource schemaResource = null; if (filename == null) { filename = String.valueOf(System.currentTimeMillis()); schemaResource = schemasCollection.createResource(filename, "XMLResource"); addToIndex(targetNamespace, filename); } else schemaResource = (XMLResource) schemasCollection.getResource(filename); schemaResource.setContent(schemaContents); schemasCollection.storeResource(schemaResource); schemasCollection.close(); } private void addToIndex(String targetNamespace, String filename) throws XMLDBException { XMLResource index = getIndexResource(); Node rootNode = index.getContentAsDOM(); Document doc = rootNode.getOwnerDocument(); Element schemaNode = doc.createElement("schema"); // Attr targetNamespaceAttr = doc.createAttribute("targetNamespace"); // // jmv: targetNamespaceAttr.setNodeValue(targetNamespace); // targetNamespaceAttr.setValue(targetNamespace); // jmv // Attr resourceNameAttr = doc.createAttribute("resourceName"); // resourceNameAttr.setValue(filename); // jmv // schemaNode.getAttributes().setNamedItem(targetNamespaceAttr); // schemaNode.getAttributes().setNamedItem(resourceNameAttr); schemaNode.setAttribute("targetNamespace", targetNamespace); schemaNode.setAttribute("resourceName", filename); rootNode.appendChild(schemaNode); index.setContentAsDOM(rootNode); getSchemasCollection().storeResource(index); // jmv: this doesn't update the .index document ???!!! } public XMLResource getSchema(String targetNamespace) throws XMLDBException { String filename = getSchemaFilename(targetNamespace); if (filename != null) return (XMLResource) getSchemasCollection().getResource(filename); else return null; } public boolean validateContents(String contents) throws XMLDBException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); ValidationErrorHandler errorHandler = new ValidationErrorHandler(); docBuilder.setErrorHandler(errorHandler); Document document = docBuilder.parse(new StringInputStream(contents)); Set namespaces = new TreeSet(); findNamespaces(document.getDocumentElement(), namespaces); SchemaService schemaService = (SchemaService) getParentCollection().getService("SchemaService", "1.0"); ArrayList schemas = new ArrayList(); LOG.debug("Getting schemas for validation (" + namespaces.size() + "): "); for (Iterator i = namespaces.iterator(); i.hasNext();) { String namespaceURI = (String) i.next(); XMLResource resource = schemaService.getSchema(namespaceURI); if (resource != null) { schemas.add((String) resource.getContent()); LOG.info(namespaceURI); } else LOG.warn("No schema for target namespace " + namespaceURI + " found."); } factory.setValidating(true); try { factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); InputSource[] schemaSources = new InputSource[schemas.size() + getTransientSchemas().size()]; int i; for (i = 0; i < schemas.size(); i++) schemaSources[i] = new InputSource(new StringReader((String) schemas.get(i))); for (Iterator iter = getTransientSchemas().iterator(); iter.hasNext(); i++) schemaSources[i] = new InputSource(new StringReader((String) iter.next())); factory.setAttribute(JAXP_SCHEMA_SOURCE, schemaSources); } catch (IllegalArgumentException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Parser does not support JAXP 1.2", e); } docBuilder = factory.newDocumentBuilder(); docBuilder.setErrorHandler(errorHandler); docBuilder.parse(new StringInputStream(contents)); if (errorHandler.getErrors().size() > 0) throw errorHandler.toException(); return true; } catch (ParserConfigurationException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Parser config error validating contents.", e); } catch (SAXException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "SAX error reading contents.", e); } catch (IOException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "IO error reading contents", e); } } public boolean validateResource(String id) throws XMLDBException { Resource doc = getParentCollection().getResource(id); if (("XMLResource".equals(doc.getResourceType())) || ("XMLView".equals(doc.getResourceType()))) { XMLResource xmlResource = (XMLResource) doc; Node root = xmlResource.getContentAsDOM(); try { return validateContents((String) xmlResource.getContent()); } catch (XMLDBException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error validating resource " + id, e); } } else { throw new XMLDBException( ErrorCodes.WRONG_CONTENT_TYPE, "Can only validate XML documents, but " + id + " is a " + doc.getResourceType(), null); } } /** * @param root * @return */ private void findNamespaces(Node root, Set namespaces) { if (root != null) { LOG.debug("locating namespace in " + root.getNodeName()); String namespace = root.getNamespaceURI(); if (namespace != null && !"".equals(namespace)) namespaces.add(namespace); findNamespaces(root.getFirstChild(), namespaces); findNamespaces(root.getNextSibling(), namespaces); } } public Collection getParentCollection() { return parentCollection; } public void setParentCollection(Collection collection) { parentCollection = collection; } /** * @return the attribute by name qname or null if no such attribute is known. */ public AttributeDecl getAttribute(QName qname) throws XMLDBException { String xquery = "declare namespace xs=\"" + W3C_XML_SCHEMA + "\";" + "/xs:schema[@targetNamespace=\"" + qname.getNamespaceURI() + "\"]/xs:attribute[@name=\"" + qname.getLocalPart() + "\"]"; XQueryService service = (XQueryService) getSchemasCollection().getService("XQueryService", "1.0"); ResourceSet result = service.query(xquery); if (result.getSize() == 0) return null; else if (result.getSize() > 1) throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Found multiple types by name " + qname, null); else { //return result.getResource(0); return null; } } /** * @return the element by name qname or null if no such element is known. */ public ElementDecl getElement(QName qname) throws XMLDBException { String xquery = "declare namespace xs=\"" + W3C_XML_SCHEMA + "\";" + "/xs:schema[@targetNamespace=\"" + qname.getNamespaceURI() + "\"]/xs:element[@name=\"" + qname.getLocalPart() + "\"]"; XQueryService service = (XQueryService) getSchemasCollection().getService("XQueryService", "1.0"); ResourceSet result = service.query(xquery); if (result.getSize() == 0) return null; else if (result.getSize() > 1) throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Found multiple types by name " + qname, null); else { //return result.getResource(0); return null; } } /** * @return the type-definition by name qname or null if no such type-definition is known. */ public XMLType getType(QName qname) throws XMLDBException { /*String xquery = "declare namespace xs=\"" + W3C_XML_SCHEMA + "\";" + "/xs:schema[@targetNamespace=\"" + qname.getNamespaceURI() + "\"]/(xs:complexType|xs:simpleType)[@name=\"" + qname.getLocalPart() + "\"]"; XQueryService service = (XQueryService) getSchemasCollection().getService("XQueryService", "1.0"); ResourceSet result = service.query(xquery); if (result.getSize() == 0) return null; else if (result.getSize() > 1) throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Found multiple types by name " + qname, null); else { //return result.getResource(0); return new Object(); }*/ XMLResource resource = getSchema(qname.getNamespaceURI()); try { Schema schema = (new SchemaReader((String) resource.getContent())).read(); return schema.getType(qname.getLocalPart()); } catch (IOException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Error reading schema information for target namespace: " + qname.getNamespaceURI(), e); } } /** * */ public boolean isKnownNamespace(String namespaceURI) throws XMLDBException { return getSchema(namespaceURI) != null; } public void registerTransientSchema(String schema) throws XMLDBException { getTransientSchemas().add(schema); } /** * @return */ public ArrayList getTransientSchemas() { if (transientSchemas == null) { transientSchemas = new ArrayList(); } return transientSchemas; } } --- NEW FILE: RemoteSchemaService.java --- /* * Created on Apr 23, 2004 * */ package org.exist.schema; import org.exist.xmldb.RemoteCollection; public class RemoteSchemaService extends GenericSchemaService { public RemoteSchemaService(RemoteCollection collection) { super(collection); } } --- NEW FILE: SchemaAccess.java --- /* * Created on May 25, 2004 * */ package org.exist.schema; import javax.xml.namespace.QName; import org.exolab.castor.xml.schema.AttributeDecl; import org.exolab.castor.xml.schema.ElementDecl; import org.exolab.castor.xml.schema.XMLType; import org.xmldb.api.base.XMLDBException; /** * @author seb * */ public interface SchemaAccess { XMLType getType(QName qname) throws XMLDBException; ElementDecl getElement(QName qname) throws XMLDBException; AttributeDecl getAttribute(QName qname) throws XMLDBException; /** * Is a schema defining this namespace known * @param namespaceURI * @return * @throws XMLDBException */ boolean isKnownNamespace(String namespaceURI) throws XMLDBException; } |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:50:47
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/schema/internalaccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32180/src/org/exist/schema/internalaccess Log Message: Directory /cvsroot/exist/eXist-1.0/src/org/exist/schema/internalaccess added to the repository |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:50:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32180/src/org/exist/schema Log Message: Directory /cvsroot/exist/eXist-1.0/src/org/exist/schema added to the repository |
From: Jean-Marc V. <jm...@us...> - 2004-08-07 14:45:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31340/src/org/exist/client Modified Files: ClientFrame.java Log Message: error window is Resizable Index: ClientFrame.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/ClientFrame.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ClientFrame.java 30 Jul 2004 07:38:14 -0000 1.24 --- ClientFrame.java 7 Aug 2004 14:45:04 -0000 1.25 *************** *** 1397,1400 **** --- 1397,1401 ---- optionPane.setMessageType(JOptionPane.ERROR_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Error"); + dialog.setResizable(true); dialog.pack(); dialog.show(); |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:40:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11713/src/org/exist/http/webdav/methods Modified Files: Lock.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: Lock.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Lock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Lock.java 25 May 2004 09:26:04 -0000 1.1 --- Lock.java 6 Aug 2004 17:40:39 -0000 1.2 *************** *** 10,26 **** import javax.xml.parsers.ParserConfigurationException; import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; - import org.exist.http.webdav.WebDAVMethod; import org.exist.http.webdav.WebDAVUtil; - import org.exist.security.Permission; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; ! public class Lock implements WebDAVMethod { private final static int SCOPE_EXCLUSIVE = 0; --- 10,26 ---- import javax.xml.parsers.ParserConfigurationException; + import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; import org.exist.http.webdav.WebDAVUtil; import org.exist.security.User; import org.exist.storage.BrokerPool; + import org.exist.storage.DBBroker; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; ! public class Lock extends AbstractWebDAVMethod { private final static int SCOPE_EXCLUSIVE = 0; *************** *** 31,35 **** public Lock(BrokerPool pool) { ! this.pool = pool; docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); --- 31,35 ---- public Lock(BrokerPool pool) { ! super(pool); docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); *************** *** 40,108 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! LOG.debug("No resource or collection found"); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, "No resource or collection found"); ! return; ! } ! if(!collection.getPermissions().validate(user, Permission.READ)) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN); ! return; ! } ! if(resource == null) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Lock on collections is not supported yet"); ! return; ! } ! DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); ! docFactory.setNamespaceAware(true); ! DocumentBuilder docBuilder; ! try { ! docBuilder = docFactory.newDocumentBuilder(); ! } catch (ParserConfigurationException e1) { ! throw new ServletException(WebDAVUtil.XML_CONFIGURATION_ERR, e1); ! } ! Document doc = WebDAVUtil.parseRequestContent(request, response, docBuilder); ! Element lockinfo = doc.getDocumentElement(); ! if(!(lockinfo.getLocalName().equals("lockinfo") && ! lockinfo.getNamespaceURI().equals(WebDAV.DAV_NS))) { ! LOG.debug(WebDAVUtil.UNEXPECTED_ELEMENT_ERR + lockinfo.getNodeName()); ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + lockinfo.getNodeName()); ! return; ! } ! int scope = SCOPE_EXCLUSIVE; ! String owner = null; ! ! Node node = lockinfo.getFirstChild(); ! while(node != null) { ! if(node.getNodeType() == Node.ELEMENT_NODE) { ! if(node.getNamespaceURI().equals(WebDAV.DAV_NS)) { ! if("lockscope".equals(node.getLocalName())) { ! Node scopeNode = WebDAVUtil.firstElementNode(node); ! if("exclusive".equals(scopeNode.getLocalName())) ! scope = SCOPE_EXCLUSIVE; ! else if("shared".equals(scopeNode.getLocalName())) ! scope = SCOPE_SHARED; ! } ! if("locktype".equals(node.getLocalName())) { ! Node typeNode = WebDAVUtil.firstElementNode(node); ! if(!"write".equals(typeNode.getLocalName())) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + typeNode.getNodeName()); ! return; ! } ! } ! if("owner".equals(node.getLocalName())) { ! Node href = WebDAVUtil.firstElementNode(node); ! owner = WebDAVUtil.getElementContent(href); ! } ! } ! } ! node = node.getNextSibling(); } - LOG.debug("Received lock request [" + scope + "] for owner " + owner); - if(resource != null) - lockResource(request, response, resource, scope); } --- 40,128 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { ! DBBroker broker = null; ! Collection collection = null; ! DocumentImpl resource = null; ! try { ! broker = pool.get(user); ! collection = broker.openCollection(path, org.exist.util.Lock.WRITE_LOCK); ! if(collection == null) { ! int pos = path.lastIndexOf('/'); ! String collName = path.substring(0, pos); ! String docName = path.substring(pos + 1); ! LOG.debug("collection = " + collName + "; doc = " + docName); ! collection = broker.openCollection(collName, org.exist.util.Lock.WRITE_LOCK); ! if(collection == null) { ! LOG.debug("No resource or collection found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! resource = collection.getDocument(broker, docName); ! if(resource == null) { ! LOG.debug("No resource found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! } ! if(resource == null) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Lock on collections is not supported yet"); ! return; ! } ! DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); ! docFactory.setNamespaceAware(true); ! DocumentBuilder docBuilder; ! try { ! docBuilder = docFactory.newDocumentBuilder(); ! } catch (ParserConfigurationException e1) { ! throw new ServletException(WebDAVUtil.XML_CONFIGURATION_ERR, e1); ! } ! Document doc = WebDAVUtil.parseRequestContent(request, response, docBuilder); ! Element lockinfo = doc.getDocumentElement(); ! if(!(lockinfo.getLocalName().equals("lockinfo") && ! lockinfo.getNamespaceURI().equals(WebDAV.DAV_NS))) { ! LOG.debug(WebDAVUtil.UNEXPECTED_ELEMENT_ERR + lockinfo.getNodeName()); ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + lockinfo.getNodeName()); ! return; ! } ! int scope = SCOPE_EXCLUSIVE; ! String owner = null; ! ! Node node = lockinfo.getFirstChild(); ! while(node != null) { ! if(node.getNodeType() == Node.ELEMENT_NODE) { ! if(node.getNamespaceURI().equals(WebDAV.DAV_NS)) { ! if("lockscope".equals(node.getLocalName())) { ! Node scopeNode = WebDAVUtil.firstElementNode(node); ! if("exclusive".equals(scopeNode.getLocalName())) ! scope = SCOPE_EXCLUSIVE; ! else if("shared".equals(scopeNode.getLocalName())) ! scope = SCOPE_SHARED; ! } ! if("locktype".equals(node.getLocalName())) { ! Node typeNode = WebDAVUtil.firstElementNode(node); ! if(!"write".equals(typeNode.getLocalName())) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + typeNode.getNodeName()); ! return; ! } ! } ! if("owner".equals(node.getLocalName())) { ! Node href = WebDAVUtil.firstElementNode(node); ! owner = WebDAVUtil.getElementContent(href); ! } ! } ! } ! node = node.getNextSibling(); ! } ! LOG.debug("Received lock request [" + scope + "] for owner " + owner); ! if(resource != null) ! lockResource(request, response, resource, scope); ! } catch (EXistException e) { ! throw new ServletException(e); ! } finally { ! if(collection != null) ! collection.release(); } } |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:36:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/src/org/exist/http/webdav/methods Modified Files: Copy.java Delete.java Get.java Options.java Mkcol.java Move.java Put.java Head.java Propfind.java Added Files: AbstractWebDAVMethod.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: Get.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Get.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Get.java 2 Jul 2004 16:53:55 -0000 1.2 --- Get.java 6 Aug 2004 17:36:36 -0000 1.3 *************** *** 31,84 **** import org.exist.EXistException; - import org.exist.collections.Collection; import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; - import org.exist.http.webdav.WebDAVMethod; import org.exist.security.Permission; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; import org.xml.sax.SAXException; /** * @author wolf */ ! public class Get implements WebDAVMethod { ! private BrokerPool pool; public Get(BrokerPool pool) { ! this.pool = pool; } - /* (non-Javadoc) - * @see org.exist.http.webdav.WebDAVMethod#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.exist.collections.Collection, org.exist.dom.DocumentImpl) - */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(resource == null) { ! // GET is not available on collections ! response.sendError(HttpServletResponse.SC_FORBIDDEN, "GET is not available on collections"); ! return; ! } ! if(!resource.getPermissions().validate(user, Permission.READ)) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, "Not allowed to read resource"); ! return; ! } ! String contentType; ! if(resource.getResourceType() == DocumentImpl.XML_FILE) ! contentType = WebDAV.XML_CONTENT; ! else ! contentType = WebDAV.BINARY_CONTENT; ! response.setContentType(contentType); ! response.addDateHeader("Last-Modified", resource.getLastModified()); ! ! byte[] contentData = null; DBBroker broker = null; try { broker = pool.get(); if(resource.getResourceType() == DocumentImpl.XML_FILE) { Serializer serializer = broker.getSerializer(); --- 31,84 ---- import org.exist.EXistException; import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; import org.exist.security.Permission; + import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; + import org.exist.util.Lock; import org.xml.sax.SAXException; /** + * Implements the WebDAV GET method. + * * @author wolf */ ! public class Get extends AbstractWebDAVMethod { ! private final static String SERIALIZE_ERROR = "Error while serializing document: "; public Get(BrokerPool pool) { ! super(pool); } public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { DBBroker broker = null; + byte[] contentData = null; + DocumentImpl resource = null; try { broker = pool.get(); + resource = broker.openDocument(path, Lock.READ_LOCK); + if(resource == null) { + // GET is not available on collections + response.sendError(HttpServletResponse.SC_FORBIDDEN, "GET is not available on collections"); + return; + } + if(!resource.getPermissions().validate(user, Permission.READ)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); + return; + } + String contentType; + if(resource.getResourceType() == DocumentImpl.XML_FILE) + contentType = WebDAV.XML_CONTENT; + else + contentType = WebDAV.BINARY_CONTENT; + response.setContentType(contentType); + response.addDateHeader("Last-Modified", resource.getLastModified()); + if(resource.getResourceType() == DocumentImpl.XML_FILE) { Serializer serializer = broker.getSerializer(); *************** *** 89,99 **** contentData = content.getBytes("UTF-8"); } catch (SAXException e) { ! throw new ServletException("Error while serializing document: " + e.getMessage(), e); } } else contentData = broker.getBinaryResourceData((BinaryDocument)resource); } catch (EXistException e) { ! throw new ServletException("Error while serializing document: " + e.getMessage(), e); } finally { pool.release(broker); } --- 89,103 ---- contentData = content.getBytes("UTF-8"); } catch (SAXException e) { ! throw new ServletException(SERIALIZE_ERROR + e.getMessage(), e); } } else contentData = broker.getBinaryResourceData((BinaryDocument)resource); } catch (EXistException e) { ! throw new ServletException(SERIALIZE_ERROR + e.getMessage(), e); ! } catch (PermissionDeniedException e) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); } finally { + if(resource != null) + resource.getUpdateLock().release(Lock.READ_LOCK); pool.release(broker); } --- NEW FILE: AbstractWebDAVMethod.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2000-04, Wolfgang M. Meier (wol...@ex...) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This library 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 Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: AbstractWebDAVMethod.java,v 1.1 2004/08/06 17:36:36 wolfgang_m Exp $ */ package org.exist.http.webdav.methods; import org.apache.log4j.Logger; import org.exist.http.webdav.WebDAVMethod; import org.exist.storage.BrokerPool; /** * Abstract base class for all WebDAV methods. * * @author wolf */ public abstract class AbstractWebDAVMethod implements WebDAVMethod { final static Logger LOG = Logger.getLogger(AbstractWebDAVMethod.class); // common error messages final static String READ_PERMISSION_DENIED = "Not allowed to read resource"; final static String NOT_FOUND_ERR = "No resource or collection found"; protected BrokerPool pool; public AbstractWebDAVMethod(BrokerPool pool) { this.pool = pool; } } Index: Mkcol.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Mkcol.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mkcol.java 5 Aug 2004 12:09:42 -0000 1.4 --- Mkcol.java 6 Aug 2004 17:36:36 -0000 1.5 *************** *** 31,89 **** import org.exist.EXistException; import org.exist.collections.Collection; - import org.exist.dom.DocumentImpl; - import org.exist.http.webdav.WebDAVMethod; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; /** * @author wolf */ ! public class Mkcol implements WebDAVMethod { - private BrokerPool pool; - - /** - * - */ public Mkcol(BrokerPool pool) { ! super(); ! this.pool = pool; } - /* (non-Javadoc) - * @see org.exist.http.webdav.WebDAVMethod#process(org.exist.security.User, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.exist.collections.Collection, org.exist.dom.DocumentImpl) - */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(collection != null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "collection " + request.getPathInfo() + " already exists"); ! return; ! } ! if(resource != null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "path conflicts with an existing resource"); ! return; ! } ! String path = request.getPathInfo(); ! if(path == null || path.equals("")) { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "no path specified"); return; } ! if(path.endsWith("/")) ! path = path.substring(0, path.length() - 1); ! int p = path.lastIndexOf('/'); ! String parentPath = -1 < p ? path.substring(0, p) : "/db"; ! String newCollection = -1 < p ? path.substring(p + 1) : path; ! DBBroker broker = null; ! try { ! broker = pool.get(user); ! Collection parent = broker.getCollection(parentPath); ! if(parent == null) { LOG.debug("Parent collection " + parentPath + " not found"); response.sendError(HttpServletResponse.SC_CONFLICT, --- 31,76 ---- import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; /** + * Implements the WebDAV MKCOL method. + * * @author wolf */ ! public class Mkcol extends AbstractWebDAVMethod { public Mkcol(BrokerPool pool) { ! super(pool); } public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { ! String origPath = request.getPathInfo(); ! if(path == null || path.equals("")) { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "no path specified"); return; } ! DBBroker broker = null; ! Collection collection = null; ! try { ! broker = pool.get(user); ! collection = broker.openCollection(path, Lock.READ_LOCK); ! if(collection != null) { ! collection.release(); ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "collection " + request.getPathInfo() + " already exists"); ! return; ! } ! int p = path.lastIndexOf('/'); ! String parentPath = -1 < p ? path.substring(0, p) : "/db"; ! String newCollection = -1 < p ? path.substring(p + 1) : path; ! collection = broker.openCollection(parentPath, Lock.WRITE_LOCK); ! if(collection == null) { LOG.debug("Parent collection " + parentPath + " not found"); response.sendError(HttpServletResponse.SC_CONFLICT, *************** *** 91,94 **** --- 78,89 ---- return; } + if(collection.hasDocument(newCollection)) { + collection.release(); + response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, + "path conflicts with an existing resource"); + return; + } + // TODO: releasing the lock here is dangerous, but we may get into deadlocks otherwise. + collection.release(); Collection created = broker.getOrCreateCollection(path); broker.saveCollection(created); Index: Copy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Copy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Copy.java 5 Aug 2004 12:09:42 -0000 1.4 --- Copy.java 6 Aug 2004 17:36:36 -0000 1.5 *************** *** 34,38 **** import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; - import org.exist.http.webdav.WebDAVMethod; import org.exist.security.PermissionDeniedException; import org.exist.security.User; --- 34,37 ---- *************** *** 48,54 **** * @author wolf */ ! public class Copy implements WebDAVMethod { ! ! private BrokerPool pool; /** --- 47,51 ---- * @author wolf */ ! public class Copy extends AbstractWebDAVMethod { /** *************** *** 56,61 **** */ public Copy(BrokerPool pool) { ! super(); ! this.pool = pool; } --- 53,57 ---- */ public Copy(BrokerPool pool) { ! super(pool); } *************** *** 64,100 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! response.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource or collection not found"); ! return; ! } ! String destination = request.getHeader("Destination"); ! String path = null; ! try { ! URI uri = new URI(destination); ! String host = uri.getHost(); ! int port = uri.getPort(); ! if(!(host.equals(request.getServerName()) && port == request.getServerPort())) { ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Copying to a different server is not yet implemented"); ! return; ! } ! path = uri.getPath(); ! if(path.startsWith(request.getContextPath())) ! path = path.substring(request.getContextPath().length()); ! if(path.startsWith(request.getServletPath())) ! path = path.substring(request.getServletPath().length()); ! } catch (URISyntaxException e) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); ! } ! if(resource != null) ! copyResource(user, request, response, resource, path); ! else ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Copying collections is not yet implemented"); } ! private void copyResource(User user, HttpServletRequest request, HttpServletResponse response, DocumentImpl resource, String destination) throws ServletException, IOException { --- 60,125 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { ! DBBroker broker = null; ! Collection collection = null; ! DocumentImpl resource = null; ! try { ! broker = pool.get(user); ! collection = broker.openCollection(path, Lock.READ_LOCK); ! if(collection == null) { ! int pos = path.lastIndexOf('/'); ! String collName = path.substring(0, pos); ! String docName = path.substring(pos + 1); ! collection = broker.openCollection(collName, Lock.READ_LOCK); ! if(collection == null) { ! LOG.debug("No resource or collection found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! resource = collection.getDocumentWithLock(broker, docName, Lock.READ_LOCK); ! if(resource == null) { ! LOG.debug("No resource found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! } ! String destination = request.getHeader("Destination"); ! String destPath = null; ! try { ! URI uri = new URI(destination); ! String host = uri.getHost(); ! int port = uri.getPort(); ! if(!(host.equals(request.getServerName()) && port == request.getServerPort())) { ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Copying to a different server is not yet implemented"); ! return; ! } ! destPath = uri.getPath(); ! if(destPath.startsWith(request.getContextPath())) ! destPath = destPath.substring(request.getContextPath().length()); ! if(destPath.startsWith(request.getServletPath())) ! destPath = destPath.substring(request.getServletPath().length()); ! } catch (URISyntaxException e) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); ! } ! if(resource != null) ! copyResource(user, broker, request, response, collection, resource, destPath); ! else ! copyCollection(user, broker, request, response, collection, destPath); ! } catch (EXistException e) { ! throw new ServletException("Failed to copy: " + e.getMessage(), e); ! } catch (LockException e) { ! throw new ServletException("Failed to copy: " + e.getMessage(), e); ! } finally { ! if(collection != null) ! collection.release(); ! if(resource != null) ! resource.getUpdateLock().release(Lock.READ_LOCK); ! pool.release(broker); ! } } ! private void copyResource(User user, DBBroker broker, HttpServletRequest request, HttpServletResponse response, ! Collection sourceCollection, DocumentImpl resource, String destination) throws ServletException, IOException { *************** *** 108,116 **** destination = destination.substring(0, p); boolean replaced = false; - DBBroker broker = null; Collection destCollection = null; - Collection sourceCollection = null; try { - broker = pool.get(user); destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); if(destCollection == null) { --- 133,138 ---- *************** *** 119,127 **** return; } - String sourcePath = resource.getName(); - int pos = sourcePath.lastIndexOf('/'); - String collName = sourcePath.substring(0, pos); - String docName = sourcePath.substring(pos + 1); - sourceCollection = broker.openCollection(collName, Lock.READ_LOCK); DocumentImpl oldDoc = destCollection.getDocument(broker, newResourceName); --- 141,144 ---- *************** *** 140,145 **** else response.setStatus(HttpServletResponse.SC_CREATED); - } catch (EXistException e) { - throw new ServletException(e.getMessage(), e); } catch (PermissionDeniedException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); --- 157,160 ---- *************** *** 147,159 **** response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { - if(sourceCollection != null) - sourceCollection.release(); if(destCollection != null) destCollection.release(); - pool.release(broker); } } ! private void copyCollection(User user, HttpServletRequest request, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { --- 162,171 ---- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { if(destCollection != null) destCollection.release(); } } ! private void copyCollection(User user, DBBroker broker, HttpServletRequest request, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { *************** *** 167,174 **** destination = destination.substring(0, p); boolean replaced = false; - DBBroker broker = null; Collection destCollection = null; try { - broker = pool.get(user); destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); if(destCollection == null) { --- 179,184 ---- *************** *** 192,197 **** else response.setStatus(HttpServletResponse.SC_CREATED); - } catch (EXistException e) { - throw new ServletException(e.getMessage(), e); } catch (PermissionDeniedException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); --- 202,205 ---- *************** *** 201,205 **** if(destCollection != null) destCollection.release(); - pool.release(broker); } } --- 209,212 ---- Index: Move.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Move.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Move.java 3 Aug 2004 15:25:58 -0000 1.4 --- Move.java 6 Aug 2004 17:36:36 -0000 1.5 *************** *** 34,42 **** import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; - import org.exist.http.webdav.WebDAVMethod; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.util.LockException; --- 34,42 ---- import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; import org.exist.util.LockException; *************** *** 45,54 **** * @author wolf */ ! public class Move implements WebDAVMethod { - private BrokerPool pool; public Move(BrokerPool pool) { ! this.pool = pool; } --- 45,53 ---- * @author wolf */ ! public class Move extends AbstractWebDAVMethod { public Move(BrokerPool pool) { ! super(pool); } *************** *** 57,92 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! response.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource or collection not found"); ! return; ! } ! String destination = request.getHeader("Destination"); ! String path = null; ! try { ! URI uri = new URI(destination); ! String host = uri.getHost(); ! int port = uri.getPort(); ! if(!(host.equals(request.getServerName()) && port == request.getServerPort())) { ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Moving to a different server is not yet implemented"); ! return; ! } ! path = uri.getPath(); ! if(path.startsWith(request.getContextPath())) ! path = path.substring(request.getContextPath().length()); ! if(path.startsWith(request.getServletPath())) ! path = path.substring(request.getServletPath().length()); ! } catch (URISyntaxException e) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); ! } ! if(resource != null) ! moveResource(user, request, response, resource, path); ! else ! moveCollection(user, request, response, collection, path); } ! private void moveCollection(User user, HttpServletRequest request, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { if(collection.getName().equals(destination)) { --- 56,120 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { ! DBBroker broker = null; ! Collection collection = null; ! DocumentImpl resource = null; ! try { ! broker = pool.get(user); ! collection = broker.openCollection(path, Lock.WRITE_LOCK); ! if(collection == null) { ! int pos = path.lastIndexOf('/'); ! String collName = path.substring(0, pos); ! String docName = path.substring(pos + 1); ! collection = broker.openCollection(collName, Lock.WRITE_LOCK); ! if(collection == null) { ! LOG.debug("No resource or collection found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! resource = collection.getDocumentWithLock(broker, docName, Lock.WRITE_LOCK); ! if(resource == null) { ! LOG.debug("No resource found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! } ! String destination = request.getHeader("Destination"); ! String destPath = null; ! try { ! URI uri = new URI(destination); ! String host = uri.getHost(); ! int port = uri.getPort(); ! if(!(host.equals(request.getServerName()) && port == request.getServerPort())) { ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Copying to a different server is not yet implemented"); ! return; ! } ! destPath = uri.getPath(); ! if(destPath.startsWith(request.getContextPath())) ! destPath = destPath.substring(request.getContextPath().length()); ! if(destPath.startsWith(request.getServletPath())) ! destPath = destPath.substring(request.getServletPath().length()); ! } catch (URISyntaxException e) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); ! } ! if(resource != null) ! moveResource(user, broker, request, response, resource, destPath); ! else ! moveCollection(user, broker, request, response, collection, destPath); ! } catch (EXistException e) { ! throw new ServletException("Failed to copy: " + e.getMessage(), e); ! } catch (LockException e) { ! throw new ServletException("Failed to copy: " + e.getMessage(), e); ! } finally { ! if(collection != null) ! collection.release(); ! if(resource != null) ! resource.getUpdateLock().release(Lock.WRITE_LOCK); ! pool.release(broker); ! } } ! private void moveCollection(User user, DBBroker broker, HttpServletRequest request, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { if(collection.getName().equals(destination)) { *************** *** 95,135 **** return; } ! DBBroker broker = null; try { - broker = pool.get(user); boolean replaced = false; ! Collection destCollection = broker.getCollection(destination); ! if(destCollection != null) { ! boolean overwrite = overwrite(request); ! if(!overwrite) { ! response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, ! "Destination collection exists"); ! return; ! } ! broker.removeCollection(destCollection); ! replaced = true; ! } ! int p = destination.lastIndexOf('/'); ! if(p < 0) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! "Bad destination: " + destination); ! return; ! } String parentPath = destination.substring(0, p); String newCollectionName = destination.substring(p + 1); LOG.debug("parent = " + parentPath + "; new name = " + newCollectionName); ! Collection parent = broker.getCollection(parentPath); ! if(parent == null) { response.sendError(HttpServletResponse.SC_CONFLICT, "No parent collection: " + parentPath); return; } ! broker.moveCollection(collection, parent, newCollectionName); if(replaced) response.setStatus(HttpServletResponse.SC_NO_CONTENT); else response.setStatus(HttpServletResponse.SC_CREATED); - } catch (EXistException e) { - throw new ServletException(e.getMessage(), e); } catch (PermissionDeniedException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); --- 123,161 ---- return; } ! int p = destination.lastIndexOf('/'); ! if(p < 0) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! "Bad destination: " + destination); ! return; ! } ! Collection destCollection = null; try { boolean replaced = false; ! destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); ! if(destCollection != null) { ! boolean overwrite = overwrite(request); ! if(!overwrite) { ! response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, ! "Destination collection exists and overwrite is not allowed"); ! return; ! } ! broker.removeCollection(destCollection); ! replaced = true; ! } ! String parentPath = destination.substring(0, p); String newCollectionName = destination.substring(p + 1); LOG.debug("parent = " + parentPath + "; new name = " + newCollectionName); ! destCollection = broker.openCollection(parentPath, Lock.WRITE_LOCK); ! if(destCollection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, "No parent collection: " + parentPath); return; } ! broker.moveCollection(collection, destCollection, newCollectionName); if(replaced) response.setStatus(HttpServletResponse.SC_NO_CONTENT); else response.setStatus(HttpServletResponse.SC_CREATED); } catch (PermissionDeniedException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); *************** *** 137,148 **** response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { pool.release(broker); } } ! private void moveResource(User user, HttpServletRequest request, HttpServletResponse response, DocumentImpl resource, ! String destination) throws ServletException, IOException { ! int p = destination.lastIndexOf('/'); if(p < 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, --- 163,176 ---- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + if(destCollection != null) + destCollection.release(); pool.release(broker); } } ! private void moveResource(User user, DBBroker broker, HttpServletRequest request, HttpServletResponse response, ! DocumentImpl resource, String destination) throws ServletException, IOException { ! int p = destination.lastIndexOf('/'); if(p < 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, *************** *** 153,160 **** destination = destination.substring(0, p); boolean replaced = false; ! DBBroker broker = null; try { ! broker = pool.get(user); ! Collection destCollection = broker.getCollection(destination); if(destCollection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, --- 181,187 ---- destination = destination.substring(0, p); boolean replaced = false; ! Collection destCollection = null; try { ! destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); if(destCollection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, *************** *** 162,165 **** --- 189,193 ---- return; } + DocumentImpl oldDoc = destCollection.getDocument(broker, newResourceName); if(oldDoc != null) { *************** *** 177,182 **** else response.setStatus(HttpServletResponse.SC_CREATED); - } catch (EXistException e) { - throw new ServletException(e.getMessage(), e); } catch (PermissionDeniedException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); --- 205,208 ---- *************** *** 184,188 **** response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { ! pool.release(broker); } } --- 210,215 ---- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { ! if(destCollection != null) ! destCollection.release(); } } Index: Put.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Put.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Put.java 5 Aug 2004 12:09:42 -0000 1.4 --- Put.java 6 Aug 2004 17:36:36 -0000 1.5 *************** *** 40,46 **** import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.collections.triggers.TriggerException; - import org.exist.dom.DocumentImpl; - import org.exist.http.webdav.WebDAVMethod; import org.exist.security.PermissionDeniedException; import org.exist.security.User; --- 40,45 ---- import org.exist.EXistException; import org.exist.collections.Collection; + import org.exist.collections.IndexInfo; import org.exist.collections.triggers.TriggerException; import org.exist.security.PermissionDeniedException; import org.exist.security.User; *************** *** 55,64 **** * @author wolf */ ! public class Put implements WebDAVMethod { ! ! private BrokerPool pool; public Put(BrokerPool pool) { ! this.pool = pool; } --- 54,61 ---- * @author wolf */ ! public class Put extends AbstractWebDAVMethod { public Put(BrokerPool pool) { ! super(pool); } *************** *** 67,72 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { File tempFile = saveRequestContent(request); String url; --- 64,68 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { File tempFile = saveRequestContent(request); String url; *************** *** 77,114 **** } String contentType = request.getContentType(); - String path = request.getPathInfo(); DBBroker broker = null; try { broker = pool.get(user); if(collection == null) { ! if(path == null) ! path = ""; ! if(path.endsWith("/")) ! path = path.substring(0, path.length() - 1); ! int p = path.lastIndexOf('/'); ! if(p < 1) { ! response.sendError(HttpServletResponse.SC_CONFLICT, "No collection specified for PUT"); ! return; ! } ! String collectionName = path.substring(0, p); ! path = path.substring(p + 1); ! collection = broker.openCollection(collectionName, Lock.WRITE_LOCK); ! if(collection == null) { ! response.sendError(HttpServletResponse.SC_CONFLICT, "Parent collection " + collectionName + ! " not found"); ! return; ! } ! } else { ! collection.getLock().acquire(Lock.WRITE_LOCK); ! path = path.substring(collection.getName().length() + 1); } if(contentType == null) { ! contentType = URLConnection.guessContentTypeFromName(path); } LOG.debug("storing document " + path + "; content-type = " + contentType); if(contentType == null || contentType.equalsIgnoreCase("text/xml") || ! contentType.equals("application/xml")) { ! DocumentImpl doc = collection.addDocument(broker, path, ! new InputSource(url)); } else { byte[] chunk = new byte[4096]; --- 73,114 ---- } String contentType = request.getContentType(); DBBroker broker = null; + Collection collection = null; + boolean collectionLocked = true; try { broker = pool.get(user); + if(path == null) + path = ""; + if(path.endsWith("/")) + path = path.substring(0, path.length() - 1); + int p = path.lastIndexOf('/'); + if(p < 1) { + response.sendError(HttpServletResponse.SC_CONFLICT, "No collection specified for PUT"); + return; + } + String collectionName = path.substring(0, p); + path = path.substring(p + 1); + + collection = broker.openCollection(collectionName, Lock.WRITE_LOCK); if(collection == null) { ! response.sendError(HttpServletResponse.SC_CONFLICT, "Parent collection " + collectionName + ! " not found"); ! return; ! } ! if(collection.hasChildCollection(path)) { ! response.sendError(HttpServletResponse.SC_CONFLICT, "Cannot overwrite an existing collection with a resource"); ! return; } if(contentType == null) { ! contentType = URLConnection.guessContentTypeFromName(path); } LOG.debug("storing document " + path + "; content-type = " + contentType); if(contentType == null || contentType.equalsIgnoreCase("text/xml") || ! contentType.equals("application/xml")) { ! InputSource is = new InputSource(url); ! IndexInfo info = collection.validate(broker, path, is); ! collection.release(); ! collectionLocked = false; ! collection.store(broker, info, is, false); } else { byte[] chunk = new byte[4096]; *************** *** 132,136 **** response.sendError(HttpServletResponse.SC_CONFLICT); } finally { ! collection.release(); pool.release(broker); } --- 132,137 ---- response.sendError(HttpServletResponse.SC_CONFLICT); } finally { ! if(collectionLocked) ! collection.release(); pool.release(broker); } Index: Options.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Options.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Options.java 3 May 2004 13:03:34 -0000 1.2 --- Options.java 6 Aug 2004 17:36:36 -0000 1.3 *************** *** 29,34 **** import javax.servlet.http.HttpServletResponse; - import org.exist.collections.Collection; - import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAVMethod; import org.exist.security.User; --- 29,32 ---- *************** *** 39,48 **** public class Options implements WebDAVMethod { - /* (non-Javadoc) - * @see org.exist.http.webdav.WebDAVMethod#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.exist.collections.Collection, org.exist.dom.DocumentImpl) - */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { response.addHeader("DAV", "1"); response.addHeader("Allow", "OPTIONS, GET, HEAD, PUT, PROPFIND,MKCOL"); --- 37,42 ---- public class Options implements WebDAVMethod { public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { response.addHeader("DAV", "1"); response.addHeader("Allow", "OPTIONS, GET, HEAD, PUT, PROPFIND,MKCOL"); Index: Head.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Head.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Head.java 7 Jul 2004 20:54:44 -0000 1.3 --- Head.java 6 Aug 2004 17:36:36 -0000 1.4 *************** *** 29,42 **** import javax.servlet.http.HttpServletResponse; ! import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; ! import org.exist.http.webdav.WebDAVMethod; import org.exist.security.User; /** * @author wolf */ ! public class Head implements WebDAVMethod { /* (non-Javadoc) --- 29,50 ---- import javax.servlet.http.HttpServletResponse; ! import org.exist.EXistException; import org.exist.dom.DocumentImpl; import org.exist.http.webdav.WebDAV; ! import org.exist.security.Permission; ! import org.exist.security.PermissionDeniedException; import org.exist.security.User; + import org.exist.storage.BrokerPool; + import org.exist.storage.DBBroker; + import org.exist.util.Lock; /** * @author wolf */ ! public class Head extends AbstractWebDAVMethod { ! ! public Head(BrokerPool pool) { ! super(pool); ! } /* (non-Javadoc) *************** *** 44,61 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(resource == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } - String contentType; - if(resource.getResourceType() == DocumentImpl.XML_FILE) - contentType = WebDAV.XML_CONTENT; - else - contentType = WebDAV.BINARY_CONTENT; - response.setContentType(contentType); - response.setContentLength(resource.getContentLength()); - response.addDateHeader("Last-Modified", resource.getLastModified()); } } --- 52,92 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { ! DBBroker broker = null; ! byte[] contentData = null; ! DocumentImpl resource = null; ! try { ! broker = pool.get(); ! resource = broker.openDocument(path, Lock.READ_LOCK); ! if(resource == null) { ! // GET is not available on collections ! response.sendError(HttpServletResponse.SC_FORBIDDEN, "GET is not available on collections"); ! return; ! } ! if(!resource.getPermissions().validate(user, Permission.READ)) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); ! return; ! } ! String contentType; ! if(resource.getResourceType() == DocumentImpl.XML_FILE) ! contentType = WebDAV.XML_CONTENT; ! else ! contentType = WebDAV.BINARY_CONTENT; ! response.setContentType(contentType); ! response.setContentLength(resource.getContentLength()); ! response.addDateHeader("Last-Modified", resource.getLastModified()); ! } catch (EXistException e) { ! throw new ServletException(e.getMessage(), e); ! } catch (PermissionDeniedException e) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); ! } finally { ! if(resource != null) ! resource.getUpdateLock().release(Lock.READ_LOCK); ! pool.release(broker); ! } ! if(contentData == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } } } Index: Delete.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Delete.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Delete.java 5 Aug 2004 12:09:42 -0000 1.5 --- Delete.java 6 Aug 2004 17:36:36 -0000 1.6 *************** *** 33,37 **** import org.exist.collections.triggers.TriggerException; import org.exist.dom.DocumentImpl; ! import org.exist.http.webdav.WebDAVMethod; import org.exist.security.PermissionDeniedException; import org.exist.security.User; --- 33,37 ---- import org.exist.collections.triggers.TriggerException; import org.exist.dom.DocumentImpl; ! import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; import org.exist.security.User; *************** *** 44,53 **** * @author wolf */ ! public class Delete implements WebDAVMethod { ! ! private BrokerPool pool; public Delete(BrokerPool pool) { ! this.pool = pool; } --- 44,51 ---- * @author wolf */ ! public class Delete extends AbstractWebDAVMethod { public Delete(BrokerPool pool) { ! super(pool); } *************** *** 56,69 **** */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, Collection collection, ! DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! response.sendError(HttpServletResponse.SC_NOT_FOUND); ! return; ! } DBBroker broker = null; try { broker = pool.get(user); ! collection.getLock().acquire(Lock.WRITE_LOCK); if(resource == null) { broker.removeCollection(collection); --- 54,87 ---- */ public void process(User user, HttpServletRequest request, ! HttpServletResponse response, String path) throws ServletException, IOException { DBBroker broker = null; + Collection collection = null; + DocumentImpl resource = null; try { broker = pool.get(user); ! collection = broker.openCollection(path, Lock.WRITE_LOCK); ! if(collection == null) { ! int pos = path.lastIndexOf('/'); ! String collName = path.substring(0, pos); ! String docName = path.substring(pos + 1); ! LOG.debug("collection = " + collName + "; doc = " + docName); ! collection = broker.openCollection(collName, Lock.WRITE_LOCK); ! if(collection == null) { ! LOG.debug("No resource or collection found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! resource = collection.getDocument(broker, docName); ! if(resource == null) { ! LOG.debug("No resource found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! } ! if(!collection.getPermissions().validate(user, Permission.READ)) { ! LOG.debug("Permission denied to read collection"); ! response.sendError(HttpServletResponse.SC_FORBIDDEN); ! return; ! } if(resource == null) { broker.removeCollection(collection); *************** *** 83,87 **** response.sendError(HttpServletResponse.SC_CONFLICT, e.getMessage()); } finally { ! collection.release(); pool.release(broker); } --- 101,106 ---- response.sendError(HttpServletResponse.SC_CONFLICT, e.getMessage()); } finally { ! if(collection != null) ! collection.release(); pool.release(broker); } Index: Propfind.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Propfind.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Propfind.java 8 Jun 2004 08:16:07 -0000 1.4 --- Propfind.java 6 Aug 2004 17:36:36 -0000 1.5 *************** *** 48,52 **** import org.exist.dom.QName; import org.exist.http.webdav.WebDAV; - import org.exist.http.webdav.WebDAVMethod; import org.exist.http.webdav.WebDAVUtil; import org.exist.security.Permission; --- 48,51 ---- *************** *** 54,57 **** --- 53,58 ---- import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; + import org.exist.util.LockException; import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; *************** *** 68,75 **** * @author wolf */ ! public class Propfind implements WebDAVMethod { ! ! // error messages ! // search types --- 69,73 ---- * @author wolf */ ! public class Propfind extends AbstractWebDAVMethod { // search types *************** *** 121,225 **** SUPPORTED_LOCK_PROP }; - - private BrokerPool pool; public Propfind(BrokerPool pool) { ! this.pool = pool; } ! /* (non-Javadoc) ! * @see org.exist.http.webdav.WebDAVMethod#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) ! */ ! public void process(User user, HttpServletRequest request, HttpServletResponse response, ! Collection collection, DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! LOG.debug("No resource or collection found"); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, "No resource or collection found"); ! return; ! } ! if(!collection.getPermissions().validate(user, Permission.READ)) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN); ! return; ! } ! DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); ! docFactory.setNamespaceAware(true); ! DocumentBuilder docBuilder; ! try { ! docBuilder = docFactory.newDocumentBuilder(); ! } catch (ParserConfigurationException e1) { ! throw new ServletException(WebDAVUtil.XML_CONFIGURATION_ERR, e1); ! } ! Document doc = WebDAVUtil.parseRequestContent(request, response, docBuilder); ! int type = FIND_ALL_PROPERTIES; ! DAVProperties searchedProperties = new DAVProperties(); ! if(doc != null) { ! Element propfind = doc.getDocumentElement(); ! if(!(propfind.getLocalName().equals("propfind") && ! propfind.getNamespaceURI().equals(WebDAV.DAV_NS))) { ! LOG.debug(WebDAVUtil.UNEXPECTED_ELEMENT_ERR + propfind.getNodeName()); ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + propfind.getNodeName()); ! return; ! } ! ! NodeList childNodes = propfind.getChildNodes(); ! for(int i = 0; i < childNodes.getLength(); i++) { ! Node currentNode = childNodes.item(i); ! if(currentNode.getNodeType() == Node.ELEMENT_NODE) { ! if(currentNode.getNamespaceURI().equals(WebDAV.DAV_NS)) { ! if(currentNode.getLocalName().equals("prop")) { ! type = FIND_BY_PROPERTY; ! getPropertyNames(currentNode, searchedProperties); ! } ! if(currentNode.getLocalName().equals("allprop")) ! type = FIND_ALL_PROPERTIES; ! if(currentNode.getLocalName().equals("propname")) ! type = FIND_PROPERTY_NAMES; ! } else { ! // Found an unknown element: return with 400 Bad Request ! LOG.debug("Unexpected child: " + currentNode.getNodeName()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + currentNode.getNodeName()); return; } } ! } ! } ! ! String servletPath = getServletPath(request); ! int depth = getDepth(request); ! StringWriter os = new StringWriter(); ! SAXSerializer serializer = SAXSerializerPool.getInstance().borrowSAXSerializer(); ! try { ! serializer.setWriter(os); ! serializer.setOutputProperties(WebDAV.OUTPUT_PROPERTIES); ! AttributesImpl attrs = new AttributesImpl(); ! serializer.startDocument(); ! serializer.startPrefixMapping(PREFIX, WebDAV.DAV_NS); ! serializer.startElement(WebDAV.DAV_NS, "multistatus", "D:multistatus", attrs); ! ! if(type == FIND_ALL_PROPERTIES || type == FIND_BY_PROPERTY) { if(resource != null) ! writeResourceProperties(user, searchedProperties, type, collection, resource, serializer, servletPath); ! else ! writeCollectionProperties(user, searchedProperties, type, collection, serializer, servletPath, depth, 0); ! } else if(type == FIND_PROPERTY_NAMES) ! writePropertyNames(collection, resource, serializer, servletPath); ! ! serializer.endElement(WebDAV.DAV_NS, "multistatus", "D:multistatus"); ! serializer.endPrefixMapping(PREFIX); ! serializer.endDocument(); ! } catch (SAXException e) { ! throw new ServletException("Exception while writing multistatus response: " + e.getMessage(), e); ! } finally { ! SAXSerializerPool.getInstance().returnSAXSerializer(serializer); } - String content = os.toString(); - LOG.debug("response:\n" + content); - writeResponse(response, content); } ! private void writeCollectionProperties(User user, DAVProperties searchedProperties, int type, Collection collection, SAXSerializer serializer, String servletPath, int maxDepth, int currentDepth) throws SAXException { --- 119,251 ---- SUPPORTED_LOCK_PROP }; public Propfind(BrokerPool pool) { ! super(pool); } ! public void process(User user, HttpServletRequest request, HttpServletResponse response, String path) throws ServletException, IOException { ! DBBroker broker = null; ! Collection collection = null; ! DocumentImpl resource = null; ! synchronized (pool.getCollectionsCache()) { ! try { ! broker = pool.get(user); ! // open the collection or resource specified in the path ! collection = broker.openCollection(path, Lock.READ_LOCK); ! if(collection == null) { ! // no collection found: check for a resource ! int pos = path.lastIndexOf('/'); ! String collName = path.substring(0, pos); ! String docName = path.substring(pos + 1); ! collection = broker.openCollection(collName, Lock.READ_LOCK); ! if(collection == null) { ! LOG.debug("No resource or collection found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! resource = collection.getDocumentWithLock(broker, docName, Lock.READ_LOCK); ! if(resource == null) { ! LOG.debug("No resource found for path: " + path); ! response.sendError(HttpServletResponse.SC_NOT_FOUND, NOT_FOUND_ERR); ! return; ! } ! } ! if(!collection.getPermissions().validate(user, Permission.READ)) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN); ! return; ! } ! ! // parse the request contents ! DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); ! docFactory.setNamespaceAware(true); ! DocumentBuilder docBuilder; ! try { ! docBuilder = docFactory.newDocumentBuilder(); ! } catch (ParserConfigurationException e1) { ! throw new ServletException(WebDAVUtil.XML_CONFIGURATION_ERR, e1); ! } ! Document doc = WebDAVUtil.parseRequestContent(request, response, docBuilder); ! int type = FIND_ALL_PROPERTIES; ! DAVProperties searchedProperties = new DAVProperties(); ! if(doc != null) { ! Element propfind = doc.getDocumentElement(); ! if(!(propfind.getLocalName().equals("propfind") && ! propfind.getNamespaceURI().equals(WebDAV.DAV_NS))) { ! LOG.debug(WebDAVUtil.UNEXPECTED_ELEMENT_ERR + propfind.getNodeName()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! WebDAVUtil.UNEXPECTED_ELEMENT_ERR + propfind.getNodeName()); return; } + + NodeList childNodes = propfind.getChildNodes(); + for(int i = 0; i < childNodes.getLength(); i++) { + Node currentNode = childNodes.item(i); + if(currentNode.getNodeType() == Node.ELEMENT_NODE) { + if(currentNode.getNamespaceURI().equals(WebDAV.DAV_NS)) { + if(currentNode.getLocalName().equals("prop")) { + type = FIND_BY_PROPERTY; + getPropertyNames(currentNode, searchedProperties); + } + if(currentNode.getLocalName().equals("allprop")) + type = FIND_ALL_PROPERTIES; + if(currentNode.getLocalName().equals("propname")) + type = FIND_PROPERTY_NAMES; + } else { + // Found an unknown element: return with 400 Bad Request + LOG.debug("Unexpected child: " + currentNode.getNodeName()); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, + WebDAVUtil.UNEXPECTED_ELEMENT_ERR + currentNode.getNodeName()); + return; + } + } + } } ! String servletPath = getServletPath(request); ! int depth = getDepth(request); ! StringWriter os = new StringWriter(); ! SAXSerializer serializer = SAXSerializerPool.getInstance().borrowSAXSerializer(); ! try { ! serializer.setWriter(os); ! serializer.setOutputProperties(WebDAV.OUTPUT_PROPERTIES); ! AttributesImpl attrs = new AttributesImpl(); ! serializer.startDocument(); ! serializer.startPrefixMapping(PREFIX, WebDAV.DAV_NS); ! serializer.startElement(WebDAV.DAV_NS, "multistatus", "D:multistatus", attrs); ! ! if(type == FIND_ALL_PROPERTIES || type == FIND_BY_PROPERTY) { ! if(resource != null) ! writeResourceProperties(user, searchedProperties, type, collection, resource, serializer, servletPath); ! else ! writeCollectionProperties(user, broker, searchedProperties, type, collection, serializer, servletPath, depth, 0); ! } else if(type == FIND_PROPERTY_NAMES) ! writePropertyNames(collection, resource, serializer, servletPath); ! ! serializer.endElement(WebDAV.DAV_NS, "multistatus", "D:multistatus"); ! serializer.endPrefixMapping(PREFIX); ! serializer.endDocument(); ! } catch (SAXException e) { ! throw new ServletException("Exception while writing multistatus response: " + e.getMessage(), e); ! } finally { ! SAXSerializerPool.getInstance().returnSAXSerializer(serializer); ! } ! String content = os.toString(); ! LOG.debug("response:\n" + content); ! writeResponse(response, content); ! } catch (EXistException e) { ! throw new ServletException(e.getMessage(), e); ! } catch (LockException e) { ! response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); ! } finally { if(resource != null) ! resource.getUpdateLock().release(Lock.READ_LOCK); ! if(collection != null) ! collection.release(); ! pool.release(broker); ! } } } ! private void writeCollectionProperties(User user, DBBroker broker, DAVProperties searchedProperties, int type, Collection collection, SAXSerializer serializer, String servletPath, int maxDepth, int currentDepth) throws SAXException { *************** *** 287,300 **** if(currentDepth++ < maxDepth) { if(collection.getDocumentCount() > 0) { ! DBBroker broker = null; ! try { ! broker = pool.get(user); ! for(Iterator i = collection.iterator(broker); i.hasNext(); ) { ! DocumentImpl doc = (DocumentImpl)i.next(); writeResourceProperties(user, searchedProperties, type, collection, doc, serializer, servletPath); } - } catch (EXistException e) { - } finally { - pool.release(broker); } } --- 313,326 ---- if(currentDepth++ < maxDepth) { if(collection.getDocumentCount() > 0) { ! for(Iter... [truncated message content] |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:36:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/src/org/exist/http/webdav Modified Files: WebDAVMethod.java WebDAVMethodFactory.java WebDAV.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: WebDAV.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAV.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WebDAV.java 3 Aug 2004 20:54:33 -0000 1.7 --- WebDAV.java 6 Aug 2004 17:36:37 -0000 1.8 *************** *** 116,155 **** LOG.debug("path = " + path + "; method = " + request.getMethod()); - DocumentImpl resource = null; - Collection collection = null; WebDAVMethod method = null; ! DBBroker broker = null; ! boolean collectionLocked = false; ! try { ! broker = pool.get(user); ! ! method = WebDAVMethodFactory.create(request.getMethod(), pool); ! if(method == null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "Method is not supported: " + request.getMethod()); ! return; ! } ! collection = broker.openCollection(path, Lock.READ_LOCK); ! if(collection == null) { ! resource = (DocumentImpl)broker.openDocument(path, Lock.READ_LOCK); ! if(resource != null) ! collection = resource.getCollection(); ! } else ! collectionLocked = true; ! } catch (EXistException e) { ! throw new ServletException("An error occurred while retrieving resource: " + e.getMessage(), e); ! } catch (PermissionDeniedException e) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, "Not allowed to access resource " + path); ! } finally { ! pool.release(broker); ! } ! try { ! method.process(user, request, response, collection, resource); ! } finally { ! if(collection != null && collectionLocked) ! collection.release(); ! if(resource != null) ! resource.getUpdateLock().release(); } } --- 116,128 ---- LOG.debug("path = " + path + "; method = " + request.getMethod()); WebDAVMethod method = null; ! ! method = WebDAVMethodFactory.create(request.getMethod(), pool); ! if(method == null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "Method is not supported: " + request.getMethod()); ! return; } + method.process(user, request, response, path); } *************** *** 167,171 **** return digestAuth.authenticate(request, response); } else { - LOG.debug("Falling back to basic authentication"); return basicAuth.authenticate(request, response); } --- 140,143 ---- Index: WebDAVMethod.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAVMethod.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WebDAVMethod.java 21 May 2004 08:35:42 -0000 1.2 --- WebDAVMethod.java 6 Aug 2004 17:36:37 -0000 1.3 *************** *** 29,35 **** import javax.servlet.http.HttpServletResponse; - import org.apache.log4j.Logger; - import org.exist.collections.Collection; - import org.exist.dom.DocumentImpl; import org.exist.security.User; --- 29,32 ---- *************** *** 41,46 **** public interface WebDAVMethod { - final static Logger LOG = Logger.getLogger(WebDAVMethod.class); - /** * Process a WebDAV request. The collection and resource parameters --- 38,41 ---- *************** *** 57,61 **** */ void process(User user, HttpServletRequest request, HttpServletResponse response, ! Collection collection, DocumentImpl resource) throws ServletException, IOException; } --- 52,56 ---- */ void process(User user, HttpServletRequest request, HttpServletResponse response, ! String path) throws ServletException, IOException; } Index: WebDAVMethodFactory.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAVMethodFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WebDAVMethodFactory.java 22 Jun 2004 10:10:18 -0000 1.3 --- WebDAVMethodFactory.java 6 Aug 2004 17:36:37 -0000 1.4 *************** *** 49,53 **** return new Get(pool); else if(method.equals("HEAD")) ! return new Head(); else if(method.equals("PUT")) return new Put(pool); --- 49,53 ---- return new Get(pool); else if(method.equals("HEAD")) ! return new Head(pool); else if(method.equals("PUT")) return new Put(pool); |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:36:47
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/src/org/exist/http/servlets Modified Files: WebDAVServlet.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: WebDAVServlet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets/WebDAVServlet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WebDAVServlet.java 25 May 2004 09:26:07 -0000 1.3 --- WebDAVServlet.java 6 Aug 2004 17:36:37 -0000 1.4 *************** *** 61,65 **** protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ! dumpHeaders(request); webdav.process(request, response); } --- 61,65 ---- protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ! // dumpHeaders(request); webdav.process(request, response); } |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:36:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/src/org/exist/storage Modified Files: DBBroker.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** DBBroker.java 4 Aug 2004 14:48:06 -0000 1.41 --- DBBroker.java 6 Aug 2004 17:36:37 -0000 1.42 *************** *** 318,322 **** throws PermissionDeniedException; ! public abstract Document openDocument(String docPath, int lockMode) throws PermissionDeniedException; --- 318,322 ---- throws PermissionDeniedException; ! public abstract DocumentImpl openDocument(String docPath, int lockMode) throws PermissionDeniedException; |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 15:34:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18526/src/org/exist/client Modified Files: InteractiveClient.java Log Message: Catch Throwable (instead of XMLDBException only) in the main loop to avoid gui freeze. Index: InteractiveClient.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/InteractiveClient.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** InteractiveClient.java 2 Jul 2004 18:05:44 -0000 1.33 --- InteractiveClient.java 6 Aug 2004 15:34:30 -0000 1.34 *************** *** 1045,1053 **** path = newPath; return true; ! } catch (XMLDBException xde) { if (startGUI) ! ClientFrame.showErrorMessage(getExceptionMessage(xde), xde); else ! System.err.println(getExceptionMessage(xde)); return true; } --- 1045,1053 ---- path = newPath; return true; ! } catch (Throwable e) { if (startGUI) ! ClientFrame.showErrorMessage(getExceptionMessage(e), e); else ! System.err.println(getExceptionMessage(e)); return true; } |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 15:32:18
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18108/src/org/exist/http/servlets Modified Files: XQueryServlet.java Log Message: Applied patch to improve content type handling. Index: XQueryServlet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets/XQueryServlet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** XQueryServlet.java 6 Aug 2004 15:30:17 -0000 1.10 --- XQueryServlet.java 6 Aug 2004 15:32:08 -0000 1.11 *************** *** 205,223 **** //------------------------------- - String contentType = this.contentType; - try { - contentType = getServletContext().getMimeType(path); - if (contentType == null) - contentType = this.contentType; - } - catch (Throwable e) { - contentType = this.contentType; - } - finally { - if (contentType.startsWith("text/") || (contentType.endsWith("+xml"))) - contentType += ";charset=" + formEncoding; - response.setContentType(contentType ); - } - String baseURI = request.getRequestURI(); int p = baseURI.lastIndexOf('/'); --- 205,208 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 15:30:26
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17790/src/org/exist/http/servlets Modified Files: XQueryServlet.java Log Message: Applied patch to improve content type handling. Index: XQueryServlet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/servlets/XQueryServlet.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** XQueryServlet.java 21 May 2004 13:35:44 -0000 1.9 --- XQueryServlet.java 6 Aug 2004 15:30:17 -0000 1.10 *************** *** 182,185 **** --- 182,223 ---- return; } + + //------------------------------- + // Added by Igor Abade (ig...@co...) + // Date: Aug/06/2004 + //------------------------------- + + String contentType = this.contentType; + try { + contentType = getServletContext().getMimeType(path); + if (contentType == null) + contentType = this.contentType; + } + catch (Throwable e) { + contentType = this.contentType; + } + finally { + if (contentType.startsWith("text/") || (contentType.endsWith("+xml"))) + contentType += ";charset=" + formEncoding; + response.setContentType(contentType ); + } + + //------------------------------- + + String contentType = this.contentType; + try { + contentType = getServletContext().getMimeType(path); + if (contentType == null) + contentType = this.contentType; + } + catch (Throwable e) { + contentType = this.contentType; + } + finally { + if (contentType.startsWith("text/") || (contentType.endsWith("+xml"))) + contentType += ";charset=" + formEncoding; + response.setContentType(contentType ); + } + String baseURI = request.getRequestURI(); int p = baseURI.lastIndexOf('/'); |
From: Wolfgang M. M. <wol...@us...> - 2004-08-06 15:24:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16444/src/org/exist/storage Modified Files: NativeBroker.java Log Message: Applied removeCollection patch. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** NativeBroker.java 4 Aug 2004 19:30:10 -0000 1.96 --- NativeBroker.java 6 Aug 2004 15:24:48 -0000 1.97 *************** *** 77,81 **** import org.exist.util.ByteArrayPool; import org.exist.util.ByteConversion; - import org.exist.util.CollectionScanner; import org.exist.util.Configuration; import org.exist.util.Lock; --- 77,80 ---- *************** *** 545,549 **** } ! public Document openDocument(String docPath, int lockMode) throws PermissionDeniedException { if (!docPath.startsWith("/")) docPath = '/' + docPath; --- 544,548 ---- } ! public DocumentImpl openDocument(String docPath, int lockMode) throws PermissionDeniedException { if (!docPath.startsWith("/")) docPath = '/' + docPath; *************** *** 1752,1769 **** throw new PermissionDeniedException("not allowed to remove collection"); final CollectionCache collectionsCache = pool.getCollectionsCache(); synchronized(collectionsCache) { String name = collection.getName(); ! // remove from parent collection ! Collection parent = openCollection(collection.getParentPath(), Lock.WRITE_LOCK); ! if (parent != null) { ! try { ! parent.removeCollection(name.substring(name.lastIndexOf("/") + 1)); ! saveCollection(parent); ! } catch (LockException e) { ! LOG.warn("LockException while removing collection " + name); ! } finally { ! parent.getLock().release(); ! } } --- 1751,1773 ---- throw new PermissionDeniedException("not allowed to remove collection"); + final boolean isRoot = collection.getParentPath() == null; + final CollectionCache collectionsCache = pool.getCollectionsCache(); synchronized(collectionsCache) { String name = collection.getName(); ! ! if (!isRoot) { ! // remove from parent collection ! Collection parent = openCollection(collection.getParentPath(), Lock.WRITE_LOCK); ! if (parent != null) { ! try { ! parent.removeCollection(name.substring(name.lastIndexOf("/") + 1)); ! saveCollection(parent); ! } catch (LockException e) { ! LOG.warn("LockException while removing collection " + name); ! } finally { ! parent.getLock().release(); ! } ! } } *************** *** 1787,1791 **** // if this is not the root collection remove it completely ! if (name.equals(ROOT_COLLECTION)) saveCollection(collection); else { --- 1791,1795 ---- // if this is not the root collection remove it completely ! if (isRoot) saveCollection(collection); else { *************** *** 1797,1803 **** } collectionsDb.remove(key); - } - if (!name.equals(ROOT_COLLECTION)) collectionsCache.remove(collection); } catch (LockException e) { LOG.warn("Failed to acquire lock on collections.dbx"); --- 1801,1808 ---- } collectionsDb.remove(key); collectionsCache.remove(collection); + freeCollection(collection.getId()); + } + } catch (LockException e) { LOG.warn("Failed to acquire lock on collections.dbx"); *************** *** 1808,1813 **** } - freeCollection(collection.getId()); - textEngine.dropIndex(collection); elementIndex.dropIndex(collection); --- 1813,1816 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-08-05 16:50:08
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6273 Modified Files: .project Log Message: Added missing java builder to eclipse .project configuration. Index: .project =================================================================== RCS file: /cvsroot/exist/eXist-1.0/.project,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** .project 28 May 2004 10:54:12 -0000 1.4 --- .project 5 Aug 2004 16:49:49 -0000 1.5 *************** *** 11,34 **** <dictionary> <key>LaunchConfigHandle</key> ! <value>Ant builder.launch</value> ! </dictionary> ! </arguments> ! </buildCommand> ! <buildCommand> ! <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> ! <arguments> ! <dictionary> ! <key>LaunchConfigHandle</key> ! <value>org.eclipse.jdt.core.javabuilder.launch</value> </dictionary> </arguments> </buildCommand> <buildCommand> ! <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value>org.antlr.eclipse.core.antlrbuilder.launch</value> - </dictionary> </arguments> </buildCommand> --- 11,21 ---- <dictionary> <key>LaunchConfigHandle</key> ! <value><project>/.externalToolBuilders/Ant builder.launch</value> </dictionary> </arguments> </buildCommand> <buildCommand> ! <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> |
From: Wolfgang M. M. <wol...@us...> - 2004-08-05 12:09:52
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11706/src/org/exist/http/webdav/methods Modified Files: Copy.java Delete.java Mkcol.java Put.java Log Message: Smaller changes to adjust the collection locking. Index: Mkcol.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Mkcol.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Mkcol.java 25 May 2004 12:52:01 -0000 1.3 --- Mkcol.java 5 Aug 2004 12:09:42 -0000 1.4 *************** *** 86,92 **** Collection parent = broker.getCollection(parentPath); if(parent == null) { ! LOG.debug("parent collection " + parentPath + " not found"); response.sendError(HttpServletResponse.SC_CONFLICT, ! "parent collection not found"); return; } --- 86,92 ---- Collection parent = broker.getCollection(parentPath); if(parent == null) { ! LOG.debug("Parent collection " + parentPath + " not found"); response.sendError(HttpServletResponse.SC_CONFLICT, ! "Parent collection not found"); return; } *************** *** 94,98 **** broker.saveCollection(created); broker.flush(); ! LOG.debug("created collection " + path); response.setStatus(HttpServletResponse.SC_CREATED); } catch(EXistException e) { --- 94,98 ---- broker.saveCollection(created); broker.flush(); ! LOG.debug("Created collection " + path); response.setStatus(HttpServletResponse.SC_CREATED); } catch(EXistException e) { Index: Copy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Copy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Copy.java 3 Aug 2004 16:45:45 -0000 1.3 --- Copy.java 5 Aug 2004 12:09:42 -0000 1.4 *************** *** 155,158 **** --- 155,208 ---- } + private void copyCollection(User user, HttpServletRequest request, HttpServletResponse response, + Collection collection, String destination) + throws ServletException, IOException { + int p = destination.lastIndexOf('/'); + if(p < 0) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, + "Bad destination: " + destination); + return; + } + String newCollectionName = destination.substring(p + 1); + destination = destination.substring(0, p); + boolean replaced = false; + DBBroker broker = null; + Collection destCollection = null; + try { + broker = pool.get(user); + destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); + if(destCollection == null) { + response.sendError(HttpServletResponse.SC_CONFLICT, + "Destination collection not found"); + return; + } + if(destCollection.hasChildCollection(newCollectionName)) { + boolean overwrite = overwrite(request); + if(!overwrite) { + response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, + "Destination collection exists and overwrite is not allowed"); + return; + } + replaced = true; + } + + broker.copyCollection(collection, destCollection, newCollectionName); + if(replaced) + response.setStatus(HttpServletResponse.SC_NO_CONTENT); + else + response.setStatus(HttpServletResponse.SC_CREATED); + } catch (EXistException e) { + throw new ServletException(e.getMessage(), e); + } catch (PermissionDeniedException e) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); + } catch (LockException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); + } finally { + if(destCollection != null) + destCollection.release(); + pool.release(broker); + } + } + private boolean overwrite(HttpServletRequest request) { String header = request.getHeader("Overwrite"); Index: Delete.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Delete.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Delete.java 3 Aug 2004 15:25:58 -0000 1.4 --- Delete.java 5 Aug 2004 12:09:42 -0000 1.5 *************** *** 38,41 **** --- 38,42 ---- import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; import org.exist.util.LockException; *************** *** 64,74 **** try { broker = pool.get(user); if(resource == null) { broker.removeCollection(collection); } else { if(resource.getResourceType() == DocumentImpl.BINARY_FILE) ! resource.getCollection().removeBinaryResource(broker, resource.getFileName()); else ! resource.getCollection().removeDocument(broker, resource.getFileName()); } } catch (EXistException e) { --- 65,76 ---- try { broker = pool.get(user); + collection.getLock().acquire(Lock.WRITE_LOCK); if(resource == null) { broker.removeCollection(collection); } else { if(resource.getResourceType() == DocumentImpl.BINARY_FILE) ! collection.removeBinaryResource(broker, resource.getFileName()); else ! collection.removeDocument(broker, resource.getFileName()); } } catch (EXistException e) { *************** *** 81,84 **** --- 83,87 ---- response.sendError(HttpServletResponse.SC_CONFLICT, e.getMessage()); } finally { + collection.release(); pool.release(broker); } Index: Put.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Put.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Put.java 21 May 2004 08:35:42 -0000 1.3 --- Put.java 5 Aug 2004 12:09:42 -0000 1.4 *************** *** 47,50 **** --- 47,51 ---- import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; import org.exist.util.LockException; import org.xml.sax.InputSource; *************** *** 92,96 **** String collectionName = path.substring(0, p); path = path.substring(p + 1); ! collection = broker.getCollection(collectionName); if(collection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, "Parent collection " + collectionName + --- 93,97 ---- String collectionName = path.substring(0, p); path = path.substring(p + 1); ! collection = broker.openCollection(collectionName, Lock.WRITE_LOCK); if(collection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, "Parent collection " + collectionName + *************** *** 98,103 **** return; } ! } else path = path.substring(collection.getName().length() + 1); if(contentType == null) { contentType = URLConnection.guessContentTypeFromName(path); --- 99,106 ---- return; } ! } else { ! collection.getLock().acquire(Lock.WRITE_LOCK); path = path.substring(collection.getName().length() + 1); + } if(contentType == null) { contentType = URLConnection.guessContentTypeFromName(path); *************** *** 129,132 **** --- 132,136 ---- response.sendError(HttpServletResponse.SC_CONFLICT); } finally { + collection.release(); pool.release(broker); } |
From: Wolfgang M. M. <wol...@us...> - 2004-08-05 09:13:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17974/src/org/exist/dom Modified Files: AbstractNodeSet.java ExtArrayNodeSet.java Log Message: Commented out the quickSelectAncestorDescendant method in AbstractNodeSet. This method can't work if the descendant nodes occur on different levels of the DOM tree. Index: AbstractNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AbstractNodeSet.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AbstractNodeSet.java 30 Jun 2004 15:56:59 -0000 1.23 --- AbstractNodeSet.java 5 Aug 2004 09:13:05 -0000 1.24 *************** *** 374,379 **** boolean includeSelf, boolean rememberContext) { ! if(!(al instanceof VirtualNodeSet)) ! return quickSelectAncestorDescendant(al, mode, includeSelf, rememberContext); NodeProxy n, p; // long start = System.currentTimeMillis(); --- 374,379 ---- boolean includeSelf, boolean rememberContext) { ! // if(!(al instanceof VirtualNodeSet)) ! // return quickSelectAncestorDescendant(al, mode, includeSelf, rememberContext); NodeProxy n, p; // long start = System.currentTimeMillis(); *************** *** 429,432 **** --- 429,435 ---- /** + * TODO: This method is rubbish. It can't work this way if descendants occur on + * different levels in the dom tree. + * * Fast ancestor descendant join based on two iterators. This method is * selected if the ancestor set is fixed, i.e. the selection step did not contain *************** *** 438,511 **** * @return */ ! private NodeSet quickSelectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, boolean rememberContext) { ! final NodeSet result = new ExtArrayNodeSet(); ! final Iterator ia = al.iterator(); ! final Iterator ib = iterator(); ! // final long start = System.currentTimeMillis(); ! NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); ! // check if one of the node sets is empty ! if(na == null || nb == null) ! return result; ! ! long pa, pb; ! while (true) { ! // first, try to find nodes belonging to the same doc ! if (na.doc.getDocId() < nb.doc.getDocId()) { ! if (ia.hasNext()) ! na = (NodeProxy) ia.next(); ! else ! break; ! } else if (na.doc.getDocId() > nb.doc.getDocId()) { ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } else { ! // same document ! pa = na.gid; ! pb = nb.gid; ! int la = na.doc.getTreeLevel(pa); ! int lb = nb.doc.getTreeLevel(pb); ! boolean foundSelf = la == lb; ! while (la < lb) { ! pb = XMLUtil.getParentId(nb.doc, pb, lb); ! --lb; ! } ! if (pa < pb) { ! if (ia.hasNext()) ! na = (NodeProxy) ia.next(); ! else ! break; ! } else if (pa > pb) { ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } else { ! if(!foundSelf || includeSelf) { ! if(mode == NodeSet.DESCENDANT) { ! if (rememberContext) ! nb.addContextNode(na); ! else ! nb.copyContext(na); ! result.add(nb); ! } else { ! if (rememberContext) ! na.addContextNode(nb); ! else ! na.copyContext(nb); ! result.add(na); ! } ! } ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } ! } ! } ! // LOG.debug("quickSelect took " + (System.currentTimeMillis() - start)); ! return result; ! } private NodeSet quickSelectParentChild(NodeSet al, int mode, boolean rememberContext) { --- 441,518 ---- * @return */ ! // private NodeSet quickSelectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, boolean rememberContext) { ! // final NodeSet result = new ExtArrayNodeSet(); ! // final Iterator ia = al.iterator(); ! // final Iterator ib = iterator(); ! //// final long start = System.currentTimeMillis(); ! // NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); ! // // check if one of the node sets is empty ! // if(na == null || nb == null) ! // return result; ! // ! // long pa, pb; ! // while (true) { ! // // first, try to find nodes belonging to the same doc ! // if (na.doc.getDocId() < nb.doc.getDocId()) { ! // if (ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else if (na.doc.getDocId() > nb.doc.getDocId()) { ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else ! // break; ! // } else { ! // // same document ! // pa = na.gid; ! // pb = nb.gid; ! // int la = na.doc.getTreeLevel(pa); ! // int lb = nb.doc.getTreeLevel(pb); ! // boolean foundSelf = la == lb; ! // while (lb> la) { ! // pb = XMLUtil.getParentId(nb.doc, pb, lb--); ! // System.out.println(pb); ! // } ! // System.out.println("Comparing " + pa + " -> " + pb + " (" + nb.gid + ") " + ! // XMLUtil.getParentId(nb.doc, pb)); ! // if (pa < pb) { ! // if (ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else if (pa > pb) { ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else if(ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else { ! // if(!foundSelf || includeSelf) { ! // if(mode == NodeSet.DESCENDANT) { ! // if (rememberContext) ! // nb.addContextNode(na); ! // else ! // nb.copyContext(na); ! // result.add(nb); ! // } else { ! // if (rememberContext) ! // na.addContextNode(nb); ! // else ! // na.copyContext(nb); ! // result.add(na); ! // } ! // } ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else ! // break; ! // } ! // } ! // } ! //// LOG.debug("quickSelect took " + (System.currentTimeMillis() - start)); ! // return result; ! // } private NodeSet quickSelectParentChild(NodeSet al, int mode, boolean rememberContext) { Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ExtArrayNodeSet.java 8 Jun 2004 08:16:08 -0000 1.21 --- ExtArrayNodeSet.java 5 Aug 2004 09:13:05 -0000 1.22 *************** *** 518,524 **** while (gid > 0) { gid = XMLUtil.getParentId(doc, gid, level); ! if ((temp = get(gid)) != null) return temp; ! else if (directParent) return null; else --- 518,524 ---- while (gid > 0) { gid = XMLUtil.getParentId(doc, gid, level); ! if ((temp = get(gid)) != null) { return temp; ! } else if (directParent) return null; else |