Package org.apache.jetspeed.portalsite.view

Examples of org.apache.jetspeed.portalsite.view.SiteView


     * @return menu definition locator
     */
    public SiteViewMenuDefinitionLocator getMenuDefinitionLocator(Node node, String name)
    {
        // return named menu definition locator for node in site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getMenuDefinitionLocator(node, name);
        }
        return null;
    }
View Full Code Here


     * @return managed page
     */
    public Page getManagedPage(Page page)
    {
        // return managed page in site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getManagedPage(page);           
        }
        return null;
    }
View Full Code Here

    {
        // save access exceptions
        SecurityException accessException = null;

        // valid SiteView required from session profile locators
        SiteView view = getSiteView();
        if (view != null)
        {
            // default request to root folder if not specified
            if (requestPath == null)
            {
                requestPath = Folder.PATH_SEPARATOR;
            }
           
            // log page request
            if (log.isDebugEnabled())
            {
                log.debug("Request page: request path=" + requestPath);
            }

            // lookup request path in view for viewable page or folder
            // nodes; note: directly requested pages/folders may be hidden
            // or not viewable
            Node requestNode = null;
            try
            {
                // try page or folder request url
                requestNode = view.getNodeProxy(requestPath, null, false, false);
            }
            catch (NodeNotFoundException nnfe)
            {
                // if request path ends with default page, strip from
                // request url to retry for folder default
                if (requestPath.endsWith(Folder.PATH_SEPARATOR + Folder.FALLBACK_DEFAULT_PAGE))
                {
                    // retry folder request url
                    requestPath = requestPath.substring(0, requestPath.length() - Folder.FALLBACK_DEFAULT_PAGE.length());
                    requestNode = view.getNodeProxy(requestPath, null, true, false);
                }
                else
                {
                    // rethrow original exception
                    throw nnfe;
                }
            }
           
            // 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 (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())
                {
                    // attempt to lookup last visited page by folder proxy
                    // path, (proxies are hashed by their path), contains
                    // test must be performed since identical paths may
                    // occur in multiple site views
                    Page requestPage = (Page)folderPageHistory.get(requestFolder);
                    if ((requestPage != null) && requestFolderPages.contains(requestPage))
                    {
                        // log selected request page
                        if (log.isDebugEnabled())
                        {
                            log.debug("Selected folder historical page: path=" + view.getManagedPage(requestPage).getPath());
                        }
                        return requestPage;
                    }
                   
                    // get default page for folder proxy 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 proxy
                            // path, (proxies are hashed by their path), and
                            // return default page
                            requestPage = requestFolder.getPage(defaultPageName);
                            if (!requestPage.isHidden())
                            {
                                folderPageHistory.put(requestFolder, requestPage);
                            }
                           
                            // log selected request page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected folder default page: path=" + view.getManagedPage(requestPage).getPath());
                            }
                            return requestPage;
                        }
                        catch (NodeException ne)
                        {
                        }
                        catch (SecurityException se)
                        {
                            accessException = se;
                        }
                    }
                   
                    // default page not available, select first page
                    // proxy in request folder; save last visited
                    // non-hidden page for folder proxy path, (proxies
                    // are hashed by their path), and return default page
                    requestPage = (Page)requestFolderPages.iterator().next();
                    if (!requestPage.isHidden())
                    {
                        folderPageHistory.put(requestFolder, requestPage);
                    }

                    // 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 proxy
                // path, (proxies are hashed by their path), and
                // return matched page
                Folder requestFolder = (Folder)requestPage.getParent();
                if (!requestPage.isHidden())
                {
                    folderPageHistory.put(requestFolder, requestPage);
                }

                // log selected request page
                if (log.isDebugEnabled())
                {
                    log.debug("Selected page, path=" + view.getManagedPage(requestPage).getPath());
                }
                return requestPage;
            }
        }
           
