Package org.apache.jetspeed.om.page

Examples of org.apache.jetspeed.om.page.Page


    /* (non-Javadoc)
     * @see org.apache.jetspeed.page.PageManager#newPage(java.lang.String)
     */
    public Page newPage(String path)
    {
        Page page = null;
        try
        {
            // factory create the page and set id/path
            page = (Page)createObject(this.pageClass);           
            if (!path.startsWith(Folder.PATH_SEPARATOR))
            {
                path = Folder.PATH_SEPARATOR + path;
            }
            if (!path.endsWith(Page.DOCUMENT_TYPE))
            {
                path += Page.DOCUMENT_TYPE;
            }
            page.setPath(path);
           
            // create the default fragment
            page.setRootFragment(newFragment());           
        }
        catch (ClassCastException e)
        {
            String message = "Failed to create page object for " + this.pageClass;
            log.error(message, e);
View Full Code Here


     */
    public Page copyPage(Page source, String path, boolean copyIds)
        throws NodeException
    {
        // create the new page and copy attributes
        Page page = newPage(path);
        copyPageAttributes(source, copyIds, page);
        page.setHidden(source.isHidden());
        return page;
    }
View Full Code Here

     * @throws NodeException
     */
    public Page getPage(String name, boolean checkAccess) throws PageNotFoundException, NodeException
    {
        // get page
        Page page = (Page) getAllNodes().subset(Page.DOCUMENT_TYPE).get(name);
        if (page == null)
        {
            throw new PageNotFoundException("Jetspeed PSML page not found: " + name);
        }

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

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

            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
                        // navigation folder found)
                        if ((searchFolder != null) &&
                            (searchFolderName.startsWith(PROFILE_NAVIGATION_PROPERTY_FOLDER_PREFIX) ||
                             !searchFolderName.startsWith(PROFILE_PROPERTY_FOLDER_PREFIX)))
                        {
                            searchFolders.add(searchFolder);
                        }
                    }
                    while (!searchFolderName.equals(Folder.PATH_SEPARATOR) &&
                           !searchFolderName.startsWith(PROFILE_PROPERTY_FOLDER_PREFIX) &&
                           !searchFolderName.startsWith(PROFILE_NAVIGATION_PROPERTY_FOLDER_PREFIX));
                }
            }
        }

        // if no page or folder found, attempt aggressive default
        // page defaulting if only one search path found and no explict
        // page requested: page selected cannot be ambiguous and using
        // any non root folder default is valid and better than a root
        // fallback default page.
        if ((page[0] == null) && (numSearchFoldersFound == 1) && ! lastSearchFolderFound.getPath().equals( Folder.PATH_SEPARATOR ) &&
            (! lastSearchFolderFoundPath.endsWith(Page.DOCUMENT_TYPE)))
        {
            // single search folder found: allow aggressive defaulting
            String defaultPagePath = lastSearchFolderFound.getDefaultPage(true);

            // use single search folder default page if found
            Page lastSearchFolderFoundPage = null;
            try
            {
                lastSearchFolderFoundPage = ((FolderImpl)lastSearchFolderFound).getPage(defaultPagePath, false);
            }
            catch (NodeException ne)
View Full Code Here

        // get page profile locator from session/principal profile locators
        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)
View Full Code Here

        {
            Filter filter = persistenceStore.newFilter();
            filter.addEqualTo("id", id);
            Object q = persistenceStore.newQuery(pageClass, filter);
            persistenceStore.getTransaction().begin();
            Page page = (Page) persistenceStore.getObjectByQuery(q);
            if (page == null)
            {
                throw new PageNotFoundException("Jetspeed PSML page not found: " + id);
            }
View Full Code Here

       
        else if(currentPage != null)
        {
            try
            {
                Page page = pageManager.getPage(currentPage);
                request.setAttribute("page", page);
            } catch (PageNotFoundException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
View Full Code Here

     *
     * @return Unique Portlet Entity ID
     */
    public void build( RequestContext context ) throws JetspeedException, IOException
    {
        Page page = context.getPage();
        if (null == page)
        {
            throw new JetspeedException("Failed to find PSML Pin PageAggregator.build");
        }

        Fragment root = page.getRootFragment();

        if (root == null)
        {
            throw new JetspeedException("No root Fragment found in Page");
        }

        String layoutDecorator = root.getDecorator();
        if (layoutDecorator == null)
        {
            layoutDecorator = page.getDefaultDecorator(root.getType());
        }

        String defaultPortletDecorator = page.getDefaultDecorator(Fragment.PORTLET);

        ///////////////////////////////////////////////////////////////////////////////////////////////
        //TODO: Remove hard coding of locations and use CM + TL
        //      DST: Im going to encapsulate this into a class, which can be accessed
        // by
View Full Code Here

                        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

TOP

Related Classes of org.apache.jetspeed.om.page.Page

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.