Re: WebDAVSource.getParent() and makeCollection()
Michal Stochmialek wrote: On Tue, Jun 29, 2004 at 06:14:12PM +0200, Unico Hommes wrote: It tried again makeCollection method, and i've got exception below: Caused by: org.apache.excalibur.source.SourceException: Unable to create collection webdav://localhost/svn/einformatyka/articles/review/1088515900892. Server responded 404 (Not Found (404)) at org.apache.cocoon.components.source.impl.WebDAVSource.makeCollection(WebDAVSource.java:763) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:79) Identical exception appeared again (like above). :/ But when i changed makeCollection to this below, it started to works :) int status = this.resource.getStatusCode(); if (status == 404) { // parent does not exist, create it and try again ((ModifiableTraversableSource) getParent()).makeCollection(); makeCollection(); } Main (and only) change is in second line (757. line in file), i changed 409 status code, to 404 (not found) status code. (btw. i'm using subversion webdav interface on apache httpd, i'm not sure if status codes are the same when you use slide or something...) 404 is undefined for MKCOL by RFC 2518. 409 is supposed to signal that one or more intermediate collections are missing. Anyway I've added the 404 check as a work around for subversion. Please file this as a bug with the subversion folks. -- Unico
Re: WebDAVSource.getParent() and makeCollection()
On Mon, Jun 28, 2004 at 12:13:27PM +0200, Unico Hommes wrote: Something's wrong with implementation of getParent and makeCollection methods. (in cocoon 2.1.5) makeCollection() - creates collection only if parent exists. Can't create directory hierarchy. When I try, i've got this exception: Directory einformatyka/articles exists, review - don't. Is this correct implementation of ModifiableTraversableSource? Nope, you found a bug :-) It tried again makeCollection method, and i've got exception below: Caused by: org.apache.excalibur.source.SourceException: Unable to create collection webdav://localhost/svn/einformatyka/articles/review/1088515900892. Server responded 404 (Not Found (404)) at org.apache.cocoon.components.source.impl.WebDAVSource.makeCollection(WebDAVSource.java:763) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:79) private void createDirectories(ModifiableTraversableSource source) throws SourceException { System.out.println(Creating dir [+source.getURI()+] + EXISTS: +source.exists()); if (source.exists()) return; if (!source.getParent().exists()) createDirectories((ModifiableTraversableSource)source.getParent()); source.makeCollection(); } Yes, is also a bug. It seems that in some cases getParent() would return itself as its parent collection. I've just committed a fix for both problems. I think its fixed now but haven't the opportunity to test. Could you check if it works for you now? I've run above method again, and getParent throwed this exception: org.apache.excalibur.source.SourceNotFoundException: Not found: webdav://localhost/svn/einformatyka/articles/review/1088515426783 at org.apache.cocoon.components.source.impl.WebDAVSource.initResource(WebDAVSource.java:225) at org.apache.cocoon.components.source.impl.WebDAVSource.getParent(WebDAVSource.java:605) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectories(FileManagerImpl.java:94) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:80) ... 5 more Caused by: org.apache.commons.httpclient.HttpException at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3185) at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3145) at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:879) at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:824) at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1746) at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1156) at org.apache.webdav.lib.WebdavResource.init(WebdavResource.java:242) at org.apache.cocoon.components.source.impl.WebDAVSource.initResource(WebDAVSource.java:211) I think you need some testcase ;) regards, -- Michal Stochmialek [EMAIL PROTECTED]
Re: WebDAVSource.getParent() and makeCollection()
Michal Stochmialek wrote: On Mon, Jun 28, 2004 at 12:13:27PM +0200, Unico Hommes wrote: Something's wrong with implementation of getParent and makeCollection methods. (in cocoon 2.1.5) makeCollection() - creates collection only if parent exists. Can't create directory hierarchy. When I try, i've got this exception: Directory einformatyka/articles exists, review - don't. Is this correct implementation of ModifiableTraversableSource? Nope, you found a bug :-) It tried again makeCollection method, and i've got exception below: Caused by: org.apache.excalibur.source.SourceException: Unable to create collection webdav://localhost/svn/einformatyka/articles/review/1088515900892. Server responded 404 (Not Found (404)) at org.apache.cocoon.components.source.impl.WebDAVSource.makeCollection(WebDAVSource.java:763) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:79) private void createDirectories(ModifiableTraversableSource source) throws SourceException { System.out.println(Creating dir [+source.getURI()+] + EXISTS: +source.exists()); if (source.exists()) return; if (!source.getParent().exists()) createDirectories((ModifiableTraversableSource)source.getParent()); source.makeCollection(); } Yes, is also a bug. It seems that in some cases getParent() would return itself as its parent collection. I've just committed a fix for both problems. I think its fixed now but haven't the opportunity to test. Could you check if it works for you now? I've run above method again, and getParent throwed this exception: org.apache.excalibur.source.SourceNotFoundException: Not found: webdav://localhost/svn/einformatyka/articles/review/1088515426783 at org.apache.cocoon.components.source.impl.WebDAVSource.initResource(WebDAVSource.java:225) at org.apache.cocoon.components.source.impl.WebDAVSource.getParent(WebDAVSource.java:605) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectories(FileManagerImpl.java:94) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:80) ... 5 more Caused by: org.apache.commons.httpclient.HttpException at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3185) at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3145) at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:879) at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:824) at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1746) at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1156) at org.apache.webdav.lib.WebdavResource.init(WebdavResource.java:242) at org.apache.cocoon.components.source.impl.WebDAVSource.initResource(WebDAVSource.java:211) I think you need some testcase ;) Actually I don't. It already exists. See src/blocks/webdav/test . I added your scenario and fixed the problem. Try again now. -- Unico
Re: WebDAVSource.getParent() and makeCollection()
On Tue, Jun 29, 2004 at 06:14:12PM +0200, Unico Hommes wrote: It tried again makeCollection method, and i've got exception below: Caused by: org.apache.excalibur.source.SourceException: Unable to create collection webdav://localhost/svn/einformatyka/articles/review/1088515900892. Server responded 404 (Not Found (404)) at org.apache.cocoon.components.source.impl.WebDAVSource.makeCollection(WebDAVSource.java:763) at pl.einformatyka.common.components.filesystem.FileManagerImpl.createDirectory(FileManagerImpl.java:79) Identical exception appeared again (like above). :/ But when i changed makeCollection to this below, it started to works :) int status = this.resource.getStatusCode(); if (status == 404) { // parent does not exist, create it and try again ((ModifiableTraversableSource) getParent()).makeCollection(); makeCollection(); } Main (and only) change is in second line (757. line in file), i changed 409 status code, to 404 (not found) status code. (btw. i'm using subversion webdav interface on apache httpd, i'm not sure if status codes are the same when you use slide or something...) Actually I don't. It already exists. See src/blocks/webdav/test . I added your scenario and fixed the problem. Try again now. You solved problem with dependecy to existence of parent element. getParent now works! Thanks fast response :) regards, -- Michal Stochmialek [EMAIL PROTECTED]
Re: WebDAVSource.getParent() and makeCollection()
Michal Stochmialek wrote: Hello, Something's wrong with implementation of getParent and makeCollection methods. (in cocoon 2.1.5) makeCollection() - creates collection only if parent exists. Can't create directory hierarchy. When I try, i've got this exception: org.apache.excalibur.source.SourceException: Unable to create collection webdav://localhost/svn/einformatyka/articles/review/1088372068812. Server responded 404 (Not Found (404)) Directory einformatyka/articles exists, review - don't. Is this correct implementation of ModifiableTraversableSource? Nope, you found a bug :-) Well, i tried to make a work around, and created method like this: private void createDirectories(ModifiableTraversableSource source) throws SourceException { System.out.println(Creating dir [+source.getURI()+] + EXISTS: +source.exists()); if (source.exists()) return; if (!source.getParent().exists()) createDirectories((ModifiableTraversableSource)source.getParent()); source.makeCollection(); } And this doesn't work too. It goes into infintive loop of recursive calls. On standard output I get: Creating dir [webdav://localhost/svn/einformatyka/articles/review/1088373196783] EXISTS: false Creating dir [webdav://localhost/svn/einformatyka/articles/review/] EXISTS: false Creating dir [webdav://localhost/svn/einformatyka/articles/review/] EXISTS: false Creating dir [webdav://localhost/svn/einformatyka/articles/review/] EXISTS: false Creating dir [webdav://localhost/svn/einformatyka/articles/review/] EXISTS: false [ and so on...] NOTE slash at the end of URI (review/) This example demonstrates that sometimes: source == source.getParent()... Is this a bug in cocoon or in webdav-lib? Or is this a feature? ;) Yes, is also a bug. It seems that in some cases getParent() would return itself as its parent collection. I've just committed a fix for both problems. I think its fixed now but haven't the opportunity to test. Could you check if it works for you now? -- Unico