Package org.apache.jetspeed.page

Examples of org.apache.jetspeed.page.PageNotFoundException


        {
            throw pnfe;
        }
        catch (Exception e)
        {
            throw new PageNotFoundException("Page " + pagePath + " not found.", e);
        }
    }
View Full Code Here


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

                }
            }
            else
            {
                log.error("computeProfiledPageContext(): Failed to find profiled page for " + requestPath + " at " + locator);
                throw new PageNotFoundException(requestPath + " at " + locator);
            }
        }
        else
        {
            // return request folder and page

            // managed folder and page
            try
            {
                // retrieve managed folder and page from request
                String folderPath = requestPath;
                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;
                    }
                }
                folder = folderHandler.getFolder(folderPath);
                String pagePath = requestPath;
                if (! pagePath.endsWith(Page.DOCUMENT_TYPE))
                {
                    pagePath = folder.getDefaultPage(true);
                }
                page = ((FolderImpl)folder).getPage(pagePath, false);
            }
            catch (NodeException ne)
            {
            }
            if (page == null)
            {
                // fallback to default page for root folder
                log.warn("computeProfiledPageContext(): Falling back to managed root default page for " + requestPath);
                try
                {
                    folder = folderHandler.getFolder(Folder.PATH_SEPARATOR);
                    String pagePath = folder.getDefaultPage(true);
                    page = ((FolderImpl)folder).getPage(pagePath, false);
                }
                catch (NodeException ne)
                {
                }
            }

            // managed page context
            if (page != null)
            {
                // return folders and pages relative to requested page
                siblingPages = ((FolderImpl)folder).getPages(false);
                parentFolder = (Folder) ((AbstractNode)folder).getParent(false);
                siblingFolders = ((FolderImpl)folder).getFolders(false);
                try
                {
                    Folder rootFolder = folderHandler.getFolder(Folder.PATH_SEPARATOR);
                    rootLinks = ((FolderImpl)rootFolder).getLinks(false);
                }
                catch (NodeException ne)
                {
                }
                try
                {
                    // get default document set order from folder
                    Comparator documentComparator = ((NodeSetImpl)((FolderImpl)folder).getAllNodes()).getComparator();

                    // aggregate and expand document sets from page to root folder;
                    documentSets = new NodeSetImpl(null, documentComparator);
                    documentSetNames = new HashMap(8);
                    documentSetNodeSets = new HashMap(8);
                    Set uniqueDocumentSetPaths = new HashSet(8);
                    FolderImpl aggregateFolder = (FolderImpl)folder;
                    do
                    {
                        // aggregate uniquely named and expand folder document sets
                        Iterator documentSetsIter = aggregateFolder.getDocumentSets(false).iterator();
                        while (documentSetsIter.hasNext())
                        {
                            DocumentSet documentSet = (DocumentSet) documentSetsIter.next();
                            String documentSetPath = documentSet.getPath();

                            // aggregate document sets
                            if (! uniqueDocumentSetPaths.contains(documentSetPath))
                            {
                                uniqueDocumentSetPaths.add(documentSetPath);

                                // expand document set using default document set order
                                NodeSetImpl documentSetNodes = new NodeSetImpl(null, documentComparator);
                                documentSetNodes = expandDocumentSet(documentSet, documentSetNodes, "", documentSetNames, documentSetNodeSets);
                                if (documentSetNodes != null)
                                {
                                    documentSets.add(documentSet);
                                }
                            }
                        }

                        // aggregate document sets in parent
                        aggregateFolder = (FolderImpl) ((AbstractNode)aggregateFolder).getParent(false);
                    }
                    while (aggregateFolder != null);
                }
                catch (NodeException ne)
                {
                }
            }
            else
            {
                log.error("computeProfiledPageContext(): Failed to find managed page for " + requestPath);
                throw new PageNotFoundException(requestPath);
            }
        }

        // cache profiled page context result
        cachedPageContext = new CacheablePageContext(page, folder, siblingPages, parentFolder, siblingFolders, rootLinks, documentSets, documentSetNames, documentSetNodeSets);
