A folder is a tab if its parent element is the layout element

@param ulm User Layout Manager
@param folderId the folder in question
@return <code>true</code> if the folder is a tab, otherwise <code>false</code>
503283
protected boolean isTab(IUserLayoutManager ulm, String folderId) throws PortalException {
        // we could be a bit more careful here and actually check the type
        return ulm.getRootFolderId().equals(ulm.getParentId(folderId));
    }
159466
void readTreeLevel(CmsUUID parentId, String openPathFragment) {

        CmsObject cms = A_CmsUI.getCmsObject();
        boolean openedFragment = false;
        try {
            CmsResource parent = cms.readResource(parentId, CmsResourceFilter.IGNORE_EXPIRATION);
            String folderPath = cms.getSitePath(parent);
            List<CmsResource> folderResources = cms.readResources(folderPath, FOLDERS, false);

            // sets the parent to leaf mode, in case no child folders are present
            m_treeContainer.setChildrenAllowed(parentId, !folderResources.isEmpty());

            for (CmsResource resource : folderResources) {
                addTreeItem(cms, resource, parentId, false, m_treeContainer);
                openedFragment = openedFragment || resource.getName().equals(openPathFragment);
            }
            if (!openedFragment && (openPathFragment != null)) {
                CmsResource resource = cms.readResource(
                    CmsStringUtil.joinPaths(folderPath, openPathFragment),
                    CmsResourceFilter.IGNORE_EXPIRATION);
                addTreeItem(cms, resource, parentId, true, m_treeContainer);
            }

            m_fileTree.markAsDirtyRecursive();
        } catch (CmsException e) {
            CmsErrorDialog.showErrorDialog(e);
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
74286
private boolean isValidOpenPath(CmsObject cms, String openPath) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(openPath)) {
            return false;
        }
        if (!cms.existsResource(openPath)) {
            // in case of a detail-page check the parent folder
            String parent = CmsResource.getParentFolder(openPath);
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(parent) || !cms.existsResource(parent)) {
                return false;
            }
        }
        return true;
    }
463099
protected boolean checkParentDirs(String path, boolean create_if_absent) throws IOException {
        String[] components=Util.components(path, File.separator);
        if(components == null)
            return false;
        if(components.length == 1) // no parent directories to create, e.g. "data.txt"
            return true;

        StringBuilder sb=new StringBuilder();
        boolean first=true;

        for(int i=0; i < components.length-1; i++) {
            String tmp=components[i];
            if(!tmp.equals(File.separator)) {
                if(first)
                    first=false;
                else
                    sb.append(File.separator);
            }
            sb.append(tmp);
            String comp=sb.toString();
            if(exists(comp)) {
                if(isFile(comp))
                    throw new IOException("cannot create " + path + " as component " + comp + " is a file");
            }
            else {
                if(create_if_absent)
                    cache.put(comp, new Metadata(0, System.currentTimeMillis(), chunk_size, Metadata.DIR), (short)-1, 0);
                else
                    return false;
            }
        }
        return true;
    }
