Gets the folders tree structure beginning from the root folder.

@return the root folder
329793
private CMFolder loadFoldersStructure()
    {
        CMFolder rootFolder = new CMFolder( getRootId(), "root" );

        HttpPost request = buildSoapRequest( "getFolderXML", "<folder id='" + rootFolder.getId() + "'/>" );
        CResponse response = retryStrategy.invokeRetry( getApiRequestInvoker( request, null ) );
        Element rootElement = findRootFolderElement( response.asDom() );

        scanFolderLevel( rootElement, rootFolder );

        return rootFolder;
    }
1287758
public Node nextNode() {

		if (currentNode == null)
			return null;

		Node result = getFirstChild(currentNode);

		if (result != null) {
			currentNode = result;
			return result;
		}

		result = getNextSibling(currentNode);

		if (result != null) {
			currentNode = result;
			return result;
		}

		// return parent's 1st sibling.
		Node parent = getParentNode(currentNode);
		while (parent != null) {
			result = getNextSibling(parent);
			if (result != null) {
				currentNode = result;
				return result;
			} else {
				parent = getParentNode(parent);
			}
		}

		// end , return null
		return null;
	}
1253804
public function getRootDirectory()
    {
        if(isset($this->rootDirectory) == false) {
            $this->rootDirectory = $this->locateRootDirectory();
        }
        return $this->rootDirectory;
    }
974065
public String getBasePath() {
        StringBuilder sb = new StringBuilder(getBaseDirUnchecked().getAbsolutePath());
        if (!getBaseDirUnchecked().exists()) {
            sb.append(" (non-existent!)");
        } else if (!getBaseDirUnchecked().isDirectory()) {
            sb.append(" (no directory!)");
        } else {
            sb.append(" (Free: ").append(NLS.formatSize(getBaseDir().getFreeSpace())).append(")");
        }

        return sb.toString();
    }
424828
public SmiOidNode getRootNode() {
        SmiOidNode parent = this;
        while (parent.getParent() != null) {
            parent = parent.getParent();
        }
        return parent;
    }
514142
@Nonnull
  public ExpressionTreeElement getRoot() {
    if (last.isEmptySlot()) {
      return this.last;
    } else {
      ExpressionTreeElement element = last;
      while (!Thread.currentThread().isInterrupted()) {
        final ExpressionTreeElement next = element.getParent();
        if (next == null) {
          return element;
        } else {
          element = next;
        }
      }
    }
    return ExpressionTreeElement.EMPTY_SLOT;
  }
674027
@SuppressWarnings( "unchecked" )
    public <V> Key<V> getRoot() {
        if ( this.getParent() == null ) {
            return (Key<V>) this;
        } else {
            return this.getParent().getRoot();
        }
    }
1213025
protected function getRootDirectory()
    {
        if ($this->addon) {
            $directories = $this->addon->config('addon.directories');

            if (! $directories) {
                $directories = ['classes'];
            }

            return $this->addon->path($directories[0]);
        }
        else {
            return parent::getRootDirectory();
        }
    }
135490
public String getPath() {

        StringBuffer path = new StringBuffer("/");
        CmsTreeItem current = this;
        while (current != null) {
            path.insert(0, current.getId()).insert(0, "/");
            current = current.getParentItem();
        }
        String result = path.toString();
        if (result.startsWith("//")) {
            // This happens if the root item has an empty id.
            // In that case, we cut off the first slash.
            result = result.substring(1);
        }
        return result;
    }
1022561
private String getParentFolder() {

        String relativeTo;
        if (isDirectPublish()) {
            relativeTo = CmsResource.getParentFolder(getResourceList().get(0));
        } else {
            relativeTo = getCms().getRequestContext().getSiteRoot() + "/";
        }
        return relativeTo;
    }
196435
public String getParentXPath() {
        Iterator<Level> levelIterator = path.descendingIterator();
        if (levelIterator.hasNext()) {
            levelIterator.next();
        }
        return getXPath(levelIterator);
    }
