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