View Full Code Here

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

            Page page = (Page) getPersistenceBrokerTemplate().getObjectByQuery(query);
           
            // return page or throw exception
            if (page == null)
            {
                throw new PageNotFoundException("Page " + path + " not found.");
            }

            // check for view access on page
            page.checkAccess(SecuredResource.VIEW_ACTION);

            return page;
        }
        catch (PageNotFoundException pnfe)
        {
            throw pnfe;
        }
        catch (SecurityException se)
        {
            throw se;
        }
        catch (Exception e)
        {
            throw new PageNotFoundException("Page " + path + " not found.", e);
        }
    }
View Full Code Here

    {
        // select page by name
        Page page = (Page)getPagesNodeSet().get(name);
        if (page == null)
        {
            throw new PageNotFoundException("Page not found: " + name);
        }

        // check for view access on page
        page.checkAccess(SecuredResource.VIEW_ACTION);
View Full Code Here

            if (page != null)
            {
                return page;
            }
        }
        throw new PageNotFoundException("Page " + name + " not found at " + getPath());
    }
View Full Code Here

            f = new File(this.documentRootDir, path + extension);
        }

        if (!f.exists())
        {
            throw new PageNotFoundException("Document not found: " + path);
        }

        try
        {
            // unmarshal: use SAX I parser to read document XML, filtering
            // for page and folder menu definition menu elements ordered
            // polymorphic collection to insert artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            XMLReader reader = parser.getXMLReader();
            final XMLReaderAdapter readerAdapter = new XMLReaderAdapter(reader);
            final InputSource readerInput = new InputSource(new InputStreamReader(new FileInputStream(f), PSML_DOCUMENT_ENCODING));
            Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
            document = (Document) unmarshaller.unmarshal(new EventProducer()
                {
                    public void setDocumentHandler(final DocumentHandler handler)
                    {
                        readerAdapter.setDocumentHandler(new DocumentHandler()
                            {
                                private int menuDepth = 0;

                                public void characters(char[] ch, int start, int length) throws SAXException
                                {
                                    handler.characters(ch, start, length);
                                }

                                public void endDocument() throws SAXException
                                {
                                    handler.endDocument();
                                }

                                public void endElement(String name) throws SAXException
                                {
                                    // always include all elements
                                    handler.endElement(name);

                                    // track menu depth and insert menu-element nodes
                                    // to encapsulate menu elements to support collection
                                    // polymorphism in Castor
                                    if (name.equals("menu"))
                                    {
                                        menuDepth--;
                                        if (menuDepth > 0)
                                        {
                                            handler.endElement("menu-element");
                                        }
                                    }
                                    else if ((menuDepth > 0) &&
                                             (name.equals("options") || name.equals("separator") ||
                                              name.equals("include") || name.equals("exclude")))
                                    {
                                        handler.endElement("menu-element");
                                    }
                                }

                                public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                                {
                                    handler.ignorableWhitespace(ch, start, length);
                                }

                                public void processingInstruction(String target, String data) throws SAXException
                                {
                                    handler.processingInstruction(target, data);
                                }

                                public void setDocumentLocator(Locator locator)
                                {
                                    handler.setDocumentLocator(locator);
                                }

                                public void startDocument() throws SAXException
                                {
                                    handler.startDocument();
                                }

                                public void startElement(String name, AttributeList atts) throws SAXException
                                {
                                    // track menu depth and insert menu-element nodes
                                    // to encapsulate menu elements to support collection
                                    // polymorphism in Castor
                                    if (name.equals("menu"))
                                    {
                                        if (menuDepth > 0)
                                        {
                                            handler.startElement("menu-element", null);
                                        }
                                        menuDepth++;
                                    }
                                    else if ((menuDepth > 0) &&
                                             (name.equals("options") || name.equals("separator") ||
                                              name.equals("include") || name.equals("exclude")))
                                    {
                                        handler.startElement("menu-element", null);
                                    }

                                    // always include all elements
                                    handler.startElement(name, atts);
                                }
                            });
                    }
                    public void start() throws SAXException
                    {
                        try
                        {
                            readerAdapter.parse(readerInput);
                        }
                        catch (IOException ioe)
                        {
                            throw new SAXException(ioe);
                        }
                    }
                });

            document.setPath(path);
            AbstractBaseElement documentImpl = (AbstractBaseElement)document;
            documentImpl.setHandlerFactory(handlerFactory);
            documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
            documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
            documentImpl.unmarshalled();
        }
        catch (IOException e)
        {
            throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
        }
        catch (MarshalException e)
        {
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
        }
        catch (MappingException e)
        {
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
        }
        catch (ValidationException e)
        {
            throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is not valid", e);
        }
        catch (SAXException e)
            {
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
            }
        catch (ParserConfigurationException e)
            {
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
            }
       

        if (document == null)
        {
View Full Code Here

            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);
            }

            pageCache.put(id, page);
            return page;
        }