View Full Code Here

    {
        // validate and update session profile locators if modified
        if (updateSessionProfileLocators(requestProfileLocators))
        {
            // valid site view required from session profile locators
            SiteView view = getSiteView();
            if (view != null)
            {
                // return root folder proxy from session site view
                return view.getRootFolderProxy();
            }
        }

        // no root folder available
        throw new NodeNotFoundException("No root folder available in site view.");
View Full Code Here

    public SiteView getSiteView()
    {
        if ((siteView == null) && (pageManager != null) && (profileLocators != null))
        {
            // create new site view
            siteView = new SiteView(pageManager, profileLocators);

            // log site view creation
            if (log.isDebugEnabled())
            {
                log.debug("Created site view: search paths=" + siteView.getSearchPathsString());
View Full Code Here

     * @return menu names set
     */
    public Set getStandardMenuNames()
    {
        // return standard menu names defined for site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getStandardMenuNames();
        }
        return null;
    }
View Full Code Here

     * @return definition locator list
     */
    public List getMenuDefinitionLocators(Node node)
    {
        // return menu definition locators for node in site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getMenuDefinitionLocators(node);
        }
        return null;
    }
View Full Code Here

     * @return menu definition locator
     */
    public SiteViewMenuDefinitionLocator getMenuDefinitionLocator(Node node, String name)
    {
        // return named menu definition locator for node in site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getMenuDefinitionLocator(node, name);
        }
        return null;
    }
View Full Code Here

     * @return managed page
     */
    public Page getManagedPage(Page page)
    {
        // return managed page in site view
        SiteView view = getSiteView();
        if (view != null)
        {
            return view.getManagedPage(page);           
        }
        return null;
    }
View Full Code Here

    {
        // save access exceptions
        SecurityException accessException = null;

        // valid SiteView required from session profile locators
        SiteView view = getSiteView();
        if (view != null)
        {
            // default request to root folder if not specified
            if (requestPath == null)
            {
                requestPath = Folder.PATH_SEPARATOR;
            }
           
            // log page request
            if (log.isDebugEnabled())
            {
                log.debug("Request page: request path=" + requestPath);
            }

            // lookup request path in view for viewable page or folder
            // nodes; note: directly requested pages/folders may be hidden
            // or not viewable
            Node requestNode = null;
            try
            {
                // try page or folder request url
                requestNode = view.getNodeProxy(requestPath, null, false, false);
            }
            catch (NodeNotFoundException nnfe)
            {
                // if request path ends with default page, strip from
                // request url to retry for folder default
                if (requestPath.endsWith(Folder.PATH_SEPARATOR + Folder.FALLBACK_DEFAULT_PAGE))
                {
                    // retry folder request url
                    requestPath = requestPath.substring(0, requestPath.length() - Folder.FALLBACK_DEFAULT_PAGE.length());
                    requestNode = view.getNodeProxy(requestPath, null, true, false);
                }
                else
                {
                    // rethrow original exception
                    throw nnfe;
                }
            }
           
            // 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 proxy
                    // path, (proxies are hashed by their path), contains
                    // test must be performed since identical paths may
                    // occur in multiple site views
                    if (useHistory)
                    {
                        requestPage = (Page)getFolderPageHistory().get(requestFolder);
                        if ((requestPage != null) && requestFolderPages.contains(requestPage))
                        {
                            // log selected request page
                            if (log.isDebugEnabled())
                            {
                                log.debug("Selected folder historical page: path=" + view.getManagedPage(requestPage).getPath());
                            }
                            return requestPage;
                        }
                    }
                   
                    // get default page for folder proxy 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 proxy
                            // path, (proxies are hashed by their path), and
                            // return default page
                            requestPage = requestFolder.getPage(defaultPageName);
                            if (!requestPage.isHidden())
                            {
                                getFolderPageHistory().put(requestFolder, requestPage);
                            }
                           
                            // 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
                    // proxy in request folder; save last visited
                    // non-hidden page for folder proxy path, (proxies
                    // are hashed by their path), and return default page
                    requestPage = (Page)requestFolderPages.iterator().next();
                    if (!requestPage.isHidden())
                    {
                        getFolderPageHistory().put(requestFolder, requestPage);
                    }

                    // 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 proxy
                // path, (proxies are hashed by their path), and
                // return matched page
                Folder requestFolder = (Folder)requestPage.getParent();
                if (!requestPage.isHidden())
                {
                  getFolderPageHistory().put(requestFolder, requestPage);
                }

                // log selected request page
                if (log.isDebugEnabled())
                {
                    log.debug("Selected page, path=" + view.getManagedPage(requestPage).getPath());
                }
                return requestPage;
            }
        }
           
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.portalsite.view.SiteView

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.