Package org.apache.jetspeed.om.page.psml

Examples of org.apache.jetspeed.om.page.psml.AbstractBaseElement


                log.warn("Recieved Document with null path/id to update");
                return;
            }
            document.setPath(path);
        }
        AbstractBaseElement documentImpl = (AbstractBaseElement)document;
        documentImpl.setHandlerFactory(handlerFactory);
        if (systemUpdate){
          // on system update: temporarily turn off security
            documentImpl.setPermissionsEnabled(false);
            documentImpl.setConstraintsEnabled(false);
        } else {
            documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
            documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
        }
        documentImpl.marshalling();
       
        // marshal page to disk
        String fileName = path;       
        if (!fileName.endsWith(this.documentType))
        {
            fileName = path + this.documentType;
        }
        File f = new File(this.documentRootDir, fileName);
        Writer writer = null;

        try
        {
            // marshal: use SAX II handler to filter document XML for
            // page and folder menu definition menu elements ordered
            // polymorphic collection to strip artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final ContentHandler handler = serializer.asContentHandler();
           
            Marshaller marshaller = new Marshaller(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 {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          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 {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (ValidationException e)
        {
            log.error("Document " + f.getAbsolutePath() + " is not valid", e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (IOException e)
        {
            log.error("Could not save the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (Exception e)
        {
            log.error("Error while saving  " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        finally
        {
            if (systemUpdate){
              // restore permissions / constraints
              documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
                documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
            }
          try
            {
                writer.close();
            }
View Full Code Here


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

                log.warn("Recieved Document with null path/id to update");
                return;
            }
            document.setPath(path);
        }
        AbstractBaseElement documentImpl = (AbstractBaseElement)document;
        documentImpl.setHandlerFactory(handlerFactory);
        if (systemUpdate){
          // on system update: temporarily turn off security
            documentImpl.setPermissionsEnabled(false);
            documentImpl.setConstraintsEnabled(false);
        } else {
            documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
            documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
        }
        documentImpl.marshalling();
       
        // marshal page to disk
        String fileName = path;       
        if (!fileName.endsWith(this.documentType))
        {
            fileName = path + this.documentType;
        }
        File f = new File(this.documentRootDir, fileName);
        Writer writer = null;

        try
        {
            // marshal: use SAX II handler to filter document XML for
            // page and folder menu definition menu elements ordered
            // polymorphic collection to strip artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final ContentHandler handler = serializer.asContentHandler();
           
            Marshaller marshaller = new Marshaller(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 {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          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 {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (ValidationException e)
        {
            log.error("Document " + f.getAbsolutePath() + " is not valid", e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (IOException e)
        {
            log.error("Could not save the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (Exception e)
        {
            log.error("Error while saving  " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
        }
        finally
        {
            if (systemUpdate){
              // restore permissions / constraints
              documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
                documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
            }
          try
            {
                writer.close();
            }
View Full Code Here

                        }
                    }
                });

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

                log.warn("Recieved Document with null path/id to update");
                return;
            }
            document.setPath(path);
        }
        AbstractBaseElement documentImpl = (AbstractBaseElement)document;
        documentImpl.setHandlerFactory(handlerFactory);
        String absolutePath = "";
        Writer writer = null;       
        try
        {
            // JS2-903: move try up to ensure no backdoors to disabling security
            if (systemUpdate)
            {
              // on system update: temporarily turn off security
                documentImpl.setPermissionsEnabled(false);
                documentImpl.setConstraintsEnabled(false);
            }
            else
            {
                try
                {
                    // JS2-903: fragments are getting stripped out on write if the current user does not have edit access to write to the file
                    document.checkAccess(JetspeedActions.EDIT);
                }
                catch (SecurityException se)
                {
                    throw new FailedToUpdateDocumentException("Insufficient Access: no edit access, cannot write.");
                }
                documentImpl.setPermissionsEnabled(false);
                documentImpl.setConstraintsEnabled(false);           
            }
            documentImpl.marshalling();
            // marshal page to disk
            String fileName = path;       
            if (!fileName.endsWith(this.documentType))
            {
                fileName = path + this.documentType;
            }
            File f = new File(this.documentRootDir, fileName);
            absolutePath = f.getAbsolutePath();
            // marshal: use SAX II handler to filter document XML for
            // page and folder menu definition menu elements ordered
            // polymorphic collection to strip artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            XMLWriter xmlWriter = new XMLWriter(writer, this.format);
            final ContentHandler handler = xmlWriter;
           
            Marshaller marshaller = new Marshaller(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 {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          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 {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + absolutePath, e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (ValidationException e)
        {
            log.error("Document " + absolutePath + " is not valid", e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (IOException e)
        {
            log.error("Could not save the file " + absolutePath, e);
            throw new FailedToUpdateDocumentException(e);
        }
        catch (Exception e)
        {
            log.error("Error while saving  " + absolutePath, e);
            throw new FailedToUpdateDocumentException(e);
        }
        finally
        {
          // restore permissions / constraints
          documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
            documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
          try
            {
              if (writer != null)
                  writer.close();
            }
View Full Code Here

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

                log.warn("Recieved Document with null path/id to update");
                return;
            }
            document.setPath(path);
        }
        AbstractBaseElement documentImpl = (AbstractBaseElement)document;
        documentImpl.setHandlerFactory(handlerFactory);
        documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
        documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
        documentImpl.marshalling();
       
        // marshal page to disk
        String fileName = path;       
        if (!fileName.endsWith(this.documentType))
        {
View Full Code Here

                        }
                    }
                });

            document.setPath(path);
            AbstractBaseElement documentImpl = (AbstractBaseElement)document;
            documentImpl.setHandlerFactory(handlerFactory);
            documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
            documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
            documentImpl.unmarshalled();
        }
        catch (IOException e)
        {
          log.error("Could not load the file " + f.getAbsolutePath(), e);
            throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
View Full Code Here

                log.warn("Recieved Document with null path/id to update");
                return;
            }
            document.setPath(path);
        }
        AbstractBaseElement documentImpl = (AbstractBaseElement)document;
        documentImpl.setHandlerFactory(handlerFactory);
        documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
        documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
        documentImpl.marshalling();
       
        // marshal page to disk
        String fileName = path;       
        if (!fileName.endsWith(this.documentType))
        {
View Full Code Here

                        }
                    }
                });

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

TOP

Related Classes of org.apache.jetspeed.om.page.psml.AbstractBaseElement

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.