Package org.apache.jetspeed.page.document

Examples of org.apache.jetspeed.page.document.NodeSet


     * @throws DocumentException
     */
    public NodeSet getFolders(boolean checkAccess) throws FolderNotFoundException, DocumentException
    {
        // get list of all folders
        NodeSet folders = getAllNodes().subset(Folder.FOLDER_TYPE);

        // filter node set by access
        if (checkAccess)
        {
            folders = checkAccess(folders, SecuredResource.VIEW_ACTION);
View Full Code Here


     * @throws NodeException
     */
    public NodeSet getPages(boolean checkAccess) throws NodeException
    {
        // get list of all pages
        NodeSet pages = getAllNodes().subset(Page.DOCUMENT_TYPE);

        // filter node set by access
        if (checkAccess)
        {
            pages = checkAccess(pages, SecuredResource.VIEW_ACTION);
View Full Code Here

     * @throws NodeException
     */
    public NodeSet getLinks(boolean checkAccess) throws NodeException
    {
        // get list of all links
        NodeSet links = getAllNodes().subset(Link.DOCUMENT_TYPE);

        // filter node set by access
        if (checkAccess)
        {
            links = checkAccess(links, SecuredResource.VIEW_ACTION);
View Full Code Here

     * @throws NodeException
     */
    public NodeSet getDocumentSets(boolean checkAccess) throws NodeException
    {
        // get list of all documentSets
        NodeSet documentSets = getAllNodes().subset(DocumentSet.DOCUMENT_TYPE);

        // filter node set by access
        if (checkAccess)
        {
            documentSets = checkAccess(documentSets, SecuredResource.VIEW_ACTION);
View Full Code Here

    public NodeSet getAll() throws FolderNotFoundException, DocumentException
    {
        // return secure set of all nodes: disable access checks on
        // folders to facilitate navigation, but enforce on documents
        // while creating filtered nodes
        NodeSet nodes = getAllNodes();
        NodeSet filteredNodes = null;
        Iterator checkAccessIter = nodes.iterator();
        while (checkAccessIter.hasNext())
        {
            Node node = (Node)checkAccessIter.next();
            try
            {
                ((AbstractNode) node).checkAccess(SecuredResource.VIEW_ACTION);
                if (filteredNodes != null)
                {
                    filteredNodes.add(node);
                }
            }
            catch (SecurityException se)
            {
                if (filteredNodes == null)
                {
                    filteredNodes = new NodeSetImpl(getPath(), ((NodeSetImpl) nodes).getComparator());
                    Iterator copyIter = nodes.iterator();
                    while (copyIter.hasNext())
                    {
                        Node copyNode = (Node)copyIter.next();
                        if (copyNode != node)
                        {
                            filteredNodes.add(copyNode);
                        }
                        else
                        {
                            break;
                        }
View Full Code Here

        String requestPath = locator.getRequestPath();

        // get profiled page context initialization parameters
        Folder folder = null;
        Page page = null;
        NodeSet siblingPages = null;
        Folder parentFolder = null;
        NodeSet siblingFolders = null;
        NodeSet rootLinks = null;
        NodeSet documentSets = null;
        Map documentSetNames = null;
        Map documentSetNodeSets = null;
        if (profilingEnabled)
        {
            // profile page request using profile locator
            Folder [] profiledFolder = new Folder[1];
            Page [] profiledPage = new Page[1];
            List profiledFolders = new ArrayList();
            List searchProfiledFolders = new ArrayList();

            // generate profile locator folder/page search paths
            List searchPaths = generateProfilingSearchPaths(requestPath, locator, false);

            // find page in page manager content using search paths
            boolean profiled = findProfiledPageAndFolders(searchPaths, profiledPage, profiledFolder, profiledFolders, searchProfiledFolders);

            // profile fallback to default root folder to locate folder/page
            boolean rootFallback = false;
            if (rootFallback = (! profiled && ! requestPath.equals(Folder.PATH_SEPARATOR)))
            {
                // profile default root folder, (ignoring request path)
                searchPaths = generateProfilingSearchPaths(Folder.PATH_SEPARATOR, locator, true);
                profiled = findProfiledPageAndFolders(searchPaths, profiledPage, profiledFolder, profiledFolders, searchProfiledFolders);

                // if profiled successfully at root fallback but failed previous
                // attempt, profile request path against available alternate profile
                // locators. This is used only to select a page: all other context
                // information remains determined from fallback.
                if (profiled && (pageContext.getLocators().size() > 1))
                {
                    // profile to locate request path using alternate locators
                    Page [] alternateProfiledPage = new Page[1];
                    Iterator locatorsIter = selectAlternatePageProfileLocators(pageContext.getLocators()).iterator();
                    while ((alternateProfiledPage[0] == null) && locatorsIter.hasNext())
                    {
                        ProfileLocator alternateLocator = (ProfileLocator) locatorsIter.next();
                        List alternateSearchPaths = generateProfilingSearchPaths(requestPath, alternateLocator, false);
                        findProfiledPageAndFolders(alternateSearchPaths, alternateProfiledPage);
                    }

                    // if request path matched, use just profiled page; note: page is
                    // not used to generate page context, (fallback default root folder
                    // is used instead); otherwise continue with root default page match
                    if (alternateProfiledPage[0] != null)
                    {
                        log.debug("computeProfiledPageContext(): Using alternate locator match " + alternateProfiledPage[0] + " for " + requestPath);
                        profiledPage[0] = alternateProfiledPage[0];
                    }
                    else
                    {
                        log.warn("computeProfiledPageContext(): No alternate locator match: falling back to profiled root default page for " + requestPath);
                    }
                }
                else
                {
                    // fallback to root default page
                    log.warn("computeProfiledPageContext(): Falling back to profiled root default page for " + requestPath);
                }
            }

            // profiled folder and page
            if (profiled)
            {
                folder = (Folder) setProfiledNodePathAndUrl((AbstractNode) profiledFolder[0]);
                page = (Page) setProfiledNodePathAndUrl((AbstractNode) profiledPage[0]);
            }

            // profile page context
            if (page != null)
            {
                // profile general document/folder order
                List documentOrder = null;
                Iterator foldersIter = searchProfiledFolders.iterator();
                while ((documentOrder == null) && foldersIter.hasNext())
                {
                    FolderImpl profiledPageFolder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode) foldersIter.next());
                    if ((profiledPageFolder.getMetaData() != null) && (profiledPageFolder.getMetaData().getDocumentOrder() != null) &&
                        ! profiledPageFolder.getMetaData().getDocumentOrder().isEmpty())
                    {
                        documentOrder = profiledPageFolder.getMetaData().getDocumentOrder();
                    }
                }
                Comparator documentComparator = new DocumentOrderComparator(documentOrder);

                // profile sibling pages by aggregating all siblings in profiled folders
                // using profiled general document order, (do not filter unordered siblings);
                // force profiled page to exist as sibling to support pages profiled using
                // alternate locators that may not select page in profiled folder: the
                // profiled page must appear in the sibling pages collection.
                siblingPages = new NodeSetImpl(null, documentComparator);
                siblingPages = addUniqueOrDescribedUrlNode((NodeSetImpl) siblingPages, (AbstractNode) page);
                foldersIter = profiledFolders.iterator();
                while (foldersIter.hasNext())
                {
                    FolderImpl aggregatePagesFolder = (FolderImpl) foldersIter.next();
                    NodeSet aggregatePages = aggregatePagesFolder.getPages(false);
                    Iterator aggregatePagesIter = aggregatePages.iterator();
                    while (aggregatePagesIter.hasNext())
                    {
                        siblingPages = addUniqueOrDescribedUrlNode((NodeSetImpl) siblingPages, setProfiledNodePathAndUrl((AbstractNode) aggregatePagesIter.next()));
                    }
                }

                // profile parent folder using profiled parent
                if ((((AbstractNode)folder).getParent(false) != null) &&
                    !((AbstractNode)folder).getProfiledPath().equals(Folder.PATH_SEPARATOR))
                {
                    parentFolder = (Folder)setProfiledNodePathAndUrl((AbstractNode)((AbstractNode)folder).getParent(false));
                }

                // profile sibling folders by aggregating all siblings in profiled folders
                // using profiled general document order, (do not filter unordered siblings)
                siblingFolders = new NodeSetImpl(null, documentComparator);
                foldersIter = profiledFolders.iterator();
                while (foldersIter.hasNext())
                {
                    FolderImpl aggregateFoldersFolder = (FolderImpl) foldersIter.next();
                    NodeSet aggregateFolders = aggregateFoldersFolder.getFolders(false).exclusiveSubset("^.*/" + PROFILE_PROPERTY_FOLDER_PREFIX + "[^/]*$");
                    Iterator aggregateFoldersIter = aggregateFolders.iterator();
                    while (aggregateFoldersIter.hasNext())
                    {
                        siblingFolders = addUniqueOrDescribedUrlNode((NodeSetImpl) siblingFolders, setProfiledNodePathAndUrl((AbstractNode) aggregateFoldersIter.next()));
                    }
                }

                // profile document sets by aggregating all document set documents by document
                // set name in all profiled folders for page
                Map aggregateDocumentSets = new HashMap(12);
                foldersIter = searchProfiledFolders.iterator();
                while (foldersIter.hasNext())
                {
                    FolderImpl aggregateFolder = (FolderImpl) foldersIter.next();
                    NodeSet aggregateFolderDocumentSets = aggregateFolder.getDocumentSets(false);
                    Iterator aggregateFolderDocumentSetsIter = aggregateFolderDocumentSets.iterator();
                    while (aggregateFolderDocumentSetsIter.hasNext())
                    {
                        DocumentSet documentSet = (DocumentSet) setProfiledNodePathAndUrl((AbstractNode) aggregateFolderDocumentSetsIter.next());
                        String documentSetProfiledPath = ((AbstractNode) documentSet).getProfiledPath();
                        if (! aggregateDocumentSets.containsKey(documentSetProfiledPath))
                        {
                            aggregateDocumentSets.put(documentSetProfiledPath, documentSet);
                        }
                    }
                }
               
                // generate profiled document sets from aggregated document set documents
                if (! aggregateDocumentSets.isEmpty())
                {
                    // profiled document sets to be returned
                    documentSets = new NodeSetImpl(null, documentComparator);
                    documentSetNames = new HashMap(aggregateDocumentSets.size() * 2);
                    documentSetNodeSets = new HashMap(aggregateDocumentSets.size() * 2);
                   
                    // profile each aggregated document set
                    Iterator documentSetsIter = aggregateDocumentSets.values().iterator();
                    while (documentSetsIter.hasNext())
                    {
                        // expand and profile each document set
                        DocumentSet documentSet = (DocumentSet) documentSetsIter.next();
                        NodeSetImpl documentSetNodes = expandAndProfileDocumentSet(pageContext.getLocators(), documentSet, null, "", documentSetNames, documentSetNodeSets);
                        if (documentSetNodes != null)
                        {
                            documentSets.add(documentSet);
                        }
                    }
                }

                // profile root links by aggregating all links in profiled root folders
                if (! rootFallback && ! requestPath.equals(Folder.PATH_SEPARATOR))
                {
                    // profile root folders if required
                    searchPaths = generateProfilingSearchPaths(Folder.PATH_SEPARATOR, locator, true);
                    profiled = findProfiledPageAndFolders(searchPaths, profiledPage, profiledFolder, profiledFolders, searchProfiledFolders);
                }
                if (profiled)
                {
                    // profile root link document order folder meta data
                    List linkDocumentOrder = null;
                    foldersIter = profiledFolders.iterator();
                    while ((linkDocumentOrder == null) && foldersIter.hasNext())
                    {
                        FolderImpl profiledRootFolder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode) foldersIter.next());
                        if (((AbstractNode) profiledRootFolder).getProfiledPath().equals(Folder.PATH_SEPARATOR) &&
                            (profiledRootFolder.getMetaData() != null) && (profiledRootFolder.getMetaData().getDocumentOrder() != null) &&
                            ! profiledRootFolder.getMetaData().getDocumentOrder().isEmpty())
                        {
                            linkDocumentOrder = profiledRootFolder.getMetaData().getDocumentOrder();
                        }
                    }
                    Comparator linkDocumentComparator = new DocumentOrderComparator(linkDocumentOrder);

                    // profile root links using profiled document order
                    rootLinks = new NodeSetImpl(null, linkDocumentComparator);
                    foldersIter = profiledFolders.iterator();
                    while (foldersIter.hasNext())
                    {
                        FolderImpl aggregateLinksFolder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode) foldersIter.next());
                        if (aggregateLinksFolder.getProfiledPath().equals(Folder.PATH_SEPARATOR))
                        {
                            NodeSet aggregateLinks = aggregateLinksFolder.getLinks(false);
                            Iterator aggregateLinksIter = aggregateLinks.iterator();
                            while (aggregateLinksIter.hasNext())
                            {
                                rootLinks = addUniqueOrDescribedUrlNode((NodeSetImpl) rootLinks, setProfiledNodePathAndUrl((AbstractNode) aggregateLinksIter.next()));
                            }
                        }
View Full Code Here

        {
            return set;
        }

        // filter expanded document set for pages, folders, links, and document sets
        NodeSet filteredSet = new NodeSetImpl(null);       
        setIter = set.iterator();
        while (setIter.hasNext())
        {
            AbstractNode node = (AbstractNode) setIter.next();
            if ((node instanceof Page) || (node instanceof Folder) || (node instanceof Link) || (node instanceof DocumentSet))
            {
                filteredSet.add(node);
            }
        }
        return filteredSet;
    }
View Full Code Here

        if (separatorIndex != -1)
        {
            // match folder name
            String folderName = path.substring(0,separatorIndex);
            String folderPath = (folder.getPath().endsWith(Folder.PATH_SEPARATOR) ? folder.getPath() : folder.getPath() + Folder.PATH_SEPARATOR) + folderName;
            NodeSet matchedFolders = null;
            if (regexp)
            {
                // get regexp matched folders
                matchedFolders = ((FolderImpl)folder).getFolders(false).inclusiveSubset(folderPath);
            }
            else
            {
                // get single matched folder
                Folder matchedFolder = getFolder(folderPath);
                if (matchedFolder != null)
                {
                    matchedFolders = new NodeSetImpl(folder.getPath());
                    matchedFolders.add(matchedFolder);
                }
            }
            if ((matchedFolders == null) || (matchedFolders.size() == 0))
            {
                throw new FolderNotFoundException("Cannot find folder" + folderName + " in " + folder.getPath());
            }

            // match recursively over matched folders
            path = path.substring(separatorIndex);
            Iterator matchedFoldersIter = matchedFolders.iterator();
            while (matchedFoldersIter.hasNext())
            {
                Folder matchedFolder = (Folder) matchedFoldersIter.next();
                getNodes(matchedFolder, path, regexp, matched);
            }
View Full Code Here

        loadChildren(folder, parent, locale, -1);
    }
   
    public void loadChildren(Folder folder, TreeControlNode parent, Locale locale, int index)
    {
        NodeSet childFolders = null;
        NodeSet childPages = null;
        NodeSet childLinks = null;
        try
        {
//            int ilevel = ((new Integer(parent.getDomain()).intValue()) + 1);       
//            String level = Integer.toString(ilevel);
            String level = "";
           
            childFolders = folder.getFolders();
            childPages = folder.getPages();
            childLinks = folder.getLinks();

            if (childFolders != null)
            {
                Iterator folderIter = childFolders.iterator();
                while (folderIter.hasNext())
                {
                    Folder childFolder = (Folder) folderIter.next();               
                    TreeControlNode childNode = createFolderNode(childFolder, locale, level);
                    parent.addChild(childNode);
                }
            }
            if (childPages != null)
            {
                Iterator pagesIter = childPages.iterator();
                while (pagesIter.hasNext())
                {
                    Page childPage = (Page) pagesIter.next();               
                    TreeControlNode childNode = createPageNode(childPage, locale, level);
                    if(index == -1)
                    {
                        parent.addChild(childNode);                       
                    }
                    else
                    {
                        parent.addChild(index, childNode);
                    }                                       
                }
            }
            if (childLinks != null)
            {
                Iterator linksIter = childLinks.iterator();
                while (linksIter.hasNext())
                {
                    Link childLink = (Link) linksIter.next();               
                    TreeControlNode childNode = createLinkNode(childLink, locale, level);
                    if(index == -1)
View Full Code Here

     * @throws DocumentException
     */
    public NodeSet getFolders(boolean checkAccess) throws FolderNotFoundException, DocumentException
    {
        // get list of all folders
        NodeSet folders = getAllNodes().subset(FOLDER_TYPE);

        // filter node set by access
        if (checkAccess)
        {
            folders = checkAccess(folders, SecuredResource.VIEW_ACTION);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.page.document.NodeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.