if(path != null && path.contains(".")){
path = path.substring(0, path.lastIndexOf("/"));
}
Folder folder=!path.equals("/") ? fAPI.findFolderByPath(path, host, user, true) : fAPI.findSystemFolder();
if(folder==null || !UtilMethods.isSet(folder.getIdentifier()))
return null;
NavResult result=navCache.getNav(host.getIdentifier(), folder.getInode());
if(result != null) {
return result;
} else {
String parentId;
if(!folder.getInode().equals(FolderAPI.SYSTEM_FOLDER)) {
Identifier ident=APILocator.getIdentifierAPI().find(folder);
parentId=ident.getParentPath().equals("/") ?
FolderAPI.SYSTEM_FOLDER : fAPI.findFolderByPath(ident.getParentPath(), host, user, false).getInode();
} else {
parentId=null;
}
result=new NavResult(parentId, host.getIdentifier(),folder.getInode());
Identifier ident=APILocator.getIdentifierAPI().find(folder);
result.setHref(ident.getURI());
result.setTitle(folder.getTitle());
result.setOrder(folder.getSortOrder());
result.setType("folder");
result.setPermissionId(folder.getPermissionId());
List<NavResult> children=new ArrayList<NavResult>();
List<String> folderIds=new ArrayList<String>();
result.setChildren(children);
result.setChildrenFolderIds(folderIds);
List menuItems;
if(path.equals("/"))
menuItems = fAPI.findSubFolders(host, true);
else
menuItems = fAPI.findMenuItems(folder, user, true);
for(Object item : menuItems) {
if(item instanceof Folder) {
Folder itemFolder=(Folder)item;
ident=APILocator.getIdentifierAPI().find(itemFolder);
NavResult nav=new NavResult(folder.getInode(),host.getIdentifier(),itemFolder.getInode());
nav.setTitle(itemFolder.getTitle());
nav.setHref(ident.getURI());
nav.setOrder(itemFolder.getSortOrder());
nav.setType("folder");
nav.setPermissionId(itemFolder.getPermissionId());
// it will load lazily its children
folderIds.add(itemFolder.getInode());
children.add(nav);
}
else if(item instanceof HTMLPage) {
final String httpProtocol = "http://";
final String httpsProtocol = "https://";