protected ContentNode translatePath(WebContentRepository wcr, String path)
throws ContentRepositoryException
{
// find the root (system or users)
ContentCollection root = null;
if (path == null || path.equals("/")) {
root = wcr.getRoot();
} else if (path.startsWith("/system")) {
path = path.substring("/system".length());
root = wcr.getSystemRoot();
} else if (path.startsWith("/users/")) {
path = path.substring("/users/".length());
String userId = path;
int endIdx = path.indexOf("/");
if (endIdx != -1) {
userId = path.substring(0, endIdx);
path = path.substring(endIdx);
} else {
path = null;
}
root = wcr.getUserRoot(userId);
} else {
root = wcr.getRoot();
}
if (root == null) {
return null;
}
if (path == null || path.length() == 0 || path.equals("/")) {
return root;
}
return root.getChild(path);
}