Package org.apache.jetspeed.om.folder

Examples of org.apache.jetspeed.om.folder.Folder


            searchFolders.clear();
        }

        // iterate through search paths looking for page in page manager content
        int numSearchFoldersFound = 0;
        Folder lastSearchFolderFound = null;
        String lastSearchFolderFoundPath = null;
        Iterator pathsIter = pageSearchPaths.iterator();
        while (pathsIter.hasNext())
        {
            String searchRequestPath = (String) pathsIter.next();
           
            log.debug("findProfiledPageAndFolders(), searchPath = " + searchRequestPath);
           
            // search for matching folder and/or page in search path
            String folderPath = searchRequestPath;
            Folder searchFolder = null;
            Page searchPage = null;
            try
            {
                // match folder
                if (folderPath.endsWith(Page.DOCUMENT_TYPE) || folderPath.endsWith(Folder.PATH_SEPARATOR))
                {
                    int lastSlashIndex = folderPath.lastIndexOf(Folder.PATH_SEPARATOR_CHAR);
                    if (lastSlashIndex > 0)
                    {
                        folderPath = folderPath.substring(0, lastSlashIndex);
                    }
                    else
                    {
                        folderPath = Folder.PATH_SEPARATOR;
                    }
                }
                searchFolder = folderHandler.getFolder(folderPath);

                // match page if not previously matched
                if (page[0] == null)
                {
                    String pagePath = searchRequestPath;
                    if (! pagePath.endsWith(Page.DOCUMENT_TYPE))
                    {
                        // only allow aggressive default page defaulting if
                        // trying to find page as last resort in root directory;
                        // otherwise, return only fallback page or explicitly
                        // specified default page name
                        boolean allowDefaulting = folderPath.equals( Folder.PATH_SEPARATOR );
                        pagePath = searchFolder.getDefaultPage(allowDefaulting);
                       
                        // if page path not fallback default page, profile again
                        // to make sure the default page is not overridden, note
                        // that the fallback page has already been profiled since
                        // it would have been matched previously and that no
                        // override is possible in first maching folder.
                        if ((pagePath != null) && ! pagePath.equals(FolderImpl.FALLBACK_DEFAULT_PAGE) && (numSearchFoldersFound > 0))
                        {
                            // append default page to search paths
                            ListIterator pageSearchPathsIter = pageSearchPaths.listIterator();
                            while (pageSearchPathsIter.hasNext())
                            {
                                String pageSearchPath = (String) pageSearchPathsIter.next();
                                if (pageSearchPath.endsWith( Folder.PATH_SEPARATOR ))
                                {
                                    pageSearchPathsIter.set(pageSearchPath + pagePath);
                                }
                                else
                                {
                                    pageSearchPathsIter.set(pageSearchPath + Folder.PATH_SEPARATOR + pagePath);
                                }
                            }

                            // profile default page
                            log.debug("findProfiledPageAndFolders(): invoking again with default page: " + pagePath);
                            return findProfiledPageAndFolders(pageSearchPaths, page, folder, folders, searchFolders);
                        }
                    }

                    // access matched page
                    if (pagePath != null)
                    {
                        searchPage = ((FolderImpl)searchFolder).getPage(pagePath, false);
                    }
                }

                // track found search folders
                numSearchFoldersFound++;
                lastSearchFolderFound = searchFolder;
                lastSearchFolderFoundPath = searchRequestPath;
            }
            catch (NodeException ne)
            {
            }
            if (searchFolder != null)
            {
                log.debug("findProfiledPageAndFolders(), matched searchFolder = " + searchFolder);
            }
            if (searchPage != null)
            {
                log.debug("findProfiledPageAndFolders(), matched searchPage = " + searchPage);
            }
           
            // return matching page and related folders
            if ((page[0] == null) && (searchPage != null))
            {
                // matched profiled folder/page
                page[0] = searchPage;
                if (folder != null)
                {
                    folder[0] = searchFolder;
                }
               
                log.debug("findProfiledPageAndFolders(), using matched searchFolder = " + searchFolder);
                log.debug("findProfiledPageAndFolders(), using matched searchPage = " + searchPage);
            }

            // return profiled folders and search profiled folders; the search
            // profiled folders are used to find other profiled documents, (i.e
            // document sets).
            if ((folders != null) && (searchFolders != null))
            {
                if (searchFolder != null)
                {
                    // profiled folder
                    folders.add(searchFolder);
                   
                    // search parent profiled folders, (excluding profile property folders
                    // and including only first profile navigation folder found)
                    if (!searchFolder.getName().startsWith(PROFILE_NAVIGATION_PROPERTY_FOLDER_PREFIX))
                    {
                        do
                        {
                            searchFolders.add(searchFolder);
                            searchFolder = (Folder) ((AbstractNode)searchFolder).getParent(false);
                        }
                        while ((searchFolder != null) &&
                               !searchFolder.getName().startsWith(PROFILE_PROPERTY_FOLDER_PREFIX) &&
                               !searchFolder.getName().startsWith(PROFILE_NAVIGATION_PROPERTY_FOLDER_PREFIX));
                    }
                    if ((searchFolder != null) && searchFolder.getName().startsWith(PROFILE_NAVIGATION_PROPERTY_FOLDER_PREFIX))
                    {
                        searchFolders.add(searchFolder);
                    }
                }
                else
                {
                    // add parents of missing profiled folders to search profiled
                    // folders if they exist
                    String searchFolderName = null;
                    do
                    {
                        // find parent path or folder
                        if (searchFolder == null)
                        {
                            // get parent folder path
                            int separatorIndex = folderPath.lastIndexOf(Folder.PATH_SEPARATOR);
                            if (separatorIndex > 0)
                            {
                                folderPath = folderPath.substring(0, separatorIndex);
                            }
                            else
                            {
                                folderPath = Folder.PATH_SEPARATOR;
                            }
                           
                            // get folder if it exists and folder name
                            try
                            {
                                searchFolder = folderHandler.getFolder(folderPath);
                                searchFolderName = searchFolder.getName();
                            }
                            catch (NodeException ne)
                            {
                                separatorIndex = folderPath.lastIndexOf(Folder.PATH_SEPARATOR);
                                if (separatorIndex > 0)
                                {
                                    searchFolderName = folderPath.substring(separatorIndex+1);
                                }
                                else
                                {
                                    searchFolderName = Folder.PATH_SEPARATOR;
                                }
                            }
                        }
                        else
                        {
                            // get folder as parent of search folder
                            searchFolder = (Folder) ((AbstractNode)searchFolder).getParent(false);
                            if (searchFolder != null)
                            {
                                searchFolderName = searchFolder.getName();
                            }
                        }
                       
                        // add to search profiled folders if it exists, (excluding
                        // profile property folders and including only first profile
View Full Code Here


     * @throws DocumentException
     */
    public Folder getFolder(String name, boolean checkAccess) throws FolderNotFoundException, DocumentException
    {
        // get folder
        Folder folder = (Folder) getAllNodes().subset(Folder.FOLDER_TYPE).get(name);
        if (folder == null)
        {
            throw new FolderNotFoundException("Jetspeed PSML folder not found: " + name);
        }

        // check access
        if (checkAccess)
        {
            folder.checkAccess(SecuredResource.VIEW_ACTION);
        }
        return folder;
    }
View Full Code Here

        ProfileLocator locator = selectPageProfileLocator(pageContext.getLocators());

        // 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;
View Full Code Here

       
        if(currentFolder != null)
        {
            try
            {
                Folder folder = pageManager.getFolder(currentFolder);
                request.setAttribute("folder", folder);
            } catch (FolderNotFoundException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
View Full Code Here

            }
           
            // invoke default page logic to determine folder page
            if (requestNode instanceof Folder)
            {
                Folder requestFolder = (Folder)requestNode;
               
                // support subfolders specified as default pages;
                // find highest subfolder with a default page that
                // specifies a default folder, (not a default page).
                try
                {
                    String defaultFolderName = requestFolder.getDefaultPage();
                    if (defaultFolderName != null)
                    {
                        // do not follow broken default folders
                        Folder defaultRequestFolder = requestFolder;
                        // follow default folders to parent folders
                        while ((defaultRequestFolder != null) && (defaultFolderName != null) &&
                               defaultFolderName.equals(".."))
                        {
                            defaultRequestFolder = (Folder)defaultRequestFolder.getParent();
                            if (defaultRequestFolder != null)
                            {
                                defaultFolderName = defaultRequestFolder.getDefaultPage();
                            }
                            else
                            {
                                defaultFolderName = null;
                            }
                        }
                        // follow default folders to subfolders
                        while ((defaultRequestFolder != null) && (defaultFolderName != null) &&
                               !defaultFolderName.endsWith(Page.DOCUMENT_TYPE) && !defaultFolderName.equals(".."))
                        {
                            defaultRequestFolder = defaultRequestFolder.getFolder(defaultFolderName);
                            defaultFolderName = defaultRequestFolder.getDefaultPage();
                        }
                        // use default request folder
                        if (defaultRequestFolder != null)
                        {
                            requestFolder = defaultRequestFolder;
                        }
                    }
                }
                catch (NodeException ne)
                {
                }
                catch (NodeNotFoundException nnfe)
                {
                }
                catch (SecurityException se)
                {
                    requestFolder = null;
                    accessException = se;
                }

                // only request folders with pages can be
                // selected by request; otherwise, fall back to
                // parent folders assuming that immediate parents
                // will have the most appropriate default page
                NodeSet requestFolderPages = null;
                if (requestFolder != null)
                {
                    try
                    {
                        requestFolderPages = requestFolder.getPages();
                        while (((requestFolderPages == null) || requestFolderPages.isEmpty()) && (requestFolder.getParent() != null))
                        {
                            requestFolder = (Folder)requestFolder.getParent();
                            requestFolderPages = requestFolder.getPages();
                        }
                    }
                    catch (NodeException ne)
                    {
                        requestFolderPages = null;
                    }
                    catch (SecurityException se)
                    {
                        requestFolderPages = null;
                        accessException = se;
                    }
                }
                if ((requestFolder != null) && (requestFolderPages != null) && !requestFolderPages.isEmpty())
                {
                    Page requestPage = null;

                    // attempt to lookup last visited page by folder path;
                    // page id test must be performed since identical paths
                    // may occur in multiple site views
                    if (useHistory)
                    {
                        String requestPageId = (String)getFolderPageHistory().get(requestFolder.getPath());
                        if (requestPageId != null)
                        {
                            // find page by id in request folder pages
                            Iterator requestFolderPagesIter = requestFolderPages.iterator();
                            while ((requestPage == null) && (requestFolderPagesIter.hasNext()))
                            {
                                Page requestFolderPage = (Page)requestFolderPagesIter.next();
                                if (requestPageId.equals(requestFolderPage.getId()))
                                {
                                    requestPage = requestFolderPage;
                                }
                            }
                           
                            // log selected request page
                            if (requestPage != null)
                            {
                                if (log.isDebugEnabled())
                                {
                                    log.debug("Selected folder historical page: path=" + view.getManagedPage(requestPage).getPath());
                                }
                                return requestPage;
                            }
                        }
                    }
                   
                    // get default page for folder view if more than one
                    // page is available to choose from
                    if (requestFolderPages.size() > 1)
                    {
                        String defaultPageName = requestFolder.getDefaultPage();
                        if (defaultPageName == null)
                        {
                            // use fallback default if default page
                            // not explicitly specified
                            defaultPageName = Folder.FALLBACK_DEFAULT_PAGE;
                        }
                        try
                        {
                            // save last visited non-hidden page for folder path
                            // and return default page
                            requestPage = requestFolder.getPage(defaultPageName);
                            if (!requestPage.isHidden())
                            {
                                getFolderPageHistory().put(requestFolder.getPath(), requestPage.getId());
                            }
                           
                            // log selected request page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected folder default page: path=" + view.getManagedPage(requestPage).getPath());
                            }
                            return requestPage;
                        }
                        catch (NodeException ne)
                        {
                        }
                        catch (NodeNotFoundException nnfe)
                        {
                        }
                        catch (SecurityException se)
                        {
                            accessException = se;
                        }
                    }
                   
                    // default page not available, select first page
                    // view in request folder; save last visited
                    // non-hidden page for folder path and return default page
                    requestPage = (Page)requestFolderPages.iterator().next();
                    if (!requestPage.isHidden())
                    {
                        getFolderPageHistory().put(requestFolder.getPath(), requestPage.getId());
                    }

                    // log selected request page
                    if (log.isDebugEnabled())
                    {
                        log.debug("Selected first folder page, path=" + view.getManagedPage(requestPage).getPath());
                    }
                    return requestPage;
                }
            }
            else if (requestNode instanceof Page)
            {
                Page requestPage = (Page)requestNode;
               
                // save last visited non-hidden page for folder path
                // and return matched page
                Folder requestFolder = (Folder)requestPage.getParent();
                if (!requestPage.isHidden())
                {
                  getFolderPageHistory().put(requestFolder.getPath(), requestPage.getId());
                }

                // log selected request page
                if (log.isDebugEnabled())
                {
View Full Code Here

                log.debug("Request content page: request path=" + requestPath);
            }
           
            // search for deepest matching content request path
            // that matches request path; start with root folder in view
            Folder contentRequestFolder = (Folder)view.getNodeView(Folder.PATH_SEPARATOR, null, null, true, false, false);
            String contentRequestPath = contentRequestFolder.getPath();
            for (;;)
            {
                // find next path name
                int startOfPathNameIndex = (contentRequestPath.equals(Folder.PATH_SEPARATOR) ? 1 : contentRequestPath.length()+1);
                int endOfPathNameIndex = requestPath.indexOf(Folder.PATH_SEPARATOR, startOfPathNameIndex);
                if ((endOfPathNameIndex == -1) || (endOfPathNameIndex == startOfPathNameIndex))
                {
                    break;
                }
                // find folder in view
                try
                {
                    String pathFolderName = requestPath.substring(startOfPathNameIndex, endOfPathNameIndex);
                    contentRequestFolder = contentRequestFolder.getFolder(pathFolderName);
                    contentRequestPath = contentRequestFolder.getPath();
                }
                catch (Exception e)
                {
                    break;
                }
            }
           
            // determine if content request folder matches request
            // folder assuming request path may include a content
            // document name, but no deeper folders
            boolean matchingContentRequestFolder = true;
            if (contentRequestPath.length() < requestPath.length())
            {
                String requestPathTail = requestPath.substring(contentRequestPath.length());
                matchingContentRequestFolder = (requestPathTail.indexOf(Folder.PATH_SEPARATOR_CHAR, (requestPathTail.startsWith(Folder.PATH_SEPARATOR) ? 1 : 0)) == -1);
            }
           
            // select matching dynamic pages in folders from deepest
            // to root folders in content request path
            while (contentRequestFolder != null)
            {
                // select dynamic page by content type or wildcard match
                try
                {
                    NodeSet dynamicPages = contentRequestFolder.getDynamicPages();
                    if ((dynamicPages != null) && !dynamicPages.isEmpty())
                    {
                        // select matching page
                        DynamicPage matchingPage = null;
                        DynamicPage inheritableMatchingPage = null;
                        DynamicPage wildcardMatchingPage = null;
                        Iterator dynamicPagesIter = dynamicPages.iterator();
                        while (dynamicPagesIter.hasNext())
                        {
                            DynamicPage dynamicPage = (DynamicPage)dynamicPagesIter.next();
                            if ((dynamicPage.getContentType() == null) || dynamicPage.getContentType().equals(DynamicPage.WILDCARD_CONTENT_TYPE))
                            {
                                wildcardMatchingPage = dynamicPage;
                            }
                            else if (dynamicPage.getContentType().equals(contentType))
                            {
                                boolean inheritableDynamicPage = dynamicPage.isInheritable();
                                if (matchingContentRequestFolder && !inheritableDynamicPage)
                                {
                                    matchingPage = dynamicPage;
                                }
                                else if (inheritableDynamicPage)
                                {
                                    inheritableMatchingPage = dynamicPage;
                                }
                            }
                        }
                        // select matching page
                        if (matchingPage != null)
                        {
                            // log selected dynamic page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected "+contentType+" content dynamic page, path=" + view.getManagedDynamicPage(matchingPage).getPath());
                            }
                            return matchingPage;
                        }
                        // select inheritable matching page
                        if (inheritableMatchingPage != null)
                        {
                            // log selected dynamic page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected "+contentType+" inheritable content dynamic page, path=" + view.getManagedDynamicPage(inheritableMatchingPage).getPath());
                            }
                            return inheritableMatchingPage;
                        }
                        // select wildcard matching page
                        if (wildcardMatchingPage != null)
                        {
                            // log selected dynamic page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected "+contentType+" wildcard content dynamic page, path=" + view.getManagedDynamicPage(wildcardMatchingPage).getPath());
                            }
                            return wildcardMatchingPage;
                        }
                    }
                }
                catch (NodeException ne)
                {
                    break;
                }
                catch (SecurityException se)
                {
                    accessException = se;
                }

                // continue search with parent folder
                contentRequestFolder = (Folder)contentRequestFolder.getParent();
                matchingContentRequestFolder = false;
            }
        }
           
        // no dynamic page matched or accessible
View Full Code Here

        // search for folder by name or absolute path from
        // aggregated folders
        NodeSet allFolders = getFolders(proxy);
        if (allFolders != null)
        {
            Folder folder = (Folder)allFolders.get(name);
            if (folder != null)
            {
                return folder;
            }
        }
View Full Code Here

            Iterator foldersIter = getSearchFolders().iterator();
            while (foldersIter.hasNext())
            {
                // test access against child in search folder
                SearchFolder searchFolder = (SearchFolder)foldersIter.next();
                Folder folder = searchFolder.folder;
                // ignore all folder access exceptions, (throws SecurityException on failed check access)
                try
                {
                    folder.getFolder(folderName);
                }
                catch (DocumentException de)
                {                   
                }
                catch (FolderNotFoundException fnfe)
View Full Code Here

            Iterator foldersIter = getSearchFolders().iterator();
            while (foldersIter.hasNext())
            {
                // test access against child in search folder
                SearchFolder searchFolder = (SearchFolder)foldersIter.next();
                Folder folder = searchFolder.folder;
                // ignore all folder access exceptions, (throws SecurityException on failed check access)
                try
                {
                    folder.getFolder(nodeName);
                }
                catch (DocumentException de)
                {                   
                }
                catch (FolderNotFoundException fnfe)
                {
                }
                // ignore all page access exceptions, (throws SecurityException on failed check access)
                try
                {
                    folder.getPage(nodeName);
                }
                catch (NodeException ne)
                {                   
                }
                catch (PageNotFoundException ne)
                {                   
                }
                // ignore all link access exceptions, (throws SecurityException on failed check access)
                try
                {
                    folder.getLink(nodeName);
                }
                catch (NodeException ne)
                {                   
                }
                catch (DocumentNotFoundException ne)
View Full Code Here

            while (inheritanceFoldersIter.hasNext())
            {
                // get menu definitions from inheritance folders and
                // merge into aggregate menu definition locators
                InheritanceFolder inheritanceFolder = (InheritanceFolder)inheritanceFoldersIter.next();
                Folder folder = inheritanceFolder.folder;
                String path = inheritanceFolder.path;
                mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, path, false);
            }
        }
        catch (FolderNotFoundException fnfe)
        {
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.folder.Folder

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.