Examples of PageNotFoundException


Examples of org.apache.jetspeed.page.PageNotFoundException

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

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

        try
        {
            // unmarshal: use SAX II 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
           
            final InputSource readerInput = new InputSource(new InputStreamReader(new FileInputStream(f), PSML_DOCUMENT_ENCODING));
            Unmarshaller unmarshaller = new Unmarshaller();
            unmarshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);           
            unmarshaller.setValidation(false); // results in better performance
           
            synchronized (xmlReader)
            {
                document = (Document) unmarshaller.unmarshal(new SAX2EventProducer()
                    {
                        public void setContentHandler(final ContentHandler handler)
                        {
                          xmlReader.setContentHandler(new ContentHandler()
                                {
                                    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 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 endElement(String uri, String localName, String qName) throws SAXException {
                                        // always include all elements
                                        handler.endElement(uri,localName,qName);
                                        // track menu depth and insert menu-element nodes
                                        // to encapsulate menu elements to support collection
                                        // polymorphism in Castor
                                        if (qName.equals("menu"))
                                        {
                                            menuDepth--;
                                            if (menuDepth > 0)
                                            {
                                                handler.endElement(null,null,"menu-element");
                                            }
                                        }
                                        else if ((menuDepth > 0) &&
                                                 (qName.equals("options") || qName.equals("separator") ||
                                                     qName.equals("include") || qName.equals("exclude")))
                                        {
                                            handler.endElement(null,null,"menu-element");
                                        }
                    }

                    public void endPrefixMapping(String prefix) throws SAXException {
                    }

                    public void skippedEntity(String name) throws SAXException {
                      handler.skippedEntity(name);
                    }

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

                                        // always include all elements
                                        handler.startElement(null,null, qName, atts);
                    }

                    public void startPrefixMapping(String prefix, String uri) throws SAXException {
                    }
                                });
                        }
                        public void start() throws SAXException
                        {
                            try
                            {
                              xmlReader.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();
            if (document.isDirty()){
                updateDocument(document, true);
                document.setDirty(false);
            }
        }
        catch (IOException e)
        {
          log.error("Could not load the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
        }
        catch (MarshalException e)
        {
          log.error("Could not unmarshal the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
        }
        catch (ValidationException e)
        {
          log.error("Document " + f.getAbsolutePath() + " is not valid", e);
            throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is not valid", e);
View Full Code Here

Examples of org.apache.jetspeed.page.PageNotFoundException

            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(JetspeedActions.VIEW);

            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

Examples of org.apache.jetspeed.page.PageNotFoundException

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

Examples of org.apache.jetspeed.page.PageNotFoundException

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

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

Examples of org.apache.jetspeed.page.PageNotFoundException

    {
        // 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

Examples of org.apache.jetspeed.page.PageNotFoundException

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

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

        try
        {
            // unmarshal: use SAX II 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
           
            final InputSource readerInput = new InputSource(new InputStreamReader(new FileInputStream(f), PSML_DOCUMENT_ENCODING));
            Unmarshaller unmarshaller = new Unmarshaller();
            unmarshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);           
            unmarshaller.setValidation(false); // results in better performance
            document = (Document) unmarshaller.unmarshal(new SAX2EventProducer()
                {
                    public void setContentHandler(final ContentHandler handler)
                    {
                      xmlReader.setContentHandler(new ContentHandler()
                            {
                                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 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 endElement(String uri, String localName, String qName) throws SAXException {
                                    // always include all elements
                                    handler.endElement(uri,localName,qName);
                                    // track menu depth and insert menu-element nodes
                                    // to encapsulate menu elements to support collection
                                    // polymorphism in Castor
                                    if (qName.equals("menu"))
                                    {
                                        menuDepth--;
                                        if (menuDepth > 0)
                                        {
                                            handler.endElement(null,null,"menu-element");
                                        }
                                    }
                                    else if ((menuDepth > 0) &&
                                             (qName.equals("options") || qName.equals("separator") ||
                                                 qName.equals("include") || qName.equals("exclude")))
                                    {
                                        handler.endElement(null,null,"menu-element");
                                    }
                }

                public void endPrefixMapping(String prefix) throws SAXException {
                }

                public void skippedEntity(String name) throws SAXException {
                  handler.skippedEntity(name);
                }

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

                                    // always include all elements
                                    handler.startElement(null,null, qName, atts);
                }

                public void startPrefixMapping(String prefix, String uri) throws SAXException {
                }
                            });
                    }
                    public void start() throws SAXException
                    {
                        try
                        {
                          xmlReader.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();
            if (document.isDirty()){
                updateDocument(document, true);
                document.setDirty(false);
            }
        }
        catch (IOException e)
        {
          log.error("Could not load the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
        }
        catch (MarshalException e)
        {
          log.error("Could not unmarshal the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
        }
        catch (ValidationException e)
        {
          log.error("Document " + f.getAbsolutePath() + " is not valid", e);
            throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is not valid", e);
View Full Code Here

Examples of org.apache.jetspeed.page.PageNotFoundException

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

Examples of org.apache.jetspeed.page.PageNotFoundException

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

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

Examples of org.apache.jetspeed.page.PageNotFoundException

            FolderImpl folder = getNodeFolder(path);
            return folder.getPage(getNodeName(path));
        }
        catch (FolderNotFoundException fnfe)
        {
            throw new PageNotFoundException(fnfe.getMessage());
        }
    }
View Full Code Here

Examples of org.apache.jetspeed.page.PageNotFoundException

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

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

        try
        {
            // unmarshal: use SAX II 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
           
            final InputSource readerInput = new InputSource(new InputStreamReader(new FileInputStream(f), PSML_DOCUMENT_ENCODING));
            Unmarshaller unmarshaller = new Unmarshaller();
            unmarshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);           
            unmarshaller.setValidation(false); // results in better performance
           
            synchronized (xmlReader)
            {
                document = (Document) unmarshaller.unmarshal(new SAX2EventProducer()
                    {
                        public void setContentHandler(final ContentHandler handler)
                        {
                          xmlReader.setContentHandler(new ContentHandler()
                                {
                                    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 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 endElement(String uri, String localName, String qName) throws SAXException {
                                        // always include all elements
                                        handler.endElement(uri,localName,qName);
                                        // track menu depth and insert menu-element nodes
                                        // to encapsulate menu elements to support collection
                                        // polymorphism in Castor
                                        if (qName.equals("menu"))
                                        {
                                            menuDepth--;
                                            if (menuDepth > 0)
                                            {
                                                handler.endElement(null,null,"menu-element");
                                            }
                                        }
                                        else if ((menuDepth > 0) &&
                                                 (qName.equals("options") || qName.equals("separator") ||
                                                     qName.equals("include") || qName.equals("exclude")))
                                        {
                                            handler.endElement(null,null,"menu-element");
                                        }
                    }

                    public void endPrefixMapping(String prefix) throws SAXException {
                    }

                    public void skippedEntity(String name) throws SAXException {
                      handler.skippedEntity(name);
                    }

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

                                        // always include all elements
                                        handler.startElement(null,null, qName, atts);
                    }

                    public void startPrefixMapping(String prefix, String uri) throws SAXException {
                    }
                                });
                        }
                        public void start() throws SAXException
                        {
                            try
                            {
                              xmlReader.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());
            boolean dirty = documentImpl.unmarshalled(generator);
            if (dirty || document.isDirty()){
                updateDocument(document, true);
                document.setDirty(false);
            }
        }
        catch (IOException e)
        {
          log.error("Could not load the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
        }
        catch (MarshalException e)
        {
          log.error("Could not unmarshal the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
        }
        catch (ValidationException e)
        {
          log.error("Document " + f.getAbsolutePath() + " is not valid", e);
            throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is not valid", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.