* @return
*/
public String createDirIfAbsent(String root, String name, ResultCollector resultCollector)
{
String path = root.length() == 0 ? name : root + "/" + name;
JCRWebdavConnection connection = null;
try
{
connection = getNewConnection();
long start = System.currentTimeMillis();
HTTPResponse nodeResponce = connection.getNode(path);
//add information about read
resultCollector.addResult(true, System.currentTimeMillis() - start);
if (nodeResponce.getStatusCode() != HTTPStatus.OK)
{
start = System.currentTimeMillis();
HTTPResponse addResponce = connection.addDir(path);
//add information about write
if (addResponce.getStatusCode() == HTTPStatus.CREATED)
{
resultCollector.addResult(false, System.currentTimeMillis() - start);
}
else
{
System.out.println(Thread.currentThread().getName() + " : Can not add (response code "
+ addResponce.getStatusCode() + new String(addResponce.getData()) + " ) node with path : " + path);
}
}
}
catch (Exception e)
{
System.out.println(e.getLocalizedMessage());
}
finally
{
if (connection != null)
{
connection.stop();
}
}
return path;
}