Purpose:
Solve the problem of heavily nested paths when using MKCOL to create a directory structure with WebDAV.
i.e. store a file under /COMPANYA/2006/08/test.file requires multiple MKCOL commands as Slide needs the parent tree to exist before creating children.
Below is a java method that takes a jakarta WebdavResource and the path (such as "/COMPANYA/2006/08/") and creates the entire tree structure.
private static String mkallcol(WebdavResource wdr, String path) throws Exception{
- if (path != null){
if (path.length() > 1){
- path.replace('\\','/'); //Now, break up path
java.util.StringTokenizer t = new java.util.StringTokenizer(path,"/"); String strsub = "/"; int count = t.countTokens(); //check each token EXCEPT last token, last token is filename
while ((t.hasMoreTokens()) && (count > 1)){
- strsub = strsub + t.nextToken() + "/";
- wdr.mkcolMethod(wdr.getPath() + strsub);
- } return wdr.getPath() + strsub + t.nextToken();
- return "";
- path.replace('\\','/'); //Now, break up path
- return "";
- if (path != null){