docs: 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();
      }