1322275
public CPath getCPath()
    {
        if ( parent == null ) {
            return CPath.ROOT;
        }

        CMFolder currentFolder = this;
        StringBuilder path = new StringBuilder(  );

        while ( currentFolder.parent != null ) {
            path.insert( 0, currentFolder.name );
            path.insert( 0, '/' );

            currentFolder = currentFolder.parent;
        }

        return new CPath( path.toString() );
    }
154880
public @CheckForNull FilePath getWorkspaceRoot() {
        FilePath r = getRootPath();
        if(r==null) return null;
        return r.child(WORKSPACE_ROOT);
    }
461607
protected DefaultMutableTreeNode getDataAsTree() {
        try {
            return (DefaultMutableTreeNode) MethodUtils.invokeMethod(view, "getDataAsTree", null);
        } catch (Exception e) {
            return null;
        }
    }
781038
protected CmsObject getRootCmsObject() {

        if (m_rootCms == null) {

            m_rootCms = getOfflineCmsObject(A_CmsUI.getCmsObject());
            m_rootCms.getRequestContext().setSiteRoot("");

        }
        return m_rootCms;
    }
1254968
public String getTree() {

        StringBuffer result = new StringBuffer(2048);

        List<String> targetFolderList = new ArrayList<String>();
        if (getTargetFolder() != null) {
            // check if there is more than one folder to update (e.g. move operation)
            StringTokenizer T = new StringTokenizer(getTargetFolder(), "|");
            while (T.hasMoreTokens()) {
                String currentFolder = T.nextToken().trim();
                //                if (OpenCms.getSiteManager().startsWithShared(currentFolder)) {
                //                    currentFolder = OpenCms.getSiteManager().cutShared(currentFolder);
                //                }
                targetFolderList.add(currentFolder);
            }
        } else {
            targetFolderList.add(null);
        }

        String storedSiteRoot = null;
        try {
            CmsFolder folder = null;
            List<CmsResource> resources = new ArrayList<CmsResource>();
            String oldSiteRoot = getCms().getRequestContext().getSiteRoot();

            Iterator<String> targets = targetFolderList.iterator();
            while (targets.hasNext()) {
                // iterate over all given target folders
                String currentTargetFolder = targets.next();

                if (getSettings().getTreeSite(getTreeType()) != null) {
                    // change the site root for popup window with site selector
                    storedSiteRoot = getCms().getRequestContext().getSiteRoot();
                    if (newTree() && (currentTargetFolder == null)) {
                        currentTargetFolder = "/";
                    }
                    getCms().getRequestContext().setSiteRoot(getSettings().getTreeSite(getTreeType()));
                    try {
                        // check presence of target folder
                        getCms().readFolder(currentTargetFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
                    } catch (CmsException e) {
                        // target folder not found, set it to "/"
                        if (LOG.isInfoEnabled()) {
                            LOG.info(e);
                        }
                        currentTargetFolder = "/";
                    }
                }

                // read the selected folder
                try {
                    folder = getCms().readFolder(currentTargetFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
                } catch (CmsException e) {
                    // return with error
                    return printError(e);
                }

                String startFolder = getStartFolder();
                String rcSite = getCms().getRequestContext().getSiteRoot();
                if (OpenCms.getSiteManager().startsWithShared(currentTargetFolder)
                    && OpenCms.getSiteManager().startsWithShared(rcSite)) {
                    currentTargetFolder = currentTargetFolder.substring(
                        OpenCms.getSiteManager().getSharedFolder().length() - 1);
                }
                if ((startFolder == null) || (!currentTargetFolder.startsWith(startFolder))) {
                    // no (valid) start folder given, just load current folder
                    try {
                        if (includeFiles()) {
                            resources.addAll(getCms().getResourcesInFolder(
                                currentTargetFolder,
                                CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                        } else {
                            resources.addAll(
                                getCms().getSubFolders(currentTargetFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                        }
                    } catch (CmsException e) {
                        // return with error
                        return printError(e);
                    }
                } else {
                    // valid start folder given, load all folders between start and current folder
                    try {
                        if (includeFiles()) {
                            resources.addAll(
                                getCms().getResourcesInFolder(startFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                        } else {
                            resources.addAll(
                                getCms().getSubFolders(startFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                        }
                        StringTokenizer tok = new StringTokenizer(
                            currentTargetFolder.substring(startFolder.length()),
                            "/");
                        while (tok.hasMoreTokens()) {
                            startFolder += tok.nextToken() + "/";
                            if (includeFiles()) {
                                resources.addAll(getCms().getResourcesInFolder(
                                    startFolder,
                                    CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                            } else {
                                resources.addAll(
                                    getCms().getSubFolders(startFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED));
                            }
                        }
                    } catch (CmsException e) {
                        // return with error
                        return printError(e);
                    }
                }
            }

            result.append("function init() {\n");

            if (newTree()) {
                // new tree must be reloaded
                result.append("parent.initTree();\n");
                result.append(getRootNode());
            }

            // read the list of project resource to select which resource is "inside" or "outside"
            List<String> projectResources = new ArrayList<String>();
            if (isProjectAware()) {
                try {
                    projectResources = getCms().readProjectResources(getCms().getRequestContext().getCurrentProject());
                } catch (CmsException e) {
                    // use an empty list (all resources are "outside")
                    if (LOG.isInfoEnabled()) {
                        LOG.info(e);
                    }
                }
            }

            // now output all the tree nodes
            Iterator<CmsResource> i = resources.iterator();
            while (i.hasNext()) {
                CmsResource resource = i.next();
                boolean grey = false;
                if (isProjectAware()) {
                    grey = !CmsProject.isInsideProject(projectResources, resource);
                }
                if (!grey) {
                    try {
                        OpenCms.getResourceManager().getResourceType(resource.getTypeId());
                    } catch (CmsLoaderException e) {
                        // if resource type is not found
                        grey = true;
                    }
                }

                result.append(
                    getNode(
                        resource.getRootPath(),
                        resource.getName(),
                        resource.getTypeId(),
                        resource.isFolder(),
                        resource.getState(),
                        grey));
            }

            if (includeFiles()) {
                result.append("parent.setIncludeFiles(true);\n");
            }
            result.append("parent.setProjectAware(").append(isProjectAware()).append(");\n");
            if (getTreeType() != null) {
                // this is a popup window tree
                result.append("parent.setTreeType(\"");
                result.append(getTreeType());
                result.append("\");\n");
                String curSite = getSettings().getTreeSite(getTreeType());
                if (curSite != null) {
                    // add the current site as prefix if present
                    result.append("parent.setSitePrefix(\"");
                    result.append(getSitePrefix(curSite, oldSiteRoot));
                    result.append("\");\n");
                }
            }
            // set the root folder in javascript
            result.append("parent.setRootFolder(\"");
            result.append(getRootFolder());
            result.append("\");\n");

            if (folder != null) {
                if (newTree()) {
                    // new tree
                    result.append("parent.showTree(parent.tree_display.document, \"");
                    result.append(folder.getRootPath().hashCode());
                    result.append("\");\n");
                } else {
                    // update the current tree with the children of the selected node
                    if (resources.size() == 0) {
                        // the node had no children
                        result.append("parent.setNoChilds(\"");
                        result.append(folder.getRootPath().hashCode());
                        result.append("\");\n");
                    }
                    result.append("parent.showLoadedNodes(parent.tree_display.document,\"");
                    result.append(folder.getRootPath().hashCode());
                    result.append("\");\n");
                }
            }

            result.append("}\n");
        } finally {
            if (storedSiteRoot != null) {
                getCms().getRequestContext().setSiteRoot(storedSiteRoot);
            }
        }
        return result.toString();
    }
950987
public SortedSet<Entry> getChildEntries() throws IOException {
        if (children == null) {
            if (isFile() || rootNodeDId == -1) {
                children = NO_CHILDREN;
            }
            else {
                // Start at root node in R/B tree, and read to the left and right,
                // re-build tree, according to the docs
                children = Collections.unmodifiableSortedSet(document.getEntries(rootNodeDId, this));
            }
        }

        return children;
    }