View Full Code Here

                }
            }
            else
            {
                log.error("computeProfiledPageContext(): Failed to find profiled page and/or folder for " + requestPath + " at " + locator);
                throw new PageNotFoundException(requestPath + " at " + locator);
            }
        }
        else
        {
            // return request folder and page

            // managed folder and page
            try
            {
                // retrieve managed folder and page from request
                String folderPath = requestPath;
                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;
                    }
                }
                folder = folderHandler.getFolder(folderPath);
                String pagePath = requestPath;
                if (! pagePath.endsWith(Page.DOCUMENT_TYPE))
                {
                    pagePath = folder.getDefaultPage(true);
                }
                page = ((FolderImpl)folder).getPage(pagePath, false);
            }
            catch (NodeException ne)
            {
            }
            if (page == null)
            {
                // fallback to default page for root folder
                log.warn("computeProfiledPageContext(): Falling back to managed root default page for " + requestPath);
                try
                {
                    folder = folderHandler.getFolder(Folder.PATH_SEPARATOR);
                    String pagePath = folder.getDefaultPage(true);
                    page = ((FolderImpl)folder).getPage(pagePath, false);
                }
                catch (NodeException ne)
                {
                }
            }

            // managed page context
            if (page != null)
            {
                // return folders and pages relative to requested page
                siblingPages = ((FolderImpl)folder).getPages(false);
                parentFolder = (Folder) ((AbstractNode)folder).getParent(false);
                siblingFolders = ((FolderImpl)folder).getFolders(false);
                try
                {
                    Folder rootFolder = folderHandler.getFolder(Folder.PATH_SEPARATOR);
                    rootLinks = ((FolderImpl)rootFolder).getLinks(false);
                }
                catch (NodeException ne)
                {
                }
                try
                {
                    // get default document set order from folder
                    Comparator documentComparator = ((NodeSetImpl)((FolderImpl)folder).getAllNodes()).getComparator();

                    // aggregate and expand document sets from page to root folder;
                    documentSets = new NodeSetImpl(null, documentComparator);
                    documentSetNames = new HashMap(8);
                    documentSetNodeSets = new HashMap(8);
                    Set uniqueDocumentSetPaths = new HashSet(8);
                    FolderImpl aggregateFolder = (FolderImpl)folder;
                    do
                    {
                        // aggregate uniquely named and expand folder document sets
                        Iterator documentSetsIter = aggregateFolder.getDocumentSets(false).iterator();
                        while (documentSetsIter.hasNext())
                        {
                            DocumentSet documentSet = (DocumentSet) documentSetsIter.next();
                            String documentSetPath = documentSet.getPath();

                            // aggregate document sets
                            if (! uniqueDocumentSetPaths.contains(documentSetPath))
                            {
                                uniqueDocumentSetPaths.add(documentSetPath);

                                // expand document set using default document set order
                                NodeSetImpl documentSetNodes = new NodeSetImpl(null, documentComparator);
                                documentSetNodes = expandDocumentSet(documentSet, documentSetNodes, "", documentSetNames, documentSetNodeSets);
                                if (documentSetNodes != null)
                                {
                                    documentSets.add(documentSet);
                                }
                            }
                        }

                        // aggregate document sets in parent
                        aggregateFolder = (FolderImpl) ((AbstractNode)aggregateFolder).getParent(false);
                    }
                    while (aggregateFolder != null);
                }
                catch (NodeException ne)
                {
                }
            }
            else
            {
                log.error("computeProfiledPageContext(): Failed to find managed page for " + requestPath);
                throw new PageNotFoundException(requestPath);
            }
        }

        // cache profiled page context result
        cachedPageContext = new CacheablePageContext(page, folder, siblingPages, parentFolder, siblingFolders, rootLinks, documentSets, documentSetNames, documentSetNodeSets, allProfiledFolders);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.page.PageNotFoundException

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.