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
(41) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 19:54:16
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/start In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9819/src/org/exist/start Removed Files: MANIFEST.MF Log Message: Moved jar manifest definition for start.jar to build.xml. --- MANIFEST.MF DELETED --- |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 19:46:27
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8045/src/org/exist/xquery Modified Files: SequenceConstructor.java Log Message: Fixed computed constructors. Index: SequenceConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/SequenceConstructor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SequenceConstructor.java 13 Sep 2004 14:06:35 -0000 1.3 --- SequenceConstructor.java 21 Sep 2004 19:45:59 -0000 1.4 *************** *** 66,74 **** public String pprint() { StringBuffer buf = new StringBuffer(); for(Iterator i = steps.iterator(); i.hasNext(); ) { - if(buf.length() > 0) - buf.append(", "); buf.append(((Expression)i.next()).pprint()); } return buf.toString(); } --- 66,76 ---- public String pprint() { StringBuffer buf = new StringBuffer(); + buf.append("#["); for(Iterator i = steps.iterator(); i.hasNext(); ) { buf.append(((Expression)i.next()).pprint()); + if(i.hasNext()) + buf.append(", "); } + buf.append("]"); return buf.toString(); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 19:46:27
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8045/src/org/exist/xquery/parser Modified Files: XQuery.g Log Message: Fixed computed constructors. Index: XQuery.g =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQuery.g,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** XQuery.g 13 Sep 2004 14:06:36 -0000 1.26 --- XQuery.g 21 Sep 2004 19:46:16 -0000 1.27 *************** *** 2434,2440 **** c.setASTNode(qn); step= c; ! elementContent = new SequenceConstructor(context); EnclosedExpr enclosed = new EnclosedExpr(context); ! enclosed.addPath(elementContent); c.setContent(enclosed); PathExpr qnamePathExpr = new PathExpr(context); --- 2434,2440 ---- c.setASTNode(qn); step= c; ! SequenceConstructor construct = new SequenceConstructor(context); EnclosedExpr enclosed = new EnclosedExpr(context); ! enclosed.addPath(construct); c.setContent(enclosed); PathExpr qnamePathExpr = new PathExpr(context); *************** *** 2449,2453 **** --- 2449,2455 ---- } | + { elementContent = new PathExpr(context); } contentExpr=expr[elementContent] + { construct.addPath(elementContent); } )* ) |
From: Giulio V. <gva...@us...> - 2004-09-21 15:06:54
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9781/src/org/exist/http Modified Files: RESTServer.java Log Message: Add enclose="no|yes(default)" attribute and mime attribute to QUERY node for POST method of REST server. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RESTServer.java 20 Sep 2004 18:00:48 -0000 1.20 --- RESTServer.java 21 Sep 2004 15:06:44 -0000 1.21 *************** *** 155,159 **** Response response = new Response(); if (query != null) { ! response.setContent(search(broker, query, path, howmany, start, outputProperties)); } else { DocumentImpl d = (DocumentImpl) broker.getDocument(path); --- 155,159 ---- Response response = new Response(); if (query != null) { ! response.setContent(search(broker, query, path, howmany, start, outputProperties, 1)); } else { DocumentImpl d = (DocumentImpl) broker.getDocument(path); *************** *** 201,204 **** --- 201,206 ---- int howmany = 10; int start = 1; + int enclose = 1; + String mime ="text/xml"; Properties outputProperties = new Properties(defaultProperties); String query = null; *************** *** 235,238 **** --- 237,253 ---- } + option = root.getAttribute("enclose"); + enclose = 1; + if(option != null) { + if (option.equals( "no")) + enclose = 0; + } + + option = root.getAttribute("mime"); + mime = "text/xml"; + if((option != null) && (!option.equals(""))) { + mime = option; + } + NodeList children =root.getChildNodes(); for(int i = 0;i < children.getLength(); i++) { *************** *** 269,274 **** } // execute query ! if (query != null) ! response = new Response(search(broker, query, path, howmany, start, outputProperties)); else throw new BadRequestException("No query specified"); --- 284,292 ---- } // execute query ! if (query != null){ ! response = new Response(); ! response.setContentType(mime); ! response.setContent(search(broker, query, path, howmany, start, outputProperties, enclose)); ! } else throw new BadRequestException("No query specified"); *************** *** 425,429 **** */ protected String search(DBBroker broker, String query, String path, ! int howmany, int start, Properties outputProperties) throws BadRequestException, PermissionDeniedException { String result = null; --- 443,447 ---- */ protected String search(DBBroker broker, String query, String path, ! int howmany, int start, Properties outputProperties, int enclose) throws BadRequestException, PermissionDeniedException { String result = null; *************** *** 462,466 **** LOG.debug("Found " + resultSequence.getLength() + " in " + queryTime + "ms."); return printResults(broker, resultSequence, howmany, start, ! queryTime, outputProperties); } finally { pool.returnCompiledXQuery(source, compiled); --- 480,484 ---- LOG.debug("Found " + resultSequence.getLength() + " in " + queryTime + "ms."); return printResults(broker, resultSequence, howmany, start, ! queryTime, outputProperties, enclose); } finally { pool.returnCompiledXQuery(source, compiled); *************** *** 576,580 **** protected String printResults(DBBroker broker, Sequence results, ! int howmany, int start, long queryTime, Properties outputProperties) throws BadRequestException { int rlen = results.getLength(); --- 594,598 ---- protected String printResults(DBBroker broker, Sequence results, ! int howmany, int start, long queryTime, Properties outputProperties, int enclose) throws BadRequestException { int rlen = results.getLength(); *************** *** 608,613 **** --- 626,634 ---- sax.startDocument(); + + if (enclose == 1) { sax.startPrefixMapping("exist", NS); sax.startElement(NS, "result", "exist:result", attrs); + } Item item; *************** *** 630,635 **** --- 651,659 ---- } } + + if (enclose == 1) { sax.endElement(NS, "result", "exist:result"); sax.endPrefixMapping("exist"); + } sax.endDocument(); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 14:42:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5047/src/org/exist/xupdate/test/results Added Files: conditional.xml Log Message: * Added missing support for xupdate:if * Fixed xupdate:value-of * Prohibit duplicate attributes --- NEW FILE: conditional.xml --- <?xml version="1.0" encoding="UTF-8"?> <addressbook count="2"> <address> <fname>John</fname> <lname>Jekyll</lname> <company>Johnny's Car Wash</company> <city>Bloomington</city> <email type="work">jo...@ca...</email> </address> <address> <fname>Andrew</fname> <lname>Hyde</lname> <company>Null-Devices</company> <city>Washington</city> </address> </addressbook> |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 14:42:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5047/src/org/exist/dom Modified Files: ElementImpl.java Log Message: * Added missing support for xupdate:if * Fixed xupdate:value-of * Prohibit duplicate attributes Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ElementImpl.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ElementImpl.java 18 Sep 2004 15:22:57 -0000 1.47 --- ElementImpl.java 21 Sep 2004 14:42:06 -0000 1.48 *************** *** 276,279 **** --- 276,280 ---- DocumentImpl prevDoc = new DocumentImpl(ownerDocument); Node node = null; + NodeImpl lastAttrib = checkDupAttributes(attribs); if (children == 0) { // no children: append a new child *************** *** 281,285 **** } else { - NodeImpl lastAttrib = getLastAttribute(); if (lastAttrib != null && lastAttrib.gid == lastChildID()) node = appendChildren(lastChildID() + 1, lastAttrib, getPath(), attribs, true); --- 282,285 ---- *************** *** 318,321 **** --- 318,322 ---- public Node appendChildren(NodeList nodes, int child) throws DOMException { + // attributes are handled differently. Call checkForAttributes to extract them. nodes = checkForAttributes(nodes); if (nodes == null || nodes.getLength() == 0) *************** *** 566,581 **** } ! private AttrImpl getLastAttribute() { long start = firstChildID(); AttrImpl attr = null; for (long i = start; i < start + children; i++) { Node child = ownerDocument.getNode(i); ! if (child != null ! && child.getNodeType() == Node.ATTRIBUTE_NODE) ! attr = (AttrImpl) child; } return attr; } /** * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String) --- 567,609 ---- } ! /** ! * Check if an attribute is already present in the node's attribute list. Throws a ! * DOMException if yes. Otherwise, returns the last attribute in the attribute list. ! * ! * @param attrs ! * @return ! * @throws DOMException ! */ ! private AttrImpl checkDupAttributes(NodeList attrs) throws DOMException { long start = firstChildID(); AttrImpl attr = null; for (long i = start; i < start + children; i++) { Node child = ownerDocument.getNode(i); ! checkAttribute(child, attrs); ! if (child != null) { ! if(child.getNodeType() == Node.ATTRIBUTE_NODE) ! attr = (AttrImpl) child; ! } else ! break; } return attr; } + private void checkAttribute(Node child, NodeList attrs) throws DOMException { + String childNS = child.getNamespaceURI(); + if(childNS == null) + childNS = ""; + for(int i = 0; i < attrs.getLength(); i++) { + Attr current = (Attr) attrs.item(i); + String currentNS = current.getNamespaceURI(); + if(currentNS == null) + currentNS = ""; + if(child.getLocalName().equals(current.getLocalName()) && + childNS.equals(currentNS)) + throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, + "Attribute " + child.getNodeName() + " is already present."); + } + } + /** * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String) *************** *** 1287,1291 **** appendChildren(firstChildID(), this, getPath(), appendList, true); } else { ! NodeImpl lastAttrib = getLastAttribute(); if (lastAttrib != null && lastAttrib.gid == lastChildID()) appendChildren(lastChildID() + 1, lastAttrib, getPath(), appendList, true); --- 1315,1319 ---- appendChildren(firstChildID(), this, getPath(), appendList, true); } else { ! NodeImpl lastAttrib = checkDupAttributes(appendList); if (lastAttrib != null && lastAttrib.gid == lastChildID()) appendChildren(lastChildID() + 1, lastAttrib, getPath(), appendList, true); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 14:42:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5047/src/org/exist/xupdate/test Modified Files: XUpdateTestCases.java AllTests.java Log Message: * Added missing support for xupdate:if * Fixed xupdate:value-of * Prohibit duplicate attributes Index: XUpdateTestCases.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/test/XUpdateTestCases.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XUpdateTestCases.java 9 Aug 2004 10:24:31 -0000 1.3 --- XUpdateTestCases.java 21 Sep 2004 14:42:05 -0000 1.4 *************** *** 28,34 **** public void appendAttribute() throws Exception { test.doTest("append_attribute", "address.xml"); }; public void appendChild() throws Exception { test.doTest("append_child", "address.xml"); }; - public void insertafter_big() throws Exception { test.doTest("insertafter_big", "address_big.xml"); }; // <add a new TestCase Method here> --- 28,35 ---- public void appendAttribute() throws Exception { test.doTest("append_attribute", "address.xml"); }; public void appendChild() throws Exception { test.doTest("append_child", "address.xml"); }; public void insertafter_big() throws Exception { test.doTest("insertafter_big", "address_big.xml"); }; + public void conditional() throws Exception { test.doTest("conditional", "address.xml"); + } // <add a new TestCase Method here> Index: AllTests.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/test/AllTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AllTests.java 9 Aug 2004 10:24:31 -0000 1.2 --- AllTests.java 21 Sep 2004 14:42:05 -0000 1.3 *************** *** 28,31 **** --- 28,32 ---- suite.addTest(new XUpdateTestCases("appendChild", test)); suite.addTest(new XUpdateTestCases("insertafter_big", test)); + suite.addTest(new XUpdateTestCases("conditional", test)); /* |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 14:42:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/test/modifications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5047/src/org/exist/xupdate/test/modifications Added Files: conditional.xml Log Message: * Added missing support for xupdate:if * Fixed xupdate:value-of * Prohibit duplicate attributes --- NEW FILE: conditional.xml --- <?xml version="1.0" encoding="UTF-8"?> <xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate"> <xu:if test="not(/addressbook/@count)"> <xu:variable name="count" select="count(//address)"/> <xu:append select="/addressbook"> <xu:attribute name="count"><xu:value-of select="$count"/></xu:attribute> </xu:append> </xu:if> </xu:modifications> |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 14:42:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5047/src/org/exist/xupdate Modified Files: XUpdateProcessor.java Modification.java Added Files: Conditional.java Log Message: * Added missing support for xupdate:if * Fixed xupdate:value-of * Prohibit duplicate attributes Index: XUpdateProcessor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/XUpdateProcessor.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** XUpdateProcessor.java 12 Sep 2004 09:25:22 -0000 1.25 --- XUpdateProcessor.java 21 Sep 2004 14:42:04 -0000 1.26 *************** *** 29,33 **** --- 29,36 ---- import org.exist.xquery.parser.XQueryParser; import org.exist.xquery.parser.XQueryTreeParser; + import org.exist.xquery.value.Item; + import org.exist.xquery.value.NodeValue; import org.exist.xquery.value.Sequence; + import org.exist.xquery.value.SequenceIterator; import org.exist.xquery.value.Type; import org.w3c.dom.Attr; *************** *** 36,40 **** import org.w3c.dom.Element; import org.w3c.dom.Node; - import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; --- 39,42 ---- *************** *** 67,79 **** --- 69,87 ---- private boolean inModification = false; private boolean inAttribute = false; + private Modification modification = null; private DocumentBuilder builder; private Document doc; + private Stack stack = new Stack(); private Node currentNode = null; private DBBroker broker; private DocumentSet documentSet; + private List modifications = new ArrayList(); + private Stack conditionals = new Stack(); + private FastStringBuffer charBuf = new FastStringBuffer(6, 15, 5); + private Map variables = new TreeMap(); private Map namespaces = new HashMap(10); *************** *** 191,227 **** if (namespaceURI.equals(XUPDATE_NS)) { if (localName.equals("modifications")) { ! String version = atts.getValue("version"); ! if (version == null) ! throw new SAXException( ! "version attribute is required for " ! + "element modifications"); ! if (!version.equals("1.0")) ! throw new SAXException( ! "Version " ! + version ! + " of XUpdate " ! + "not supported."); return; } - String select = null; // variable declaration if (localName.equals("variable")) { ! select = atts.getValue("select"); ! if (select == null) ! throw new SAXException("variable declaration requires a select attribute"); ! String name = atts.getValue("name"); ! if (name == null) ! throw new SAXException("variable declarations requires a name attribute"); ! createVariable(name, select); return; } ! ! if (localName.equals("append") ! || localName.equals("insert-before") ! || localName.equals("insert-after") ! || localName.equals("remove") ! || localName.equals("rename") ! || localName.equals("update")) { if (inModification) throw new SAXException("nested modifications are not allowed"); --- 199,226 ---- if (namespaceURI.equals(XUPDATE_NS)) { if (localName.equals("modifications")) { ! startModifications(atts); return; } // variable declaration if (localName.equals("variable")) { ! startVariableDecl(atts); return; } ! ! String select = null; ! if ("if".equals(localName)) { ! if (inModification) ! throw new SAXException("xupdate:if is not allowed inside a modification"); ! select = atts.getValue("test"); ! Conditional cond = new Conditional(broker, documentSet, select, namespaces); ! conditionals.push(cond); ! return; ! } else if ("append".equals(localName) ! || "insert-before".equals(localName) ! || "insert-after".equals(localName) ! || "remove".equals(localName) ! || "rename".equals(localName) ! || "update".equals(localName)) { if (inModification) throw new SAXException("nested modifications are not allowed"); *************** *** 234,242 **** inModification = true; } else if ( ! (localName.equals("element") ! || localName.equals("attribute") ! || localName.equals("text") ! || localName.equals("processing-instruction") ! || localName.equals("comment")) && (!inModification)) throw new SAXException( --- 233,241 ---- inModification = true; } else if ( ! ("element".equals(localName) ! || "attribute".equals(localName) ! || "text".equals(localName) ! || "processing-instruction".equals(localName) ! || "comment".equals(localName)) && (!inModification)) throw new SAXException( *************** *** 245,266 **** // start a new modification section ! if (localName.equals("append")) { String child = atts.getValue("child"); modification = new Append(broker, documentSet, select, child, namespaces); ! } else if (localName.equals("update")) modification = new Update(broker, documentSet, select, namespaces); ! else if (localName.equals("insert-before")) modification = new Insert(broker, documentSet, select, Insert.INSERT_BEFORE, namespaces); ! else if (localName.equals("insert-after")) modification = new Insert(broker, documentSet, select, Insert.INSERT_AFTER, namespaces); ! else if (localName.equals("remove")) modification = new Remove(broker, documentSet, select, namespaces); ! else if (localName.equals("rename")) modification = new Rename(broker, documentSet, select, namespaces); // process commands for node creation ! else if (localName.equals("element")) { String name = atts.getValue("name"); if (name == null) --- 244,265 ---- // start a new modification section ! if ("append".equals(localName)) { String child = atts.getValue("child"); modification = new Append(broker, documentSet, select, child, namespaces); ! } else if ("update".equals(localName)) modification = new Update(broker, documentSet, select, namespaces); ! else if ("insert-before".equals(localName)) modification = new Insert(broker, documentSet, select, Insert.INSERT_BEFORE, namespaces); ! else if ("insert-after".equals(localName)) modification = new Insert(broker, documentSet, select, Insert.INSERT_AFTER, namespaces); ! else if ("remove".equals(localName)) modification = new Remove(broker, documentSet, select, namespaces); ! else if ("rename".equals(localName)) modification = new Rename(broker, documentSet, select, namespaces); // process commands for node creation ! else if ("element".equals(localName)) { String name = atts.getValue("name"); if (name == null) *************** *** 290,294 **** } stack.push(elem); ! } else if (localName.equals("attribute")) { String name = atts.getValue("name"); if (name == null) --- 289,293 ---- } stack.push(elem); ! } else if ("attribute".equals(localName)) { String name = atts.getValue("name"); if (name == null) *************** *** 308,315 **** } Attr attrib = doc.createAttributeNS(namespace, name); ! if (stack.isEmpty()) contents.add(attrib); ! else { Element last = (Element) stack.peek(); last.setAttributeNode(attrib); } --- 307,326 ---- } Attr attrib = doc.createAttributeNS(namespace, name); ! if (stack.isEmpty()) { ! for(int i = 0; i < contents.getLength(); i++) { ! Node n = contents.item(i); ! String ns = n.getNamespaceURI(); ! if(ns == null) ns = ""; ! if(n.getNodeType() == Node.ATTRIBUTE_NODE && ! n.getLocalName().equals(name) && ! ns.equals(namespace)) ! throw new SAXException("The attribute " + attrib.getNodeName() + " cannot be specified twice"); ! } contents.add(attrib); ! } else { Element last = (Element) stack.peek(); + if(last.getAttributeNS(namespace, name) != null) + throw new SAXException("The attribute " + attrib.getNodeName() + " cannot be specified " + + "twice on the same element"); last.setAttributeNode(attrib); } *************** *** 318,342 **** // process value-of ! } else if (localName.equals("value-of")) { select = atts.getValue("select"); if (select == null) throw new SAXException("value-of requires a select attribute"); ! List nodes; ! if (select.startsWith("$")) { ! nodes = (List) variables.get(select); ! if (nodes == null) ! throw new SAXException( ! "variable " + select + " not found"); ! } else ! nodes = processQuery(select); ! LOG.debug("found " + nodes.size() + " nodes for value-of"); ! Node node; ! for (Iterator i = nodes.iterator(); i.hasNext();) { ! node = XMLUtil.copyNode(doc, (Node) i.next()); ! if (stack.isEmpty()) ! contents.add(node); ! else { ! Element last = (Element) stack.peek(); ! last.appendChild(node); } } --- 329,356 ---- // process value-of ! } else if ("value-of".equals(localName)) { select = atts.getValue("select"); if (select == null) throw new SAXException("value-of requires a select attribute"); ! Sequence seq = processQuery(select); ! LOG.debug("Found " + seq.getLength() + " items for value-of"); ! Item item; ! for (SequenceIterator i = seq.iterate(); i.hasNext();) { ! item = i.nextItem(); ! if(Type.subTypeOf(item.getType(), Type.NODE)) { ! Node node = XMLUtil.copyNode(doc, ((NodeValue)item).getNode()); ! if (stack.isEmpty()) ! contents.add(node); ! else { ! Element last = (Element) stack.peek(); ! last.appendChild(node); ! } ! } else { ! try { ! String value = item.getStringValue(); ! characters(value.toCharArray(), 0, value.length()); ! } catch(XPathException e) { ! throw new SAXException(e.getMessage(), e); ! } } } *************** *** 360,363 **** --- 374,401 ---- } + private void startVariableDecl(Attributes atts) throws SAXException { + String select = atts.getValue("select"); + if (select == null) + throw new SAXException("variable declaration requires a select attribute"); + String name = atts.getValue("name"); + if (name == null) + throw new SAXException("variable declarations requires a name attribute"); + createVariable(name, select); + } + + private void startModifications(Attributes atts) throws SAXException { + String version = atts.getValue("version"); + if (version == null) + throw new SAXException( + "version attribute is required for " + + "element modifications"); + if (!version.equals("1.0")) + throw new SAXException( + "Version " + + version + + " of XUpdate " + + "not supported."); + } + /** * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) *************** *** 379,388 **** charBuf.setLength(0); } ! if (namespaceURI.equals(XUPDATE_NS)) { ! if (localName.equals("element")) { stack.pop(); ! } else if (localName.equals("attribute")) inAttribute = false; ! if (localName.equals("append") || localName.equals("update") || localName.equals("remove") --- 417,429 ---- charBuf.setLength(0); } ! if (XUPDATE_NS.equals(namespaceURI)) { ! if ("if".equals(localName)) { ! Conditional cond = (Conditional) conditionals.pop(); ! modifications.add(cond); ! } else if (localName.equals("element")) { stack.pop(); ! } else if (localName.equals("attribute")) { inAttribute = false; ! } else if (localName.equals("append") || localName.equals("update") || localName.equals("remove") *************** *** 392,396 **** inModification = false; modification.setContent(contents); ! modifications.add(modification); modification = null; } --- 433,442 ---- inModification = false; modification.setContent(contents); ! if(!conditionals.isEmpty()) { ! Conditional cond = (Conditional) conditionals.peek(); ! cond.addModification(modification); ! } else { ! modifications.add(modification); ! } modification = null; } *************** *** 467,476 **** throws SAXException { LOG.debug("creating variable " + name + " as " + select); ! List result = processQuery(select); ! LOG.debug("found " + result.size() + " for variable " + name); ! variables.put('$' + name, result); } ! private List processQuery(String select) throws SAXException { try { XQueryContext context = new XQueryContext(broker); --- 513,522 ---- throws SAXException { LOG.debug("creating variable " + name + " as " + select); ! Sequence result = processQuery(select); ! LOG.debug("found " + result.getLength() + " for variable " + name); ! variables.put(name, result); } ! private Sequence processQuery(String select) throws SAXException { try { XQueryContext context = new XQueryContext(broker); *************** *** 483,486 **** --- 529,536 ---- (String) entry.getValue()); } + for (Iterator i = variables.entrySet().iterator(); i.hasNext(); ) { + entry = (Map.Entry) i.next(); + context.declareVariable(entry.getKey().toString(), entry.getValue()); + } XQueryLexer lexer = new XQueryLexer(context, new StringReader(select)); XQueryParser parser = new XQueryParser(lexer); *************** *** 501,513 **** Sequence seq = expr.eval(null, null); ! if (!(seq.getItemType() == Type.NODE)) ! throw new SAXException( ! "select expression should evaluate to a" + "node-set"); ! NodeList set = (NodeList)seq; ! ArrayList out = new ArrayList(set.getLength()); ! for (int i = 0; i < set.getLength(); i++) { ! out.add(set.item(i)); ! } ! return out; } catch (RecognitionException e) { LOG.warn("error while creating variable", e); --- 551,555 ---- Sequence seq = expr.eval(null, null); ! return seq; } catch (RecognitionException e) { LOG.warn("error while creating variable", e); Index: Modification.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Modification.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Modification.java 12 Sep 2004 09:25:23 -0000 1.31 --- Modification.java 21 Sep 2004 14:42:04 -0000 1.32 *************** *** 116,126 **** context.setExclusiveMode(true); context.setStaticallyKnownDocuments(docs); ! Map.Entry entry; ! for (Iterator i = namespaces.entrySet().iterator(); i.hasNext();) { ! entry = (Map.Entry) i.next(); ! context.declareNamespace( ! (String) entry.getKey(), ! (String) entry.getValue()); ! } XQueryLexer lexer = new XQueryLexer(context, new StringReader(selectStmt)); XQueryParser parser = new XQueryParser(lexer); --- 116,120 ---- context.setExclusiveMode(true); context.setStaticallyKnownDocuments(docs); ! declareNamespaces(context); XQueryLexer lexer = new XQueryLexer(context, new StringReader(selectStmt)); XQueryParser parser = new XQueryParser(lexer); *************** *** 156,159 **** --- 150,166 ---- /** + * @param context + */ + protected void declareNamespaces(XQueryContext context) { + Map.Entry entry; + for (Iterator i = namespaces.entrySet().iterator(); i.hasNext();) { + entry = (Map.Entry) i.next(); + context.declareNamespace( + (String) entry.getKey(), + (String) entry.getValue()); + } + } + + /** * Acquire a lock on all documents processed by this modification. * We have to avoid that node positions change during the --- NEW FILE: Conditional.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: Conditional.java,v 1.1 2004/09/21 14:42:04 wolfgang_m Exp $ */ package org.exist.xupdate; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.exist.EXistException; import org.exist.dom.DocumentSet; import org.exist.security.PermissionDeniedException; import org.exist.storage.DBBroker; import org.exist.util.LockException; import org.exist.xquery.CompiledXQuery; import org.exist.xquery.XPathException; import org.exist.xquery.XQuery; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; /** * @author wolf */ public class Conditional extends Modification { private List modifications = new ArrayList(5); /** * @param broker * @param docs * @param selectStmt * @param namespaces */ public Conditional(DBBroker broker, DocumentSet docs, String selectStmt, Map namespaces) { super(broker, docs, selectStmt, namespaces); } public void addModification(Modification mod) { modifications.add(mod); } /* (non-Javadoc) * @see org.exist.xupdate.Modification#process() */ public long process() throws PermissionDeniedException, LockException, EXistException, XPathException { LOG.debug("Processing xupdate:if ..."); XQuery xquery = broker.getXQueryService(); XQueryContext context = xquery.newContext(); context.setBackwardsCompatibility(true); context.setStaticallyKnownDocuments(docs); declareNamespaces(context); CompiledXQuery compiled = xquery.compile(context, new StringReader(selectStmt)); Sequence seq = xquery.execute(compiled, null); if(seq.effectiveBooleanValue()) { long mods = 0; for (int i = 0; i < modifications.size(); i++) { mods += ((Modification)modifications.get(i)).process(); broker.flush(); } LOG.debug(mods + " modifications processed."); return mods; } else return 0; } /* (non-Javadoc) * @see org.exist.xupdate.Modification#getName() */ public String getName() { return "if"; } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 11:49:30
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3185/src/org/exist/xquery/functions Modified Files: FunNot.java Log Message: Corrected: fn:not() should return TRUE if its argument evaluates to an empty sequence. Index: FunNot.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunNot.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FunNot.java 21 Sep 2004 11:17:10 -0000 1.5 --- FunNot.java 21 Sep 2004 11:49:21 -0000 1.6 *************** *** 90,94 **** result = result.except(argSet); if (result.getLength() == 0) ! return BooleanValue.FALSE; else return result; --- 90,94 ---- result = result.except(argSet); if (result.getLength() == 0) ! return BooleanValue.TRUE; else return result; |
From: Wolfgang M. M. <wol...@us...> - 2004-09-21 11:17:19
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29645/src/org/exist/xquery/functions Modified Files: FunNot.java Log Message: fn:not() should return FALSE if its argument evaluates to an empty sequence. Index: FunNot.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunNot.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunNot.java 12 Sep 2004 09:25:14 -0000 1.4 --- FunNot.java 21 Sep 2004 11:17:10 -0000 1.5 *************** *** 88,92 **** arg.eval(contextSequence, contextItem); NodeSet argSet = argSeq.toNodeSet().getContextNodes(true); ! return result.except(argSet); // case 2: simply invert the boolean value } else { --- 88,96 ---- arg.eval(contextSequence, contextItem); NodeSet argSet = argSeq.toNodeSet().getContextNodes(true); ! result = result.except(argSet); ! if (result.getLength() == 0) ! return BooleanValue.FALSE; ! else ! return result; // case 2: simply invert the boolean value } else { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 20:31:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28913/src/org/exist/xquery Modified Files: GeneralComparison.java ValueComparison.java Log Message: General and value comparisons should return an empty sequence if one of the two arguments is empty. Index: GeneralComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/GeneralComparison.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GeneralComparison.java 12 Sep 2004 10:40:14 -0000 1.7 --- GeneralComparison.java 20 Sep 2004 20:31:38 -0000 1.8 *************** *** 159,163 **** } ! protected BooleanValue genericCompare( Sequence contextSequence, Item contextItem) --- 159,163 ---- } ! protected Sequence genericCompare( Sequence contextSequence, Item contextItem) Index: ValueComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/ValueComparison.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValueComparison.java 12 Sep 2004 09:25:14 -0000 1.2 --- ValueComparison.java 20 Sep 2004 20:31:38 -0000 1.3 *************** *** 61,65 **** } ! protected BooleanValue genericCompare( Sequence contextSequence, Item contextItem) --- 61,65 ---- } ! protected Sequence genericCompare( Sequence contextSequence, Item contextItem) *************** *** 67,70 **** --- 67,72 ---- Sequence ls = getLeft().eval(contextSequence, contextItem); Sequence rs = getRight().eval(contextSequence, contextItem); + if(ls.getLength() == 0 || rs.getLength() == 0) + return Sequence.EMPTY_SEQUENCE; AtomicValue lv, rv; if (ls.getLength() == 1 && rs.getLength() == 1) { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 18:00:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27729/src/org/exist/http Modified Files: RESTServer.java Log Message: Added support to set output properties via XQuery pragma to xmlrpc, XQueryGenerator and REST interface. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RESTServer.java 20 Sep 2004 10:23:19 -0000 1.19 --- RESTServer.java 20 Sep 2004 18:00:48 -0000 1.20 *************** *** 60,63 **** --- 60,64 ---- import org.exist.util.serializer.SAXSerializerPool; import org.exist.xquery.CompiledXQuery; + import org.exist.xquery.Pragma; import org.exist.xquery.XPathException; import org.exist.xquery.XQuery; *************** *** 451,457 **** context = compiled.getContext(); context.setStaticallyKnownDocuments(docs); ! if(compiled == null) compiled = xquery.compile(context, source); try { long startTime = System.currentTimeMillis(); --- 452,459 ---- context = compiled.getContext(); context.setStaticallyKnownDocuments(docs); ! if(compiled == null) compiled = xquery.compile(context, source); + checkPragmas(context, outputProperties); try { long startTime = System.currentTimeMillis(); *************** *** 471,474 **** --- 473,497 ---- } + /** + * Check if the XQuery contains pragmas that define serialization settings. + * If yes, copy the corresponding settings to the current set of output properties. + * + * @param context + */ + protected void checkPragmas(XQueryContext context, Properties properties) throws XPathException { + Pragma pragma = context.getPragma(Pragma.SERIALIZE_QNAME); + if(pragma == null) + return; + String[] contents = pragma.tokenizeContents(); + for(int i = 0; i < contents.length; i++) { + String[] pair = Pragma.parseKeyValuePair(contents[i]); + if(pair == null) + throw new XPathException("Unknown parameter found in " + pragma.getQName().toString() + + ": '" + contents[i] + "'"); + LOG.debug("Setting serialization property from pragma: " + pair[0] + " = " + pair[1]); + properties.setProperty(pair[0], pair[1]); + } + } + protected String printCollection(DBBroker broker, Collection collection) { SAXSerializer serializer = null; |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 18:00:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27729/src/org/exist/xmlrpc Modified Files: QueryResult.java RpcConnection.java Log Message: Added support to set output properties via XQuery pragma to xmlrpc, XQueryGenerator and REST interface. Index: QueryResult.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/QueryResult.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QueryResult.java 29 Jan 2004 15:06:44 -0000 1.3 --- QueryResult.java 20 Sep 2004 18:00:48 -0000 1.4 *************** *** 1,16 **** package org.exist.xmlrpc; import org.exist.xquery.value.Sequence; public class QueryResult { ! long queryTime = 0; ! Sequence result; ! long timestamp = 0; ! public QueryResult(Sequence result) { ! this(result, 0); } ! public QueryResult(Sequence result, long queryTime) { this.result = result; this.queryTime = queryTime; --- 1,20 ---- package org.exist.xmlrpc; + import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; public class QueryResult { ! ! protected long queryTime = 0; ! protected Sequence result; ! protected XQueryContext context; ! protected long timestamp = 0; ! public QueryResult(XQueryContext context, Sequence result) { ! this(context, result, 0); } ! public QueryResult(XQueryContext context, Sequence result, long queryTime) { ! this.context = context; this.result = result; this.queryTime = queryTime; Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** RpcConnection.java 16 Sep 2004 12:33:44 -0000 1.72 --- RpcConnection.java 20 Sep 2004 18:00:48 -0000 1.73 *************** *** 81,84 **** --- 81,85 ---- import org.exist.xquery.CompiledXQuery; import org.exist.xquery.PathExpr; + import org.exist.xquery.Pragma; import org.exist.xquery.XPathException; import org.exist.xquery.XQuery; *************** *** 215,219 **** } ! protected Sequence doQuery(User user, DBBroker broker, String xpath, DocumentSet docs, NodeSet contextSet, Hashtable parameters) throws Exception { --- 216,220 ---- } ! protected QueryResult doQuery(User user, DBBroker broker, String xpath, DocumentSet docs, NodeSet contextSet, Hashtable parameters) throws Exception { *************** *** 254,262 **** if(compiled == null) compiled = xquery.compile(context, source); try { long start = System.currentTimeMillis(); Sequence result = xquery.execute(compiled, contextSet); LOG.info("query took " + (System.currentTimeMillis() - start) + "ms."); ! return result; } finally { pool.returnCompiledXQuery(source, compiled); --- 255,264 ---- if(compiled == null) compiled = xquery.compile(context, source); + checkPragmas(context, parameters); try { long start = System.currentTimeMillis(); Sequence result = xquery.execute(compiled, contextSet); LOG.info("query took " + (System.currentTimeMillis() - start) + "ms."); ! return new QueryResult(context, result); } finally { pool.returnCompiledXQuery(source, compiled); *************** *** 264,279 **** } public int executeQuery(User user, String xpath, Hashtable parameters) throws Exception { long startTime = System.currentTimeMillis(); - LOG.debug("query: " + xpath); DBBroker broker = null; try { broker = brokerPool.get(user); ! Sequence resultValue = doQuery(user, broker, xpath, null, null, parameters); ! QueryResult qr = new QueryResult(resultValue, (System ! .currentTimeMillis() - startTime)); ! connectionPool.resultSets.put(qr.hashCode(), qr); ! return qr.hashCode(); } finally { brokerPool.release(broker); --- 266,300 ---- } + /** + * Check if the XQuery contains pragmas that define serialization settings. + * If yes, copy the corresponding settings to the current set of output properties. + * + * @param context + */ + protected void checkPragmas(XQueryContext context, Hashtable parameters) throws XPathException { + Pragma pragma = context.getPragma(Pragma.SERIALIZE_QNAME); + if(pragma == null) + return; + String[] contents = pragma.tokenizeContents(); + for(int i = 0; i < contents.length; i++) { + String[] pair = Pragma.parseKeyValuePair(contents[i]); + if(pair == null) + throw new XPathException("Unknown parameter found in " + pragma.getQName().toString() + + ": '" + contents[i] + "'"); + LOG.debug("Setting serialization property from pragma: " + pair[0] + " = " + pair[1]); + parameters.put(pair[0], pair[1]); + } + } + public int executeQuery(User user, String xpath, Hashtable parameters) throws Exception { long startTime = System.currentTimeMillis(); DBBroker broker = null; try { broker = brokerPool.get(user); ! QueryResult result = doQuery(user, broker, xpath, null, null, parameters); ! result.queryTime = System.currentTimeMillis() - startTime; ! connectionPool.resultSets.put(result.hashCode(), result); ! return result.hashCode(); } finally { brokerPool.release(broker); *************** *** 1172,1182 **** try { broker = brokerPool.get(user); ! Sequence resultSeq = doQuery(user, broker, xpath, null, null, parameters); ! if (resultSeq == null) return "<?xml version=\"1.0\"?>\n" + "<exist:result xmlns:exist=\"http://exist.sourceforge.net/NS/exist\" " + "hitCount=\"0\"/>"; ! result = printAll(broker, resultSeq, howmany, start, parameters, (System.currentTimeMillis() - startTime)); } finally { --- 1193,1203 ---- try { broker = brokerPool.get(user); ! QueryResult qr = doQuery(user, broker, xpath, null, null, parameters); ! if (qr == null) return "<?xml version=\"1.0\"?>\n" + "<exist:result xmlns:exist=\"http://exist.sourceforge.net/NS/exist\" " + "hitCount=\"0\"/>"; ! result = printAll(broker, qr.result, howmany, start, parameters, (System.currentTimeMillis() - startTime)); } finally { *************** *** 1195,1198 **** --- 1216,1220 ---- NodeSet nodes = null; DocumentSet docs = null; + QueryResult queryResult; Sequence resultSeq = null; DBBroker broker = null; *************** *** 1213,1219 **** docs.add(node.getDocument()); } ! resultSeq = doQuery(user, broker, xpath, docs, nodes, parameters); ! if (resultSeq == null) return ret; LOG.debug("found " + resultSeq.getLength()); --- 1235,1242 ---- docs.add(node.getDocument()); } ! queryResult = doQuery(user, broker, xpath, docs, nodes, parameters); ! if (queryResult == null) return ret; + resultSeq = queryResult.result; LOG.debug("found " + resultSeq.getLength()); *************** *** 1257,1264 **** brokerPool.release(broker); } ! QueryResult qr = new QueryResult(resultSeq, ! (System.currentTimeMillis() - startTime)); ! connectionPool.resultSets.put(qr.hashCode(), qr); ! ret.put("id", new Integer(qr.hashCode())); ret.put("results", result); return ret; --- 1280,1287 ---- brokerPool.release(broker); } ! queryResult.result = resultSeq; ! queryResult.queryTime = (System.currentTimeMillis() - startTime); ! connectionPool.resultSets.put(queryResult.hashCode(), queryResult); ! ret.put("id", new Integer(queryResult.hashCode())); ret.put("results", result); return ret; *************** *** 1371,1374 **** --- 1394,1398 ---- Serializer serializer = broker.getSerializer(); serializer.reset(); + checkPragmas(qr.context, parameters); serializer.setProperties(parameters); return serializer.serialize(nodeValue); *************** *** 1390,1394 **** throw new EXistException("result set unknown or timed out"); qr.timestamp = System.currentTimeMillis(); ! Serializer serializer = broker.getSerializer(); serializer.reset(); --- 1414,1418 ---- throw new EXistException("result set unknown or timed out"); qr.timestamp = System.currentTimeMillis(); ! checkPragmas(qr.context, parameters); Serializer serializer = broker.getSerializer(); serializer.reset(); *************** *** 1688,1695 **** try { broker = brokerPool.get(user); ! Sequence resultSeq = doQuery(user, broker, xpath, null, null, null); ! if (resultSeq == null) return new Hashtable(); ! NodeList resultSet = (NodeList) resultSeq; HashMap map = new HashMap(); HashMap doctypes = new HashMap(); --- 1712,1719 ---- try { broker = brokerPool.get(user); ! QueryResult qr = doQuery(user, broker, xpath, null, null, null); ! if (qr == null) return new Hashtable(); ! NodeList resultSet = (NodeList) qr.result; HashMap map = new HashMap(); HashMap doctypes = new HashMap(); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 18:00:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27729/src/org/exist/http/test Modified Files: RESTServiceTest.java Log Message: Added support to set output properties via XQuery pragma to xmlrpc, XQueryGenerator and REST interface. Index: RESTServiceTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/test/RESTServiceTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RESTServiceTest.java 20 Sep 2004 11:32:25 -0000 1.2 --- RESTServiceTest.java 20 Sep 2004 18:00:47 -0000 1.3 *************** *** 64,68 **** "<property name=\"encoding\" value=\"UTF-8\"/>" + "</properties>" + ! "<text>//para[. = 'ääüüööÃÃÃÃÃÃ']/text()</text>" + "</query>"; --- 64,72 ---- "<property name=\"encoding\" value=\"UTF-8\"/>" + "</properties>" + ! "<text>" + ! "xquery version \"1.0\";" + ! "(::pragma exist:serialize indent=no ::)" + ! "//para[. = 'ääüüööÃÃÃÃÃÃ']/text()" + ! "</text>" + "</query>"; |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 18:00:58
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27729/src/org/exist/xmlrpc/test Modified Files: XmlRpcTest.java Log Message: Added support to set output properties via XQuery pragma to xmlrpc, XQueryGenerator and REST interface. Index: XmlRpcTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/test/XmlRpcTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XmlRpcTest.java 15 Sep 2004 14:11:30 -0000 1.2 --- XmlRpcTest.java 20 Sep 2004 18:00:46 -0000 1.3 *************** *** 120,124 **** public void testQuery() throws Exception { Vector params = new Vector(); ! String query = "//para"; params.addElement(query.getBytes("UTF-8")); params.addElement(new Integer(10)); --- 120,125 ---- public void testQuery() throws Exception { Vector params = new Vector(); ! String query = ! "(::pragma exist:serialize indent=no::) //para"; params.addElement(query.getBytes("UTF-8")); params.addElement(new Integer(10)); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 18:00:58
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27729/src/org/exist/xmldb Modified Files: LocalXPathQueryService.java Log Message: Added support to set output properties via XQuery pragma to xmlrpc, XQueryGenerator and REST interface. Index: LocalXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXPathQueryService.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** LocalXPathQueryService.java 12 Sep 2004 09:25:15 -0000 1.44 --- LocalXPathQueryService.java 20 Sep 2004 18:00:47 -0000 1.45 *************** *** 159,162 **** --- 159,163 ---- context.setStaticallyKnownDocuments(docs); setupContext(context); + checkPragmas(context); XQuery xquery = broker.getXQueryService(); result = xquery.execute(expr, contextSet); *************** *** 198,201 **** --- 199,203 ---- if(compiled == null) compiled = xquery.compile(context, source); + checkPragmas(context); try { result = xquery.execute(compiled, null); *************** *** 228,232 **** setupContext(context); CompiledXQuery expr = xquery.compile(context, new StringReader(query)); ! LOG.debug("compilation took " + (System.currentTimeMillis() - start)); return expr; --- 230,234 ---- setupContext(context); CompiledXQuery expr = xquery.compile(context, new StringReader(query)); ! checkPragmas(context); LOG.debug("compilation took " + (System.currentTimeMillis() - start)); return expr; *************** *** 260,264 **** } context.setBackwardsCompatibility(xpathCompatible); - checkPragmas(context); } --- 262,265 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 13:13:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/src/org/exist/xmldb/test/concurrent Modified Files: ConcurrentResourceTest.java ConcurrentXUpdateTest.java Log Message: Index: ConcurrentResourceTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent/ConcurrentResourceTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConcurrentResourceTest.java 20 Sep 2004 10:21:37 -0000 1.2 --- ConcurrentResourceTest.java 20 Sep 2004 13:12:52 -0000 1.3 *************** *** 57,61 **** String[] wordList = DBUtils.wordList(rootCol); ! tempFile = DBUtils.generateXMLFile(1000, 10, wordList); Collection c1 = DBUtils.addCollection(getTestCollection(), "C1-C2"); --- 57,61 ---- String[] wordList = DBUtils.wordList(rootCol); ! tempFile = DBUtils.generateXMLFile(500, 10, wordList); Collection c1 = DBUtils.addCollection(getTestCollection(), "C1-C2"); *************** *** 65,73 **** DBUtils.addXMLResource(c2, "R1.xml", tempFile); ! addAction(new ReplaceResourceAction(URI + "/C1/C1-C2", "R1.xml", wordList), 20, 200); ! addAction(new RetrieveResourceAction(URI + "/C1/C1-C2", "R1.xml"), 20, 1000); ! addAction(new ReplaceResourceAction(URI + "/C1/C1-C3", "R1.xml", wordList), 20, 200); ! addAction(new RetrieveResourceAction(URI + "/C1/C1-C3", "R1.xml"), 20, 1000); // TODO: using a second replace thread on the same resource generates a deadlock condition !!! --- 65,73 ---- DBUtils.addXMLResource(c2, "R1.xml", tempFile); ! // addAction(new ReplaceResourceAction(URI + "/C1/C1-C2", "R1.xml", wordList), 20, 200); ! addAction(new RetrieveResourceAction(URI + "/C1/C1-C2", "R1.xml"), 20, 500); ! // addAction(new ReplaceResourceAction(URI + "/C1/C1-C3", "R1.xml", wordList), 20, 200); ! addAction(new RetrieveResourceAction(URI + "/C1/C1-C3", "R1.xml"), 20, 500); // TODO: using a second replace thread on the same resource generates a deadlock condition !!! Index: ConcurrentXUpdateTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent/ConcurrentXUpdateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConcurrentXUpdateTest.java 20 Sep 2004 10:21:37 -0000 1.3 --- ConcurrentXUpdateTest.java 20 Sep 2004 13:12:52 -0000 1.4 *************** *** 47,51 **** String[] wordList = DBUtils.wordList(rootCol); ! tempFile = DBUtils.generateXMLFile(1000, 10, wordList); DBUtils.addXMLResource(getTestCollection(), "R1.xml", tempFile); --- 47,51 ---- String[] wordList = DBUtils.wordList(rootCol); ! tempFile = DBUtils.generateXMLFile(500, 10, wordList); DBUtils.addXMLResource(getTestCollection(), "R1.xml", tempFile); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 13:13:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/src/org/exist/util/serializer Modified Files: ReceiverToSAX.java Log Message: Index: ReceiverToSAX.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/ReceiverToSAX.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReceiverToSAX.java 12 Sep 2004 09:25:16 -0000 1.1 --- ReceiverToSAX.java 20 Sep 2004 13:12:53 -0000 1.2 *************** *** 40,43 **** --- 40,45 ---- private LexicalHandler lexicalHandler = null; + private char[] charBuf = new char[2048]; + /** * *************** *** 108,112 **** */ public void characters(CharSequence seq) throws SAXException { ! contentHandler.characters(seq.toString().toCharArray(), 0, seq.length()); } --- 110,121 ---- */ public void characters(CharSequence seq) throws SAXException { ! int len = seq.length(); ! if(len < charBuf.length) { ! for (int i = 0; i < len; i++) ! charBuf[i] = seq.charAt(i); ! contentHandler.characters(charBuf, 0, len); ! } else { ! contentHandler.characters(seq.toString().toCharArray(), 0, seq.length()); ! } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 13:13:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/src/org/exist/client Modified Files: InteractiveClient.java Log Message: Index: InteractiveClient.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/InteractiveClient.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** InteractiveClient.java 8 Sep 2004 14:37:07 -0000 1.37 --- InteractiveClient.java 20 Sep 2004 13:12:52 -0000 1.38 *************** *** 85,88 **** --- 85,89 ---- import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; + import org.exist.xmldb.CollectionManagementServiceImpl; import org.exist.xmldb.DatabaseInstanceManager; import org.exist.xmldb.IndexQueryService; *************** *** 578,586 **** } getResources(); } else if (args[0].equalsIgnoreCase("edit")) { if (args.length == 2) { editResource(args[1]); } else { ! messageln("Please give a resource name."); } } else if (args[0].equalsIgnoreCase("get")) { --- 579,595 ---- } getResources(); + } else if (args[0].equalsIgnoreCase("cp")) { + if (args.length != 3) { + messageln("cp requires two arguments."); + return true; + } + copy(args[1], args[2]); + getResources(); + } else if (args[0].equalsIgnoreCase("edit")) { if (args.length == 2) { editResource(args[1]); } else { ! messageln("Please specify a resource."); } } else if (args[0].equalsIgnoreCase("get")) { *************** *** 1327,1330 **** --- 1336,1364 ---- } + private final void copy(String source, String destination) throws XMLDBException { + CollectionManagementServiceImpl mgtService = (CollectionManagementServiceImpl) + current.getService("CollectionManagementService", "1.0"); + String destName = null; + Collection destCol = resolveCollection(destination); + if(destCol == null) { + int p = destination.lastIndexOf('/'); + if(p < 0) { + destName = destination; + destination = current.getName(); + } else { + destName = destination.substring(p + 1); + destination = destination.substring(0, p); + } + } + Resource srcDoc = resolveResource(source); + if(srcDoc != null) { + String resourcePath = srcDoc.getParentCollection().getName() + '/' + srcDoc.getId(); + messageln("Copying resource " + resourcePath + " to " + destination); + mgtService.copyResource(resourcePath, destination, destName); + } else + messageln("Copying collection " + source + " to " + destination); + mgtService.copy(source, destination, destName); + } + private final void reindex() throws XMLDBException { IndexQueryService service = (IndexQueryService) *************** *** 2300,2303 **** --- 2334,2361 ---- } + private Collection resolveCollection(String path) throws XMLDBException { + return DatabaseManager.getCollection(properties.getProperty("uri") + + path, properties.getProperty("user"), properties.getProperty("password")); + } + + private Resource resolveResource(String path) throws XMLDBException { + String collectionPath; + String resourceName = path; + int p = path.lastIndexOf('/'); + if(p < 0) { + collectionPath = current.getName(); + } else { + collectionPath = path.substring(0, p); + resourceName = path.substring(p + 1); + } + Collection collection = resolveCollection(collectionPath); + if(collection == null) { + messageln("Collection " + collectionPath + " not found."); + return null; + } + messageln("Locating resource " + resourceName + " in collection " + collection.getName()); + return collection.getResource(resourceName); + } + private String[] splitProperty(String key) { String value = properties.getProperty(key); *************** *** 2361,2365 **** os.write((byte[]) data); os.close(); ! } else { OutputStreamWriter writer = new OutputStreamWriter(os, Charset .forName(properties.getProperty("encoding"))); --- 2419,2423 ---- os.write((byte[]) data); os.close(); ! } else { OutputStreamWriter writer = new OutputStreamWriter(os, Charset .forName(properties.getProperty("encoding"))); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 11:32:34
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8789/src/org/exist/http/test Modified Files: RESTServiceTest.java Log Message: junit test for the REST server. Index: RESTServiceTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/test/RESTServiceTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RESTServiceTest.java 20 Sep 2004 10:22:16 -0000 1.1 --- RESTServiceTest.java 20 Sep 2004 11:32:25 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- import java.io.BufferedReader; import java.io.IOException; + import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; *************** *** 56,59 **** --- 57,70 ---- "</xu:modifications>"; + private final static String QUERY_REQUEST = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<query xmlns=\"http://exist.sourceforge.net/NS/exist\">" + + "<properties>" + + "<property name=\"indent\" value=\"yes\"/>" + + "<property name=\"encoding\" value=\"UTF-8\"/>" + + "</properties>" + + "<text>//para[. = 'ääüüööÃÃÃÃÃÃ']/text()</text>" + + "</query>"; + public RESTServiceTest(String name) { super(name); *************** *** 79,91 **** public void testXUpdate() throws IOException { ! HttpURLConnection connect = getConnection(RESOURCE_URI); ! connect.setRequestMethod("POST"); ! connect.setDoOutput(true); ! connect.setRequestProperty("ContentType", "text/xml"); ! ! Writer writer = new OutputStreamWriter(connect.getOutputStream(), "UTF-8"); ! writer.write(XUPDATE); ! writer.close(); ! connect.connect(); int r = connect.getResponseCode(); --- 90,94 ---- public void testXUpdate() throws IOException { ! HttpURLConnection connect = preparePost(XUPDATE); connect.connect(); int r = connect.getResponseCode(); *************** *** 95,98 **** --- 98,110 ---- } + public void testQueryPost() throws IOException { + HttpURLConnection connect = preparePost(QUERY_REQUEST); + connect.connect(); + int r = connect.getResponseCode(); + assertEquals("Server returned response code " + r, 200, r); + + System.out.println(readResponse(connect.getInputStream())); + } + protected void doGet() throws IOException { System.out.println("--- Retrieving document ---"); *************** *** 101,112 **** connect.connect(); BufferedReader reader = ! new BufferedReader(new InputStreamReader(connect.getInputStream(), "UTF-8")); String line; while((line = reader.readLine()) != null) { ! System.out.println(line); } ! int r = connect.getResponseCode(); ! assertEquals("Server returned response code " + r, 200, r); } --- 113,145 ---- connect.connect(); + int r = connect.getResponseCode(); + assertEquals("Server returned response code " + r, 200, r); + + System.out.println(readResponse(connect.getInputStream())); + } + + protected HttpURLConnection preparePost(String content) throws IOException { + HttpURLConnection connect = getConnection(RESOURCE_URI); + connect.setRequestMethod("POST"); + connect.setDoOutput(true); + connect.setRequestProperty("ContentType", "text/xml"); + + Writer writer = new OutputStreamWriter(connect.getOutputStream(), "UTF-8"); + writer.write(content); + writer.close(); + + return connect; + } + + protected String readResponse(InputStream is) throws IOException { BufferedReader reader = ! new BufferedReader(new InputStreamReader(is, "UTF-8")); String line; + StringBuffer out = new StringBuffer(); while((line = reader.readLine()) != null) { ! out.append(line); ! out.append("\r\n"); } ! return out.toString(); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 10:26:02
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25697 Modified Files: build.xml Log Message: Added REST + concurrency tests. Index: build.xml =================================================================== RCS file: /cvsroot/exist/eXist-1.0/build.xml,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** build.xml 15 Sep 2004 14:24:00 -0000 1.55 --- build.xml 20 Sep 2004 10:25:49 -0000 1.56 *************** *** 257,261 **** <!-- Run JUnit tests --> <!-- ================================================================== --> ! <target name="test" depends="test-local,test-remote"/> <target name="test-local" depends="jar"> --- 257,261 ---- <!-- Run JUnit tests --> <!-- ================================================================== --> ! <target name="test" depends="test-local,test-concurrent,test-remote"/> <target name="test-local" depends="jar"> *************** *** 263,267 **** <fileset dir="webapp/WEB-INF/data" includes="*.dbx"/> </delete> ! <mkdir dir="${junit.reports}"/> <junit haltonfailure="yes" printsummary="yes" showoutput="${junit.output}"> --- 263,273 ---- <fileset dir="webapp/WEB-INF/data" includes="*.dbx"/> </delete> ! <mkdir dir="${junit.reports}"/> ! ! <echo> ! ------------------------------------------ ! Running tests on a local database instance ! ------------------------------------------ ! </echo> <junit haltonfailure="yes" printsummary="yes" showoutput="${junit.output}"> *************** *** 272,275 **** --- 278,284 ---- </test> <test fork="yes" name="org.exist.xupdate.test.AllTests" todir="${junit.reports}"/> + <!-- Execute all other tests except those that have to be called + manually. + --> <batchtest fork="yes" todir="${junit.reports}"> <fileset dir="${src}"> *************** *** 279,287 **** <exclude name="**/xquery/test/*.java"/> <exclude name="**/xmlrpc/test/*.java"/> </fileset> </batchtest> </junit> </target> ! <target name="start-server"> <echo>Starting stand-alone database server... --- 288,307 ---- <exclude name="**/xquery/test/*.java"/> <exclude name="**/xmlrpc/test/*.java"/> + <exclude name="**/http/test/*.java"/> </fileset> </batchtest> </junit> </target> ! ! <target name="test-concurrent"> ! <echo> ! ----------------- ! Concurrency tests ! ----------------- ! </echo> ! <test fork="yes" name="org.exist.xmldb.test.concurrent.AllTests" ! todir="${junit.reports}"/> ! </target> ! <target name="start-server"> <echo>Starting stand-alone database server... *************** *** 303,308 **** </typedef> <mkdir dir="${junit.reports}"/> ! ! <echo message="Running tests ..."/> <junit haltonfailure="yes" printsummary="yes" showoutput="${junit.output}"> --- 323,332 ---- </typedef> <mkdir dir="${junit.reports}"/> ! ! <echo> ! -------------------------------- ! Running tests on remote database ! -------------------------------- ! </echo> <junit haltonfailure="yes" printsummary="yes" showoutput="${junit.output}"> *************** *** 315,318 **** --- 339,344 ---- todir="${junit.reports}"> </test> + <test fork="yes" name="org.exist.http.test.RESTServiceTest" + todir="${junit.reports}"/> </junit> |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 10:23:28
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25106/src/org/exist/http Modified Files: RESTServer.java Log Message: Fixed NPE if the content of a POST request is neither a query nor an xupdate. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** RESTServer.java 17 Sep 2004 10:07:25 -0000 1.18 --- RESTServer.java 20 Sep 2004 10:23:19 -0000 1.19 *************** *** 217,221 **** Document doc = docBuilder.parse(src); Element root = doc.getDocumentElement(); ! if(root.getNamespaceURI().equals(NS)) { if(root.getLocalName().equals("query")) { // process <query>xpathQuery</query> --- 217,222 ---- Document doc = docBuilder.parse(src); Element root = doc.getDocumentElement(); ! String rootNS = root.getNamespaceURI(); ! if(rootNS != null && rootNS.equals(NS)) { if(root.getLocalName().equals("query")) { // process <query>xpathQuery</query> *************** *** 271,275 **** else throw new BadRequestException("No query specified"); ! } else if(root.getNamespaceURI().equals(XUPDATE_NS)) { LOG.debug("Got xupdate request: " + content); DocumentSet docs =new DocumentSet(); --- 272,276 ---- else throw new BadRequestException("No query specified"); ! } else if(rootNS != null && rootNS.equals(XUPDATE_NS)) { LOG.debug("Got xupdate request: " + content); DocumentSet docs =new DocumentSet(); *************** *** 325,328 **** --- 326,331 ---- public Response doPut(DBBroker broker, File tempFile, String contentType, String docPath) throws BadRequestException, PermissionDeniedException { + if(tempFile == null) + throw new BadRequestException("No request content found for PUT"); Response response; try { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 10:22:26
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24902/src/org/exist/http/test Added Files: RESTServiceTest.java Log Message: junit test for the REST server. --- NEW FILE: RESTServiceTest.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: RESTServiceTest.java,v 1.1 2004/09/20 10:22:16 wolfgang_m Exp $ */ package org.exist.http.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import junit.framework.TestCase; /** * @author wolf */ public class RESTServiceTest extends TestCase { private final static String SERVER_URI = "http://localhost:8088"; private final static String RESOURCE_URI =SERVER_URI + "/db/test/test.xml"; private final static String XML_DATA = "<test>" + "<para>ääüüööÃÃÃÃÃÃ</para>" + "</test>"; private final static String XUPDATE = "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" + "<xu:append select=\"/test\" child=\"1\">" + "<para>Inserted paragraph.</para>" + "</xu:append>" + "</xu:modifications>"; public RESTServiceTest(String name) { super(name); } public void testPut() throws IOException { System.out.println("--- Storing document ---"); HttpURLConnection connect = getConnection(RESOURCE_URI); connect.setRequestMethod("PUT"); connect.setDoOutput(true); connect.setRequestProperty("ContentType", "text/xml"); Writer writer = new OutputStreamWriter(connect.getOutputStream(), "UTF-8"); writer.write(XML_DATA); writer.close(); connect.connect(); int r = connect.getResponseCode(); assertEquals("Server returned response code " + r, 200, r); doGet(); } public void testXUpdate() throws IOException { HttpURLConnection connect = getConnection(RESOURCE_URI); connect.setRequestMethod("POST"); connect.setDoOutput(true); connect.setRequestProperty("ContentType", "text/xml"); Writer writer = new OutputStreamWriter(connect.getOutputStream(), "UTF-8"); writer.write(XUPDATE); writer.close(); connect.connect(); int r = connect.getResponseCode(); assertEquals("Server returned response code " + r, 200, r); doGet(); } protected void doGet() throws IOException { System.out.println("--- Retrieving document ---"); HttpURLConnection connect = getConnection(RESOURCE_URI); connect.setRequestMethod("GET"); connect.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream(), "UTF-8")); String line; while((line = reader.readLine()) != null) { System.out.println(line); } int r = connect.getResponseCode(); assertEquals("Server returned response code " + r, 200, r); } protected HttpURLConnection getConnection(String url) throws IOException { URL u = new URL(url); return (HttpURLConnection)u.openConnection(); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-20 10:22:23
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24874/src/org/exist/http/test Log Message: Directory /cvsroot/exist/eXist-1.0/src/org/exist/http/test added to the repository |