Hello Thierry, thanks for your answer. I forgot to tell you that I've already tried that, but in any way, I've tried differently now, by using DomRepresentation#setNamespaceAware (my test was with the W3C classes directly), and here's the result:
28/09/2011 07:50:55 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: ++++DBG: DomRepresentation is NS aware (before setting to false)? false 28/09/2011 07:50:55 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: ++++DBG: DomRepresentation is NS aware (after setting to false)? false 28/09/2011 07:50:56 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: Requested DAV properties: [] 28/09/2011 07:50:56 org.restlet.engine.log.LogFilter afterHandle INFO: 2011-09-28 07:50:56 0:0:0:0:0:0:0:1 [email protected] 0:0:0:0:0:0:0:1 9000 PROPFIND /workspaces/W1/classifications/ - 207 - 288 597 http://localhost:9000 cadaver/0.23.3 neon/0.29.6 - As you can see, the DomRepresentation was already constructed without being NS-aware, but resetting it anyway didn't change anything, the requested DAV properties list is still empty (meaning basically that there was no XML node selected by the XPath query). For completness, I've also tried to use DomRepresentation#setNamespaceAware to set it to true, and the result doesn't change at all: 28/09/2011 07:56:49 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: ++++DBG: DomRepresentation is NS aware (before setting to true)? false 28/09/2011 07:56:49 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: ++++DBG: DomRepresentation is NS aware (after setting to true)? true 28/09/2011 07:56:49 com.calenco.ext.webdav.resource.DavClassificationsServerResource propfind INFO: Requested DAV properties: [] 28/09/2011 07:56:50 org.restlet.engine.log.LogFilter afterHandle INFO: 2011-09-28 07:56:50 0:0:0:0:0:0:0:1 [email protected] 0:0:0:0:0:0:0:1 9000 PROPFIND /workspaces/W1/classifications/ - 207 - 288 1113 http://localhost:9000 cadaver/0.23.3 neon/0.29.6 - Any other ideas? Thanks in advance... On Wed, Sep 28, 2011 at 5:04 AM, Thierry Boileau <[email protected]> wrote: > Hello Fabian, > > I think there is a link with the "DAV" namespace. Could you try by making > the DomRepresentation namespace unaware? > > Best regards, > Thierry Boileau > > > > >> Hello, >> >> I've updated restlet libs for my app to 2.0.9, and now PROPFIND >> (WebDAV) requests are not working anymore. Basically, a WebDAV request >> has (can have, but most do ;)) an XML entity body. My handler is doing >> this (code didn't change): >> >> @Override >> public Representation propfind(Representation reqData) throws >> ResourceException { >> setCustomHttpHeader("DAV", "1,2"); // NOI18N // DAV level 2 support >> List<DavProperty> reqDavProps = new ArrayList<DavProperty>(); >> if (reqData != null) { >> try { >> final DomRepresentation reqXML = new >> DomRepresentation(reqData); >> //getLogger().info("XML body:\n" + reqData.getText()); >> NodeList props = reqXML.getNodes("/propfind/prop/*"); // >> NOI18N >> for (int i = 0; i < props.getLength(); i++) { >> Node n = props.get(i); >> if (n.getNodeType() == Node.ELEMENT_NODE) { >> Element e = (Element) n; >> reqDavProps.add(new >> DavProperty(e.getAttribute("xmlns"), e.getTagName())); // NOI18N >> } >> } >> getLogger().info(String.format("Requested DAV >> properties: %s", reqDavProps)); >> } catch (Exception ex) { >> ex.printStackTrace(); >> >> >> getLogger().warning(Localisation.getMessage("core.err.res.wksp.cont.propfind.bad.xml", >> ex)); // NOI18N >> } >> } >> // Rest of the handler code here, not reproduced >> } >> >> With 2.0.9 I get *0* requested dav properties (it's ok for the 1st >> PROPFIND request which doesn't have an entity body, but it's not OK >> for the subsequent PROPFIND request which does have an entity body). >> >> If I remove the comment from the log tracing line I *do* see the XML >> text of the request body on the logs, reqData.getMediaType() is >> correctly set to text/xml (Microsoft "web folders" client) or >> application/xml (cadaver command line DAV client). Removing the >> comment from the log trace though, raises a MalformedURLException when >> trying to do reqXML.getNodes("/propfind/prop/*"), here's the full >> stack trace (including the XML entity body of the request, so you can >> see what a PROPFIND DAV request looks like): >> >> Sep 22, 2011 8:49:59 AM >> com.calenco.core.resource.workspace.ClassificationsServerResource >> propfind >> INFO: XML body: >> <?xml version="1.0" ?> >> <propfind xmlns="DAV:"> >> <prop> >> <name/> >> <parentname/> >> <href/> >> <ishidden/> >> <iscollection/> >> <isreadonly/> >> <getcontenttype/> >> <contentclass/> >> <getcontentlanguage/> >> <creationdate/> >> <lastaccessed/> >> <getlastmodified/> >> <getcontentlength/> >> <resourcetype/> >> <isstructureddocument/> >> <defaultdocument/> >> <displayname/> >> <isroot/> >> </prop> >> </propfind> >> >> java.lang.RuntimeException: java.net.MalformedURLException >> at >> org.restlet.ext.xml.XmlRepresentation.internalEval(XmlRepresentation.java:556) >> at >> org.restlet.ext.xml.XmlRepresentation.getNodes(XmlRepresentation.java:437) >> at >> com.calenco.core.resource.workspace.ClassificationsServerResource.propfind(ClassificationsServerResource.java:225) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.restlet.resource.ServerResource.doHandle(ServerResource.java:446) >> at >> org.restlet.resource.ServerResource.doHandle(ServerResource.java:546) >> at >> org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:587) >> at >> org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299) >> at >> org.restlet.resource.ServerResource.handle(ServerResource.java:846) >> at org.restlet.resource.Finder.handle(Finder.java:510) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Router.doHandle(Router.java:497) >> at org.restlet.routing.Router.handle(Router.java:737) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Router.doHandle(Router.java:497) >> at org.restlet.routing.Router.handle(Router.java:737) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at >> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111) >> at >> org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72) >> at org.restlet.Application.handle(Application.java:388) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Router.doHandle(Router.java:497) >> at org.restlet.routing.Router.handle(Router.java:737) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Router.doHandle(Router.java:497) >> at org.restlet.routing.Router.handle(Router.java:737) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at >> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.routing.Filter.doHandle(Filter.java:156) >> at org.restlet.routing.Filter.handle(Filter.java:203) >> at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111) >> at org.restlet.Component.handle(Component.java:388) >> at org.restlet.Server.handle(Server.java:488) >> at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71) >> at >> org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150) >> at >> org.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:167) >> at >> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594) >> at >> org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059) >> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764) >> at >> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217) >> at >> org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424) >> at >> org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506) >> at >> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436) >> at java.lang.Thread.run(Thread.java:662) >> Caused by: java.net.MalformedURLException >> at java.net.URL.<init>(URL.java:601) >> at java.net.URL.<init>(URL.java:464) >> at java.net.URL.<init>(URL.java:413) >> at >> org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) >> at >> org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown >> Source) >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown >> Source) >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown >> Source) >> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) >> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) >> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) >> at >> org.restlet.ext.xml.DomRepresentation.getDocument(DomRepresentation.java:169) >> at >> org.restlet.ext.xml.XmlRepresentation.evaluate(XmlRepresentation.java:270) >> at >> org.restlet.ext.xml.XmlRepresentation.internalEval(XmlRepresentation.java:552) >> ... 61 more >> Sep 22, 2011 8:53:20 AM >> com.calenco.core.resource.workspace.ClassificationsServerResource >> propfind >> WARNING: Bad XML in the PROPFIND request body: >> java.lang.RuntimeException: java.net.MalformedURLException >> Sep 22, 2011 8:53:20 AM org.restlet.engine.log.LogFilter afterHandle >> INFO: 2011-09-22 08:53:20 192.168.1.102 [email protected] >> 192.168.1.10 9000 PROPFIND /workspaces/W1/classifications >> - 207 - 380 32 http://192.168.1.10:9000 >> Microsoft >> Data Access Internet Publishing Provider DAV 1.1 - >> >> I've tried with the following code to parse the request XML, and got >> the same results: >> >> DocumentBuilderFactory dbf = >> DocumentBuilderFactory.newInstance(); >> dbf.setNamespaceAware(true); >> try { >> Document doc = >> dbf.newDocumentBuilder().parse(reqData.getStream()); >> XPath xp = XPathFactory.newInstance().newXPath(); >> org.w3c.dom.NodeList props = (org.w3c.dom.NodeList) >> xp.evaluate("/propfind/prop/*", doc, XPathConstants.NODESET); >> for (int i = 0; i < props.getLength(); i++) { >> org.w3c.dom.Node n = props.item(i); >> if (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) { >> Element e = (Element) n; >> reqDavProps.add(new >> DavProperty(e.getAttribute("xmlns"), e.getTagName())); >> } >> } >> getLogger().info(String.format("Requested DAV >> properties [%d]: %s", reqDavProps.size(), reqDavProps)); >> } catch (Exception ex) { >> ex.printStackTrace(); >> >> >> getLogger().warning(Localisation.getMessage("core.err.res.wksp.cont.propfind.bad.xml", >> ex)); // NOI18N >> } >> >> Any ideas? Hints? Thanks in advance (will keep trying a few more >> things meanwhile...) >> >> -- >> Fabián Mandelbaum >> IS Engineer >> >> ------------------------------------------------------ >> >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2843267 > > -- Fabián Mandelbaum IS Engineer ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2847201

