Package org.apache.jetspeed.page.document

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


        if (!StringUtils.isEmpty(getSubSiteRoot()))
        {
            try
            {
                Folder subsiteFolder = pageManager.getFolder(getSubSiteRoot());
                NodeSet set = pageManager.getFolders(subsiteFolder);
                if (set != null && !set.isEmpty())
                {
                    Iterator setIterator = set.iterator();
                    while (setIterator.hasNext())
                    {
                        Folder f = (Folder) setIterator.next();
                        subsites.add(f.getTitle());
                    }
View Full Code Here


    private void updateFolderNodes(FolderImpl folderImpl) throws FolderNotUpdatedException
    {
        try
        {
            // update folder documents
            NodeSet nodes = folderImpl.getAllNodes();
            Iterator nodesIter = nodes.iterator();
            while (nodesIter.hasNext())
            {
                Node node = (Node) nodesIter.next();
                if (node instanceof Page)
                {
                    updatePage((Page)node);
                }
                else if (node instanceof PageTemplate)
                {
                    updatePageTemplate((PageTemplate)node);
                }
                else if (node instanceof DynamicPage)
                {
                    updateDynamicPage((DynamicPage)node);
                }
                else if (node instanceof FragmentDefinition)
                {
                    updateFragmentDefinition((FragmentDefinition)node);
                }
                else if (node instanceof Link)
                {
                    updateLink((Link)node);
                }
                else if (node instanceof PageSecurity)
                {
                    updatePageSecurity((PageSecurity)node);
                }
            }

            // update folders last: breadth first recursion
            nodesIter = nodes.iterator();
            while (nodesIter.hasNext())
            {
                Node node = (Node) nodesIter.next();
                if (node instanceof Folder)
                {
View Full Code Here

     * @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;
        List allProfiledFolders = null;
        if (profilingEnabled)
        {
            // profile page request using profile locator
            Folder [] profiledFolder = new Folder[1];
            Page [] profiledPage = new Page[1];
            List profiledFolders = new ArrayList(16);
            List searchProfiledFolders = new ArrayList(24);

            // 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 and folder found
            if ((page != null) && (folder != null))
            {
                // add profiled folders to all profiled folders list
                allProfiledFolders = new ArrayList(24);
                Iterator foldersIter = profiledFolders.iterator();
                while (foldersIter.hasNext())
                {
                    FolderImpl profiledPageFolder = (FolderImpl) foldersIter.next();
                    if (!profiledPageFolder.isHidden())
                    {
                        allProfiledFolders.add(setProfiledNodePathAndUrl(profiledPageFolder));
                    }
                }

                // profile general document/folder order
                List documentOrder = null;
                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())
                    {
                        AbstractNode siblingPageNode = (AbstractNode)aggregatePagesIter.next();
                        if (!siblingPageNode.isHidden())
                        {
                            siblingPages = addUniqueOrDescribedUrlNode((NodeSetImpl)siblingPages, setProfiledNodePathAndUrl(siblingPageNode));
                        }
                    }
                }

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

                // 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_NAVIGATION_PROPERTY_FOLDER_PREFIX + "[^/]*$").exclusiveSubset("^.*/" + PROFILE_PROPERTY_FOLDER_PREFIX + "[^/]*$");
                    Iterator aggregateFoldersIter = aggregateFolders.iterator();
                    while (aggregateFoldersIter.hasNext())
                    {
                        AbstractNode siblingFolderNode = (AbstractNode)aggregateFoldersIter.next();
                        if (!siblingFolderNode.isHidden())
                        {
                            siblingFolders = addUniqueOrDescribedUrlNode((NodeSetImpl)siblingFolders, setProfiledNodePathAndUrl(siblingFolderNode));
                            allProfiledFolders.add(siblingFolderNode);
                        }
                    }
                }

                // 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())
                    {
                        AbstractNode documentSetNode = (AbstractNode)setProfiledNodePathAndUrl((AbstractNode)aggregateFolderDocumentSetsIter.next());
                        if (!documentSetNode.isHidden())
                        {
                            String documentSetProfiledPath = documentSetNode.getProfiledPath();
                            if (!aggregateDocumentSets.containsKey(documentSetProfiledPath))
                            {
                                aggregateDocumentSets.put(documentSetProfiledPath, documentSetNode);
                            }
                        }
                    }
                }
               
                // 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, allProfiledFolders);
                        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())
                            {
                                AbstractNode rootLinkNode = (AbstractNode)aggregateLinksIter.next();
                                if (!rootLinkNode.isHidden())
                                {
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

        // profiling not implemented, return raw managed page context;
        // document sets not supported
        Page page = getPage(locator.getValue("page"));
        Folder folder = (Folder) page.getParent();
        NodeSet siblingPages = folder.getPages();
        Folder parentFolder = (Folder) folder.getParent();
        NodeSet siblingFolders = folder.getFolders();
        Folder rootFolder = folder;
        while (rootFolder.getParent() != null)
            rootFolder = (Folder) rootFolder.getParent();
        NodeSet rootLinks = rootFolder.getLinks();
        NodeSet documentSets = null;
        Map documentSetNames = null;
        Map documentSetNodeSets = null;
        List allProfiledFolders = null;

        // populate profiled page context instance and return
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.