389732
private boolean folderExists(CmsObject cms, String folder) {

        try {
            CmsFolder test = cms.readFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION);
            if (test.isFile()) {
                return false;
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }
211046
public static boolean createFolder(String folderPath) {
        if (!StringUtils.isEmpty(folderPath)) {
            File folder = new File(folderPath);
            return createFolder(folder);
        }
        return false;
    }
1330156
private void fragmentizeLayout(UserView view, FragmentDefinition fragment) {
        // if fragment not bound to user or layout empty due to error, return
        if (view.getUserId() == -1 || view.getLayout() == null) {
            return;
        }

        // Choose what types of content to apply from the fragment
        Pattern contentPattern = STANDARD_PATTERN; // default
        boolean allowExpandedContent =
                Boolean.parseBoolean(
                        PropertiesManager.getProperty(PROPERTY_ALLOW_EXPANDED_CONTENT));
        if (allowExpandedContent) {
            contentPattern = EXPANDED_PATTERN;
        }

        // remove all non-regular or hidden top level folders
        // skip root folder that is only child of top level layout element
        Element layout = view.getLayout().getDocumentElement();
        Element root = (Element) layout.getFirstChild();
        NodeList children = root.getChildNodes();

        // process the children backwards since as we delete some the indices
        // shift around
        for (int i = children.getLength() - 1; i >= 0; i--) {
            Node node = children.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("folder")) {
                Element folder = (Element) node;

                // strip out folder types 'header', 'footer' and regular,
                // hidden folder "User Preferences" since users have their own
                boolean isApplicable =
                        contentPattern.matcher(folder.getAttribute("type")).matches();
                if (!isApplicable || folder.getAttribute("hidden").equals("true")) {
                    try {
                        root.removeChild(folder);
                    } catch (Exception e) {
                        throw new RuntimeException(
                                "Anomaly occurred while stripping out "
                                        + " portions of layout for fragment '"
                                        + fragment.getName()
                                        + "'. The fragment will not be available for "
                                        + "inclusion into user layouts.",
                                e);
                    }
                }
            }
        }
        // now re-lable all remaining nodes below root to have a safe system
        // wide id.

        setIdsAndAttribs(
                layout,
                layout.getAttribute(Constants.ATT_ID),
                "" + fragment.getId(),
                "" + fragment.getPrecedence());
    }
1320575
private void addFoldersToSearchIn(final List<String> folders) {

        if (null == folders) {
            return;
        }

        for (String folder : folders) {
            if (!CmsResource.isFolder(folder)) {
                folder += "/";
            }

            m_foldersToSearchIn.add(folder);
        }
    }
62998
public static boolean checkIsPathOrLinkToSvg(String path) {

        if (path == null) {
            return false;
        }
        path = path.trim().toLowerCase();
        int paramPos = path.indexOf("?");
        if (paramPos >= 0) {
            path = path.substring(0, paramPos);
        }
        return path.endsWith(".svg");
    }
785152
private static String checkFolder(String directory) {
        File dir = new File(directory);
        if (dir.isFile()) {
            directory = dir.getParent();
        }
        createFolder(directory);
        return directory;
    }
835363
private static boolean isNotReparentable(
            NodeInfo ni, Element compViewParent, Element positionSet) {

        // This one is easy -- can't re-parent a node with dlm:moveAllowed=false
        if (ni.getNode().getAttribute(Constants.ATT_MOVE_ALLOWED).equals("false")) {
            return true;
        }

        try {
            /*
             *  Annoying to do in Java, but we need to find our own placeholder
             *  element in the positionSet
             */
            final XPathFactory xpathFactory = XPathFactory.newInstance();
            final XPath xpath = xpathFactory.newXPath();
            final String findPlaceholderXpath =
                    ".//*[local-name()='position' and @name='" + ni.getId() + "']";
            final XPathExpression findPlaceholder = xpath.compile(findPlaceholderXpath);
            final NodeList findPlaceholderList =
                    (NodeList) findPlaceholder.evaluate(positionSet, XPathConstants.NODESET);
            switch (findPlaceholderList.getLength()) {
                case 0:
                    LOG.warn(
                            "Node not found for XPathExpression=\""
                                    + findPlaceholderXpath
                                    + "\" in positionSet="
                                    + XmlUtilitiesImpl.toString(positionSet));
                    return true;
                case 1:
                    // This is healthy
                    break;
                default:
                    LOG.warn(
                            "More than one node found for XPathExpression=\""
                                    + findPlaceholderXpath
                                    + "\" in positionSet="
                                    + XmlUtilitiesImpl.toString(positionSet));
                    return true;
            }
            final Element placeholder = (Element) findPlaceholderList.item(0); // At last

            for (Element nextPlaceholder =
                            (Element)
                                    placeholder
                                            .getNextSibling(); // Start with the next dlm:position
                    // element after placeholder
                    nextPlaceholder != null; // As long as we have a placeholder to look at
                    nextPlaceholder =
                            (Element)
                                    nextPlaceholder
                                            .getNextSibling()) { // Advance to the next placeholder

                if (LOG.isDebugEnabled()) {
                    LOG.debug(
                            "Considering whether node ''"
                                    + ni.getId()
                                    + "' is Reparentable;  subsequent sibling is:  "
                                    + nextPlaceholder.getAttribute("name"));
                }

                /*
                 * Next task:  we have to find the non-placeholder representation of
                 * the nextSiblingPlaceholder within the compViewParent
                 */
                final String unmaskPlaceholderXpath =
                        ".//*[@ID='" + nextPlaceholder.getAttribute("name") + "']";
                final XPathExpression unmaskPlaceholder = xpath.compile(unmaskPlaceholderXpath);
                final NodeList unmaskPlaceholderList =
                        (NodeList)
                                unmaskPlaceholder.evaluate(compViewParent, XPathConstants.NODESET);
                switch (unmaskPlaceholderList.getLength()) {
                    case 0:
                        // Not a problem;  the nextSiblingPlaceholder also refers
                        // to a node that has been moved to this context (afaik)
                        continue;
                    case 1:
                        final Element nextSibling = (Element) unmaskPlaceholderList.item(0);
                        if (LOG.isDebugEnabled()) {
                            LOG.debug(
                                    "Considering whether node ''"
                                            + ni.getId()
                                            + "' is Reparentable;  subsequent sibling '"
                                            + nextSibling.getAttribute("ID")
                                            + "' has dlm:moveAllowed="
                                            + !nextSibling
                                                    .getAttribute(Constants.ATT_MOVE_ALLOWED)
                                                    .equals("false"));
                        }

                        // Need to perform some checks...
                        if (nextSibling.getAttribute(Constants.ATT_MOVE_ALLOWED).equals("false")) {

                            /*
                             *  The following check is a bit strange;  it seems to verify
                             *  that the current NodeInfo and the nextSibling come from the
                             *  same fragment.  If they don't, the re-parenting is allowable.
                             *  I believe this check could only be unsatisfied in the case
                             *  of tabs.
                             */
                            Precedence p =
                                    Precedence.newInstance(
                                            nextSibling.getAttribute(Constants.ATT_FRAGMENT));
                            if (ni.getPrecedence().isEqualTo(p)) {
                                return true;
                            }
                        }
                        break;
                    default:
                        LOG.warn(
                                "More than one node found for XPathExpression=\""
                                        + unmaskPlaceholderXpath
                                        + "\" in compViewParent");
                        return true;
                }
            }
        } catch (XPathExpressionException xpe) {
            throw new RuntimeException("Failed to evaluate XPATH", xpe);
        }

        return false; // Re-parenting is "not disallowed" (double-negative less readable)
    }
611322
private function activateFolderById($id, FolderInterface $folder)
    {
        foreach ($folder->getChildren() as $child) {
            if ($child->getId() == $id) {
                $child->setActive(true);
                return true;
            }
            if ($this->activateFolderById($id, $child)) {
                return true;
            }
        }
        return false;
    }
534819
public void setSubfolder(String subfolder) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(subfolder)) {
            m_subfolder = Boolean.valueOf(subfolder).booleanValue();
        }
    }
179444
public boolean isSelectedPartially(TreePath path) {
        CheckedNode cn = nodesCheckingState.get(path);
        return cn.isSelected && cn.hasChildren && !cn.allChildrenSelected;
    }
120619
public static boolean foundFunctionInAnyGroupHeader(ReportLayout layout) {
		List<Band> groupHeaderBands = layout.getGroupHeaderBands();
		for (Band band : groupHeaderBands) {
			boolean found = foundFunctionInBand(band);
			if (found) {
				return true;
			}
		}
		return false;
	}
23463
private boolean isViewTopAligned(ViewGroup.MarginLayoutParams layoutParams) {
		final int top = getView().getTop();
		boolean viewTopAligned = top == 0 || top == layoutParams.topMargin;
		LOGGER.trace("View is {} aligned", viewTopAligned ? "TOP" : "BOTTOM");
		return viewTopAligned;
	}
770960
public void onSelectFolder(String folder, boolean selected) {

        if (selected) {
            m_controller.addFolder(folder);
        } else {
            m_controller.removeFolder(folder);
        }
    }